[gnode] gobject: Add a base class template



commit fd9398e2a202ff5412fe651ec47ed8a7f56b4c87
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Fri Nov 27 15:05:11 2015 -0800

    gobject: Add a base class template

 src/gobject.cc |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)
---
diff --git a/src/gobject.cc b/src/gobject.cc
index e7e578f..68bf554 100644
--- a/src/gobject.cc
+++ b/src/gobject.cc
@@ -176,6 +176,12 @@ static void DefinePrototypeMethods(Handle<ObjectTemplate> prototype, GIBaseInfo
     }
 }
 
+static Handle<FunctionTemplate> GetBaseClassTemplate() {
+    Local<FunctionTemplate> tpl = FunctionTemplate::New ();
+    tpl->InstanceTemplate ()->SetInternalFieldCount (1);
+    return tpl;
+}
+
 static Handle<FunctionTemplate> GetClassTemplateFromGI(GIBaseInfo *info);
 
 static Handle<FunctionTemplate> GetClassTemplate(GIBaseInfo *info, GType gtype) {
@@ -198,13 +204,13 @@ static Handle<FunctionTemplate> GetClassTemplate(GIBaseInfo *info, GType gtype)
         if (parent_info) {
             Handle<FunctionTemplate> parent_tpl = GetClassTemplateFromGI ((GIBaseInfo *) parent_info);
             tpl->Inherit (parent_tpl);
+        } else {
+            tpl->Inherit (GetBaseClassTemplate ());
         }
 
         DefineConstructorMethods (tpl, info);
         DefinePrototypeMethods (tpl->PrototypeTemplate (), info);
 
-        tpl->InstanceTemplate ()->SetInternalFieldCount (1);
-
         return tpl;
     }
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]