# HG changeset patch # User William Welliver # Date 1624589419 14400 # Thu Jun 24 22:50:19 2021 -0400 # Node ID f2d370bac06732629bce1f88142a159dc94bdb65 # Parent e7145d8c0ff0f590b52aad6ac1918e795863fd3d more fixes for objective c 2 diff --git a/ObjC.mmod b/ObjC.mmod --- a/ObjC.mmod +++ b/ObjC.mmod @@ -905,7 +905,7 @@ strcpy ((char*)new_class->name, name); meta_class->name = new_class->name; #else - objc_allocateClassPair(super_class, name, 0); + new_class = objc_allocateClassPair(super_class, name, 0); #endif /* OBJC_V1 */ diff --git a/dynamic_class.m b/dynamic_class.m --- a/dynamic_class.m +++ b/dynamic_class.m @@ -191,7 +191,7 @@ struct svalue * o_retval; int num_float_arguments = 0; int num_pointer_return_arguments = 0; - void* volatile msgResult; + ffi_arg msgResult; ffi_cif * cif; SEL sel; pool = [global_autorelease_pool getAutoreleasePool]; @@ -347,7 +347,7 @@ { Class cls; wrapper = id_from_object(o); - argumentList[x] = (wrapper); + argumentList[x] = &(wrapper); } } else if(TYPEOF(*sv) == T_ARRAY) @@ -461,7 +461,7 @@ LOG("SENDING MESSAGE %s WITH %d args AND RETURN TYPE %s\n", select, arguments, type); LOG("OBJ: %p, %p\n", obj, select); pop_n_elems(args); - + @try { switch(*type){ case '@': o_retval = object_dispatch_method(cif, argumentList); @@ -469,10 +469,9 @@ case 'd': case 'f': - case 'q': - case 'Q': - ffi_call(cif, FFI_FN(objc_msgSend_fpret), msgResult, argumentList); + ffi_call(cif, FFI_FN(objc_msgSend), msgResult, argumentList); break; + case '[': case '{': @@ -483,68 +482,70 @@ THREADS_DISALLOW(); break; - default: + default: THREADS_ALLOW(); LOG("calling%s\n", ""); - ffi_call(cif, FFI_FN(objc_msgSend), msgResult, argumentList); + ffi_call(cif, FFI_FN(objc_msgSend), &msgResult, argumentList); THREADS_DISALLOW(); LOG("calling2%s\n", ""); break; } // free(msgResult); +printf("whoo\n"); free(cif); LOG("called!%s\n", ""); - @try - { - switch(*type){ + + switch(*type){ case 'c': - push_int(*(INT_TYPE *)msgResult); + push_int((INT_TYPE)msgResult); break; case 'C': - push_int(*(INT_TYPE *)msgResult); + push_int((INT_TYPE)msgResult); break; case 'i': - push_int(*(INT_TYPE *)msgResult); + push_int((INT_TYPE)msgResult); break; // TODO: fix the casting... should we support auto objectize for bignums? case 'l': - push_int(*(INT_TYPE *)msgResult); + push_int((INT_TYPE)msgResult); free(result); break; case 'L': - push_int(*(INT_TYPE *)msgResult); + push_int((INT_TYPE)msgResult); break; case 'I': - push_int(*(INT_TYPE *)msgResult); + push_int((INT_TYPE)msgResult); break; case 'd': - push_float(*(FLOAT_TYPE *)msgResult); + push_float((FLOAT_TYPE)msgResult); break; case 'f': - push_float(*(FLOAT_TYPE *)msgResult); + push_float((FLOAT_TYPE)msgResult); break; +/* TODO we need to make sure we're not losing data here if the return size + is larger than INT_TYPE */ case 'q': - push_float(*(FLOAT_TYPE *)msgResult); + push_int((INT_TYPE)msgResult); break; case 'Q': - push_float(*(FLOAT_TYPE *)msgResult); + push_int((INT_TYPE)msgResult); break; case 's': - push_int(*(INT_TYPE *)msgResult); + push_int((INT_TYPE)msgResult); break; case 'S': - push_int(*(INT_TYPE *)msgResult); + push_int((INT_TYPE)msgResult); break; case 'v': diff --git a/examples/exportbook.pike b/examples/exportbook.pike --- a/examples/exportbook.pike +++ b/examples/exportbook.pike @@ -12,10 +12,11 @@ { mixed book = Cocoa.ABAddressBook.sharedAddressBook(); mixed e; -werror("BOOK:%O\n", indices(book)); object p = book->people(); foreach(p;; object person) { +werror("!!!!\n"); +//werror("p: %O\n", person); row = ({}); foreach(fields;; object f) { @@ -48,6 +49,6 @@ werror("error casting %O, %O to string.\n", fv?fv->__objc_classname:"", fv?sort(indices(fv)):fv); -exit(1);} +} } } diff --git a/mixins/NSArray.mx b/mixins/NSArray.mx --- a/mixins/NSArray.mx +++ b/mixins/NSArray.mx @@ -5,6 +5,7 @@ PIKEFUN object _get_iterator() { +printf("get_iterator\n"); push_text("Public.ObjectiveC.NSArrayIterator"); SAFE_APPLY_MASTER("resolv", 1); @@ -55,7 +56,7 @@ PIKEFUN int _sizeof() { int s; - +printf("_sizeof()\n"); s = [THIS->obj count]; push_int(s); diff --git a/util.m b/util.m --- a/util.m +++ b/util.m @@ -494,8 +494,11 @@ c = PiObjC_FindObjCProxy(o); if(!c) { +LOG("object wasn't in the proxy registry, so we will wrap it.%s\n", ""); c = objcify_pike_object(o); - } + } else { + LOG("found object in registry %p\n", c); +} return c; } @@ -1683,7 +1686,7 @@ for (x = 2; x < argcount; x++) { int is_pointer_return = 0; - method_getArgumentType(nssig, x, type, 100); + method_getArgumentType(nssig, x, ltype, 100); type = ltype; LOG("type: %s\n", type); while((*type)&&(*type=='r' || *type =='n' || *type =='N' || *type=='o' || *type=='O' || *type =='V'))