本文整理汇总了C++中JS_GetInstancePrivate函数的典型用法代码示例。如果您正苦于以下问题:C++ JS_GetInstancePrivate函数的具体用法?C++ JS_GetInstancePrivate怎么用?C++ JS_GetInstancePrivate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了JS_GetInstancePrivate函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: location_set_property
/* @location_class.setProperty */
static JSBool
location_set_property(JSContext *ctx, JSObject *obj, jsid id, JSBool strict, jsval *vp)
{
JSObject *parent_win; /* instance of @window_class */
struct view_state *vs;
struct document_view *doc_view;
/* This can be called if @obj if not itself an instance of the
* appropriate class but has one in its prototype chain. Fail
* such calls. */
if (!JS_InstanceOf(ctx, obj, (JSClass *) &location_class, NULL))
return JS_FALSE;
parent_win = JS_GetParent(ctx, obj);
assert(JS_InstanceOf(ctx, parent_win, (JSClass *) &window_class, NULL));
if_assert_failed return JS_FALSE;
vs = (struct view_state *)JS_GetInstancePrivate(ctx, parent_win,
(JSClass *) &window_class, NULL);
doc_view = vs->doc_view;
if (!JSID_IS_INT(id))
return JS_TRUE;
switch (JSID_TO_INT(id)) {
case JSP_LOC_HREF:
location_goto(doc_view, jsval_to_string(ctx, vp));
break;
}
return JS_TRUE;
}
示例2: rpmdc_Init
/* --- Object methods */
static JSBool
rpmdc_Init(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
void * ptr = JS_GetInstancePrivate(cx, obj, &rpmdcClass, NULL);
rpmdc dc = ptr;
JSBool ok = JS_FALSE;
unsigned int _dalgo = PGPHASHALGO_NONE;
unsigned int _flags = RPMDIGEST_NONE;
_METHOD_DEBUG_ENTRY(_debug);
if (!(ok = JS_ConvertArguments(cx, argc, argv, "/uu", &_dalgo, &_flags)))
goto exit;
if (dc) {
if (_dalgo == PGPHASHALGO_NONE) _dalgo = rpmDigestAlgo(dc);
(void) rpmDigestFinal(dc, NULL, NULL, 0);
(void) JS_SetPrivate(cx, obj, (void *)NULL);
}
if (_dalgo == PGPHASHALGO_NONE) _dalgo = _dalgo_default;
dc = rpmDigestInit(_dalgo, _flags);
(void) JS_SetPrivate(cx, obj, (void *)dc);
*rval = JSVAL_TRUE;
ok = JS_TRUE;
exit:
return ok;
}
示例3: rpmdc_Fini
static JSBool
rpmdc_Fini(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
void * ptr = JS_GetInstancePrivate(cx, obj, &rpmdcClass, NULL);
rpmdc dc = ptr;
JSBool ok = JS_FALSE;
const char * s = NULL;
size_t ns = 0;
_METHOD_DEBUG_ENTRY(_debug);
*rval = JSVAL_FALSE;
if (dc == NULL)
goto exit;
(void) rpmDigestFinal(dc, &s, &ns, 1);
*rval = STRING_TO_JSVAL(JS_NewStringCopyZ(cx, s));
(void) JS_SetPrivate(cx, obj, (void *)NULL);
ok = JS_TRUE;
exit:
s = _free(s);
return ok;
}
示例4: rpmmpf_Close
static JSBool
rpmmpf_Close(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
void * ptr = JS_GetInstancePrivate(cx, obj, &rpmmpfClass, NULL);
DB_MPOOLFILE * mpf = ptr;
uint32_t _flags = 0;
JSBool ok = JS_FALSE;
_METHOD_DEBUG_ENTRY(_debug);
if (mpf == NULL) goto exit;
*rval = JSVAL_FALSE;
if (!(ok = JS_ConvertArguments(cx, argc, argv, "/u", &_flags)))
goto exit;
{ int ret = mpf->close(mpf, _flags);
if (ret)
fprintf(stderr, "DB_MPOOLFILE->close: %s\n", db_strerror(ret));
else
*rval = JSVAL_TRUE;
mpf = ptr = NULL;
(void) JS_SetPrivate(cx, obj, ptr);
}
ok = JS_TRUE;
exit:
return ok;
}
示例5: rpmmg_setprop
static JSBool
rpmmg_setprop(JSContext *cx, JSObject *obj, jsid id, JSBool strict, jsval *vp)
{
void * ptr = JS_GetInstancePrivate(cx, obj, &rpmmgClass, NULL);
jsval idval;
JS_IdToValue(cx, id, &idval);
jsint tiny = JSVAL_TO_INT(idval);
_PROP_DEBUG_ENTRY(_debug < 0);
/* XXX the class has ptr == NULL, instances have ptr != NULL. */
if (ptr == NULL)
return JS_TRUE;
switch (tiny) {
case _DEBUG:
if (!JS_ValueToInt32(cx, *vp, &_debug))
break;
break;
default:
break;
}
return JS_TRUE;
}
示例6: jsSetBits
static JSBool
jsSetBits( JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval )
{
*rval = JSVAL_FALSE ;
jsPort_t *port = (jsPort_t *)JS_GetInstancePrivate( cx, obj, &jsSerialPortClass_, NULL );
if( port )
{
if( ( 1 == argc ) && JSVAL_IS_INT( argv[0] ) )
{
int const bits = JSVAL_TO_INT( argv[0] );
if( ( 5 <= bits ) && ( 8 >= bits ) )
{
struct termios termState;
tcgetattr(port->getFd(),&termState);
termState.c_cflag &= ~CSIZE ;
termState.c_cflag |= csLengthMasks_[bits-5];
int result = tcsetattr( port->getFd(), TCSANOW, &termState );
if( 0 == result )
{
*rval = JSVAL_TRUE ;
}
else
perror( "setBits" );
}
else
JS_ReportError( cx, "unsupported character length" );
}
else
JS_ReportError( cx, "Usage: scanner.setBits( 7|8 );" );
}
return JS_TRUE ;
}
示例7: rpmmpf_getprop
static JSBool
rpmmpf_getprop(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
{
void * ptr = JS_GetInstancePrivate(cx, obj, &rpmmpfClass, NULL);
DB_MPOOLFILE * mpf = ptr;
int32_t _i = 0;
uint32_t _u = 0;
uint32_t _gb = 0;
jsint tiny = JSVAL_TO_INT(id);
/* XXX the class has ptr == NULL, instances have ptr != NULL. */
if (ptr == NULL)
return JS_TRUE;
switch (tiny) {
case _DEBUG:
*vp = INT_TO_JSVAL(_debug);
break;
case _CLEARLEN: *vp = _GET_U(!mpf->get_clear_len(mpf, &_u)); break;
case _FLAGS: *vp = _GET_U(!mpf->get_flags(mpf, &_u)); break;
case _FTYPE: *vp = _GET_I(!mpf->get_ftype(mpf, &_i)); break;
case _LSNOFFSET: *vp = _GET_I(!mpf->get_lsn_offset(mpf, &_i)); break;
case _MAXSIZE: *vp = _GET_U(!mpf->get_maxsize(mpf, &_gb, &_u)); break;
case _PGCOOKIE: *vp = JSVAL_VOID; break; /* XXX FIXME */
case _PRIORITY: *vp = _GET_U(!mpf->get_priority(mpf, (DB_CACHE_PRIORITY *)&_u)); break;
default:
break;
}
return JS_TRUE;
}
示例8: rpmte_fi
static JSBool
rpmte_fi(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
void * ptr = JS_GetInstancePrivate(cx, obj, &rpmteClass, NULL);
rpmte te = ptr;
rpmTag tagN = RPMTAG_BASENAMES;
JSBool ok = JS_FALSE;
_METHOD_DEBUG_ENTRY(_debug);
if (!(ok = JS_ConvertArguments(cx, argc, argv, "/i", &tagN)))
goto exit;
{ rpmfi fi = NULL;
JSObject *fio = NULL;
if ((fi = rpmteFI(te, tagN)) == NULL)
*rval = JSVAL_NULL;
else
if ((fio = JS_NewObject(cx, &rpmfiClass, NULL, NULL)) != NULL
&& JS_SetPrivate(cx, fio, rpmfiLink(fi, __FUNCTION__)))
*rval = OBJECT_TO_JSVAL(fio);
else {
fi = rpmfiFree(fi);
*rval = JSVAL_VOID;
}
}
ok = JS_TRUE;
exit:
return ok;
}
示例9: UNUSED2
JSBool JSI_IGUIObject::getComputedSize(JSContext* cx, uintN argc, jsval* vp)
{
UNUSED2(argc);
IGUIObject* e = (IGUIObject*)JS_GetInstancePrivate(cx, JS_THIS_OBJECT(cx, vp), &JSI_IGUIObject::JSI_class, NULL);
if (!e)
return JS_FALSE;
e->UpdateCachedSize();
CRect size = e->m_CachedActualSize;
JSObject* obj = JS_NewObject(cx, NULL, NULL, NULL);
try
{
g_ScriptingHost.SetObjectProperty_Double(obj, "left", size.left);
g_ScriptingHost.SetObjectProperty_Double(obj, "right", size.right);
g_ScriptingHost.SetObjectProperty_Double(obj, "top", size.top);
g_ScriptingHost.SetObjectProperty_Double(obj, "bottom", size.bottom);
}
catch (PSERROR_Scripting_ConversionFailed)
{
debug_warn(L"Error creating size object!");
return JS_FALSE;
}
JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj));
return JS_TRUE;
}
示例10: rpmte_ctor
static JSBool
rpmte_ctor(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
JSBool ok = JS_FALSE;
JSObject *tso = NULL;
JSObject *hdro = NULL;
_CTOR_DEBUG_ENTRY(_debug);
if (!(ok = JS_ConvertArguments(cx, argc, argv, "o/o", &tso, &hdro)))
goto exit;
if (JS_IsConstructing(cx)) {
rpmts ts = JS_GetInstancePrivate(cx, tso, &rpmtsClass, NULL);
if (rpmte_init(cx, obj, ts, hdro) == NULL)
goto exit;
} else {
if ((obj = JS_NewObject(cx, &rpmteClass, NULL, NULL)) == NULL)
goto exit;
*rval = OBJECT_TO_JSVAL(obj);
}
ok = JS_TRUE;
exit:
return ok;
}
示例11: rpmte_ds
/* --- Object methods */
static JSBool
rpmte_ds(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
void * ptr = JS_GetInstancePrivate(cx, obj, &rpmteClass, NULL);
rpmte te = ptr;
rpmTag tagN = RPMTAG_NAME;
JSBool ok = JS_FALSE;
_METHOD_DEBUG_ENTRY(_debug);
if (!(ok = JS_ConvertArguments(cx, argc, argv, "/i", &tagN)))
goto exit;
{ rpmds ds = NULL;
JSObject *dso = NULL;
if ((ds = rpmteDS(te, tagN)) == NULL)
*rval = JSVAL_NULL;
else
if ((dso = JS_NewObject(cx, &rpmdsClass, NULL, NULL)) != NULL
&& JS_SetPrivate(cx, dso, rpmdsLink(ds, __FUNCTION__)))
*rval = OBJECT_TO_JSVAL(dso);
else {
ds = rpmdsFree(ds);
*rval = JSVAL_VOID;
}
}
ok = JS_TRUE;
exit:
return ok;
}
示例12: JSDestructor
void ADM_JSDialogFactory::JSDestructor(JSContext *cx, JSObject *obj)
{
ADM_JSDialogFactoryHelper *pObject = (ADM_JSDialogFactoryHelper*)JS_GetInstancePrivate(cx, obj, &m_dialogFactoryHelper, NULL);
if (pObject != NULL)
delete pObject;
}
示例13: rpmmpf_Sync
static JSBool
rpmmpf_Sync(JSContext *cx, uintN argc, jsval *vp)
{
jsval *argv = JS_ARGV(cx, vp);
JSObject *obj = JS_THIS_OBJECT(cx, vp);
void * ptr = JS_GetInstancePrivate(cx, obj, &rpmmpfClass, NULL);
DB_MPOOLFILE * mpf = ptr;
JSBool ok = JS_FALSE;
_METHOD_DEBUG_ENTRY(_debug);
if (mpf == NULL) goto exit;
*vp = JSVAL_FALSE;
{ int ret = mpf->sync(mpf);
if (ret)
fprintf(stderr, "DB_MPOOLFILE->sync: %s\n", db_strerror(ret));
*vp = (!ret ? JSVAL_TRUE : JSVAL_FALSE);
}
ok = JS_TRUE;
exit:
return ok;
}
示例14: jsGetParity
static JSBool
jsGetParity( JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval )
{
jsPort_t *port = (jsPort_t *)JS_GetInstancePrivate( cx, obj, &jsSerialPortClass_, NULL );
if( port )
{
struct termios oldTermState;
tcgetattr(port->getFd(),&oldTermState);
char const *parity ;
if( oldTermState.c_cflag & PARENB )
{
if( oldTermState.c_cflag & PARODD )
parity = "O" ;
else
parity = "E" ;
}
else
parity = "N" ;
*rval = STRING_TO_JSVAL( JS_NewStringCopyN( cx, parity, 1 ) );
}
else
*rval = JSVAL_FALSE ;
return JS_TRUE ;
}
示例15: method_missing
static JSBool method_missing(JSContext* js_context, JSObject* obj, uintN argc, jsval* argv, jsval* retval)
{
VALUE ruby_context = (VALUE)JS_GetContextPrivate(js_context);
JohnsonContext* context;
JohnsonRuntime* runtime;
Data_Get_Struct(ruby_context, JohnsonContext, context);
VALUE ruby_runtime = (VALUE)JS_GetRuntimePrivate(JS_GetRuntime(js_context));
Data_Get_Struct(ruby_runtime, JohnsonRuntime, runtime);
PREPARE_JROOTS(js_context, 0);
VALUE self = (VALUE)JS_GetInstancePrivate(context->js, obj, JS_GET_CLASS(context->js, obj), NULL);
assert(argc >= 2);
char* key = JS_GetStringBytes(JSVAL_TO_STRING(argv[0]));
VALUE ruby_id = rb_intern(key);
// FIXME: this is horrible and lazy, to_a comes from enumerable on proxy (argv[1] is a JSArray)
VALUE args;
JCHECK(call_ruby_from_js2(runtime, &args, CONVERT_TO_RUBY(runtime, argv[1]), rb_intern("to_a"), 0));
JCHECK(call_ruby_from_js(runtime, retval, Johnson_SpiderMonkey_JSLandProxy(),
rb_intern("send_with_possible_block"), 3, self, ID2SYM(ruby_id), args));
JRETURN;
}