lucy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nwelln...@apache.org
Subject [11/14] lucy-clownfish git commit: Introduce struct cfish_ParcelSpec
Date Sat, 19 Mar 2016 17:27:21 GMT
Introduce struct cfish_ParcelSpec

Change Class_bootstrap to take a single pointer to struct
cfish_ParcelSpec.


Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/8b71db60
Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/8b71db60
Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/8b71db60

Branch: refs/heads/master
Commit: 8b71db60c361fde4135e7b16b4e018a48bae1d2f
Parents: 70f2562
Author: Nick Wellnhofer <wellnhofer@aevum.de>
Authored: Thu Mar 10 21:15:12 2016 +0100
Committer: Nick Wellnhofer <wellnhofer@aevum.de>
Committed: Thu Mar 10 21:49:25 2016 +0100

----------------------------------------------------------------------
 compiler/src/CFCBindSpecs.c      | 24 ++++++++++++++++++++----
 runtime/core/Clownfish/Class.c   | 17 ++++++++++-------
 runtime/core/Clownfish/Class.cfh |  5 +----
 3 files changed, 31 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/8b71db60/compiler/src/CFCBindSpecs.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCBindSpecs.c b/compiler/src/CFCBindSpecs.c
index d9aecca..ee10a50 100644
--- a/compiler/src/CFCBindSpecs.c
+++ b/compiler/src/CFCBindSpecs.c
@@ -131,6 +131,14 @@ CFCBindSpecs_get_typedefs() {
         "    uint32_t      num_inherited_meths;\n"
         "    uint32_t      flags;\n"
         "} cfish_ClassSpec;\n"
+        "\n"
+        "typedef struct cfish_ParcelSpec {\n"
+        "    const cfish_ClassSpec          *class_specs;\n"
+        "    const cfish_NovelMethSpec      *novel_specs;\n"
+        "    const cfish_OverriddenMethSpec *overridden_specs;\n"
+        "    const cfish_InheritedMethSpec  *inherited_specs;\n"
+        "    uint32_t num_classes;\n"
+        "} cfish_ParcelSpec;\n"
         "\n";
 }
 
@@ -267,9 +275,18 @@ CFCBindSpecs_defs(CFCBindSpecs *self) {
         "%s"
         "static cfish_ClassSpec class_specs[] = {\n"
         "%s\n"
+        "};\n"
+        "\n"
+        "static const cfish_ParcelSpec parcel_spec = {\n"
+        "    class_specs,\n"
+        "    novel_specs,\n"
+        "    overridden_specs,\n"
+        "    inherited_specs,\n"
+        "    %d\n" // num_classes
         "};\n";
     char *defs = CFCUtil_sprintf(pattern, novel_specs, overridden_specs,
-                                 inherited_specs, self->class_specs);
+                                 inherited_specs, self->class_specs,
+                                 self->num_specs);
 
     FREEMEM(inherited_specs);
     FREEMEM(overridden_specs);
@@ -284,10 +301,9 @@ CFCBindSpecs_init_func_def(CFCBindSpecs *self) {
         "S_bootstrap_specs() {\n"
         "%s"
         "\n"
-        "    cfish_Class_bootstrap(class_specs, %d, novel_specs,\n"
-        "                          overridden_specs, inherited_specs);\n"
+        "    cfish_Class_bootstrap(&parcel_spec);\n"
         "}\n";
-    return CFCUtil_sprintf(pattern, self->init_code, self->num_specs);
+    return CFCUtil_sprintf(pattern, self->init_code);
 }
 
 static char*

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/8b71db60/runtime/core/Clownfish/Class.c
----------------------------------------------------------------------
diff --git a/runtime/core/Clownfish/Class.c b/runtime/core/Clownfish/Class.c
index 86fe7c1..15cde2c 100644
--- a/runtime/core/Clownfish/Class.c
+++ b/runtime/core/Clownfish/Class.c
@@ -57,17 +57,20 @@ static LockFreeRegistry *Class_registry;
 cfish_Class_bootstrap_hook1_t cfish_Class_bootstrap_hook1;
 
 void
-Class_bootstrap(const cfish_ClassSpec *specs, size_t num_specs,
-                const cfish_NovelMethSpec *novel_specs,
-                const cfish_OverriddenMethSpec *overridden_specs,
-                const cfish_InheritedMethSpec *inherited_specs) {
+Class_bootstrap(const cfish_ParcelSpec *parcel_spec) {
+    const ClassSpec          *specs            = parcel_spec->class_specs;
+    const NovelMethSpec      *novel_specs      = parcel_spec->novel_specs;
+    const OverriddenMethSpec *overridden_specs = parcel_spec->overridden_specs;
+    const InheritedMethSpec  *inherited_specs  = parcel_spec->inherited_specs;
+    uint32_t num_classes = parcel_spec->num_classes;
+
     int32_t parcel_id = S_claim_parcel_id();
 
     /* Pass 1:
      * - Allocate memory.
      * - Initialize global Class pointers.
      */
-    for (size_t i = 0; i < num_specs; ++i) {
+    for (uint32_t i = 0; i < num_classes; ++i) {
         const ClassSpec *spec = &specs[i];
         Class *parent = NULL;
 
@@ -110,7 +113,7 @@ Class_bootstrap(const cfish_ClassSpec *specs, size_t num_specs,
     uint32_t num_novel      = 0;
     uint32_t num_overridden = 0;
     uint32_t num_inherited  = 0;
-    for (size_t i = 0; i < num_specs; ++i) {
+    for (uint32_t i = 0; i < num_classes; ++i) {
         const ClassSpec *spec = &specs[i];
         Class *klass  = *spec->klass;
         Class *parent = spec->parent ? *spec->parent : NULL;
@@ -197,7 +200,7 @@ Class_bootstrap(const cfish_ClassSpec *specs, size_t num_specs,
     num_novel      = 0;
     num_overridden = 0;
     num_inherited  = 0;
-    for (size_t i = 0; i < num_specs; ++i) {
+    for (uint32_t i = 0; i < num_classes; ++i) {
         const ClassSpec *spec = &specs[i];
         Class *klass = *spec->klass;
 

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/8b71db60/runtime/core/Clownfish/Class.cfh
----------------------------------------------------------------------
diff --git a/runtime/core/Clownfish/Class.cfh b/runtime/core/Clownfish/Class.cfh
index bdef4fb..ab6e2b8 100644
--- a/runtime/core/Clownfish/Class.cfh
+++ b/runtime/core/Clownfish/Class.cfh
@@ -38,10 +38,7 @@ public final class Clownfish::Class inherits Clownfish::Obj {
     inert uint32_t offset_of_parent;
 
     inert void
-    bootstrap(const cfish_ClassSpec *specs, size_t num_specs,
-              const cfish_NovelMethSpec *novel_specs,
-              const cfish_OverriddenMethSpec *overridden_specs,
-              const cfish_InheritedMethSpec *inherited_specs);
+    bootstrap(const cfish_ParcelSpec *parcel_spec);
 
     /** Return a singleton.  If a Class can be found in the registry based on
      * the supplied class name, it will be returned.  Otherwise, a new Class


Mime
View raw message