本文整理汇总了C++中JSValueProtect函数的典型用法代码示例。如果您正苦于以下问题:C++ JSValueProtect函数的具体用法?C++ JSValueProtect怎么用?C++ JSValueProtect使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了JSValueProtect函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: context
KKJSMethod::KKJSMethod(JSContextRef context, JSObjectRef jsobject, JSObjectRef thisObject) :
context(NULL),
jsobject(jsobject),
thisObject(thisObject)
{
/* KJS methods run in the global context that they originated from
* this seems to prevent nasty crashes from trying to access invalid
* contexts later. Global contexts need to be registered by all modules
* that use a KJS context. */
JSObjectRef globalObject = JSContextGetGlobalObject(context);
JSGlobalContextRef globalContext = KJSUtil::GetGlobalContext(globalObject);
// This context hasn't been registered. Something has gone pretty
// terribly wrong and Kroll will likely crash soon. Nonetheless, keep
// the user up-to-date to keep their hopes up.
if (globalContext == NULL)
std::cerr << "Could not locate global context for a KJS method." <<
" One of the modules is misbehaving." << std::endl;
this->context = globalContext;
KJSUtil::ProtectGlobalContext(this->context);
JSValueProtect(this->context, jsobject);
if (thisObject != NULL)
JSValueProtect(this->context, thisObject);
this->kobject = new KKJSObject(this->context, jsobject);
}
开发者ID:jonnymind,项目名称:kroll,代码行数:29,代码来源:k_kjs_method.cpp
示例2: EJ_BIND_FUNCTION
EJ_BIND_FUNCTION(EJBindingCanvas,createImageData, ctx, argc, argv) {
if( argc < 2 ) { return NULL; }
float
sw = JSValueToNumberFast(ctx, argv[0]),
sh = JSValueToNumberFast(ctx, argv[1]);
GLubyte * pixels = (GLubyte *)calloc( sw * sh * 4, sizeof(GLubyte) );
EJImageData * imageData = new EJImageData(sw ,sh ,pixels);
imageData->autorelease();
// Create the JS object
EJBindingImageData* tempData = new EJBindingImageData();
JSClassRef imageDataClass = EJApp::instance()->getJSClassForClass((EJBindingBase*)tempData);
delete tempData;
JSObjectRef obj = JSObjectMake( ctx, imageDataClass, NULL );
JSValueProtect(ctx, obj);
// Create the native instance
EJBindingImageData * jsImageData =new EJBindingImageData(ctx,obj,imageData);
// Attach the native instance to the js object
JSObjectSetPrivate( obj, (void *)jsImageData );
JSValueUnprotect(ctx, obj);
return obj;
}
开发者ID:YaakovDavis,项目名称:Ejecta-X,代码行数:26,代码来源:EJBindingCanvas.cpp
示例3: ASSERT
void InspectorController::scriptObjectReady()
{
ASSERT(m_scriptContext);
if (!m_scriptContext)
return;
JSObjectRef global = JSContextGetGlobalObject(m_scriptContext);
ASSERT(global);
JSStringRef inspectorString = JSStringCreateWithUTF8CString("WebInspector");
JSValueRef inspectorValue = JSObjectGetProperty(m_scriptContext, global, inspectorString, 0);
JSStringRelease(inspectorString);
ASSERT(inspectorValue);
if (!inspectorValue)
return;
m_scriptObject = JSValueToObject(m_scriptContext, inspectorValue, 0);
ASSERT(m_scriptObject);
JSValueProtect(m_scriptContext, m_scriptObject);
// Make sure our window is visible now that the page loaded
m_client->showWindow();
}
开发者ID:FilipBE,项目名称:qtextended,代码行数:25,代码来源:InspectorController.cpp
示例4: nativeFlushQueueImmediate
static JSValueRef nativeFlushQueueImmediate(
JSContextRef ctx,
JSObjectRef function,
JSObjectRef thisObject,
size_t argumentCount,
const JSValueRef arguments[],
JSValueRef *exception) {
if (argumentCount != 1) {
*exception = createErrorString(ctx, "Got wrong number of args");
return JSValueMakeUndefined(ctx);
}
JSCExecutor *executor;
try {
executor = s_globalContextRefToJSCExecutor.at(JSContextGetGlobalContext(ctx));
} catch (std::out_of_range& e) {
*exception = createErrorString(ctx, "Global JS context didn't map to a valid executor");
return JSValueMakeUndefined(ctx);
}
JSValueProtect(ctx, arguments[0]);
std::string resStr = Value(ctx, arguments[0]).toJSONString();
executor->flushQueueImmediate(resStr);
return JSValueMakeUndefined(ctx);
}
开发者ID:sidshah13,项目名称:react-native,代码行数:27,代码来源:JSCExecutor.cpp
示例5: make_object_for_class
JSObjectRef
make_object_for_class(JSContextRef ctx, int iclass, GObject *o, gboolean protect)
{
ScriptContext *sctx = scripts_get_context();
if (sctx == NULL)
return JSValueToObject(ctx, NIL, NULL);
JSObjectRef retobj = g_object_get_qdata(o, sctx->ref_quark);
if (retobj != NULL) {
goto finish;
}
retobj = JSObjectMake(ctx, sctx->classes[iclass], o);
if (protect)
{
g_object_set_qdata_full(o, sctx->ref_quark, retobj, (GDestroyNotify)object_destroy_cb);
JSValueProtect(ctx, retobj);
}
else
g_object_set_qdata_full(o, sctx->ref_quark, retobj, NULL);
finish:
scripts_release_context();
return retobj;
}
开发者ID:vifino,项目名称:dwb,代码行数:25,代码来源:shared.c
示例6: addAccessibilityNotificationHandler
void addAccessibilityNotificationHandler(AccessibilityNotificationHandler* notificationHandler)
{
if (!notificationHandler)
return;
#if PLATFORM(GTK)
JSGlobalContextRef jsContext = webkit_web_frame_get_global_context(mainFrame);
#elif PLATFORM(EFL)
JSGlobalContextRef jsContext = DumpRenderTreeSupportEfl::globalContextRefForFrame(browser->mainFrame());
#else
JSContextRef jsContext = 0;
#endif
if (!jsContext)
return;
JSValueProtect(jsContext, notificationHandler->notificationFunctionCallback());
// Check if this notification handler is related to a specific element.
if (notificationHandler->platformElement()) {
NotificationHandlersMap::iterator currentNotificationHandler = notificationHandlers.find(notificationHandler->platformElement());
if (currentNotificationHandler != notificationHandlers.end()) {
ASSERT(currentNotificationHandler->value->platformElement());
JSValueUnprotect(jsContext, currentNotificationHandler->value->notificationFunctionCallback());
notificationHandlers.remove(currentNotificationHandler->value->platformElement());
}
notificationHandlers.add(notificationHandler->platformElement(), notificationHandler);
} else {
if (globalNotificationHandler)
JSValueUnprotect(jsContext, globalNotificationHandler->notificationFunctionCallback());
globalNotificationHandler = notificationHandler;
}
connectAccessibilityCallbacks();
}
开发者ID:JefferyJeffery,项目名称:webkit,代码行数:33,代码来源:AccessibilityCallbacksAtk.cpp
示例7: add_signal_callback
SIGNAL_CALLBACK_ID add_signal_callback(JSContextRef ctx, struct DBusObjectInfo *info,
struct Signal *sig, JSObjectRef func)
{
g_assert(sig != NULL);
g_assert(func != NULL);
if (__sig_info_hash == NULL) {
__sig_info_hash = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, (GDestroyNotify)g_hash_table_destroy);
}
char* key = g_strdup_printf("%s%s%s", info->path, info->iface, sig->name);
GHashTable *cbs = g_hash_table_lookup(__sig_info_hash, key);
if (cbs == NULL) {
cbs = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, (GDestroyNotify)signal_info_free);
g_hash_table_insert(__sig_info_hash, key, cbs);
}
struct SignalInfo* sig_info = g_new0(struct SignalInfo, 1);
sig_info->name = sig->name;
sig_info->signatures = sig->signature;
sig_info->path = info->path;
sig_info->iface = info->iface;
sig_info->callback = func;
JSValueProtect(ctx, func);
SIGNAL_CALLBACK_ID id = (SIGNAL_CALLBACK_ID)GPOINTER_TO_INT(func);
g_hash_table_insert(cbs, GINT_TO_POINTER((int)id), sig_info);
return id;
}
开发者ID:PeterDaveHello,项目名称:deepin-installer,代码行数:29,代码来源:dbus_introspect.c
示例8: add_signal_callback
int add_signal_callback(JSContextRef ctx, struct DBusObjectInfo *info,
struct Signal *sig, JSObjectRef func)
{
g_assert(sig != NULL);
g_assert(func != NULL);
if (__sig_info_hash == NULL) {
__sig_info_hash = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, (GDestroyNotify)signal_info_free);
}
char* key = g_strdup_printf("%s%s%s", info->path, info->iface, sig->name);
GSList *infos = g_hash_table_lookup(__sig_info_hash, key);
if (infos != NULL) {
return -1; //alerady has this callback
}
struct SignalInfo* sig_info = g_new0(struct SignalInfo, 1);
sig_info->name = sig->name;
sig_info->signatures = sig->signature;
sig_info->path = info->path;
sig_info->iface = info->iface;
sig_info->callback = func;
JSValueProtect(ctx, func);
g_hash_table_insert(__sig_info_hash, key, sig_info);
return GPOINTER_TO_INT(func);
}
开发者ID:jouyouyun,项目名称:sinaweibo,代码行数:27,代码来源:dbus_introspect.c
示例9: fz_malloc_struct
pdf_jsimp_obj *pdf_jsimp_new_obj(pdf_jsimp *imp, pdf_jsimp_type *type, void *natobj)
{
fz_context *ctx = imp->ctx;
pdf_jsimp_obj *obj = fz_malloc_struct(ctx, pdf_jsimp_obj);
priv_data *pdata = NULL;
fz_var(pdata);
fz_try(ctx)
{
pdata = fz_malloc_struct(ctx, priv_data);
pdata->type = type;
pdata->natobj = natobj;
obj->ref = JSObjectMake(imp->jscore_ctx, imp->class_ref, pdata);
if (obj->ref == NULL)
fz_throw(ctx, FZ_ERROR_GENERIC, "JSObjectMake failed");
JSValueProtect(imp->jscore_ctx, obj->ref);
}
fz_catch(ctx)
{
fz_free(ctx, pdata);
fz_free(ctx, obj);
fz_rethrow(ctx);
}
return obj;
}
开发者ID:azaleafisitania,项目名称:sumatrapdf,代码行数:27,代码来源:pdf-jsimp-jscore.c
示例10: Closure_privateData
Closure_privateData(JSContextRef context, JSObjectRef function, const char *type) :
cy::Functor(type, NULL),
context_(CYGetJSContext(context)),
function_(function)
{
//XXX:JSGlobalContextRetain(context_);
JSValueProtect(context_, function_);
}
开发者ID:liufeigit,项目名称:cycript-1,代码行数:8,代码来源:Internal.hpp
示例11: js_context__
// For interoperability with the JavaScriptCore C API.
JSObject::JSObject(const JSContext& js_context, JSObjectRef js_object_ref)
: js_context__(js_context)
, js_object_ref__(js_object_ref) {
HAL_LOG_TRACE("JSObject:: ctor 2 ", this);
HAL_LOG_TRACE("JSObject:: retain ", js_object_ref__, " for ", this);
JSValueProtect(static_cast<JSContextRef>(js_context__), js_object_ref__);
RegisterJSContext(static_cast<JSContextRef>(js_context__), js_object_ref__);
}
开发者ID:garymathews,项目名称:HAL,代码行数:9,代码来源:JSObject.cpp
示例12: JSValueUnprotect
JSObject& JSObject::operator=(const JSObject& other) {
JSValueUnprotect(ctx_, instance_);
ctx_ = other.ctx_;
instance_ = other.instance_;
JSValueProtect(ctx_, instance_);
return *this;
}
开发者ID:FinnProjects,项目名称:ultralight,代码行数:8,代码来源:JSHelpers.cpp
示例13: JSValueUnprotect
jsc::Value &jsc::Value::operator = (const Value &other) {
if (value != nullptr) {
JSValueUnprotect(context, value);
}
value = other.value;
JSValueProtect(context, value);
return *this;
}
开发者ID:sbennett912,项目名称:jsc,代码行数:8,代码来源:Value.cpp
示例14: EJ_BIND_GET
EJ_BIND_GET( EJBindingImageData, data, ctx ) {
if( !dataArray ) {
int count = m_imageData->width * m_imageData->height * 4;
dataArray = ByteArrayToJSObject(ctx, m_imageData->pixels, count);
JSValueProtect(ctx, dataArray);
}
return dataArray;
}
开发者ID:BenjaminHorn,项目名称:Ejecta-X,代码行数:8,代码来源:EJBindingImageData.cpp
示例15: CYProtect
CYProtect(JSContextRef context, JSObjectRef object) :
context_(CYGetJSContext(context)),
object_(object)
{
//XXX:JSGlobalContextRetain(context_);
if (object_ != NULL)
JSValueProtect(context_, object_);
}
开发者ID:simpzan,项目名称:cycript,代码行数:8,代码来源:Internal.hpp
示例16: CYOwned
CYOwned(void *value, JSContextRef context, JSObjectRef owner) :
CYValue(value),
context_(CYGetJSContext(context)),
owner_(owner)
{
//XXX:JSGlobalContextRetain(context_);
if (owner_ != NULL)
JSValueProtect(context_, owner_);
}
开发者ID:liufeigit,项目名称:cycript-1,代码行数:9,代码来源:Internal.hpp
示例17: setScriptObject
void setScriptObject(JSContextRef context, JSObjectRef newScriptObject)
{
if (scriptContext && scriptObject)
JSValueUnprotect(scriptContext, scriptObject);
scriptObject = newScriptObject;
scriptContext = context;
ASSERT((context && newScriptObject) || (!context && !newScriptObject));
if (context && newScriptObject)
JSValueProtect(context, newScriptObject);
}
开发者ID:FilipBE,项目名称:qtextended,代码行数:12,代码来源:InspectorController.cpp
示例18: GetSize
//
// Returns the contents of the array as an array of JSValueRef.
// The caller is responsible for deleting the array returned by this method.
//
JSValueRef* ArrayWrapper::AsArray()
{
size_t len = GetSize();
JSValueRef* array = new JSValueRef[len];
for (size_t i = 0; i < len; ++i)
{
array[i] = JSObjectGetPropertyAtIndex(g_ctx, m_arr, (int) i, NULL);
JSValueProtect(g_ctx, array[i]);
}
return array;
}
开发者ID:vnmc,项目名称:zephyros,代码行数:17,代码来源:jsbridge_webview.cpp
示例19: JSValueProtect
void BB::PatchCollection::managePatch(BB::Patch& patch)
{
if (!this->m_patches.insert(&patch).second)
{
std::cerr << "Could not manage patch, perhaps it is already managed!" << std::endl;
}
else
{
JSContextRef ctx;
ctx = this->m_context.context();
JSValueProtect(ctx, patch.object());
}
}
开发者ID:hjqqq,项目名称:Brain-Box,代码行数:13,代码来源:BBPatchCollection.cpp
示例20: IsArray
bool IsArray(JSObjectRef obj)
{
if (g_fnxIsArray == NULL)
{
JSStringRef fnScript = JSStringCreateWithUTF8CString("return arguments[0] instanceof Array");
g_fnxIsArray = JSObjectMakeFunction(g_ctx, NULL, 0, NULL, fnScript, NULL, 0, NULL);
JSValueProtect(g_ctx, g_fnxIsArray);
JSStringRelease(fnScript);
}
JSValueRef isArray = JSObjectCallAsFunction(g_ctx, g_fnxIsArray, NULL, 1, (JSValueRef*) &obj, NULL);
return JSValueToBoolean(g_ctx, isArray);
}
开发者ID:vnmc,项目名称:zephyros,代码行数:13,代码来源:jsbridge_webview.cpp
注:本文中的JSValueProtect函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论