changeset 564:0cd1511272d2 Android_Skia

Make base type for shapes. With following methods - show(), and - hide().
author Thinker K.F. Li <thinker@branda.to>
date Mon, 07 Jun 2010 19:18:20 +0800
parents bc207070e3d5
children c0bc60448913
files nodejs/Makefile.am nodejs/shapes.cc nodejs/wscript
diffstat 3 files changed, 60 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/nodejs/Makefile.am	Mon Jun 07 17:24:46 2010 +0800
+++ b/nodejs/Makefile.am	Mon Jun 07 19:18:20 2010 +0800
@@ -1,5 +1,5 @@
 
-mbfly_node_SRCS = mbfly_njs.cc X_supp_njs.c coord.cc
+mbfly_node_SRCS = mbfly_njs.cc X_supp_njs.c coord.cc shapes.cc
 mbfly_node_CFLAGS= -I$(abs_top_builddir)/include \
 	-I$(abs_top_srcdir)/include \
 	-I$(prefix)/include \
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nodejs/shapes.cc	Mon Jun 07 19:18:20 2010 +0800
@@ -0,0 +1,58 @@
+#include <v8.h>
+#include "mbfly_njs.h"
+
+extern "C" {
+#include <mb.h>
+}
+
+using namespace v8;
+
+/*! \defgroup shape_temp Templates for shape and derive.
+ *
+ * @{
+ */
+static Persistent<FunctionTemplate> xnjsmb_shape_temp;
+
+static Handle<Value>
+xnjsmb_shape_show(const Arguments &args) {
+    shape_t *sh;
+    Handle<Object> self;
+
+    self = args.This();
+    sh = (shape_t *)UNWRAP(self);
+    sh_show(sh);
+    
+    return Null();
+}
+
+static Handle<Value>
+xnjsmb_shape_hide(const Arguments &args) {
+    shape_t *sh;
+    Handle<Object> self;
+
+    self = args.This();
+    sh = (shape_t *)UNWRAP(self);
+    sh_hide(sh);
+    
+    return Null();
+}
+
+static void
+xnjsmb_init_shape_temp(void) {
+    Handle<FunctionTemplate> temp;
+    Handle<ObjectTemplate> proto_temp;
+    Handle<FunctionTemplate> method_temp;
+
+    temp = FunctionTemplate::New();
+    temp->SetClassName(String::New("shape"));
+    xnjsmb_shape_temp = Persistent<FunctionTemplate>::New(temp);
+    proto_temp = temp->PrototypeTemplate();
+    
+    method_temp = FunctionTemplate::New(xnjsmb_shape_show);
+    SET(proto_temp, "show", method_temp);
+    method_temp = FunctionTemplate::New(xnjsmb_shape_hide);
+    SET(proto_temp, "hide", method_temp);
+}
+
+/* @} */
+
--- a/nodejs/wscript	Mon Jun 07 17:24:46 2010 +0800
+++ b/nodejs/wscript	Mon Jun 07 19:18:20 2010 +0800
@@ -23,7 +23,7 @@
     
     obj = conf.new_task_gen('cxx', 'shlib', 'node_addon')
     obj.target = 'mbfly'
-    obj.source = 'mbfly_njs.cc coord.cc'
+    obj.source = 'mbfly_njs.cc coord.cc shapes.cc'
     obj.add_objects = 'X_supp_njs.o'
     obj.staticlib = 'mbfly'