예제 #1
0
파일: Conv.cpp 프로젝트: Armen138/anode
int Conv::BindToJavaObject(JNIEnv *jniEnv, jobject jLocal, Handle<Object> val, jobject *jGlobal) {
  int result = OK;
  Persistent<Object> pVal = Persistent<Object>::New(val);
  jobject ob = jniEnv->NewGlobalRef(jLocal);
  pVal.MakeWeak(ob, releaseJavaRef);
  val->SetPointerInInternalField(0, ob);
  jniEnv->SetLongField(jLocal, instHandle, asLong(pVal));
  *jGlobal = ob;
  return result;
}
예제 #2
0
Handle<Value> WrapObject(void* obj) {

  HandleScope scope;

  Persistent<ObjectTemplate> obj_template = Persistent<ObjectTemplate>::New(ObjectTemplate::New());
  obj_template->SetInternalFieldCount(1);

  Handle<Object> self = obj_template->NewInstance();

  self->SetPointerInInternalField(0, obj);

  return scope.Close(self);
}
예제 #3
0
Handle<Value> Window::New(const Arguments& args) {
  HandleScope scope;

  Handle<Object> self = Persistent<Object>::New(args.This());

  char* url = (args[0]->IsString()) ? V8StringToChar(args[0]->ToString()) : (char*) "/";
  Persistent<Object> windowSettings = Persistent<Object>::New((args[1]->IsObject()) ? args[1]->ToObject() : Object::New());

  Settings* settings = new Settings(windowSettings);
  NativeWindow* window = new NativeWindow(url, settings);
  window->SetV8Handle(self);

  self->SetPointerInInternalField (0, window);

  return scope.Close(args.This());
}