本文整理汇总了C++中JS_GetInstancePrivate函数的典型用法代码示例。如果您正苦于以下问题:C++ JS_GetInstancePrivate函数的具体用法?C++ JS_GetInstancePrivate怎么用?C++ JS_GetInstancePrivate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了JS_GetInstancePrivate函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:rkd77,项目名称:elinks-tv,代码行数:32,代码来源:location.c
示例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;
}
开发者ID:hahnakane,项目名称:junkcode,代码行数:29,代码来源:rpmdc-js.c
示例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;
}
开发者ID:hahnakane,项目名称:junkcode,代码行数:25,代码来源:rpmdc-js.c
示例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;
}
开发者ID:hahnakane,项目名称:junkcode,代码行数:29,代码来源:rpmmpf-js.c
示例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;
}
开发者ID:avokhmin,项目名称:RPM5,代码行数:25,代码来源:rpmmg-js.c
示例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 ;
}
开发者ID:boundarydevices,项目名称:bdScript,代码行数:35,代码来源:jsSerial.cpp
示例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;
}
开发者ID:hahnakane,项目名称:junkcode,代码行数:32,代码来源:rpmmpf-js.c
示例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;
}
开发者ID:hahnakane,项目名称:junkcode,代码行数:29,代码来源:rpmte-js.c
示例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;
}
开发者ID:Marlinc,项目名称:0ad,代码行数:28,代码来源:JSInterface_IGUIObject.cpp
示例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;
}
开发者ID:hahnakane,项目名称:junkcode,代码行数:26,代码来源:rpmte-js.c
示例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;
}
开发者ID:hahnakane,项目名称:junkcode,代码行数:30,代码来源:rpmte-js.c
示例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;
}
开发者ID:BackupTheBerlios,项目名称:avidemux-svn,代码行数:7,代码来源:ADM_JSDialogFactory.cpp
示例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;
}
开发者ID:cmjonze,项目名称:rpm5_tarballs,代码行数:25,代码来源:rpmmpf-js.c
示例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 ;
}
开发者ID:boundarydevices,项目名称:bdScript,代码行数:26,代码来源:jsSerial.cpp
示例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;
}
开发者ID:aasmith,项目名称:johnson,代码行数:29,代码来源:js_land_proxy.c
示例16: jsGetBits
static JSBool
jsGetBits( 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);
unsigned csMask = oldTermState.c_cflag & CSIZE ;
unsigned charLen = 0 ;
if( CS8 == csMask )
charLen = 8 ;
else if( CS7 == csMask )
charLen = 7 ;
else if( CS6 == csMask )
charLen = 6 ;
else if( CS5 == csMask )
charLen = 5 ;
*rval = INT_TO_JSVAL( charLen );
}
else
*rval = JSVAL_FALSE ;
return JS_TRUE ;
}
开发者ID:boundarydevices,项目名称:bdScript,代码行数:25,代码来源:jsSerial.cpp
示例17: call
static JSBool call(JSContext* js_context, JSObject* UNUSED(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, JSVAL_TO_OBJECT(JS_ARGV_CALLEE(argv)), &JSLandCallableProxyClass, NULL);
VALUE args = rb_ary_new();
uintN i;
for (i = 0; i < argc; ++i)
rb_ary_push(args, CONVERT_TO_RUBY(runtime, argv[i]));
JCHECK(call_ruby_from_js(runtime, retval, Johnson_SpiderMonkey_JSLandProxy(),
rb_intern("send_with_possible_block"), 3, self, ID2SYM(rb_intern("call")), args));
JRETURN;
}
开发者ID:aasmith,项目名称:johnson,代码行数:25,代码来源:js_land_proxy.c
示例18: rpmps_push
/* --- Object methods */
static JSBool
rpmps_push(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, &rpmpsClass, NULL);
rpmps ps = ptr;
char *pkgNEVR;
char *altNEVR;
JSObject *o;
rpmProblemType type;
char *dn;
char *bn;
uint32 ui;
JSBool ok = JS_FALSE;
_METHOD_DEBUG_ENTRY(_debug);
if (!(ok = JS_ConvertArguments(cx, argc, argv, "ssoissu",
&pkgNEVR, &altNEVR, &o, &type, &dn, &bn, &ui)))
goto exit;
rpmpsAppend(ps, type, pkgNEVR, o, dn, bn, altNEVR, ui);
ok = JS_TRUE;
exit:
return ok;
}
开发者ID:cmjonze,项目名称:rpm5_tarballs,代码行数:28,代码来源:rpmps-js.c
示例19: rpmts_mi
static JSBool
rpmts_mi(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
void * ptr = JS_GetInstancePrivate(cx, obj, &rpmtsClass, NULL);
rpmts ts = ptr;
jsval tagid = JSVAL_VOID;
jsval kv = JSVAL_VOID;
rpmTag tag = RPMDBI_PACKAGES;
JSObject *mio;
JSBool ok = JS_FALSE;
_METHOD_DEBUG_ENTRY(_debug);
if (!(ok = JS_ConvertArguments(cx, argc, argv, "/vv", &tagid, &kv)))
goto exit;
if (!JSVAL_IS_VOID(tagid)) {
/* XXX TODO: make sure both tag and key were specified. */
tag = JSVAL_IS_INT(tagid)
? (rpmTag) JSVAL_TO_INT(tagid)
: tagValue(JS_GetStringBytes(JS_ValueToString(cx, tagid)));
}
if ((mio = rpmjs_NewMiObject(cx, ts, tag, kv)) == NULL)
goto exit;
*rval = OBJECT_TO_JSVAL(mio);
ok = JS_TRUE;
exit:
return ok;
}
开发者ID:hahnakane,项目名称:junkcode,代码行数:32,代码来源:rpmts-js.c
示例20: rpmmpf_call
static JSBool
rpmmpf_call(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
/* XXX obj is the global object so lookup "this" object. */
JSObject * o = JSVAL_TO_OBJECT(argv[-2]);
void * ptr = JS_GetInstancePrivate(cx, o, &rpmmpfClass, NULL);
#ifdef NOTYET
DB_MPOOLFILE * mpf = ptr;
const char *_fn = NULL;
const char * _con = NULL;
#endif
JSBool ok = JS_FALSE;
#ifdef NOTYET
if (!(ok = JS_ConvertArguments(cx, argc, argv, "s", &_fn)))
goto exit;
*rval = (mpf && _fn && (_con = rpmmpfLgetfilecon(mpf, _fn)) != NULL)
? STRING_TO_JSVAL(JS_NewStringCopyZ(cx, _con)) : JSVAL_VOID;
_con = _free(_con);
ok = JS_TRUE;
exit:
#endif
if (_debug)
fprintf(stderr, "<== %s(%p,%p,%p[%u],%p) o %p ptr %p\n", __FUNCTION__, cx, obj, argv, (unsigned)argc, rval, o, ptr);
return ok;
}
开发者ID:hahnakane,项目名称:junkcode,代码行数:31,代码来源:rpmmpf-js.c
注:本文中的JS_GetInstancePrivate函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论