• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ JSStringRelease函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: 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


示例2: mk_zs__

void mk_zs__(WebKitWebView* wwv){
	WebKitWebFrame* web_frame;
	JSGlobalContextRef js_context;
	JSObjectRef js_global;
	JSStringRef js_function_name;
	JSObjectRef js_function;
	web_frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (wwv));
	js_context = webkit_web_frame_get_global_context (web_frame);
	js_global = JSContextGetGlobalObject (js_context);
	js_function_name = JSStringCreateWithUTF8CString (s1_[zs_].c_str());
	js_function = JSObjectMakeFunctionWithCallback (js_context,
			js_function_name, zs__);
	JSObjectSetProperty (js_context, js_global, js_function_name, js_function,
			kJSPropertyAttributeNone, NULL);
	JSStringRelease (js_function_name);
}
开发者ID:BGCX261,项目名称:zhscript-svn-to-git,代码行数:16,代码来源:control___.cpp


示例3: JSValueCreateJSONString

std::string NX::Value::toJSON(unsigned int indent)
{
  JSValueRef exception = nullptr;
  JSStringRef strRef = JSValueCreateJSONString(myContext, myVal, indent, &exception);
  if (exception)
  {
    NX::Object except (myContext, exception);
    throw std::runtime_error (except["message"]->toString());
  }
  std::size_t len = JSStringGetMaximumUTF8CStringSize (strRef);
  std::string str (len, ' ');
  len = JSStringGetUTF8CString (strRef, &str[0], len);
  JSStringRelease (strRef);
  str.resize (len);
  return str;
}
开发者ID:cigraphics,项目名称:nexusjs,代码行数:16,代码来源:value.cpp


示例4: print_callAsFunction

static JSValueRef print_callAsFunction(JSContextRef context, JSObjectRef functionObject, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
{
    UNUSED_PARAM(functionObject);
    UNUSED_PARAM(thisObject);
    
    if (argumentCount > 0) {
        JSStringRef string = JSValueToStringCopy(context, arguments[0], NULL);
        size_t sizeUTF8 = JSStringGetMaximumUTF8CStringSize(string);
        char stringUTF8[sizeUTF8];
        JSStringGetUTF8CString(string, stringUTF8, sizeUTF8);
        printf("%s\n", stringUTF8);
        JSStringRelease(string);
    }
    
    return JSValueMakeUndefined(context);
}
开发者ID:FilipBE,项目名称:qtextended,代码行数:16,代码来源:testapi.c


示例5: MyObject_hasInstance

static bool MyObject_hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleValue, JSValueRef* exception)
{
    UNUSED_PARAM(context);
    UNUSED_PARAM(constructor);

    if (JSValueIsString(context, possibleValue) && JSStringIsEqualToUTF8CString(JSValueToStringCopy(context, possibleValue, 0), "throwOnHasInstance")) {
        JSEvaluateScript(context, JSStringCreateWithUTF8CString("throw 'an exception'"), constructor, JSStringCreateWithUTF8CString("test script"), 1, exception);
        return false;
    }

    JSStringRef numberString = JSStringCreateWithUTF8CString("Number");
    JSObjectRef numberConstructor = JSValueToObject(context, JSObjectGetProperty(context, JSContextGetGlobalObject(context), numberString, exception), exception);
    JSStringRelease(numberString);

    return JSValueIsInstanceOfConstructor(context, possibleValue, numberConstructor, exception);
}
开发者ID:jackiekaon,项目名称:owb-mirror,代码行数:16,代码来源:testapi.c


示例6: plat_create_window

void* plat_create_window(void* tag, int w, int h) {
  struct gtk_state* state = malloc(sizeof(struct gtk_state));
  state->tag = tag;

  GtkWidget* window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title(GTK_WINDOW(window), "WebUI");

  state->window = window;

  gtk_signal_connect(GTK_OBJECT(window), "destroy",
                     GTK_SIGNAL_FUNC(close_window), state);

  GtkWidget* scroll = gtk_scrolled_window_new(NULL, NULL);
  state->web_view = webkit_web_view_new();

  gtk_container_add(GTK_CONTAINER(scroll), state->web_view);
  gtk_container_add(GTK_CONTAINER(window), scroll);

  WebKitWebFrame* web_frame = webkit_web_view_get_main_frame(
                              WEBKIT_WEB_VIEW(state->web_view));

  gtk_window_set_default_size(GTK_WINDOW(window), w, h);
  gtk_widget_show_all(window);

  JSGlobalContextRef jsctx = webkit_web_frame_get_global_context(web_frame);

  state->jsctx = jsctx;

  JSClassDefinition system_def = kJSClassDefinitionEmpty;
  system_def.className = "ruby";
  system_def.getProperty = ruby_getprop;

  JSClassRef system_class = JSClassCreate(&system_def);

  JSObjectRef o = JSObjectMake(jsctx, system_class, NULL);
  if(!JSObjectSetPrivate(o, tag)) {
    printf("WebKit is busted.\n");
    abort();
  }

  JSStringRef	name = JSStringCreateWithUTF8CString("ruby");
  JSObjectSetProperty(jsctx, JSContextGetGlobalObject(jsctx), name, o,
                      kJSPropertyAttributeDontDelete, NULL);
  JSStringRelease(name);

  return state;
}
开发者ID:deadprogram,项目名称:webui,代码行数:47,代码来源:webui_gtk.c


示例7: JSString

 JSValue::operator JSString() const {
   HAL_JSVALUE_LOCK_GUARD;
   JSValueRef exception { nullptr };
   JSStringRef js_string_ref = JSValueToStringCopy(static_cast<JSContextRef>(js_context__), js_value_ref__, &exception);
   if (exception) {
     // If this assert fails then we need to JSStringRelease
     // js_string_ref.
     assert(!js_string_ref);
     detail::ThrowRuntimeError("JSValue", JSValue(js_context__, exception));
   }
   
   assert(js_string_ref);
   JSString js_string(js_string_ref);
   JSStringRelease(js_string_ref);
   
   return js_string;
 }
开发者ID:CodexLabs,项目名称:HAL,代码行数:17,代码来源:JSValue.cpp


示例8: function_file_writer_write

JSValueRef function_file_writer_write(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject,
                                      size_t argc, const JSValueRef args[], JSValueRef *exception) {
    if (argc == 2
        && JSValueGetType(ctx, args[0]) == kJSTypeString
        && JSValueGetType(ctx, args[1]) == kJSTypeString) {

        char *descriptor = value_to_c_string(ctx, args[0]);
        JSStringRef str_ref = JSValueToStringCopy(ctx, args[1], NULL);

        ufile_write(descriptor_str_to_int(descriptor), str_ref);

        free(descriptor);
        JSStringRelease(str_ref);
    }

    return JSValueMakeNull(ctx);
}
开发者ID:mfikes,项目名称:planck,代码行数:17,代码来源:functions.c


示例9: code

    void JavaScriptModuleInstance::Run()
    {
        std::string code(FileUtils::ReadFile(this->path));

        // Check the script's syntax.
        JSValueRef exception;
        JSStringRef jsCode = JSStringCreateWithUTF8CString(code.c_str());
        bool syntax = JSCheckScriptSyntax(context, jsCode, NULL, 0, &exception);
        if (!syntax)
        {
            KValueRef e = KJSUtil::ToKrollValue(exception, context, NULL);
            JSStringRelease(jsCode);
            throw ValueException(e);
        }

        KJSUtil::Evaluate(context, code.c_str());
    }
开发者ID:fossamikom,项目名称:TideSDK,代码行数:17,代码来源:javascript_module_instance.cpp


示例10: ext_util_js_ref_to_string

/**
 * Returns a new allocates string for given value reference.
 * String must be freed if not used anymore.
 */
char* ext_util_js_ref_to_string(JSContextRef ctx, JSValueRef ref)
{
    char *string;
    size_t len;
    JSStringRef str_ref;

    g_return_val_if_fail(ref != NULL, NULL);

    str_ref = JSValueToStringCopy(ctx, ref, NULL);
    len     = JSStringGetMaximumUTF8CStringSize(str_ref);

    string = g_new0(char, len);
    JSStringGetUTF8CString(str_ref, string, len);
    JSStringRelease(str_ref);

    return string;
}
开发者ID:cdlscpmv,项目名称:vimb,代码行数:21,代码来源:ext-util.c


示例11: JSValueToStringCopy

static char *js2utf8(JSContextRef ctx, JSValueRef val, size_t* out_len) {
	JSStringRef str = JSValueToStringCopy(ctx, val, NULL);
	size_t max = 0, len;
	char *buf;

	max = JSStringGetMaximumUTF8CStringSize(str);
	buf = malloc(max);
	len = JSStringGetUTF8CString(str, buf, max);

	if (out_len) {
		*out_len = len;
	}

	JSStringRelease(str);

	return buf;
}
开发者ID:rottame,项目名称:gtk-webkit-ruby,代码行数:17,代码来源:webkit.c


示例12: ENABLE

HRESULT STDMETHODCALLTYPE DRTDesktopNotificationPresenter::checkNotificationPermission(
        /* [in] */ BSTR origin, 
        /* [out, retval] */ int* result)
{
#if ENABLE(NOTIFICATIONS)
    JSStringRef jsOrigin = JSStringCreateWithBSTR(origin);
    bool allowed = ::gLayoutTestController->checkDesktopNotificationPermission(jsOrigin);

    if (allowed)
        *result = WebCore::NotificationPresenter::PermissionAllowed;
    else
        *result = WebCore::NotificationPresenter::PermissionDenied;

    JSStringRelease(jsOrigin);
#endif
    return S_OK;
}
开发者ID:0x4d52,项目名称:JavaScriptCore-X,代码行数:17,代码来源:DRTDesktopNotificationPresenter.cpp


示例13: JSStringCreateWithUTF8CString

size_t VJSArray::GetLength() const
{
	size_t length;
	JSStringRef jsString = JSStringCreateWithUTF8CString( "length");
	JSValueRef result = JSObjectGetProperty( fContext, fObject, jsString, NULL);
	JSStringRelease( jsString);
	if (testAssert( result != NULL))
	{
		double r = JSValueToNumber( fContext, result, NULL);
		length = (size_t) r;
	}
	else
	{
		length = 0;
	}
	return length;
}
开发者ID:sanyaade-iot,项目名称:core-XToolbox,代码行数:17,代码来源:VJSValue.cpp


示例14: ext_util_js_eval

/**
 * Evaluates given string as script and return if this call succeed or not.
 */
gboolean ext_util_js_eval(JSContextRef ctx, const char *script, JSValueRef *result)
{
    JSStringRef js_str;
    JSValueRef exc = NULL, res = NULL;

    js_str = JSStringCreateWithUTF8CString(script);
    res = JSEvaluateScript(ctx, js_str, JSContextGetGlobalObject(ctx), NULL, 0, &exc);
    JSStringRelease(js_str);

    if (exc) {
        *result = exc;
        return FALSE;
    }

    *result = res;
    return TRUE;
}
开发者ID:cdlscpmv,项目名称:vimb,代码行数:20,代码来源:ext-util.c


示例15: js_fill_exception

void js_fill_exception(JSContextRef ctx,
                       JSValueRef* excp,
                       const char* format,
                       ...)
{
    va_list args;
    va_start (args, format);
    char* str = g_strdup_vprintf(format, args);
    va_end(args);

    JSStringRef string = JSStringCreateWithUTF8CString(str);
    JSValueRef exc_str = JSValueMakeString(ctx, string);
    JSStringRelease(string);
    g_free(str);

    *excp= JSValueToObject(ctx, exc_str, NULL);
}
开发者ID:choldrim,项目名称:deepin-installer,代码行数:17,代码来源:jsextension.c


示例16: nativeProfilerEnd

static JSValueRef nativeProfilerEnd(
    JSContextRef ctx,
    JSObjectRef function,
    JSObjectRef thisObject,
    size_t argumentCount,
    const JSValueRef arguments[],
    JSValueRef* exception) {
  if (argumentCount < 1) {
    // Could raise an exception here.
    return JSValueMakeUndefined(ctx);
  }

  JSStringRef title = JSValueToStringCopy(ctx, arguments[0], NULL);
  JSEndProfilingAndRender(ctx, title, "/sdcard/profile.json");
  JSStringRelease(title);
  return JSValueMakeUndefined(ctx);
}
开发者ID:12527133,项目名称:ios122,代码行数:17,代码来源:JSCLegacyProfiler.cpp


示例17: print_js

void
print_js(JSContextRef ctx, JSValueRef jsvalue)
{
    if (!jsvalue)
        return;
    JSStringRef jsstr = JSValueToStringCopy(ctx, jsvalue, NULL);
    int length = JSStringGetMaximumUTF8CStringSize(jsstr);
    if (length > 0) {
        char buf[length + 1];
        JSStringGetUTF8CString(jsstr, buf, length);
        printf("%d: %s\n", length, buf);
    } else {
        printf("l <= 0\n");
    }
    if (jsstr)
        JSStringRelease(jsstr);
}
开发者ID:yuyichao,项目名称:explore,代码行数:17,代码来源:main.c


示例18: ASSERT

void InspectorController::updateScriptResourceResponse(InspectorResource* resource)
{
    ASSERT(resource->scriptObject);
    ASSERT(m_scriptContext);
    if (!resource->scriptObject || !m_scriptContext)
        return;

    JSStringRef mimeType = JSStringCreateWithCharacters(resource->mimeType.characters(), resource->mimeType.length());
    JSValueRef mimeTypeValue = JSValueMakeString(m_scriptContext, mimeType);
    JSStringRelease(mimeType);

    JSStringRef suggestedFilename = JSStringCreateWithCharacters(resource->suggestedFilename.characters(), resource->suggestedFilename.length());
    JSValueRef suggestedFilenameValue = JSValueMakeString(m_scriptContext, suggestedFilename);
    JSStringRelease(suggestedFilename);

    JSValueRef expectedContentLengthValue = JSValueMakeNumber(m_scriptContext, static_cast<double>(resource->expectedContentLength));
    JSValueRef statusCodeValue = JSValueMakeNumber(m_scriptContext, resource->responseStatusCode);

    JSStringRef propertyName = JSStringCreateWithUTF8CString("mimeType");
    JSObjectSetProperty(m_scriptContext, resource->scriptObject, propertyName, mimeTypeValue, kJSPropertyAttributeNone, 0);
    JSStringRelease(propertyName);

    propertyName = JSStringCreateWithUTF8CString("suggestedFilename");
    JSObjectSetProperty(m_scriptContext, resource->scriptObject, propertyName, suggestedFilenameValue, kJSPropertyAttributeNone, 0);
    JSStringRelease(propertyName);

    propertyName = JSStringCreateWithUTF8CString("expectedContentLength");
    JSObjectSetProperty(m_scriptContext, resource->scriptObject, propertyName, expectedContentLengthValue, kJSPropertyAttributeNone, 0);
    JSStringRelease(propertyName);

    propertyName = JSStringCreateWithUTF8CString("statusCode");
    JSObjectSetProperty(m_scriptContext, resource->scriptObject, propertyName, statusCodeValue, kJSPropertyAttributeNone, 0);
    JSStringRelease(propertyName);
    
    propertyName = JSStringCreateWithUTF8CString("responseHeaders");
    JSObjectSetProperty(m_scriptContext, resource->scriptObject, propertyName, scriptObjectForResponse(m_scriptContext, resource), kJSPropertyAttributeNone, 0);
    JSStringRelease(propertyName);

    JSValueRef typeValue = JSValueMakeNumber(m_scriptContext, resource->type());
    propertyName = JSStringCreateWithUTF8CString("type");
    JSObjectSetProperty(m_scriptContext, resource->scriptObject, propertyName, typeValue, kJSPropertyAttributeNone, 0);
    JSStringRelease(propertyName);
}
开发者ID:FilipBE,项目名称:qtextended,代码行数:43,代码来源:InspectorController.cpp


示例19: console_report

/**
 * The callback from JavaScriptCore.  We told JSC to call this function
 * whenever it sees "console.report".
 */
static JSValueRef console_report(JSContextRef ctx, JSObjectRef /*function*/, JSObjectRef thisObject, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception)
{
    if (!JSValueIsObjectOfClass(ctx, thisObject, ConsoleClass()))
        return JSValueMakeUndefined(ctx);

    CallJSDlg* dlg = static_cast<CallJSDlg*>(JSObjectGetPrivate(thisObject));
    if (!dlg)
        return JSValueMakeUndefined(ctx);

    if (argumentCount)
        return JSValueMakeUndefined(ctx);

    JSStringRef jsString = JSStringCreateWithBSTR(dlg->sharedString());
    JSValueRef jsValue = JSValueMakeString(ctx, jsString);
    JSStringRelease(jsString);

    return jsValue;
}
开发者ID:Omgan,项目名称:CallJS,代码行数:22,代码来源:JSBindings.cpp


示例20: assertEqualsAsUTF8String

static void assertEqualsAsUTF8String(JSValueRef value, const char* expectedValue)
{
    JSStringRef valueAsString = JSValueToStringCopy(context, value, NULL);

    size_t jsSize = JSStringGetMaximumUTF8CStringSize(valueAsString);
    char jsBuffer[jsSize];
    JSStringGetUTF8CString(valueAsString, jsBuffer, jsSize);
    
    unsigned i;
    for (i = 0; jsBuffer[i]; i++)
        if (jsBuffer[i] != expectedValue[i])
            fprintf(stderr, "assertEqualsAsUTF8String failed at character %d: %c(%d) != %c(%d)\n", i, jsBuffer[i], jsBuffer[i], expectedValue[i], expectedValue[i]);
        
    if (jsSize < strlen(jsBuffer) + 1)
        fprintf(stderr, "assertEqualsAsUTF8String failed: jsSize was too small\n");

    JSStringRelease(valueAsString);
}
开发者ID:FilipBE,项目名称:qtextended,代码行数:18,代码来源:testapi.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ JSVAL_IS_BOOLEAN函数代码示例发布时间:2022-05-30
下一篇:
C++ JSStringGetUTF8CString函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap