本文整理汇总了C++中JSObjectGetPrivate函数的典型用法代码示例。如果您正苦于以下问题:C++ JSObjectGetPrivate函数的具体用法?C++ JSObjectGetPrivate怎么用?C++ JSObjectGetPrivate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了JSObjectGetPrivate函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: nativeobject_ConvertToType
static JSValueRef nativeobject_ConvertToType(JSContextRef ctx, JSObjectRef object, JSType type, JSValueRef* exception)
{
if ( type == kJSTypeString ) {
void* data = JSObjectGetPrivate( object );
JSStringRef str = nativeobject_ConvertToString_go( data, (void*)ctx, (void*)object );
if ( !str ) {
str = JSStringCreateWithUTF8CString( "nativeobject" );
}
JSValueRef ret = JSValueMakeString( ctx, str );
JSStringRelease( str );
return ret;
}
return 0;
}
示例2: notationsAttrGetter
JSValueRef JSCDocumentType::notationsAttrGetter(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef *exception) {
struct JSCDocumentTypePrivate* privData = (struct JSCDocumentTypePrivate*)JSObjectGetPrivate(object);
Arabica::DOM::NamedNodeMap<std::string>* arabicaRet = new Arabica::DOM::NamedNodeMap<std::string>(privData->nativeObj->getNotations());
JSClassRef arbaicaRetClass = JSCNamedNodeMap::getTmpl();
struct JSCNamedNodeMap::JSCNamedNodeMapPrivate* retPrivData = new JSCNamedNodeMap::JSCNamedNodeMapPrivate();
retPrivData->dom = privData->dom;
retPrivData->nativeObj = arabicaRet;
JSObjectRef arbaicaRetObj = JSObjectMake(ctx, arbaicaRetClass, retPrivData);
return arbaicaRetObj;
}
示例3: console_getSharedValue
static JSValueRef console_getSharedValue(JSContextRef ctx, JSObjectRef thisObject, JSStringRef /*propertyName*/, JSValueRef* /*exception*/)
{
if (!JSValueIsObjectOfClass(ctx, thisObject, ConsoleClass()))
return JSValueMakeUndefined(ctx);
CallJSDlg* dlg = static_cast<CallJSDlg*>(JSObjectGetPrivate(thisObject));
if (!dlg)
return JSValueMakeUndefined(ctx);
JSStringRef jsString = JSStringCreateWithBSTR(dlg->sharedString());
JSValueRef jsValue = JSValueMakeString(ctx, jsString);
JSStringRelease(jsString);
return jsValue;
}
示例4: JSNode_getNodeType
static JSValueRef JSNode_getNodeType(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception)
{
UNUSED_PARAM(propertyName);
UNUSED_PARAM(exception);
Node* node = JSObjectGetPrivate(object);
if (node) {
JSStringRef nodeType = JSStringCreateWithUTF8CString(node->nodeType);
JSValueRef value = JSValueMakeString(context, nodeType);
JSStringRelease(nodeType);
return value;
}
return NULL;
}
示例5: call
static JSValueRef call(
JSContextRef ctx,
JSObjectRef function,
JSObjectRef thisObject,
size_t argumentCount,
const JSValueRef arguments[],
JSValueRef *exception) {
try {
auto globalObj = JSContextGetGlobalObject(ctx);
auto executor = static_cast<JSCExecutor*>(JSObjectGetPrivate(globalObj));
return (executor->*method)(argumentCount, arguments);
} catch (...) {
*exception = translatePendingCppExceptionToJSError(ctx, function);
return JSValueMakeUndefined(ctx);
}
}
示例6: highlightDOMNode
static JSValueRef highlightDOMNode(JSContextRef context, JSObjectRef /*function*/, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* /*exception*/)
{
JSValueRef undefined = JSValueMakeUndefined(context);
InspectorController* controller = reinterpret_cast<InspectorController*>(JSObjectGetPrivate(thisObject));
if (argumentCount < 1 || !controller)
return undefined;
Node* node = toNode(toJS(arguments[0]));
if (!node)
return undefined;
controller->highlight(node);
return undefined;
}
示例7: localStorageCustomAttrGetter
JSValueRef JSCDocument::localStorageCustomAttrGetter(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception) {
struct JSCDocumentPrivate* privData = (struct JSCDocumentPrivate*)JSObjectGetPrivate(object);
if (!privData->dom->storage) {
return JSValueMakeUndefined(ctx);
}
JSClassRef retClass = JSCStorage::getTmpl();
struct JSCStorage::JSCStoragePrivate* retPrivData = new JSCStorage::JSCStoragePrivate();
retPrivData->dom = privData->dom;
retPrivData->nativeObj = retPrivData->dom->storage;
JSObjectRef arbaicaRetObj = JSObjectMake(ctx, retClass, retPrivData);
return arbaicaRetObj;
}
示例8: qt_postWebChannelMessageCallback
static JSValueRef qt_postWebChannelMessageCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef*)
{
// FIXME: should it work regardless of the thisObject?
if (argumentCount < 1 || !JSValueIsString(context, arguments[0]))
return JSValueMakeUndefined(context);
QtBuiltinBundlePage* bundlePage = reinterpret_cast<QtBuiltinBundlePage*>(JSObjectGetPrivate(thisObject));
ASSERT(bundlePage);
// TODO: can we transmit the data as JS object, instead of as a string?
JSRetainPtr<JSStringRef> jsContents = JSValueToStringCopy(context, arguments[0], 0);
WKRetainPtr<WKStringRef> contents(AdoptWK, WKStringCreateWithJSString(jsContents.get()));
bundlePage->postMessageFromNavigatorQtWebChannelTransport(contents.get());
return JSValueMakeUndefined(context);
}
示例9: js_event_start_timer_func
JSValueRef js_event_start_timer_func(JSContextRef cx,JSObjectRef func,JSObjectRef j_obj,size_t argc,const JSValueRef argv[],JSValueRef *exception)
{
int script_idx;
char err_str[256];
if (!script_check_param_count(cx,func,argc,2,exception)) return(script_null_to_value(cx));
if (!script_check_fail_in_construct(cx,func,j_obj,exception)) return(script_null_to_value(cx));
script_idx=(int)JSObjectGetPrivate(j_obj);
if (!timers_add(script_idx,script_value_to_int(cx,argv[0]),script_value_to_int(cx,argv[1]),NULL,timer_mode_repeat,err_str)) {
*exception=script_create_exception(cx,err_str);
return(script_bool_to_value(cx,FALSE));
}
return(script_bool_to_value(cx,TRUE));
}
示例10: console_setSharedDouble
static bool console_setSharedDouble(JSContextRef ctx, JSObjectRef thisObject, JSStringRef /*propertyName*/, JSValueRef value, JSValueRef* exception)
{
if (!JSValueIsNumber(ctx, value))
return false;
CallJSDlg* dlg = static_cast<CallJSDlg*>(JSObjectGetPrivate(thisObject));
if (!dlg)
return false;
double temp = JSValueToNumber (ctx, value, exception);
if (exception && *exception)
return false;
dlg->setSharedDouble(temp);
return true;
}
示例11: NativeFunctionWithRetvalCallback
JSValueRef NativeFunctionWithRetvalCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject,
size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) {
JSCallbackWithRetval* callback = static_cast<JSCallbackWithRetval*>(JSObjectGetPrivate(function));
if (!callback)
return JSValueMakeNull(ctx);
JSContextRef old_ctx = GetJSContext();
SetJSContext(ctx);
JSArgs args;
for (size_t i = 0; i < argumentCount; ++i)
args.push_back(arguments[i]);
JSValueRef result = (*callback)(thisObject, args);
SetJSContext(old_ctx);
return result;
}
示例12: getProperty
static JSValueRef getProperty(JSContextRef jscore_ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef *exception)
{
pdf_jsimp *imp;
char buf[STRING_BUF_SIZE];
prop *p;
JSValueRef res = NULL;
priv_data *pdata = JSObjectGetPrivate(object);
if (pdata == NULL)
return NULL;
JSStringGetUTF8CString(propertyName, buf, STRING_BUF_SIZE);
p = find_prop(pdata->type->props, buf);
if (p == NULL)
return NULL;
imp = pdata->type->imp;
switch(p->type)
{
case PROP_FN:
{
/*
For some reason passing the method pointer as private data doesn't work: the data comes back
NULL when interrogated in callMethod above. So we also specify the method name when
creating the function so that we can look it up again in callMethod. Not ideal, but
will do until we can find a better solution.
*/
JSObjectRef ores = JSObjectMakeFunctionWithCallback(jscore_ctx, propertyName, callMethod);
JSObjectSetPrivate(ores, p->u.fn.meth);
res = ores;
}
break;
case PROP_VAL:
{
pdf_jsimp_obj *pres = p->u.val.get(imp->nat_ctx, pdata->natobj);
res = pres->ref;
pdf_jsimp_drop_obj(imp, pres);
}
break;
}
return res;
}
示例13: gumjs_proxy_has_property
static bool
gumjs_proxy_has_property (JSContextRef ctx,
JSObjectRef object,
JSStringRef property_name)
{
GumJscProxy * self;
GumJscCore * core;
self = GUMJS_PROXY (object);
if (self->has == NULL)
return false;
core = JSObjectGetPrivate (JSContextGetGlobalObject (ctx));
{
GumJscScope scope = GUM_JSC_SCOPE_INIT (core);
JSValueRef * ex = &scope.exception;
JSValueRef property_name_value, value;
bool result = false;
property_name_value = JSValueMakeString (ctx, property_name);
value = JSObjectCallAsFunction (ctx, self->has, self->receiver,
1, &property_name_value, ex);
if (value == NULL)
goto beach;
if (!JSValueIsBoolean (ctx, value))
goto invalid_result_type;
result = JSValueToBoolean (ctx, value);
goto beach;
invalid_result_type:
{
_gumjs_throw (ctx, ex, "expected has() to return a boolean");
goto beach;
}
beach:
{
_gum_jsc_scope_flush (&scope);
return result;
}
}
}
示例14: getChildren
static JSValueRef getChildren(JSContextRef ctx, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
{
KJS::JSLock lock(false);
if (!JSValueIsObjectOfClass(ctx, thisObject, ProfileNodeClass()))
return JSValueMakeUndefined(ctx);
ProfileNode* profileNode = static_cast<ProfileNode*>(JSObjectGetPrivate(thisObject));
const Vector<RefPtr<ProfileNode> >& children = profileNode->children();
JSObjectRef global = JSContextGetGlobalObject(ctx);
JSRetainPtr<JSStringRef> arrayString(Adopt, JSStringCreateWithUTF8CString("Array"));
JSValueRef arrayProperty = JSObjectGetProperty(ctx, global, arrayString.get(), exception);
if (exception && *exception)
return JSValueMakeUndefined(ctx);
JSObjectRef arrayConstructor = JSValueToObject(ctx, arrayProperty, exception);
if (exception && *exception)
return JSValueMakeUndefined(ctx);
JSObjectRef result = JSObjectCallAsConstructor(ctx, arrayConstructor, 0, 0, exception);
if (exception && *exception)
return JSValueMakeUndefined(ctx);
JSRetainPtr<JSStringRef> pushString(Adopt, JSStringCreateWithUTF8CString("push"));
JSValueRef pushProperty = JSObjectGetProperty(ctx, result, pushString.get(), exception);
if (exception && *exception)
return JSValueMakeUndefined(ctx);
JSObjectRef pushFunction = JSValueToObject(ctx, pushProperty, exception);
if (exception && *exception)
return JSValueMakeUndefined(ctx);
for (Vector<RefPtr<ProfileNode> >::const_iterator it = children.begin(); it != children.end(); ++it) {
JSValueRef arg0 = toRef(toJS(toJS(ctx), (*it).get() ));
JSObjectCallAsFunction(ctx, pushFunction, result, 1, &arg0, exception);
if (exception && *exception)
return JSValueMakeUndefined(ctx);
}
return result;
}
示例15: getActionForJava_android_view_MotionEvent
JSValueRef getActionForJava_android_view_MotionEvent(JSContextRef ctx, JSObjectRef function, JSObjectRef object, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
{
JSPrivateObject* p = (JSPrivateObject*)JSObjectGetPrivate(object);
if (p && p->object) {
JNI_ENV_ENTER
jclass javaClass = (*env)->FindClass(env, "android/view/MotionEvent");
if (javaClass == NULL) return HyperloopMakeException(ctx, "Class not found: android.view.MotionEvent", exception);
jmethodID methodId = (*env)->GetMethodID(env, javaClass, "getAction", "()I");
if (methodId == NULL) return HyperloopMakeException(ctx, "Method not found: android.view.MotionEvent#getAction", exception);
(*env)->DeleteLocalRef(env, javaClass);
jint result = (*env)->CallIntMethod(env, p->object, methodId);
CHECK_JAVAEXCEPTION
JNI_ENV_EXIT
return JSValueMakeNumber(ctx, (int)result);
}