Beispiel #1
0
Handle<Value> getValueObjectWriteCount(const Arguments &args) {
  HandleScope scope;
  Local<Object> obj = args[0]->ToObject();
  NdbRecordObject * nro =
    static_cast<NdbRecordObject *>(obj->GetPointerFromInternalField(1));
 
  return scope.Close(Number::New(nro->getWriteCount()));
}
Beispiel #2
0
 void* Get<void*> (Handle<Value> value) {
   void *ptr = NULL;
   if (value->IsObject()) {
     Local<Object> object = value->ToObject();
     if (object->InternalFieldCount()) {
       ptr = object->GetPointerFromInternalField(0);
     }
   }
   return ptr;
 }
static void
gum_script_file_on_destroy (Persistent<Value> value,
                            void * data)
{
  (void) data;

  HandleScope handle_scope;
  Local<Object> object (value->ToObject ());
  FILE * file = static_cast<FILE *> (object->GetPointerFromInternalField (0));
  if (file != NULL)
    fclose (file);
  value.Dispose ();
}
static Handle<Value> require_file(const Arguments &args) //读取js文件
{
	HandleScope scope;
	
		if(!args[0]->IsString()){
		return ThrowException(Exception::TypeError(String::New("require(filepath): filapath must needed")));
	}

	Local<Object> Gobj = args.This();

	String::Utf8Value* dirname_p = (String::Utf8Value*) Gobj->GetPointerFromInternalField(0);
	std::string dirname = **dirname_p;


	//c++利用js函数加工处理参数,这里让c++利用 _object_toString
	
	Local<Object> path_resolve_obj = Script::Compile(String::New(path_resolve_js))->Run()->ToObject();
#ifdef WIN32
	Local<Object> path_resolve_func = path_resolve_obj->Get(String::New("resolve_win"))->ToObject();
#else
	Local<Object> path_resolve_func = path_resolve_obj->Get(String::New("resolve_linux"))->ToObject();
#endif   
	Local<Value> argv[2];
    argv[0] = String::New(dirname.c_str());
	argv[1] = args[0];

	Local<Value> path_str_value = path_resolve_func->CallAsFunction(Object::New(), 2, argv);


	String::Utf8Value utf8_value(path_str_value->ToString());
	std::string path_str = *utf8_value;


	char *file = readFile(String::New(path_str.c_str()));
	
	TryCatch onError;
	Script::Compile(String::New(file))->Run();

	if(onError.HasCaught()){
		std::string err_str= "require has error";
		
		err_str += path_str;
		return ThrowException(Exception::TypeError(String::New(err_str.c_str())));
	}
	
	return scope.Close(Gobj);

}
Beispiel #5
0
  void DisposeOpenCLObject (Persistent<Value> value, void* release) {
    if (release && value->IsObject()) {
      Local<Object> object = value->ToObject();
      if (object->InternalFieldCount()) {
        void *ptr = object->GetPointerFromInternalField(0);

        int32_t (CALL *clRelease) (void* smth);
        *(void**) &clRelease = release;

        clRelease(ptr); // Returned value is omitted. Check when debugging.
      }
    }

    value.Dispose();
    value.Clear();
  }
Beispiel #6
0
Handle<Value> isValueObject(const Arguments &args) {
  HandleScope scope;
  bool answer = false;  
  Handle<Value> v = args[0];

  if(v->IsObject()) {
    Local<Object> o = v->ToObject();
    if(o->InternalFieldCount() == 2) {
      Envelope * n = (Envelope *) o->GetPointerFromInternalField(0);
      if(n == & nroEnvelope) {
        answer = true;
      }
    }
  }

  return scope.Close(Boolean::New(answer));
}
void NativeStatusIcon::Init(Settings* settings) {
  char* iconFile = settings->getString("icon","");
  char* tooltip  = settings->getString("tooltip","");
  bool  visible  = settings->getBoolean("visible",true);

  // TODO local or persistent?
  Local<Object> menu = settings->getObject("menu");

  NativeMenu* nativeMenu;
  GtkStatusIcon *statusIcon;

  if( settings->has("icon") ) {
    statusIcon = gtk_status_icon_new_from_file(iconFile);
  } else {
    statusIcon = gtk_status_icon_new_from_stock(GTK_STOCK_MISSING_IMAGE);
  }

  statusIconHandle_ = statusIcon;

  if( settings->has("tooltip") ) {
    gtk_status_icon_set_tooltip_text(statusIcon, tooltip);
    gtk_status_icon_set_title(statusIcon,tooltip);
  }

  if( settings->has("menu") ) {

    GtkWidget* gtkMenu = gtk_menu_new();

    nativeMenu = (NativeMenu*)menu->GetPointerFromInternalField(0);
    nativeMenu->Attach(GTK_MENU_SHELL(gtkMenu));

    g_signal_connect(statusIcon, "popup-menu", GTK_SIGNAL_FUNC (status_icon_show_menu), gtkMenu);

  }

  g_signal_connect(statusIcon, "activate", G_CALLBACK(status_icon_click), this);
  g_signal_connect(statusIcon, "popup-menu", G_CALLBACK(status_icon_popup), this);

  gtk_status_icon_set_visible(statusIcon, visible);
}