bitfield class
parent
d8df3f3539
commit
d2cfb8c4c4
@ -1,30 +1,41 @@
|
||||
SHELL=/bin/sh
|
||||
CC=gcc
|
||||
CC=
|
||||
AR=
|
||||
|
||||
LIB_NAME=yeslib
|
||||
|
||||
SRC=src
|
||||
BUILD=build
|
||||
|
||||
C_FILES := $(shell find $(SRC) -name '*.c')
|
||||
M_FILES := $(shell find $(SRC) -name '*.m')
|
||||
O_FILES := $(patsubst $(SRC)/%.m, $(BUILD)/%.o, $(M_FILES))
|
||||
O_FILES += $(patsubst $(SRC)/%.c, $(BUILD)/%.o, $(C_FILES))
|
||||
|
||||
LIB := -L
|
||||
LIB :=
|
||||
OS :=
|
||||
|
||||
ifeq ($(OS),windows)
|
||||
#change these if needed
|
||||
LIB += ../lib
|
||||
LIB += -l:objc-1.dll -l:test.dll
|
||||
CC=x86_64-w64-mingw32-gcc
|
||||
AR=x86_64-w64-mingw32-ar
|
||||
LIB += -lopengl32 -lgdi32 -lwinmm -luser32
|
||||
endif
|
||||
|
||||
ifeq ($(OS),linux)
|
||||
LIB += ~/code/objc/wow/lib/linux64
|
||||
CC=gcc
|
||||
AR=ar
|
||||
endif
|
||||
|
||||
static:
|
||||
$(CC) YSObject.m -c
|
||||
$(CC) YSZone.m -c
|
||||
$(CC) YSArray.m -c
|
||||
ar rcs libyeslib.a YSObject.o YSZone.o YSArray.o
|
||||
static: $(LIB_NAME)
|
||||
|
||||
$(LIB_NAME): $(O_FILES)
|
||||
$(AR) rcs lib$(LIB_NAME).a $(O_FILES)
|
||||
|
||||
$(BUILD)/%.o: $(SRC)/%.c
|
||||
$(CC) -c $< -o $@
|
||||
|
||||
shared:
|
||||
$(CC) YSObject.m -c -Wl,--enable-auto-import
|
||||
$(CC) YSZone.m -c
|
||||
$(CC) YSArray.m -c
|
||||
$(CC) -shared -o yeslib.dll YSObject.o YSZone.o YSArray.o $(LIB)
|
||||
$(BUILD)/%.o: $(SRC)/%.m
|
||||
$(CC) -c $< -o $@
|
||||
|
||||
clean:
|
||||
rm *.o
|
||||
rm $(BUILD)/*.o
|
||||
@ -1,30 +0,0 @@
|
||||
#include <stdlib.h>
|
||||
#include <objc/objc.h>
|
||||
#include <objc/runtime.h>
|
||||
|
||||
//a wrapper to make linking easier
|
||||
#define YLAPI
|
||||
|
||||
#if defined(__MINGW32__) || defined(__MINGW64__)
|
||||
#define YLAPI __declspec(dllexport)
|
||||
#endif
|
||||
|
||||
YLAPI size_t __imp_class_getInstanceSize(Class class_) {
|
||||
extern size_t class_getInstanceSize(class_);
|
||||
}
|
||||
|
||||
YLAPI Class __imp_object_setClass(id object, Class class_) {
|
||||
extern Class object_setClass(object, class_);
|
||||
}
|
||||
|
||||
YLAPI BOOL __imp_class_isMetaClass(Class class_) {
|
||||
extern BOOL class_isMetaClass(class_);
|
||||
}
|
||||
|
||||
YLAPI id __imp_object_dispose(id object) {
|
||||
extern id object_dispose(object);
|
||||
}
|
||||
|
||||
YLAPI Class __imp_class_getSuperclass(Class class_) {
|
||||
extern Class class_getSuperclass(class_);
|
||||
}
|
||||
@ -0,0 +1,23 @@
|
||||
#ifndef YSBITFIELD_H
|
||||
#define YSBITFIELD_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#import "YSObject.h"
|
||||
|
||||
@interface YSBitField : YSObject {
|
||||
int x : 1;
|
||||
int y : 1;
|
||||
int z : 1;
|
||||
int w : 1;
|
||||
int h : 4;
|
||||
}
|
||||
|
||||
-(bool) x;
|
||||
-(bool) y;
|
||||
-(bool) z;
|
||||
-(bool) w;
|
||||
-(unsigned int) h;
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,25 @@
|
||||
#import "YSBitField.h"
|
||||
|
||||
@implementation YSBitField
|
||||
|
||||
-(bool) x {
|
||||
return x;
|
||||
}
|
||||
|
||||
-(bool) y {
|
||||
return y;
|
||||
}
|
||||
|
||||
-(bool) z {
|
||||
return z;
|
||||
}
|
||||
|
||||
-(bool) w {
|
||||
return w;
|
||||
}
|
||||
|
||||
-(unsigned int) h {
|
||||
return h;
|
||||
}
|
||||
|
||||
@end
|
||||
Loading…
Reference in New Issue