annotate nodejs/shapes.cc @ 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
children c0bc60448913
rev   line source
564
0cd1511272d2 Make base type for shapes.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
1 #include <v8.h>
0cd1511272d2 Make base type for shapes.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
2 #include "mbfly_njs.h"
0cd1511272d2 Make base type for shapes.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
3
0cd1511272d2 Make base type for shapes.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
4 extern "C" {
0cd1511272d2 Make base type for shapes.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
5 #include <mb.h>
0cd1511272d2 Make base type for shapes.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
6 }
0cd1511272d2 Make base type for shapes.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
7
0cd1511272d2 Make base type for shapes.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
8 using namespace v8;
0cd1511272d2 Make base type for shapes.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
9
0cd1511272d2 Make base type for shapes.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
10 /*! \defgroup shape_temp Templates for shape and derive.
0cd1511272d2 Make base type for shapes.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
11 *
0cd1511272d2 Make base type for shapes.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
12 * @{
0cd1511272d2 Make base type for shapes.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
13 */
0cd1511272d2 Make base type for shapes.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
14 static Persistent<FunctionTemplate> xnjsmb_shape_temp;
0cd1511272d2 Make base type for shapes.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
15
0cd1511272d2 Make base type for shapes.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
16 static Handle<Value>
0cd1511272d2 Make base type for shapes.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
17 xnjsmb_shape_show(const Arguments &args) {
0cd1511272d2 Make base type for shapes.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
18 shape_t *sh;
0cd1511272d2 Make base type for shapes.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
19 Handle<Object> self;
0cd1511272d2 Make base type for shapes.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
20
0cd1511272d2 Make base type for shapes.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
21 self = args.This();
0cd1511272d2 Make base type for shapes.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
22 sh = (shape_t *)UNWRAP(self);
0cd1511272d2 Make base type for shapes.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
23 sh_show(sh);
0cd1511272d2 Make base type for shapes.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
24
0cd1511272d2 Make base type for shapes.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
25 return Null();
0cd1511272d2 Make base type for shapes.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
26 }
0cd1511272d2 Make base type for shapes.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
27
0cd1511272d2 Make base type for shapes.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
28 static Handle<Value>
0cd1511272d2 Make base type for shapes.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
29 xnjsmb_shape_hide(const Arguments &args) {
0cd1511272d2 Make base type for shapes.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
30 shape_t *sh;
0cd1511272d2 Make base type for shapes.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
31 Handle<Object> self;
0cd1511272d2 Make base type for shapes.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
32
0cd1511272d2 Make base type for shapes.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
33 self = args.This();
0cd1511272d2 Make base type for shapes.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
34 sh = (shape_t *)UNWRAP(self);
0cd1511272d2 Make base type for shapes.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
35 sh_hide(sh);
0cd1511272d2 Make base type for shapes.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
36
0cd1511272d2 Make base type for shapes.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
37 return Null();
0cd1511272d2 Make base type for shapes.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
38 }
0cd1511272d2 Make base type for shapes.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
39
0cd1511272d2 Make base type for shapes.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
40 static void
0cd1511272d2 Make base type for shapes.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
41 xnjsmb_init_shape_temp(void) {
0cd1511272d2 Make base type for shapes.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
42 Handle<FunctionTemplate> temp;
0cd1511272d2 Make base type for shapes.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
43 Handle<ObjectTemplate> proto_temp;
0cd1511272d2 Make base type for shapes.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
44 Handle<FunctionTemplate> method_temp;
0cd1511272d2 Make base type for shapes.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
45
0cd1511272d2 Make base type for shapes.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
46 temp = FunctionTemplate::New();
0cd1511272d2 Make base type for shapes.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
47 temp->SetClassName(String::New("shape"));
0cd1511272d2 Make base type for shapes.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
48 xnjsmb_shape_temp = Persistent<FunctionTemplate>::New(temp);
0cd1511272d2 Make base type for shapes.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
49 proto_temp = temp->PrototypeTemplate();
0cd1511272d2 Make base type for shapes.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
50
0cd1511272d2 Make base type for shapes.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
51 method_temp = FunctionTemplate::New(xnjsmb_shape_show);
0cd1511272d2 Make base type for shapes.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
52 SET(proto_temp, "show", method_temp);
0cd1511272d2 Make base type for shapes.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
53 method_temp = FunctionTemplate::New(xnjsmb_shape_hide);
0cd1511272d2 Make base type for shapes.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
54 SET(proto_temp, "hide", method_temp);
0cd1511272d2 Make base type for shapes.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
55 }
0cd1511272d2 Make base type for shapes.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
56
0cd1511272d2 Make base type for shapes.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
57 /* @} */
0cd1511272d2 Make base type for shapes.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
58