bitfield class

main
sandyx86 1 year ago
parent d8df3f3539
commit d2cfb8c4c4

@ -1,30 +1,41 @@
SHELL=/bin/sh 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 := OS :=
ifeq ($(OS),windows) ifeq ($(OS),windows)
#change these if needed
LIB += ../lib
LIB += -l:objc-1.dll -l:test.dll
CC=x86_64-w64-mingw32-gcc CC=x86_64-w64-mingw32-gcc
AR=x86_64-w64-mingw32-ar
LIB += -lopengl32 -lgdi32 -lwinmm -luser32
endif endif
ifeq ($(OS),linux) ifeq ($(OS),linux)
LIB += ~/code/objc/wow/lib/linux64 CC=gcc
AR=ar
endif endif
static: static: $(LIB_NAME)
$(CC) YSObject.m -c
$(CC) YSZone.m -c $(LIB_NAME): $(O_FILES)
$(CC) YSArray.m -c $(AR) rcs lib$(LIB_NAME).a $(O_FILES)
ar rcs libyeslib.a YSObject.o YSZone.o YSArray.o
$(BUILD)/%.o: $(SRC)/%.c
$(CC) -c $< -o $@
shared: $(BUILD)/%.o: $(SRC)/%.m
$(CC) YSObject.m -c -Wl,--enable-auto-import $(CC) -c $< -o $@
$(CC) YSZone.m -c
$(CC) YSArray.m -c
$(CC) -shared -o yeslib.dll YSObject.o YSZone.o YSArray.o $(LIB)
clean: 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_);
}

@ -12,7 +12,7 @@
-(void) addObject: (id) theObject { -(void) addObject: (id) theObject {
if (array == NULL) { if (array == NULL) {
printf("%s\n", "addObject Init"); //it needs malloced
array = malloc(sizeof(id)); array = malloc(sizeof(id));
if (array == NULL) { if (array == NULL) {

@ -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

@ -40,6 +40,8 @@ typedef unsigned int YSUInteger;
} }
-(id) init;
@end @end
#endif #endif

@ -60,17 +60,13 @@ inline id YSDeallocateObject(id theObject) {
#endif #endif
@implementation YSObject @implementation YSObject
#if !defined(__MINGW32__) && !defined(__MINGW64__)
/*
+(void) load {
//impl
return;
}*/
-(id) init { -(id) init {
return self; return self;
} }
#if !defined(__MINGW32__) && !defined(__MINGW64__)
-(id) self { -(id) self {
return self; return self;
} }

@ -4,10 +4,6 @@
#include <stddef.h> #include <stddef.h>
#include <stdlib.h> #include <stdlib.h>
#define BOOL int
#define true YES
#define false NO
typedef unsigned int YSUInteger; typedef unsigned int YSUInteger;
typedef struct _YSZone YSZone; typedef struct _YSZone YSZone;
Loading…
Cancel
Save