当前位置: 首页>>代码示例>>C++>>正文


C++ JSGlobalObject::js_setCurrentContext方法代码示例

本文整理汇总了C++中JSGlobalObject::js_setCurrentContext方法的典型用法代码示例。如果您正苦于以下问题:C++ JSGlobalObject::js_setCurrentContext方法的具体用法?C++ JSGlobalObject::js_setCurrentContext怎么用?C++ JSGlobalObject::js_setCurrentContext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JSGlobalObject的用法示例。


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

示例1: fromjs_isTimerValid

JSBool JSJSGlobalObject::fromjs_isTimerValid(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
  // get instance
  JSGlobalObject *object = static_cast<JSGlobalObject *>(reinterpret_cast<JSScriptable *>(JS_GetPrivate(cx, obj)));
  if (!object) {
    JSScriptable::js_throwNullCallException(JSJSGlobalObject::classDescriptor.name, JSJSGlobalObject::functionTable[4].name);
    return JS_FALSE;
  }
  // record context
  object->js_setCurrentContext(cx);
  // JSTimer *timer
  JSObject *p0;
  if (!JS_ValueToObject(cx, argv[0], &p0))
    return JS_FALSE;
  argv[0] = OBJECT_TO_JSVAL(p0);
  JSTimer *p0o = NULL;
  if (p0) {
    JSScriptable *pobj = reinterpret_cast<JSScriptable*>(JS_GetPrivate(cx, p0));
    if (!pobj) {
      object->js_throwNullParamException(0, JSJSGlobalObject::functionTable[4].name, JSJSGlobalObject::classDescriptor.name);
      return JS_FALSE;
    }
    p0o = static_cast<JSTimer *>(pobj->js_getInterface(JS_JSTimer_GUID));
    if (!p0o) {
      object->js_throwParamTypeException(0, JSJSTimer::classDescriptor.name, JSJSGlobalObject::functionTable[4].name, JSJSGlobalObject::classDescriptor.name);
      return JS_FALSE;
    }
  }
  // call method
  ASSERT(object != NULL);
  bool rv = object->isTimerValid(p0o);
  // handle return value
  *rval = BOOLEAN_TO_JSVAL(rv);
  // success
  return JS_TRUE;
}
开发者ID:bizzehdee,项目名称:wasabi,代码行数:35,代码来源:JSJSGlobalObject.cpp

示例2: fromjs_shutdown

JSBool JSJSGlobalObject::fromjs_shutdown(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
  // get instance
  JSGlobalObject *object = static_cast<JSGlobalObject *>(reinterpret_cast<JSScriptable *>(JS_GetPrivate(cx, obj)));
  if (!object) {
    JSScriptable::js_throwNullCallException(JSJSGlobalObject::classDescriptor.name, JSJSGlobalObject::functionTable[5].name);
    return JS_FALSE;
  }
  // record context
  object->js_setCurrentContext(cx);
  // call method
  ASSERT(object != NULL);
  object->shutdown();
  // success
  return JS_TRUE;
}
开发者ID:bizzehdee,项目名称:wasabi,代码行数:15,代码来源:JSJSGlobalObject.cpp

示例3: fromjs_createTimer

JSBool JSJSGlobalObject::fromjs_createTimer(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
  // get instance
  JSGlobalObject *object = static_cast<JSGlobalObject *>(reinterpret_cast<JSScriptable *>(JS_GetPrivate(cx, obj)));
  if (!object) {
    JSScriptable::js_throwNullCallException(JSJSGlobalObject::classDescriptor.name, JSJSGlobalObject::functionTable[2].name);
    return JS_FALSE;
  }
  // record context
  object->js_setCurrentContext(cx);
  // call method
  ASSERT(object != NULL);
  JSTimer * rv = object->createTimer();
  // handle return value
  if (!rv) *rval = JSVAL_VOID;
  else *rval = OBJECT_TO_JSVAL(rv->js_getJSObject(cx));
  // success
  return JS_TRUE;
}
开发者ID:bizzehdee,项目名称:wasabi,代码行数:18,代码来源:JSJSGlobalObject.cpp

示例4: fromjs_alert

JSBool JSJSGlobalObject::fromjs_alert(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
  // get instance
  JSGlobalObject *object = static_cast<JSGlobalObject *>(reinterpret_cast<JSScriptable *>(JS_GetPrivate(cx, obj)));
  if (!object) {
    JSScriptable::js_throwNullCallException(JSJSGlobalObject::classDescriptor.name, JSJSGlobalObject::functionTable[1].name);
    return JS_FALSE;
  }
  // record context
  object->js_setCurrentContext(cx);
  // const char *str
  JSString * p0;
  p0 = JS_ValueToString(cx, argv[0]);
  argv[0] = STRING_TO_JSVAL(p0);
  const char *p0b = JS_GetStringBytes(p0);
  // call method
  ASSERT(object != NULL);
  object->alert(p0b);
  // success
  return JS_TRUE;
}
开发者ID:bizzehdee,项目名称:wasabi,代码行数:20,代码来源:JSJSGlobalObject.cpp


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