Make method offsets a uint32_t Also make class_alloc_size a uint32_t.
See CLOWNFISH-15. Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/25c561a4 Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/25c561a4 Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/25c561a4 Branch: refs/heads/master Commit: 25c561a4fe43b32fce10a61dc056974cd6e4bdbe Parents: 5e24780 Author: Nick Wellnhofer <[email protected]> Authored: Fri Apr 17 21:25:53 2015 +0200 Committer: Nick Wellnhofer <[email protected]> Committed: Mon Jul 27 19:03:42 2015 +0200 ---------------------------------------------------------------------- compiler/src/CFCBindClass.c | 2 +- compiler/src/CFCBindCore.c | 8 ++++---- compiler/src/CFCBindMethod.c | 2 +- compiler/src/CFCBindSpecs.c | 10 +++++----- runtime/core/Clownfish/Class.c | 30 +++++++++++++++--------------- runtime/core/Clownfish/Class.cfh | 4 ++-- runtime/core/Clownfish/Method.c | 4 ++-- runtime/core/Clownfish/Method.cfh | 6 +++--- 8 files changed, 33 insertions(+), 33 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/25c561a4/compiler/src/CFCBindClass.c ---------------------------------------------------------------------- diff --git a/compiler/src/CFCBindClass.c b/compiler/src/CFCBindClass.c index f19a174..70dd211 100644 --- a/compiler/src/CFCBindClass.c +++ b/compiler/src/CFCBindClass.c @@ -293,7 +293,7 @@ CFCBindClass_to_c_data(CFCBindClass *self) { // Define method offset variable. char *full_offset_sym = CFCMethod_full_offset_sym(method, client); - offsets = CFCUtil_cat(offsets, "size_t ", full_offset_sym, ";\n", + offsets = CFCUtil_cat(offsets, "uint32_t ", full_offset_sym, ";\n", NULL); FREEMEM(full_offset_sym); http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/25c561a4/compiler/src/CFCBindCore.c ---------------------------------------------------------------------- diff --git a/compiler/src/CFCBindCore.c b/compiler/src/CFCBindCore.c index ce0f9f7..5b20de8 100644 --- a/compiler/src/CFCBindCore.c +++ b/compiler/src/CFCBindCore.c @@ -201,7 +201,7 @@ S_write_parcel_h(CFCBindCore *self, CFCParcel *parcel) { " ((_full_meth ## _t)cfish_method(_class, _full_meth ## _OFFSET))\n" "\n" "static CFISH_INLINE cfish_method_t\n" - "cfish_method(const void *klass, size_t offset) {\n" + "cfish_method(const void *klass, uint32_t offset) {\n" " union { char *cptr; cfish_method_t *fptr; } ptr;\n" " ptr.cptr = (char*)klass + offset;\n" " return ptr.fptr[0];\n" @@ -215,7 +215,7 @@ S_write_parcel_h(CFCBindCore *self, CFCParcel *parcel) { "/* Access the function pointer for a given method from the object.\n" " */\n" "static CFISH_INLINE cfish_method_t\n" - "cfish_obj_method(const void *object, size_t offset) {\n" + "cfish_obj_method(const void *object, uint32_t offset) {\n" " cfish_Dummy *dummy = (cfish_Dummy*)object;\n" " return cfish_method(dummy->klass, offset);\n" "}\n" @@ -228,7 +228,7 @@ S_write_parcel_h(CFCBindCore *self, CFCParcel *parcel) { "\n" "extern CFISH_VISIBLE size_t cfish_Class_offset_of_parent;\n" "static CFISH_INLINE cfish_method_t\n" - "cfish_super_method(const void *klass, size_t offset) {\n" + "cfish_super_method(const void *klass, uint32_t offset) {\n" " char *class_as_char = (char*)klass;\n" " cfish_Class **parent_ptr\n" " = (cfish_Class**)(class_as_char + cfish_Class_offset_of_parent);\n" @@ -237,7 +237,7 @@ S_write_parcel_h(CFCBindCore *self, CFCParcel *parcel) { "\n" "typedef void\n" "(*cfish_destroy_t)(void *vself);\n" - "extern CFISH_VISIBLE size_t CFISH_Obj_Destroy_OFFSET;\n" + "extern CFISH_VISIBLE uint32_t CFISH_Obj_Destroy_OFFSET;\n" "\n" "/** Invoke the [](cfish:.Destroy) method found in `klass` on\n" " * `self`.\n" http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/25c561a4/compiler/src/CFCBindMethod.c ---------------------------------------------------------------------- diff --git a/compiler/src/CFCBindMethod.c b/compiler/src/CFCBindMethod.c index e4d7301..400d554 100644 --- a/compiler/src/CFCBindMethod.c +++ b/compiler/src/CFCBindMethod.c @@ -127,7 +127,7 @@ S_method_def(CFCMethod *method, CFCClass *klass, int optimized_final_meth) { } const char pattern[] = - "extern %sVISIBLE size_t %s;\n" + "extern %sVISIBLE uint32_t %s;\n" "static CFISH_INLINE %s\n" "%s(%s%s) {\n" "%s" http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/25c561a4/compiler/src/CFCBindSpecs.c ---------------------------------------------------------------------- diff --git a/compiler/src/CFCBindSpecs.c b/compiler/src/CFCBindSpecs.c index 4db517b..7c5c2a3 100644 --- a/compiler/src/CFCBindSpecs.c +++ b/compiler/src/CFCBindSpecs.c @@ -99,21 +99,21 @@ CFCBindSpecs_get_typedefs() { " */\n" "\n" "typedef struct cfish_NovelMethSpec {\n" - " size_t *offset;\n" + " uint32_t *offset;\n" " const char *name;\n" " cfish_method_t func;\n" " cfish_method_t callback_func;\n" "} cfish_NovelMethSpec;\n" "\n" "typedef struct cfish_OverriddenMethSpec {\n" - " size_t *offset;\n" - " size_t *parent_offset;\n" + " uint32_t *offset;\n" + " uint32_t *parent_offset;\n" " cfish_method_t func;\n" "} cfish_OverriddenMethSpec;\n" "\n" "typedef struct cfish_InheritedMethSpec {\n" - " size_t *offset;\n" - " size_t *parent_offset;\n" + " uint32_t *offset;\n" + " uint32_t *parent_offset;\n" "} cfish_InheritedMethSpec;\n" "\n" "typedef enum {\n" http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/25c561a4/runtime/core/Clownfish/Class.c ---------------------------------------------------------------------- diff --git a/runtime/core/Clownfish/Class.c b/runtime/core/Clownfish/Class.c index 5f30de2..d2de1ff 100644 --- a/runtime/core/Clownfish/Class.c +++ b/runtime/core/Clownfish/Class.c @@ -70,12 +70,12 @@ Class_bootstrap(const cfish_ClassSpec *specs, size_t num_specs, const ClassSpec *spec = &specs[i]; Class *parent = spec->parent ? *spec->parent : NULL; - size_t novel_offset = parent - ? parent->class_alloc_size - : offsetof(Class, vtable); - size_t class_alloc_size = novel_offset - + spec->num_novel_meths - * sizeof(cfish_method_t); + uint32_t novel_offset = parent + ? parent->class_alloc_size + : offsetof(Class, vtable); + uint32_t class_alloc_size = novel_offset + + spec->num_novel_meths + * sizeof(cfish_method_t); Class *klass = (Class*)Memory_wrapped_calloc(class_alloc_size, 1); @@ -128,12 +128,12 @@ Class_bootstrap(const cfish_ClassSpec *specs, size_t num_specs, // recalculated. Class_Init_Obj_IMP(CLASS, klass); - size_t novel_offset = parent - ? parent->class_alloc_size - : offsetof(Class, vtable); - size_t class_alloc_size = novel_offset - + spec->num_novel_meths - * sizeof(cfish_method_t); + uint32_t novel_offset = parent + ? parent->class_alloc_size + : offsetof(Class, vtable); + uint32_t class_alloc_size = novel_offset + + spec->num_novel_meths + * sizeof(cfish_method_t); klass->parent = parent; klass->parcel_id = parcel_id; @@ -161,8 +161,8 @@ Class_bootstrap(const cfish_ClassSpec *specs, size_t num_specs, if (parent) { // Copy parent vtable. - size_t parent_vt_size = parent->class_alloc_size - - offsetof(Class, vtable); + uint32_t parent_vt_size = parent->class_alloc_size + - offsetof(Class, vtable); memcpy(klass->vtable, parent->vtable, parent_vt_size); } @@ -224,7 +224,7 @@ Class_Destroy_IMP(Class *self) { } void -Class_Override_IMP(Class *self, cfish_method_t method, size_t offset) { +Class_Override_IMP(Class *self, cfish_method_t method, uint32_t offset) { union { char *char_ptr; cfish_method_t *func_ptr; } pointer; pointer.char_ptr = ((char*)self) + offset; pointer.func_ptr[0] = method; http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/25c561a4/runtime/core/Clownfish/Class.cfh ---------------------------------------------------------------------- diff --git a/runtime/core/Clownfish/Class.cfh b/runtime/core/Clownfish/Class.cfh index 733e06e..4a789eb 100644 --- a/runtime/core/Clownfish/Class.cfh +++ b/runtime/core/Clownfish/Class.cfh @@ -31,7 +31,7 @@ final class Clownfish::Class inherits Clownfish::Obj { uint32_t flags; int32_t parcel_id; size_t obj_alloc_size; - size_t class_alloc_size; + uint32_t class_alloc_size; Method **methods; cfish_method_t[1] vtable; /* flexible array */ @@ -97,7 +97,7 @@ final class Clownfish::Class inherits Clownfish::Obj { /** Replace a function pointer in the Class's vtable. */ void - Override(Class *self, cfish_method_t method_ptr, size_t offset); + Override(Class *self, cfish_method_t method_ptr, uint32_t offset); /** Create an empty object of the type defined by the Class: allocate, * assign its class and give it an initial refcount of 1. The caller is http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/25c561a4/runtime/core/Clownfish/Method.c ---------------------------------------------------------------------- diff --git a/runtime/core/Clownfish/Method.c b/runtime/core/Clownfish/Method.c index 5fc02da..c75bd4c 100644 --- a/runtime/core/Clownfish/Method.c +++ b/runtime/core/Clownfish/Method.c @@ -23,14 +23,14 @@ #include "Clownfish/Class.h" Method* -Method_new(String *name, cfish_method_t callback_func, size_t offset) { +Method_new(String *name, cfish_method_t callback_func, uint32_t offset) { Method *self = (Method*)Class_Make_Obj(METHOD); return Method_init(self, name, callback_func, offset); } Method* Method_init(Method *self, String *name, cfish_method_t callback_func, - size_t offset) { + uint32_t offset) { /* The `name` member which Method exposes via the `Get_Name` accessor uses * a "wrapped" string because that is effectively threadsafe: an INCREF * results in a copy and the only reference is owned by an immortal http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/25c561a4/runtime/core/Clownfish/Method.cfh ---------------------------------------------------------------------- diff --git a/runtime/core/Clownfish/Method.cfh b/runtime/core/Clownfish/Method.cfh index 4fb4f28..3fa8633 100644 --- a/runtime/core/Clownfish/Method.cfh +++ b/runtime/core/Clownfish/Method.cfh @@ -26,15 +26,15 @@ final class Clownfish::Method inherits Clownfish::Obj { String *host_alias; String *host_alias_internal; cfish_method_t callback_func; - size_t offset; + uint32_t offset; bool is_excluded; inert Method* - new(String *name, cfish_method_t callback_func, size_t offset); + new(String *name, cfish_method_t callback_func, uint32_t offset); inert Method* init(Method *self, String *name, cfish_method_t callback_func, - size_t offset); + uint32_t offset); String* Get_Name(Method *self);
