当前位置: 首页>>代码示例>>C++>>正文


C++ JSValueMakeNull函数代码示例

本文整理汇总了C++中JSValueMakeNull函数的典型用法代码示例。如果您正苦于以下问题:C++ JSValueMakeNull函数的具体用法?C++ JSValueMakeNull怎么用?C++ JSValueMakeNull使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了JSValueMakeNull函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: set_language_cb

static JSValueRef
set_language_cb(JSContextRef context,
				JSObjectRef function,
				JSObjectRef thisObject,
				size_t argumentCount,
				const JSValueRef arguments[],
				JSValueRef *exception) {

	gchar *language = NULL;

	if (argumentCount != 1) {
		return mkexception(context, exception, ARGNOTSUPPLIED);
	}

	language = arg_to_string(context, arguments[0], exception);

	if (!language) {
		return JSValueMakeNull(context);
	}

	lightdm_greeter_set_language(GREETER, language);

	g_free(language);

	return JSValueMakeNull(context);
}
开发者ID:sbalneav,项目名称:lightdm-webkit2-greeter,代码行数:26,代码来源:lightdm-webkit2-greeter-ext.c

示例2: seed_gobject_signal_connect_on_property

static JSValueRef
seed_gobject_signal_connect_on_property (JSContextRef ctx,
					 JSObjectRef function,
					 JSObjectRef thisObject,
					 size_t argumentCount,
					 const JSValueRef arguments[],
					 JSValueRef * exception)
{
  gulong id = 0;
  JSObjectRef this_obj;
  signal_privates *privates;

  privates = (signal_privates *) JSObjectGetPrivate (thisObject);
  if (!privates)
    g_error ("Signal constructed with invalid parameters"
	     "in namespace import \n");

  this_obj =
    (JSObjectRef) seed_value_from_object (ctx, privates->object, exception);

  if ((argumentCount > 2) || (argumentCount == 0))
    {
      seed_make_exception (ctx, exception, "ArgumentError",
			   "Signal connection expected"
			   " 1, or 2 arguments. Got " "%zd", argumentCount);

      return JSValueMakeNull (ctx);
    }

  if (JSValueIsNull (ctx, arguments[0]) ||
      !JSValueIsObject (ctx, arguments[0]) ||
      !JSObjectIsFunction (ctx, (JSObjectRef) arguments[0]))
    {
      seed_make_exception (ctx, exception, "ArgumentError",
			   "Signal connection requires a function"
			   " as first argument");
      return JSValueMakeNull (ctx);
    }

  if (argumentCount == 1)
    {
      id = seed_gobject_signal_connect (ctx, privates->signal_name,
					privates->object,
					(JSObjectRef) arguments[0], this_obj,
					NULL);

    }
  else if (argumentCount == 2)
    {
      id = seed_gobject_signal_connect (ctx, privates->signal_name,
					privates->object,
					(JSObjectRef) arguments[0],
					this_obj, (JSObjectRef) arguments[1]);
    }

  return seed_value_from_ulong (ctx, id, exception);
}
开发者ID:dannote,项目名称:seed,代码行数:57,代码来源:seed-signals.c

示例3: get_dirlist_cb

static JSValueRef
get_dirlist_cb(JSContextRef context,
			JSObjectRef function,
			JSObjectRef thisObject,
			size_t argumentCount,
			const JSValueRef arguments[],
			JSValueRef *exception) {
	JSObjectRef array;
	guint n_entries = 0;
	JSValueRef *args = NULL;
	GDir *dir;
	gchar *path, *fullpath;
	const gchar *dirent;
	GError *err = NULL;

	if (argumentCount != 1) {
		return mkexception(context, exception, ARGNOTSUPPLIED);
	}

	path = arg_to_string(context, arguments[0], exception);
	if (!path) {
		return JSValueMakeNull(context);
	}

	dir = g_dir_open (path, 0, &err);

	if (err) {
		_mkexception(context, exception, err->message);
		g_error_free(err);
		return JSValueMakeNull(context);
	}

	/*
	 * Create the lis of the directory entries
	 */

	while ((dirent = g_dir_read_name (dir)) != NULL) {
		n_entries++;
		args = g_realloc (args, sizeof (JSValueRef) * (n_entries + 1));
		fullpath = g_build_filename (path, dirent, NULL); /* Give theme developer full pathname */
		args[(n_entries - 1)] = string_or_null (context, fullpath);
		g_free (fullpath);
	}

	g_dir_close (dir);

	array = JSObjectMakeArray (context, n_entries, args, exception);
	g_free (args);
	if (array == NULL) {
		return JSValueMakeNull (context);
	} else {
		return array;
	}
}
开发者ID:sbalneav,项目名称:lightdm-webkit2-greeter,代码行数:54,代码来源:lightdm-webkit2-greeter-ext.c

示例4: JSValueMakeNull

static JSValueRef
zs__                (JSContextRef     js_context,
                     JSObjectRef      js_function,
                     JSObjectRef      js_this,
                     size_t           argument_count,
                     const JSValueRef js_arguments[],
                     JSValueRef*      js_exception)
{
	if(argument_count<=0){
		return JSValueMakeNull (js_context);
	}
	const char*ret;
	{
		window___* w=reinterpret_cast<window___*>(JSObjectGetPrivate(js_function));
		if(!w){
			return JSValueMakeNull (js_context);
		}
		char** argv=new char*[argument_count+1];
		JSStringRef* jsr=new JSStringRef[argument_count];
		for(size_t i=0;i<argument_count;i++){
			jsr[i]=JSValueToStringCopy(js_context, js_arguments[i], js_exception);
			size_t jsSize = JSStringGetMaximumUTF8CStringSize(jsr[i]);
			argv[i]=new char[jsSize];
			JSStringGetUTF8CString(jsr[i], argv[i], jsSize);
		}
		if(!argv[0][0]){
			ret=NULL;
			for(size_t i=1;i<argument_count;i++)
				cout<<argv[i];
			cout<<endl;
		}else
			ret=call4__(argv[0],NULL,argument_count,(const char**)argv,1);
		for(size_t i=0;i<argument_count;i++){
			delete argv[i];
			JSStringRelease(jsr[i]);
		}
		delete jsr;
		delete argv;
	}

	if(!ret)
		return JSValueMakeNull (js_context);
	JSValueRef ret2;
	if(true_==ret||false_==ret){
		ret2=JSValueMakeBoolean(js_context,true_==ret);
	}else{
		JSStringRef ret1=JSStringCreateWithUTF8CString(ret);
		ret2=JSValueMakeString(js_context,ret1);
		JSStringRelease (ret1);
	}
	return ret2;
}
开发者ID:zzzzzzzzzzz0,项目名称:zhscript,代码行数:52,代码来源:webkit_view___.cpp

示例5: switch

JSValueRef Value::fromDynamicInner(JSContextRef ctx, const folly::dynamic& obj) {
  switch (obj.type()) {
    // For premitive types (and strings), just create and return an equivalent JSValue
    case folly::dynamic::Type::NULLT:
      return JSValueMakeNull(ctx);

    case folly::dynamic::Type::BOOL:
      return JSValueMakeBoolean(ctx, obj.getBool());

    case folly::dynamic::Type::DOUBLE:
      return JSValueMakeNumber(ctx, obj.getDouble());

    case folly::dynamic::Type::INT64:
      return JSValueMakeNumber(ctx, obj.asDouble());

    case folly::dynamic::Type::STRING:
      return JSValueMakeString(ctx, String(obj.getString().c_str()));

    case folly::dynamic::Type::ARRAY: {
      // Collect JSValue for every element in the array
      JSValueRef vals[obj.size()];
      for (size_t i = 0; i < obj.size(); ++i) {
        vals[i] = fromDynamicInner(ctx, obj[i]);
      }
      // Create a JSArray with the values
      JSValueRef arr = JSObjectMakeArray(ctx, obj.size(), vals, nullptr);
      return arr;
    }

    case folly::dynamic::Type::OBJECT: {
      // Create an empty object
      JSObjectRef jsObj = JSObjectMake(ctx, nullptr, nullptr);
      // Create a JSValue for each of the object's children and set them in the object
      for (auto it = obj.items().begin(); it != obj.items().end(); ++it) {
        JSObjectSetProperty(
          ctx,
          jsObj,
          String(it->first.asString().c_str()),
          fromDynamicInner(ctx, it->second),
          kJSPropertyAttributeNone,
          nullptr);
      }
      return jsObj;
    }
    default:
      // Assert not reached
      LOG(FATAL) << "Trying to convert a folly object of unsupported type.";
      return JSValueMakeNull(ctx);
  }
}
开发者ID:Curse,项目名称:react-native,代码行数:50,代码来源:Value.cpp

示例6: JSValueMakeNull

JS4D::ValueRef JS4D::VBlobToValue( ContextRef inContext, const VBlob& inBlob, const VString& inContentType)
{
	if (inBlob.IsNull())
		return JSValueMakeNull( inContext);

	VJSBlobValue_Slice* blobValue = VJSBlobValue_Slice::Create( inBlob, inContentType);
	if (blobValue == NULL)
		return JSValueMakeNull( inContext);
		
	ValueRef value = VJSBlob::CreateInstance( inContext, blobValue);
	ReleaseRefCountable( &blobValue);

	return value;
}
开发者ID:sanyaade-webdev,项目名称:core-XToolbox,代码行数:14,代码来源:JS4D.cpp

示例7: seed_gobject_signal_connect_by_name

static JSValueRef
seed_gobject_signal_connect_by_name (JSContextRef ctx,
				     JSObjectRef function,
				     JSObjectRef thisObject,
				     size_t argumentCount,
				     const JSValueRef arguments[],
				     JSValueRef * exception)
{
  GType obj_type;
  JSObjectRef user_data = NULL;
  gchar *signal_name;
  GObject *obj;
  gulong id;

  if (argumentCount < 2 || argumentCount > 3)
    {
      seed_make_exception (ctx, exception, "ArgumentError",
			   "Signal connection expected"
			   " 2 or 3 arguments. Got " "%zd", argumentCount);

      return JSValueMakeNull (ctx);
    }

  if (JSValueIsNull (ctx, arguments[1]) ||
      !JSValueIsObject (ctx, arguments[1]) ||
      !JSObjectIsFunction (ctx, (JSObjectRef) arguments[1]))
    {
      seed_make_exception (ctx, exception, "ArgumentError",
			   "Signal connection by name "
			   "requires a function" " as second argument");
      return JSValueMakeNull (ctx);
    }

  if (argumentCount == 3)
    {
      user_data = (JSObjectRef) arguments[2];
    }

  signal_name = seed_value_to_string (ctx, arguments[0], exception);
  obj = (GObject *) JSObjectGetPrivate (thisObject);
  obj_type = G_OBJECT_TYPE (obj);

  id = seed_gobject_signal_connect (ctx, signal_name, obj,
				    (JSObjectRef) arguments[1], NULL,
				    user_data);

  g_free (signal_name);

  return seed_value_from_ulong (ctx, id, exception);
}
开发者ID:dannote,项目名称:seed,代码行数:50,代码来源:seed-signals.c

示例8: js_cb_launcher_submit

static JSValueRef
js_cb_launcher_submit(JSContextRef context,
                      JSObjectRef function,
                      JSObjectRef self,
                      size_t argc,
                      const JSValueRef argv[],
                      JSValueRef* exception)
{
    if (argc != 2)
        return JSValueMakeNull(context);

    int len = JSValueToNumber(context, argv[0], NULL);
    JSObjectRef arr = JSValueToObject(context, argv[1], NULL);

    static const int CMD_LINE_SIZE = 4096;
    static const int CMD_ARGS_SIZE = 256;

    char  cmd_str_buf[CMD_LINE_SIZE];
    int   cmd_str_buf_cur = 0;
    char *cmd_idx_buf[CMD_ARGS_SIZE];

    if (len == 0 || len >= CMD_ARGS_SIZE) return JSValueMakeNull(context);

    int i;
    for (i = 0; i < len; ++ i)
    {
        JSValueRef cur = JSObjectGetPropertyAtIndex(context, arr, i, NULL);
        JSStringRef str = JSValueToStringCopy(context, cur, NULL);
        size_t l = JSStringGetUTF8CString(str, cmd_str_buf + cmd_str_buf_cur, CMD_LINE_SIZE - cmd_str_buf_cur);
        cmd_idx_buf[i] = cmd_str_buf + cmd_str_buf_cur;
        cmd_str_buf_cur += l;
        JSStringRelease(str);
        JSValueUnprotect(context, cur);
    }
    cmd_idx_buf[i] = 0;

    if (fork() == 0)
    {
        /* Redirect I/O streams */
        freopen("/dev/null", "r", stdin);
        freopen("/dev/null", "w", stdout);
        execvp(cmd_idx_buf[0], cmd_idx_buf);
        fprintf(stderr, "RETURNED");
        exit(1);
    }
    
    return JSValueMakeNull(context);
}
开发者ID:HenryHu,项目名称:weblet,代码行数:48,代码来源:main.c

示例9: get_hint_cb

static JSValueRef
get_hint_cb(JSContextRef context,
			JSObjectRef function,
			JSObjectRef thisObject,
			size_t argumentCount,
			const JSValueRef arguments[],
			JSValueRef *exception) {

	gchar *hint_name = NULL;
	JSValueRef result;

	if (argumentCount != 1) {
		return mkexception(context, exception, ARGNOTSUPPLIED);
	}

	hint_name = arg_to_string(context, arguments[0], exception);

	if (!hint_name) {
		return JSValueMakeNull(context);
	}

	result = string_or_null(context, lightdm_greeter_get_hint(GREETER, hint_name));
	g_free(hint_name);

	return result;
}
开发者ID:sbalneav,项目名称:lightdm-webkit2-greeter,代码行数:26,代码来源:lightdm-webkit2-greeter-ext.c

示例10: get_sessions_cb

static JSValueRef
get_sessions_cb(JSContextRef context,
				JSObjectRef thisObject,
				JSStringRef propertyName,
				JSValueRef *exception) {

	JSObjectRef array;
	const GList *sessions, *link;
	guint i, n_sessions = 0;
	JSValueRef *args;

	sessions = lightdm_get_sessions();
	n_sessions = g_list_length((GList *) sessions);
	args = g_malloc(sizeof(JSValueRef) * ( n_sessions + 1 ));

	for (i = 0, link = sessions; link; i++, link = link->next) {
		LightDMSession *session = link->data;
		g_object_ref(session);

		args[i] = JSObjectMake(context, lightdm_session_class, session);
	}

	array = JSObjectMakeArray(context, n_sessions, args, exception);
	g_free(args);

	if (array == NULL) {
		return JSValueMakeNull(context);
	} else {
		return array;
	}
}
开发者ID:sbalneav,项目名称:lightdm-webkit2-greeter,代码行数:31,代码来源:lightdm-webkit2-greeter-ext.c

示例11: get_users_cb

static JSValueRef
get_users_cb(JSContextRef context,
			 JSObjectRef thisObject,
			 JSStringRef propertyName,
			 JSValueRef *exception) {

	JSObjectRef array;
	const GList *users, *link;
	guint i, n_users = 0;
	JSValueRef *args;

	users = lightdm_user_list_get_users(lightdm_user_list_get_instance());
	n_users = g_list_length((GList *) users);
	args = g_malloc(sizeof(JSValueRef) * ( n_users + 1 ));

	for (i = 0, link = users; link; i++, link = link->next) {
		LightDMUser *user = link->data;
		g_object_ref(user);
		args[i] = JSObjectMake(context, lightdm_user_class, user);
	}

	array = JSObjectMakeArray(context, n_users, args, exception);
	g_free(args);

	if (array == NULL) {
		return JSValueMakeNull(context);
	} else {
		return array;
	}
}
开发者ID:sbalneav,项目名称:lightdm-webkit2-greeter,代码行数:30,代码来源:lightdm-webkit2-greeter-ext.c

示例12: HyperloopJSValueIsArray

/*
 * Tests whether a JavaScript value is an array object
 * 
 * This invokes Array.isArray(value) and returns its result
 */
EXPORTAPI bool HyperloopJSValueIsArray(JSContextRef ctx, JSValueRef value) 
{
    if (JSValueIsObject(ctx, value)) 
    {
        JSObjectRef global = JSContextGetGlobalObject(ctx);
        JSValueRef exception = JSValueMakeNull(ctx);
        JSStringRef string = JSStringCreateWithUTF8CString("Array");
        JSObjectRef array = JSValueToObject(ctx, JSObjectGetProperty(ctx, global, string, &exception), &exception);
        JSStringRelease(string);
        if (!JSValueIsNull(ctx, exception)) 
        {
            return false;
        }

        string = JSStringCreateWithUTF8CString("isArray");
        JSObjectRef isArray = JSValueToObject(ctx, JSObjectGetProperty(ctx, array, string, &exception), &exception);
        JSStringRelease(string);
        if (!JSValueIsNull(ctx, exception))
        {
            return false;
        }

        JSValueRef result = JSObjectCallAsFunction(ctx, isArray, global, 1, &value, &exception);

        if (JSValueIsNull(ctx, exception) && JSValueIsBoolean(ctx, result)) 
        {
            return JSValueToBoolean(ctx, result);
        }
    }
    return false;
}
开发者ID:Sophrinix,项目名称:hyperloop-common,代码行数:36,代码来源:hyperloop.cpp

示例13: function_set_exit_value

JSValueRef function_set_exit_value(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject,
		size_t argc, const JSValueRef args[], JSValueRef* exception) {
	if (argc == 1 && JSValueGetType (ctx, args[0]) == kJSTypeNumber) {
		exit_value = JSValueToNumber(ctx, args[0], NULL);
	}
	return JSValueMakeNull(ctx);
}
开发者ID:gsnewmark,项目名称:planck,代码行数:7,代码来源:main.c

示例14: hints_keypress

VbResult hints_keypress(int key)
{
    JSValueRef arguments[1];

    if (key == KEY_CR) {
        hints_fire();

        return RESULT_COMPLETE;
    } else if (key == CTRL('H')) {
        fire_timeout(false);
        arguments[0] = JSValueMakeNull(hints.ctx);
        if (call_hints_function("update", 1, arguments)) {
            return RESULT_COMPLETE;
        }
    } else if (key == KEY_TAB) {
        fire_timeout(false);
        hints_focus_next(false);

        return RESULT_COMPLETE;
    } else if (key == KEY_SHIFT_TAB) {
        fire_timeout(false);
        hints_focus_next(true);

        return RESULT_COMPLETE;
    } else {
        fire_timeout(true);
        /* try to handle the key by the javascript */
        arguments[0] = js_string_to_ref(hints.ctx, (char[]){key, '\0'});
        if (call_hints_function("update", 1, arguments)) {
            return RESULT_COMPLETE;
        }
    }
开发者ID:j1r1k,项目名称:vimb,代码行数:32,代码来源:hints.c

示例15: gettext_cb

static JSValueRef
gettext_cb(JSContextRef context,
		   JSObjectRef function,
		   JSObjectRef thisObject,
		   size_t argumentCount,
		   const JSValueRef arguments[],
		   JSValueRef *exception) {

	gchar *string = NULL;
	JSValueRef result;

	if (argumentCount != 1) {
		return mkexception(context, exception, ARGNOTSUPPLIED);
	}

	string = arg_to_string(context, arguments[0], exception);

	if (!string) {
		return JSValueMakeNull(context);
	}

	result = string_or_null(context, gettext(string));
	g_free(string);

	return result;
}
开发者ID:sbalneav,项目名称:lightdm-webkit2-greeter,代码行数:26,代码来源:lightdm-webkit2-greeter-ext.c


注:本文中的JSValueMakeNull函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。