本文整理汇总了C++中JS_EndRequest函数的典型用法代码示例。如果您正苦于以下问题:C++ JS_EndRequest函数的具体用法?C++ JS_EndRequest怎么用?C++ JS_EndRequest使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了JS_EndRequest函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: Function_dealloc
void
Function_dealloc(Function* self)
{
if(self->parent != JSVAL_VOID)
{
JS_BeginRequest(self->obj.cx->cx);
JS_RemoveRoot(self->obj.cx->cx, &(self->parent));
JS_EndRequest(self->obj.cx->cx);
}
ObjectType->tp_dealloc((PyObject*) self);
}
开发者ID:FromPointer,项目名称:python-spidermonkey,代码行数:12,代码来源:jsfunction.c
示例2: def_timestep_image_map_get_url
CEXPORT bool def_timestep_image_map_get_url(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp) {
JS_BeginRequest(cx);
timestep_image_map *thiz = (timestep_image_map*)JS_GetPrivate(obj.get());
if (thiz) {
vp.setString(JS_NewStringCopyZ(cx, thiz->url));
}
JS_EndRequest(cx);
return true;
}
开发者ID:Tufals,项目名称:native-ios,代码行数:12,代码来源:js_timestep_image_map_template.gen.cpp
示例3: def_animate_resume
CEXPORT JSBool def_animate_resume(JSContext *cx, unsigned argc, jsval *vp) {
JS_BeginRequest(cx);
JSObject *thiz = JSVAL_TO_OBJECT(JS_THIS(cx, vp));
view_animation *anim = (view_animation *)JS_GetPrivate(thiz);
view_animation_resume(anim);
jsval thiz_val = OBJECT_TO_JSVAL(thiz);
JS_SET_RVAL(cx, vp, thiz_val);
JS_EndRequest(cx);
return JS_TRUE;
}
开发者ID:rampr,项目名称:native-ios,代码行数:12,代码来源:js_animate.cpp
示例4: EvaluateAdminConfigScript
nsresult EvaluateAdminConfigScript(const char *js_buffer, size_t length,
const char *filename, PRBool bGlobalContext,
PRBool bCallbacks, PRBool skipFirstLine)
{
JSBool ok;
jsval result;
if (skipFirstLine) {
/* In order to protect the privacy of the JavaScript preferences file
* from loading by the browser, we make the first line unparseable
* by JavaScript. We must skip that line here before executing
* the JavaScript code.
*/
unsigned int i = 0;
while (i < length) {
char c = js_buffer[i++];
if (c == '\r') {
if (js_buffer[i] == '\n')
i++;
break;
}
if (c == '\n')
break;
}
length -= i;
js_buffer += i;
}
nsresult rv;
nsCOMPtr<nsIJSContextStack> cxstack =
do_GetService("@mozilla.org/js/xpc/ContextStack;1");
rv = cxstack->Push(autoconfig_cx);
if (NS_FAILED(rv)) {
NS_ERROR("coudn't push the context on the stack");
return rv;
}
JS_BeginRequest(autoconfig_cx);
ok = JS_EvaluateScript(autoconfig_cx, autoconfig_glob,
js_buffer, length, filename, 0, &result);
JS_EndRequest(autoconfig_cx);
JS_MaybeGC(autoconfig_cx);
JSContext *cx;
cxstack->Pop(&cx);
NS_ASSERTION(cx == autoconfig_cx, "AutoConfig JS contexts didn't match");
if (ok)
return NS_OK;
return NS_ERROR_FAILURE;
}
开发者ID:EdgarChen,项目名称:mozilla-cvs-history,代码行数:53,代码来源:nsJSConfigTriggers.cpp
示例5: GetJSContext
nsresult
xgGtkElement::DefineProperties ()
{
nsresult rv;
JSContext *jscx;
rv = GetJSContext (&jscx);
NS_ENSURE_SUCCESS (rv, rv);
nsCOMPtr<nsIXPConnect> xpc (do_GetService ("@mozilla.org/js/xpc/XPConnect;1", &rv));
NS_ENSURE_SUCCESS (rv, rv);
nsCOMPtr<nsIDOMElement> elem;
rv = mWrapper->GetElementNode (getter_AddRefs (elem));
NS_ENSURE_SUCCESS (rv, rv);
nsCOMPtr<nsIXPConnectJSObjectHolder> jswrapper;
rv = xpc->WrapNative (jscx, JS_GetGlobalObject (jscx), elem,
NS_GET_IID (nsISupports),
getter_AddRefs (jswrapper));
NS_ENSURE_SUCCESS (rv, rv);
JSObject *jsobj;
rv = jswrapper->GetJSObject (&jsobj);
NS_ENSURE_SUCCESS (rv, rv);
g_message (GOM_LOC ("Got JSObject: %p"), (void *)jsobj);
guint n_properties;
GParamSpec **props = g_object_class_list_properties (G_OBJECT_GET_CLASS (mObject), &n_properties);
g_message (GOM_LOC ("Adding %d properties from %s"), n_properties, G_OBJECT_TYPE_NAME (mObject));
JS_BeginRequest (jscx);
const char *camelName;
for (guint i = 0; i < n_properties; i++) {
camelName = gom_camel_case (props[i]->name);
if (!JS_DefineProperty (jscx, jsobj, camelName, JSVAL_VOID,
xgGObject::GetProperty,
xgGObject::SetProperty,
JSPROP_ENUMERATE | JSPROP_PERMANENT)) {
g_printerr ("Could not define a property for %s\n", camelName);
} else {
g_print (GOM_LOC ("Defined property: %s.%s\n"),
G_OBJECT_TYPE_NAME (mObject), camelName);
}
GOM_CAMEL_FREE (camelName, props[i]->name);
}
JS_EndRequest (jscx);
return NS_OK;
}
开发者ID:jberkman,项目名称:gom,代码行数:53,代码来源:xgGtkElement.cpp
示例6: gjs_intern_string_to_id
jsid
gjs_intern_string_to_id (JSContext *context,
const char *string)
{
JSString *str;
jsid id;
JS_BeginRequest(context);
str = JS_InternString(context, string);
id = INTERNED_STRING_TO_JSID(context, str);
JS_EndRequest(context);
return id;
}
开发者ID:victoryang,项目名称:gjs,代码行数:12,代码来源:jsapi-util-string.cpp
示例7: fprintf
AutoRoot::~AutoRoot() {
if(count < 0)
{
fprintf(stderr, "AutoRoot failed: Count is still %i, but the root is being destroyed", count);
DebugBreak();
exit(3);
}
//JS_RemoveRoot(cx, &var);
JS_BeginRequest(cx);
JS_RemoveValueRoot(cx, &var);
JS_EndRequest(cx);
}
开发者ID:ds-hwang,项目名称:d2bs,代码行数:12,代码来源:AutoRoot.cpp
示例8: def_animate_isPaused
CEXPORT JSBool def_animate_isPaused(JSContext *cx, unsigned argc, jsval *vp) {
JS_BeginRequest(cx);
JSObject *thiz = JSVAL_TO_OBJECT(JS_THIS(cx, vp));
view_animation *anim = (view_animation *)JS_GetPrivate(thiz);
jsval val = BOOLEAN_TO_JSVAL(anim->is_paused);
JS_SET_RVAL(cx, vp, val);
JS_EndRequest(cx);
return JS_TRUE;
}
开发者ID:rampr,项目名称:native-ios,代码行数:12,代码来源:js_animate.cpp
示例9: win32_impersonateuser
JSBool win32_impersonateuser(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
{
JSString * username, * password, *domain = NULL;
DWORD logonType = LOGON32_LOGON_INTERACTIVE;
JS_BeginRequest(cx);
if(!JS_ConvertArguments(cx, argc, argv, "S S /S u", &username, &password, &domain, &logonType))
{
JS_ReportError(cx, "Unable to parse arguments in ImpersonateUser");
JS_EndRequest(cx);
return JS_FALSE;
}
if(logonType == LOGON32_LOGON_NETWORK)
{
*rval = JSVAL_FALSE;
JS_EndRequest(cx);
return JS_TRUE;
}
LPWSTR domainName = NULL;
if(domain != NULL)
domainName = (LPWSTR)JS_GetStringChars(domain);
HANDLE newToken = NULL;
JS_YieldRequest(cx);
if(!LogonUser((LPWSTR)JS_GetStringChars(username), domainName, (LPWSTR)JS_GetStringChars(password), logonType, LOGON32_PROVIDER_DEFAULT, &newToken))
{
*rval = JSVAL_FALSE;
JS_EndRequest(cx);
return JS_TRUE;
}
if(!ImpersonateLoggedOnUser(newToken))
*rval = JSVAL_FALSE;
else
*rval = JSVAL_TRUE;
CloseHandle(newToken);
JS_EndRequest(cx);
return JS_TRUE;
}
开发者ID:z4y4,项目名称:njord,代码行数:40,代码来源:win32s.cpp
示例10: func
/* JSCall function by name, cvalues will be converted
*
* deactivates controller if any script errors!
*
* format values:
* case 'b': BOOLEAN_TO_JSVAL((JSBool) va_arg(ap, int));
* case 'c': INT_TO_JSVAL((uint16) va_arg(ap, unsigned int));
* case 'i':
* case 'j': js_NewNumberValue(cx, (jsdouble) va_arg(ap, int32), sp)
* case 'u': js_NewNumberValue(cx, (jsdouble) va_arg(ap, uint32), sp)
* case 'd':
* case 'I': js_NewDoubleValue(cx, va_arg(ap, jsdouble), sp)
* case 's': JS_NewStringCopyZ(cx, va_arg(ap, char *))
* case 'W': JS_NewUCStringCopyZ(cx, va_arg(ap, jschar *))
* case 'S': va_arg(ap, JSString *)
* case 'o': OBJECT_TO_JSVAL(va_arg(ap, JSObject *)
* case 'f':
* fun = va_arg(ap, JSFunction *);
* fun ? OBJECT_TO_JSVAL(fun->object) : JSVAL_NULL;
* case 'v': va_arg(ap, jsval);
*/
bool ControllerListener::call(const char *funcname, int argc, const char *format, ...) {
va_list ap;
jsval fval = JSVAL_VOID;
jsval ret = JSVAL_VOID;
func("%s try calling method %s.%s(argc:%i)", __func__, name, funcname, argc);
JS_SetContextThread(jsContext);
JS_BeginRequest(jsContext);
int res = JS_GetProperty(jsContext, jsObject, funcname, &fval);
if(JSVAL_IS_VOID(fval)) {
warning("method unresolved by JS_GetProperty");
} else {
jsval *argv;
void *markp;
va_start(ap, format);
argv = JS_PushArgumentsVA(jsContext, &markp, format, ap);
va_end(ap);
res = JS_CallFunctionValue(jsContext, jsObject, fval, argc, argv, &ret);
JS_PopArguments(jsContext, &markp);
if (res) {
if(!JSVAL_IS_VOID(ret)) {
JSBool ok;
JS_ValueToBoolean(jsContext, ret, &ok);
if (ok) // JSfunc returned 'true', so event is done
{
JS_EndRequest(jsContext);
JS_ClearContextThread(jsContext);
return true;
}
}
}
}
JS_EndRequest(jsContext);
JS_ClearContextThread(jsContext);
return false; // no callback, redo on next controller
}
开发者ID:dewn49,项目名称:FreeJ,代码行数:61,代码来源:controller.cpp
示例11: round_js_sm_removeregistry
JSBool round_js_sm_removeregistry(JSContext* cx, unsigned argc, jsval* vp)
{
if (argc < 1)
return JS_FALSE;
RoundLocalNode* node = round_js_sm_getlocalnode();
if (!node)
return JS_FALSE;
JS_BeginRequest(cx);
jsval* argv = JS_ARGV(cx, vp);
jsval param = argv[0];
#if defined(ROUND_USE_JS_JSON_PARAMS)
char key[ROUND_SCRIPT_JS_SM_REGISTRY_KEY_MAX];
if (!JSOBJECT_GET_GETPROPERTYSTRING(cx, param, ROUND_SYSTEM_METHOD_PARAM_KEY, key, sizeof(key)))
return false;
#else
char paramStr[ROUND_SCRIPT_JS_SM_REGISTRY_VALUE_MAX];
if (!JSOBJECT_TO_CSTRING(param, paramStr, sizeof(paramStr)))
return false;
const char* key;
RoundJSON* json = round_json_new();
RoundError* err = round_error_new();
if (json && err && round_json_parse(json, paramStr, err)) {
RoundJSONObject* paramObj = round_json_getrootobject(json);
if (round_json_object_ismap(paramObj)) {
round_json_map_getstring(paramObj, ROUND_SYSTEM_METHOD_PARAM_KEY, &key);
}
}
#endif
bool isSuccess = round_local_node_removeregistry(node, key);
#if !defined(ROUND_USE_JS_JSON_PARAMS)
if (json) {
round_json_delete(json);
}
if (err) {
round_error_delete(err);
}
#endif
JS_SET_RVAL(cx, vp, BOOLEAN_TO_JSVAL(isSuccess));
JS_EndRequest(cx);
return JS_TRUE;
}
开发者ID:cybergarage,项目名称:round,代码行数:52,代码来源:js_sm_functions.c
示例12: SetEvent
NS_IMETHODIMP DOMEventListener::HandleEvent(nsIDOMEvent *aEvent)
{
if(!active)
return NS_OK;
SetEvent(myHandle);
if(callBack != NULL)
{
JS_BeginRequest(aOwner->mContext);
JS_CallFunctionName(aOwner->mContext, JS_GetGlobalObject(aOwner->mContext), callBack, 0, NULL, NULL);
JS_EndRequest(aOwner->mContext);
}
return NS_OK;
}
开发者ID:z4y4,项目名称:njord,代码行数:13,代码来源:domeventhandler.cpp
示例13: def_animate_cb
void def_animate_cb(void *view, void *cb, double tt, double t) {
JSObject *js_view = (JSObject*)view;
JSObject *js_cb = (JSObject*)cb;
jsval args[2] = {DOUBLE_TO_JSVAL(tt),DOUBLE_TO_JSVAL(t)};
JSContext *cx = get_js_context();
JS_BeginRequest(cx);
jsval ret;
JS_CallFunctionValue(cx, js_view, OBJECT_TO_JSVAL(js_cb), 2, args, &ret);
JS_EndRequest(cx);
}
开发者ID:rampr,项目名称:native-ios,代码行数:13,代码来源:js_animate.cpp
示例14: TCP_finalize
void
TCP_finalize (JSContext* cx, JSObject* object)
{
JS_BeginRequest(cx);
TCPInformation* data = (TCPInformation*) JS_GetPrivate(cx, object);
if (data) {
delete data;
}
JS_EndRequest(cx);
}
开发者ID:mandrake,项目名称:lulzjs,代码行数:13,代码来源:TCP.cpp
示例15: wimg_apply_image
JSBool wimg_apply_image(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
{
DWORD applyFlags = 0;
LPWSTR path = NULL;
JS_BeginRequest(cx);
if(!JS_ConvertArguments(cx, argc, argv, "W /u", &path, &applyFlags))
{
JS_ReportError(cx, "Error during argument parsing in WIMApplyImage");
JS_EndRequest(cx);
return JS_FALSE;
}
HANDLE imageHandle = JS_GetPrivate(cx, obj);
jsrefcount rCount = JS_SuspendRequest(cx);
*rval = WIMApplyImage(imageHandle, path, applyFlags) ? JSVAL_TRUE : JSVAL_FALSE;
JS_ResumeRequest(cx, rCount);
if(*rval == JSVAL_FALSE)
{
JS_EndRequest(cx);
return JS_TRUE;
}
TCHAR volumeName[MAX_PATH + 1];
memset(volumeName, 0, sizeof(TCHAR) * (MAX_PATH + 1));
_tcscat_s(volumeName, MAX_PATH + 1, TEXT("\\\\.\\"));
_tcscat_s(volumeName, (MAX_PATH + 1) - 4, path);
if(!GetVolumePathName(volumeName, volumeName, MAX_PATH + 1))
{
JS_EndRequest(cx);
*rval = JSVAL_FALSE;
return JS_TRUE;
}
LPTSTR lastSlash = _tcsrchr(volumeName, _T('\\'));
*lastSlash = '\0';
HANDLE volumeHandle = CreateFile(volumeName, GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
if(volumeHandle == INVALID_HANDLE_VALUE)
{
JS_EndRequest(cx);
*rval = JSVAL_FALSE;
return JS_TRUE;
}
rCount = JS_SuspendRequest(cx);
if(!FlushFileBuffers(volumeHandle))
{
CloseHandle(volumeHandle);
JS_ResumeRequest(cx, rCount);
JS_EndRequest(cx);
*rval = JSVAL_FALSE;
return JS_TRUE;
}
CloseHandle(volumeHandle);
JS_ResumeRequest(cx, rCount);
*rval = JSVAL_TRUE;
JS_EndRequest(cx);
return JS_TRUE;
}
开发者ID:z4y4,项目名称:njord,代码行数:59,代码来源:js_wimg.cpp
示例16: gjs_get_instance_private_dynamic_with_typecheck
void*
gjs_get_instance_private_dynamic_with_typecheck(JSContext *context,
JSObject *obj,
JSClass *static_clasp,
jsval *argv)
{
RuntimeData *rd;
JSClass *obj_class;
void *instance;
if (static_clasp->name != NULL) {
g_warning("Dynamic class should not have a name in the JSClass struct");
return NULL;
}
JS_BeginRequest(context);
obj_class = JS_GET_CLASS(context, obj);
g_assert(obj_class != NULL);
rd = get_data_from_context(context);
g_assert(rd != NULL);
/* Check that it's safe to cast to DynamicJSClass */
if (g_hash_table_lookup(rd->dynamic_classes, obj_class) == NULL) {
JS_EndRequest(context);
return NULL;
}
if (static_clasp != ((DynamicJSClass*) obj_class)->static_class) {
JS_EndRequest(context);
return NULL;
}
instance = JS_GetInstancePrivate(context, obj, obj_class, argv);
JS_EndRequest(context);
return instance;
}
开发者ID:sjokkis,项目名称:gjs,代码行数:38,代码来源:jsapi-util.c
示例17: jsd_GetScriptForValue
JSDScript*
jsd_GetScriptForValue(JSDContext* jsdc, JSDValue* jsdval)
{
JSContext* cx = jsdc->dumbContext;
jsval val = jsdval->val;
JSFunction* fun = NULL;
JSExceptionState* exceptionState;
JSScript* script = NULL;
JSDScript* jsdscript;
JSCrossCompartmentCall *call = NULL;
if (!jsd_IsValueFunction(jsdc, jsdval))
return NULL;
JS_BeginRequest(cx);
call = JS_EnterCrossCompartmentCall(cx, JSVAL_TO_OBJECT(val));
if (!call) {
JS_EndRequest(cx);
return NULL;
}
exceptionState = JS_SaveExceptionState(cx);
fun = JSD_GetValueFunction(jsdc, jsdval);
JS_RestoreExceptionState(cx, exceptionState);
if (fun)
script = JS_GetFunctionScript(cx, fun);
JS_LeaveCrossCompartmentCall(call);
JS_EndRequest(cx);
if (!script)
return NULL;
JSD_LOCK_SCRIPTS(jsdc);
jsdscript = jsd_FindJSDScript(jsdc, script);
JSD_UNLOCK_SCRIPTS(jsdc);
return jsdscript;
}
开发者ID:moussa1,项目名称:mozilla-central,代码行数:38,代码来源:jsd_val.c
示例18: gjs_object_require_property
/* Returns whether the object had the property; if the object did
* not have the property, always sets an exception. Treats
* "the property's value is JSVAL_VOID" the same as "no such property,"
* while JS_GetProperty() treats only "no such property" as an error.
* Guarantees that *value_p is set to something, if only JSVAL_VOID,
* even if an exception is set and false is returned.
*/
gboolean
gjs_object_require_property(JSContext *context,
JSObject *obj,
const char *obj_description,
const char *property_name,
jsval *value_p)
{
jsval value;
JS_BeginRequest(context);
value = JSVAL_VOID;
JS_GetProperty(context, obj, property_name, &value);
if (value_p)
*value_p = value;
if (value != JSVAL_VOID) {
JS_ClearPendingException(context); /* in case JS_GetProperty() was on crack */
JS_EndRequest(context);
return TRUE;
} else {
/* remember gjs_throw() is a no-op if JS_GetProperty()
* already set an exception
*/
if (obj_description)
gjs_throw(context,
"No property '%s' in %s (or its value was undefined)",
property_name, obj_description);
else
gjs_throw(context,
"No property '%s' in object %p (or its value was undefined)",
property_name, obj);
JS_EndRequest(context);
return FALSE;
}
}
开发者ID:sjokkis,项目名称:gjs,代码行数:45,代码来源:jsapi-util.c
示例19: gjs_closure_invoke
void
gjs_closure_invoke(GClosure *closure,
int argc,
jsval *argv,
jsval *retval)
{
Closure *c;
JSContext *context;
c = (Closure*) closure;
check_context_valid(c);
if (c->obj == NULL) {
/* We were destroyed; become a no-op */
c->context = NULL;
return;
}
context = gjs_runtime_get_context(c->runtime);
JS_BeginRequest(context);
if (JS_IsExceptionPending(context)) {
gjs_debug_closure("Exception was pending before invoking callback??? "
"Not expected");
gjs_log_exception(context, NULL);
}
if (!gjs_call_function_value(context,
NULL, /* "this" object; NULL is some kind of default presumably */
OBJECT_TO_JSVAL(c->obj),
argc,
argv,
retval)) {
/* Exception thrown... */
gjs_debug_closure("Closure invocation failed (exception should "
"have been thrown) closure %p callable %p",
closure, c->obj);
if (!gjs_log_exception(context, NULL))
gjs_debug_closure("Closure invocation failed but no exception was set?");
goto out;
}
if (gjs_log_exception(context, NULL)) {
gjs_debug_closure("Closure invocation succeeded but an exception was set");
}
out:
JS_EndRequest(context);
}
开发者ID:darkxst,项目名称:gjs-js188,代码行数:50,代码来源:closure.c
示例20: createMyObject
static bool
createMyObject(JSContext* context, unsigned argc, jsval *vp)
{
JS_BeginRequest(context);
//JS_GC(context); //<- if we make GC here, all is ok
JSObject* myObject = JS_NewObject(context, &myClass, JS::NullPtr(), JS::NullPtr());
*vp = OBJECT_TO_JSVAL(myObject);
JS_EndRequest(context);
return true;
}
开发者ID:ashishrana7,项目名称:firefox,代码行数:14,代码来源:testOps.cpp
注:本文中的JS_EndRequest函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论