Mercurial > MadButterfly
view nodejs/coord.cc @ 559:ef078d7c57b4 Android_Skia
Use internal field to store njs_runtime_t object.
Instead of using named property to keep reference of njs_runtime_t
object, the internal field of v8 object is used.
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Mon, 07 Jun 2010 11:42:45 +0800 |
parents | 0ca8437a91fa |
children | ce7a35abcb0d |
line wrap: on
line source
#include <stdio.h> #include <v8.h> extern "C" { #include "mb.h" #include "mb_X_supp.h" #include "mb_tools.h" #include "X_supp_njs.h" } using namespace v8; static Handle<Value> xnjsmb_coord_get_index(uint32_t index, const AccessorInfo &info) { HandleScope scope; Handle<Object> self; coord_t *coord; co_aix v; Handle<Value> exc; if(index < 0 || index >= 6) { exc = Exception::Error(String::New("Invalid index")); return ThrowException(exc); } self = info.This(); coord = (coord_t *)External::Unwrap(self->Get(String::New("_njs_coord"))); v = coord_get_matrix(coord)[index]; return Number::New(v); } static Handle<Value> xnjsmb_coord_set_index(uint32_t index, Local<Value> value, const AccessorInfo &info) { HandleScope scope; Handle<Object> self; redraw_man_t *rdman; coord_t *coord; co_aix v; Handle<Value> exc; if(index < 0 || index >= 6) { exc = Exception::Error(String::New("Invalid index")); return ThrowException(exc); } if(!value->IsNumber()) { exc = Exception::Error(String::New("Invalid value")); return ThrowException(exc); } self = info.This(); coord = (coord_t *)External::Unwrap(self->Get(String::New("_njs_coord"))); v = value->NumberValue(); coord_get_matrix(coord)[index] = v; rdman = (redraw_man_t *) External::Unwrap(self->Get(String::New("_njs_rdman"))); rdman_coord_changed(rdman, coord); return value; }