diff --git a/makefile b/makefile index 6489b84..f70f4bd 100644 --- a/makefile +++ b/makefile @@ -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 \ No newline at end of file + rm $(BUILD)/*.o \ No newline at end of file diff --git a/mingw32.c b/mingw32.c deleted file mode 100644 index e1a57e8..0000000 --- a/mingw32.c +++ /dev/null @@ -1,30 +0,0 @@ -#include -#include -#include - -//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_); -} \ No newline at end of file diff --git a/YSArray.h b/src/YSArray.h similarity index 100% rename from YSArray.h rename to src/YSArray.h diff --git a/YSArray.m b/src/YSArray.m similarity index 95% rename from YSArray.m rename to src/YSArray.m index 117577c..c36aee7 100644 --- a/YSArray.m +++ b/src/YSArray.m @@ -12,7 +12,7 @@ -(void) addObject: (id) theObject { if (array == NULL) { - printf("%s\n", "addObject Init"); + //it needs malloced array = malloc(sizeof(id)); if (array == NULL) { diff --git a/src/YSBitField.h b/src/YSBitField.h new file mode 100644 index 0000000..4621744 --- /dev/null +++ b/src/YSBitField.h @@ -0,0 +1,23 @@ +#ifndef YSBITFIELD_H +#define YSBITFIELD_H + +#include +#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 \ No newline at end of file diff --git a/src/YSBitField.m b/src/YSBitField.m new file mode 100644 index 0000000..d4912de --- /dev/null +++ b/src/YSBitField.m @@ -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 \ No newline at end of file diff --git a/YSObject.h b/src/YSObject.h similarity index 97% rename from YSObject.h rename to src/YSObject.h index 00511f8..2488866 100644 --- a/YSObject.h +++ b/src/YSObject.h @@ -40,6 +40,8 @@ typedef unsigned int YSUInteger; } +-(id) init; + @end #endif \ No newline at end of file diff --git a/YSObject.m b/src/YSObject.m similarity index 98% rename from YSObject.m rename to src/YSObject.m index 5e0563d..7ae2a5b 100644 --- a/YSObject.m +++ b/src/YSObject.m @@ -60,17 +60,13 @@ inline id YSDeallocateObject(id theObject) { #endif @implementation YSObject -#if !defined(__MINGW32__) && !defined(__MINGW64__) -/* -+(void) load { - //impl - return; -}*/ -(id) init { return self; } +#if !defined(__MINGW32__) && !defined(__MINGW64__) + -(id) self { return self; } diff --git a/YSString.h b/src/YSString.h similarity index 100% rename from YSString.h rename to src/YSString.h diff --git a/YSZone.h b/src/YSZone.h similarity index 88% rename from YSZone.h rename to src/YSZone.h index 21c4c1e..a62d907 100644 --- a/YSZone.h +++ b/src/YSZone.h @@ -4,10 +4,6 @@ #include #include -#define BOOL int -#define true YES -#define false NO - typedef unsigned int YSUInteger; typedef struct _YSZone YSZone; diff --git a/YSZone.m b/src/YSZone.m similarity index 100% rename from YSZone.m rename to src/YSZone.m