Browse Source

Fixed compiler warnings.

woollybah 5 năm trước cách đây
mục cha
commit
f61e777d30

+ 4 - 10
blitz.mod/blitz_array.c

@@ -156,7 +156,7 @@ static void initializeArray( BBArray *arr, BBArrayStructInit structInit ){
 		memset( p,0,arr->size );
 		if (structInit) {
 			int k;
-			char * s = p;
+			char * s = (char*)p;
 			for( k=arr->scales[0];k>0;--k ) {
 				structInit(s);
 				s += arr->data_size;
@@ -165,12 +165,6 @@ static void initializeArray( BBArray *arr, BBArrayStructInit structInit ){
 	}
 }
 
-static volatile void *t;
-void *addressOfParam( void *p ){
-	t=p;
-	return t;
-} 
-
 BBArray *bbArrayNew( const char *type,int dims,... ){
 
 	int lens[256];
@@ -185,7 +179,7 @@ BBArray *bbArrayNew( const char *type,int dims,... ){
 	}
 	va_end(lengths);
 
-	BBArray *arr=allocateArray( type,dims, &lens, 0 );
+	BBArray *arr=allocateArray( type,dims, lens, 0 );
 	
 	initializeArray( arr, 0 );
 	
@@ -206,7 +200,7 @@ BBArray *bbArrayNewStruct( const char *type, unsigned short data_size, BBArraySt
 	}
 	va_end(lengths);
 
-	BBArray *arr=allocateArray( type,dims, &lens, data_size );
+	BBArray *arr=allocateArray( type,dims, lens, data_size );
 	
 	initializeArray( arr, init );
 	
@@ -524,5 +518,5 @@ void bbArraySort( BBArray *arr,int ascending ){
 }
 
 int bbObjectIsEmptyArray(BBObject * o) {
-	return o == &bbEmptyArray;
+	return (BBArray*)o == &bbEmptyArray;
 }

+ 1 - 1
blitz.mod/blitz_enum.c

@@ -165,7 +165,7 @@ BBEnum * bbEnumGetInfo( char * name ) {
 	bbEnum.atype = name;
 	node.bbEnum = &bbEnum;
 	
-	struct enum_info_node * found = (struct enum_info_node *)tree_search(&node, enum_info_node_compare, enum_info_root);
+	struct enum_info_node * found = (struct enum_info_node *)tree_search((struct tree_root_np *)&node, enum_info_node_compare, (struct tree_root_np *)enum_info_root);
 
 	if (found) {
 		return found->bbEnum;

+ 1 - 1
blitz.mod/blitz_gc.c

@@ -209,7 +209,7 @@ void bbGCRelease( BBObject *p ) {
 	
 	bb_mutex_lock(bbReleaseRetainGuard);
 
-	struct retain_node * found = (struct retain_node *)tree_search(&node, node_compare, retain_root);
+	struct retain_node * found = (struct retain_node *)tree_search((struct tree_root_np *)&node, node_compare, (struct tree_root_np *)retain_root);
 
 	if (found) {
 		// found a retained object!

+ 5 - 8
blitz.mod/blitz_handle.c

@@ -89,16 +89,14 @@ static int node_compare(const void *x, const void *y) {
 }
 
 size_t bbHandleFromObject( BBObject *o ) {
-	struct handle_node * node = (struct handle_node *)malloc(sizeof(struct handle_node));
+	struct handle_node * node = (struct handle_node *)GC_malloc_uncollectable(sizeof(struct handle_node));
 	node->obj = o;
 	
 	struct handle_node * old_node = (struct handle_node *)avl_map(&node->link, node_compare, &handle_root );
 
 	if (&node->link != &old_node->link) {
 		// delete the new node, since we don't need it
-		free(node);
-	} else {
-		BBRETAIN(o);
+		GC_FREE(node);
 	}
 	
 	return (size_t)o;
@@ -108,7 +106,7 @@ BBObject *bbHandleToObject( size_t handle ) {
 	struct handle_node node;
 	node.obj = (BBOBJECT)handle;
 	
-	struct handle_node * found = (struct handle_node *)tree_search(&node, node_compare, handle_root );
+	struct handle_node * found = (struct handle_node *)tree_search((struct tree_root_np *)&node, node_compare, (struct tree_root_np *)handle_root );
 
 	if (found) {
 		return (BBOBJECT)handle;
@@ -121,11 +119,10 @@ void bbHandleRelease( size_t handle ) {
 	struct handle_node node;
 	node.obj = (BBOBJECT)handle;
 	
-	struct handle_node * found = (struct handle_node *)tree_search(&node, node_compare, handle_root);
+	struct handle_node * found = (struct handle_node *)tree_search((struct tree_root_np *)&node, node_compare, (struct tree_root_np *)handle_root);
 	
 	if (found) {
-		BBRELEASE(found->obj);
 		avl_del(&found->link, &handle_root);
-		free(found);
+		GC_FREE(found);
 	}
 }

+ 6 - 6
blitz.mod/blitz_object.c

@@ -4,7 +4,7 @@
 #define REG_GROW 256
 
 static BBClass **reg_base,**reg_put,**reg_end;
-static BBClass **ireg_base,**ireg_put,**ireg_end;
+static BBInterface **ireg_base,**ireg_put,**ireg_end;
 
 static BBDebugScope debugScope={
 	BBDEBUGSCOPE_USERTYPE,
@@ -108,7 +108,7 @@ BBObject *bbObjectStringcast( BBObject *o ){
 	if (o->clas == &bbStringClass) {
 		return o;
 	} else {
-		return &bbEmptyString;
+		return (BBObject *)&bbEmptyString;
 	}
 }
 
@@ -116,14 +116,14 @@ BBObject *bbObjectArraycast( BBObject *o ){
 	if (o->clas == &bbArrayClass) {
 		return o;
 	} else {
-		return &bbEmptyArray;
+		return (BBObject *)&bbEmptyArray;
 	}
 }
 
 BBObject *bbObjectDowncast( BBObject *o,BBClass *t ){
 	BBClass *p=o->clas;
 	while( p && p!=t ) p=p->super;
-	return p ? o : (t==&bbStringClass) ? &bbEmptyString : (t==&bbArrayClass) ? &bbEmptyArray : &bbNullObject;
+	return p ? o : (t==&bbStringClass) ? (BBObject *)&bbEmptyString : (t==&bbArrayClass) ? (BBObject *)&bbEmptyArray : &bbNullObject;
 }
 
 void bbObjectRegisterType( BBClass *clas ){
@@ -234,7 +234,7 @@ BBDebugScope * bbObjectStructInfo( char * name ) {
 	scope.name = name;
 	node.scope = &scope;
 	
-	struct struct_node * found = (struct struct_node *)tree_search(&node, struct_node_compare, struct_root);
+	struct struct_node * found = (struct struct_node *)tree_search((struct tree_root_np *)&node, struct_node_compare, (struct tree_root_np *)struct_root);
 
 	if (found) {
 		return found->scope;
@@ -278,7 +278,7 @@ BBDebugScope * bbObjectEnumInfo( char * name ) {
 	scope.name = name;
 	node.scope = &scope;
 	
-	struct enum_node * found = (struct enum_node *)tree_search(&node, enum_node_compare, enum_root);
+	struct enum_node * found = (struct enum_node *)tree_search((struct tree_root_np *)&node, enum_node_compare, (struct tree_root_np *)enum_root);
 
 	if (found) {
 		return found->scope;

+ 9 - 7
blitz.mod/blitz_thread.c

@@ -89,13 +89,14 @@ static DWORD WINAPI threadProc( void *p ){
 	
 	TlsSetValue( curThreadTls,thread );
 	
-	DWORD ret=(DWORD)thread->proc( thread->data[0] );
+	BBObject * result = thread->proc( thread->data[0] );
+	thread->result = result;
 	
 	BB_LOCK
 	removeThread( thread );
 	BB_UNLOCK
 	
-	return ret;
+	return 0;
 }
 
 void bbThreadStartup(){
@@ -128,6 +129,7 @@ BBThread *bbThreadCreate( BBThreadProc proc,BBObject *data ){
 	memset( thread->data,0,sizeof(thread->data) );
 	thread->data[0]=data;
 	thread->detached=0;
+	thread->result = &bbNullObject;
 	thread->handle=CreateThread( 0,0,threadProc,thread,CREATE_SUSPENDED,&thread->id );
 
 	BB_LOCK
@@ -145,10 +147,10 @@ void bbThreadDetach( BBThread *thread ){
 
 BBObject *bbThreadWait( BBThread *thread ){
 	if( WaitForSingleObject( thread->handle,INFINITE )==WAIT_OBJECT_0 ){
-		BBObject *p;
-		if( GetExitCodeThread( thread->handle,(DWORD*)&p ) ){
+		DWORD res;
+		if( GetExitCodeThread( thread->handle, &res ) ){
 			thread->detached=1;
-			return p;
+			return thread->result;
 		}else{
 			printf( "ERROR! bbThreadWait: GetExitCodeThread failed!\n" );
 		}
@@ -220,7 +222,7 @@ void bbThreadStartup() {
 	mainThread=thread;
 }
 
-static int threadProc( void *p ){
+static BBObject * threadProc( void *p ){
 	BBThread *thread = p;
 	
 	bbThread = thread;
@@ -233,7 +235,7 @@ static int threadProc( void *p ){
 	printf( "Thread %p added\n",thread );fflush( stdout );
 #endif
 	
-	void *ret=thread->proc( thread->data[0] );
+	BBObject * ret=thread->proc( thread->data[0] );
 	
 	BB_LOCK
 	removeThread( thread );

+ 1 - 0
blitz.mod/blitz_thread.h

@@ -104,6 +104,7 @@ struct BBThread{
 	int detached;
 	int locked_regs[BB_THREADREGS];
 #ifdef _WIN32
+	BBObject * result;
 	HANDLE handle;
 	DWORD id;
 #elif __SWITCH__