本文整理汇总了C++中JS_EndRequest函数的典型用法代码示例。如果您正苦于以下问题:C++ JS_EndRequest函数的具体用法?C++ JS_EndRequest怎么用?C++ JS_EndRequest使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了JS_EndRequest函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}