changeset 829:379fd510ba38

Define accessor for the opacity attribute of the coord
author wycc
date Wed, 15 Sep 2010 01:17:43 +0800
parents fc035abcf82a
children 2a73ff24c141
files nodejs/coord.cc nodejs/coord.m4
diffstat 2 files changed, 17 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/nodejs/coord.cc	Wed Sep 15 01:15:58 2010 +0800
+++ b/nodejs/coord.cc	Wed Sep 15 01:17:43 2010 +0800
@@ -259,19 +259,29 @@
 }
 
 static void
-xnjsmb_coord_set_opacity(coord_t *coord, Handle<Object> self,
-			 float opacity) {
+xnjsmb_coord_set_opacity(Handle<Object> self, coord_t *coord, Handle<Value> value, const char **str)
+{
     Handle<Object> js_rt;
     redraw_man_t *rdman;
-
+    
     js_rt = GET(self, "mbrt")->ToObject();
     ASSERT(js_rt != NULL);
     rdman = xnjsmb_rt_rdman(js_rt);
 
-    coord_set_opacity(coord, opacity);
+    
+    coord_set_opacity(coord, value->NumberValue());
     rdman_coord_changed(rdman, coord);
 }
 
+static Handle<Value>
+xnjsmb_coord_get_opacity(Handle<Object> self, coord_t *coord,
+			      const char **err) {
+    float opacity;
+
+    opacity = coord_get_opacity(coord);
+    return Number::New(opacity);
+}
+
 #include "coord-inc.h"
 
 /*! \brief This function used by \ref xnjsmb_mb_rt to wrap coord object.
--- a/nodejs/coord.m4	Wed Sep 15 01:15:58 2010 +0800
+++ b/nodejs/coord.m4	Wed Sep 15 01:17:43 2010 +0800
@@ -1,12 +1,11 @@
 define([PROJ_PREFIX], [xnjsmb_auto_])dnl
-STRUCT([coord], [coord_t], [],
+STRUCT([coord], [coord_t], 
+        [ACCESSOR([opacity], [xnjsmb_coord_get_opacity],[xnjsmb_coord_set_opacity])],
 	[METHOD([add_shape], [xnjsmb_coord_add_shape],
 		(SELF, OBJ([shape], [shape], [shape_t]), ERR), 1, []),
 	 METHOD([remove], [xnjsmb_coord_remove], (SELF), 0, []),
 	 METHOD([show], [xnjsmb_coord_show], (SELF), 0, []),
-	 METHOD([hide], [xnjsmb_coord_hide], (SELF), 0, []),
-	 METHOD([set_opacity], [xnjsmb_coord_set_opacity],
-	        (SELF, NUMBER([opacity])), 1, [])],
+	 METHOD([hide], [xnjsmb_coord_hide], (SELF), 0, [])],
 	((GET_INDEX, (coord_get_index, NUMBER)),
 	 (SET_INDEX, (coord_set_index, NUMBER)),
 	 ([STMOD], [xnjsmb_coord_mod])))