本文整理汇总了C++中duk_remove函数的典型用法代码示例。如果您正苦于以下问题:C++ duk_remove函数的具体用法?C++ duk_remove怎么用?C++ duk_remove使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了duk_remove函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: PrivatePush
static Box * PrivatePush( duk_context * ctx, const size_t class_index, const size_t object_size, finalizer_t finalizer )
{
duk_push_global_object( ctx );
duk_get_prop_string( ctx, -1, "Proxy" );
duk_remove( ctx, -2 );
duk_push_object( ctx );
size_t require_size = sizeof( Box ) + object_size;
Box * box = reinterpret_cast<Box*>( duk_push_fixed_buffer( ctx, require_size ) );
box->ClassIndex = class_index;
box->Finalizer = finalizer;
duk_put_prop_string( ctx, -2, "\xFF" "Box" );
duk_push_c_function( ctx, &internal::ClassFinalizer, 1 );
duk_set_finalizer( ctx, -2 );
duk_push_heap_stash( ctx );
duk_get_prop_string( ctx, -1, "InstanceHandler" );
duk_remove( ctx, -2 );
duk_new( ctx, 2 );
return box;
}
开发者ID:crazyjul,项目名称:dukbind,代码行数:26,代码来源:dukbind.cpp
示例2: duk_push_sphere_bytearray
void
duk_push_sphere_bytearray(duk_context* ctx, bytearray_t* array)
{
duk_push_object(ctx);
duk_push_string(ctx, "bytearray"); duk_put_prop_string(ctx, -2, "\xFF" "sphere_type");
duk_push_pointer(ctx, array); duk_put_prop_string(ctx, -2, "\xFF" "ptr");
duk_push_c_function(ctx, js_ByteArray_finalize, DUK_VARARGS); duk_set_finalizer(ctx, -2);
duk_push_c_function(ctx, js_ByteArray_toString, DUK_VARARGS); duk_put_prop_string(ctx, -2, "toString");
duk_push_c_function(ctx, js_ByteArray_concat, DUK_VARARGS); duk_put_prop_string(ctx, -2, "concat");
duk_push_c_function(ctx, js_ByteArray_slice, DUK_VARARGS); duk_put_prop_string(ctx, -2, "slice");
duk_push_string(ctx, "length"); duk_push_int(ctx, array->size);
duk_def_prop(ctx, -3,
DUK_DEFPROP_HAVE_CONFIGURABLE | 0
| DUK_DEFPROP_HAVE_WRITABLE | 0
| DUK_DEFPROP_HAVE_VALUE);
// return proxy object so we can catch array accesses
duk_push_global_object(ctx);
duk_get_prop_string(ctx, -1, "Proxy");
duk_dup(ctx, -3);
duk_push_object(ctx);
duk_push_c_function(ctx, js_ByteArray_getProp, DUK_VARARGS); duk_put_prop_string(ctx, -2, "get");
duk_push_c_function(ctx, js_ByteArray_setProp, DUK_VARARGS); duk_put_prop_string(ctx, -2, "set");
duk_new(ctx, 2);
duk_remove(ctx, -2);
duk_remove(ctx, -2);
}
开发者ID:carriercomm,项目名称:minisphere,代码行数:27,代码来源:bytearray.c
示例3: PushWeakObject
void PushWeakObject(duk_context* ctx, Object* object)
{
if (!object)
{
duk_push_null(ctx);
return;
}
duk_push_heap_stash(ctx);
// Check if the wrapper for the object already exists in stash
// This is required so that comparisons of object references (e.g. against the me property) work properly
if (duk_has_prop_index(ctx, -1, (size_t)object))
{
duk_get_prop_index(ctx, -1, (size_t)object);
WeakPtr<Object>* oldPtr = GetWeakPtr(ctx, -1);
if (oldPtr && oldPtr->Get() == object)
{
duk_remove(ctx, -2); // Remove stash
return;
}
else
duk_pop(ctx); // Valid existing wrapper not found
}
duk_push_object(ctx);
WeakPtr<Object>* ptr = new WeakPtr<Object>(object);
duk_push_pointer(ctx, ptr);
duk_put_prop_string(ctx, -2, "\xff""weak");
duk_push_c_function(ctx, WeakPtr_Finalizer, 1);
duk_set_finalizer(ctx, -2);
// Set prototype. If not found, use base class prototype (e.g. IComponent)
duk_get_global_string(ctx, object->GetTypeName().CString());
if (!duk_is_object(ctx, -1))
{
duk_pop(ctx);
duk_get_global_string(ctx, object->GetTypeInfo()->GetBaseTypeInfo()->GetTypeName().CString());
}
duk_get_prop_string(ctx, -1, "prototype");
duk_set_prototype(ctx, -3);
duk_pop(ctx);
// Proxied property access handling for scene, entity & component
if (object->GetType() == Scene::GetTypeStatic())
SetupProxy(ctx, SceneProxyFunctions);
if (object->GetType() == Entity::GetTypeStatic())
SetupProxy(ctx, EntityProxyFunctions);
else if (dynamic_cast<IComponent*>(object))
SetupProxy(ctx, ComponentProxyFunctions);
// Store to stash
duk_dup(ctx, -1);
duk_put_prop_index(ctx, -3, (size_t)object);
duk_remove(ctx, -2); // Remove stash
}
开发者ID:realXtend,项目名称:tundra-urho3d,代码行数:56,代码来源:BindingsHelpers.cpp
示例4: test_3
static duk_ret_t test_3(duk_context *ctx) {
prep(ctx);
duk_remove(ctx, 0); /* -> [ 234 345 ] (legal) */
printf("remove at 0 ok\n");
duk_remove(ctx, -2); /* -> [ 345 ] (legal) */
printf("remove at -2 ok\n");
duk_remove(ctx, -2); /* (illegal) */
printf("remove at -2 ok\n");
return 0;
}
开发者ID:iotcafe,项目名称:duktape,代码行数:10,代码来源:test-remove.c
示例5: test_2
static duk_ret_t test_2(duk_context *ctx) {
prep(ctx);
duk_remove(ctx, 2); /* -> [ 123 234 ] (legal) */
printf("remove at 2 ok\n");
duk_remove(ctx, -1); /* -> [ 123 ] (legal) */
printf("remove at -1 ok\n");
duk_remove(ctx, 1); /* (illegal) */
printf("remove at 1 ok\n");
return 0;
}
开发者ID:iotcafe,项目名称:duktape,代码行数:10,代码来源:test-remove.c
示例6: SetupProxy
void SetupProxy(duk_context* ctx, const duk_function_list_entry* funcs)
{
duk_push_global_object(ctx);
duk_get_prop_string(ctx, -1, "Proxy");
duk_dup(ctx, -3); // Duplicate target at stack top
duk_remove(ctx, -4); // Remove original target
duk_push_object(ctx); // Handler
duk_put_function_list(ctx, -1, funcs);
duk_new(ctx, 2); // Create proxy
duk_remove(ctx, -2); // Remove global object
}
开发者ID:realXtend,项目名称:tundra-urho3d,代码行数:11,代码来源:BindingsHelpers.cpp
示例7: duk__get_cached_module
static duk_bool_t duk__get_cached_module(duk_context *ctx, const char *id) {
duk_push_global_stash(ctx);
(void) duk_get_prop_string(ctx, -1, "\xff" "requireCache");
if (duk_get_prop_string(ctx, -1, id)) {
duk_remove(ctx, -2);
duk_remove(ctx, -2);
return 1;
} else {
duk_pop_3(ctx);
return 0;
}
}
开发者ID:davidluca3000,项目名称:vscp_software,代码行数:12,代码来源:duk_module_node.c
示例8: mn_push_ref
void
mn_push_ref(duk_context *ctx, int ref) {
if (!ref) {
duk_push_undefined(ctx);
return;
}
/* Get the "refs" array in the heap stash */
duk_push_heap_stash(ctx);
duk_get_prop_string(ctx, -1, "refs");
duk_remove(ctx, -2);
duk_get_prop_index(ctx, -1, ref);
duk_remove(ctx, -2);
}
开发者ID:hypoalex,项目名称:mininode,代码行数:15,代码来源:ref.c
示例9: duv_resolve
// Assumes nargs are the top of the stack. Rest comes from request
// Return value is not left on the stack.
void duv_resolve(uv_req_t* req, int nargs) {
duk_context *ctx = req->data;
duv_push_handle(ctx, req);
// stack: args... obj
duk_get_prop_string(ctx, -1, "\xff""uv-callback");
// stack: args... obj callback
duk_del_prop_string(ctx, -2, "\xff""uv-callback");
// stack: args... obj callback
if (!duk_is_function(ctx, -1)) {
// stack: args... obj callback
duk_pop_n(ctx, 2 + nargs);
return;
}
duk_remove(ctx, -2);
// stack: args... callback
duk_insert(ctx, -(nargs + 1));
// stack: callback args...
duk_call(ctx, nargs);
// stack: result
duk_pop(ctx);
// Remove the request from the GC roots
duv_remove_handle(ctx, req);
}
开发者ID:nucleus-js,项目名称:seaduk,代码行数:27,代码来源:utils.c
示例10: duv_setup_request
duk_ret_t duv_setup_request(duk_context *ctx, uv_req_t* req, int callback) {
// Create a new container object for the request with request methods
duk_push_object(ctx);
duk_push_heap_stash(ctx);
duk_get_prop_string(ctx, -1, "req-prototype");
duk_remove(ctx, -2);
duk_set_prototype(ctx, -2);
// Set buffer as uv-data internal property.
duk_insert(ctx, -2);
duk_put_prop_string(ctx, -2, "\xff""uv-data");
// Store the request type.
duk_push_int(ctx, req->type);
duk_put_prop_string(ctx, -2, "\xff""req-type");
// Store a reference to the lua callback
duk_dup(ctx, callback);
duk_put_prop_string(ctx, -2, "\xff""uv-callback");
// Store this object in the heap stack keyed by the request's pointer address.
// This will prevent it from being garbage collected and allow us to find
// it with nothing more than the request's address.
duv_store_handle(ctx, req);
// Store the context in the handle so it can use duktape APIs.
req->data = ctx;
// TODO: is this still on the stack?
return 1;
}
开发者ID:nucleus-js,项目名称:seaduk,代码行数:31,代码来源:utils.c
示例11: duk__push_this_number_plain
static duk_double_t duk__push_this_number_plain(duk_context *ctx) {
duk_hobject *h;
/* Number built-in accepts a plain number or a Number object (whose
* internal value is operated on). Other types cause TypeError.
*/
duk_push_this(ctx);
if (duk_is_number(ctx, -1)) {
DUK_DDD(DUK_DDDPRINT("plain number value: %!T", (duk_tval *) duk_get_tval(ctx, -1)));
goto done;
}
h = duk_get_hobject(ctx, -1);
if (!h ||
(DUK_HOBJECT_GET_CLASS_NUMBER(h) != DUK_HOBJECT_CLASS_NUMBER)) {
DUK_DDD(DUK_DDDPRINT("unacceptable this value: %!T", (duk_tval *) duk_get_tval(ctx, -1)));
DUK_ERROR((duk_hthread *) ctx, DUK_ERR_TYPE_ERROR, "expected a number");
}
duk_get_prop_stridx(ctx, -1, DUK_STRIDX_INT_VALUE);
DUK_ASSERT(duk_is_number(ctx, -1));
DUK_DDD(DUK_DDDPRINT("number object: %!T, internal value: %!T",
(duk_tval *) duk_get_tval(ctx, -2), (duk_tval *) duk_get_tval(ctx, -1)));
duk_remove(ctx, -2);
done:
return duk_get_number(ctx, -1);
}
开发者ID:cherry-wb,项目名称:duktape,代码行数:27,代码来源:duk_bi_number.c
示例12: LOGE
bool StyleContext::evalFunction(FunctionID id) {
// Get all functions (array) in context
if (!duk_get_global_string(m_ctx, FUNC_ID)) {
LOGE("EvalFilterFn - functions array not initialized");
duk_pop(m_ctx); // pop [undefined] sitting at stack top
return false;
}
// Get function at index `id` from functions array, put it at stack top
if (!duk_get_prop_index(m_ctx, -1, id)) {
LOGE("EvalFilterFn - function %d not set", id);
duk_pop(m_ctx); // pop "undefined" sitting at stack top
duk_pop(m_ctx); // pop functions (array) now sitting at stack top
return false;
}
// pop fns array
duk_remove(m_ctx, -2);
// call popped function (sitting at stack top), evaluated value is put on stack top
if (duk_pcall(m_ctx, 0) != 0) {
LOGE("EvalFilterFn: %s", duk_safe_to_string(m_ctx, -1));
duk_pop(m_ctx);
return false;
}
return true;
}
开发者ID:NabilNoaman,项目名称:tangram-es,代码行数:28,代码来源:styleContext.cpp
示例13: duk_dump_function
DUK_EXTERNAL void duk_dump_function(duk_context *ctx) {
duk_hthread *thr;
duk_hcompiledfunction *func;
duk_bufwriter_ctx bw_ctx_alloc;
duk_bufwriter_ctx *bw_ctx = &bw_ctx_alloc;
duk_uint8_t *p;
DUK_ASSERT(ctx != NULL);
thr = (duk_hthread *) ctx;
/* Bound functions don't have all properties so we'd either need to
* lookup the non-bound target function or reject bound functions.
* For now, bound functions are rejected.
*/
func = duk_require_hcompiledfunction(ctx, -1);
DUK_ASSERT(func != NULL);
DUK_ASSERT(!DUK_HOBJECT_HAS_BOUND(&func->obj));
/* Estimating the result size beforehand would be costly, so
* start with a reasonable size and extend as needed.
*/
DUK_BW_INIT_PUSHBUF(thr, bw_ctx, DUK__BYTECODE_INITIAL_ALLOC);
p = DUK_BW_GET_PTR(thr, bw_ctx);
*p++ = DUK__SER_MARKER;
*p++ = DUK__SER_VERSION;
p = duk__dump_func(ctx, func, bw_ctx, p);
DUK_BW_SET_PTR(thr, bw_ctx, p);
DUK_BW_COMPACT(thr, bw_ctx);
DUK_DD(DUK_DDPRINT("serialized result: %!T", duk_get_tval(ctx, -1)));
duk_remove(ctx, -2); /* [ ... func buf ] -> [ ... buf ] */
}
开发者ID:smalleric,项目名称:duktape,代码行数:33,代码来源:duk_api_bytecode.c
示例14: OnSignal
void OnSignal(Entity * param0, Entity * param1, const float3 & param2, const float3 & param3, float param4, float param5, bool param6)
{
duk_context* ctx = ctx_;
duk_push_global_object(ctx);
duk_get_prop_string(ctx, -1, "_OnSignal");
duk_remove(ctx, -2);
duk_push_number(ctx, (size_t)key_);
duk_push_array(ctx);
PushWeakObject(ctx, param0);
duk_put_prop_index(ctx, -2, 0);
PushWeakObject(ctx, param1);
duk_put_prop_index(ctx, -2, 1);
PushValueObjectCopy<float3>(ctx, param2, float3_ID, float3_Finalizer);
duk_put_prop_index(ctx, -2, 2);
PushValueObjectCopy<float3>(ctx, param3, float3_ID, float3_Finalizer);
duk_put_prop_index(ctx, -2, 3);
duk_push_number(ctx, param4);
duk_put_prop_index(ctx, -2, 4);
duk_push_number(ctx, param5);
duk_put_prop_index(ctx, -2, 5);
duk_push_boolean(ctx, param6);
duk_put_prop_index(ctx, -2, 6);
bool success = duk_pcall(ctx, 2) == 0;
if (!success) LogError("[JavaScript] OnSignal: " + GetErrorString(ctx));
duk_pop(ctx);
}
开发者ID:realXtend,项目名称:tundra-urho3d,代码行数:26,代码来源:PhysicsWorldBindings.cpp
示例15: MessageSetup
/*
* Called with a service object on the top of the stack. Returns with a message object on top of
* the stack replacing the service object.
*/
static void MessageSetup(duk_context* ctx, const char* iface, const char* member, const char* path, uint8_t msgType)
{
AJ_Status status;
AJ_MsgHeader hdr;
AJ_Message msg;
AJS_MsgInfo* msgInfo;
const char* dest;
uint8_t secure;
size_t dlen;
duk_idx_t objIdx = duk_push_object(ctx);
/*
* Get the destination from the service object
*/
duk_get_prop_string(ctx, -2, "dest");
dest = duk_get_lstring(ctx, -1, &dlen);
duk_pop(ctx);
/*
* If this is not a broadcast message make sure the destination peer is still connected
*/
if (dlen) {
CheckPeerIsAlive(ctx, dest);
}
/*
* Initialize a message struct so we can lookup the message id. We do this now because it is
* alot more efficient if the method object we are creating is used multiple times.
*/
memset(&msg, 0, sizeof(AJ_Message));
memset(&hdr, 0, sizeof(AJ_MsgHeader));
msg.hdr = &hdr;
msg.signature = "*";
msg.member = member;
msg.iface = iface;
msg.objPath = path ? path : AJS_GetStringProp(ctx, -2, "path");
/*
* This allows us to use one object table entry for all messages
*/
AJS_SetObjectPath(msg.objPath);
hdr.msgType = msgType;
status = AJ_LookupMessageId(&msg, &secure);
if (status != AJ_OK) {
duk_error(ctx, DUK_ERR_REFERENCE_ERROR, "Unknown %s %s", path ? "SIGNAL" : "METHOD", member);
}
/*
* Buffer to caching message information stored in the "info" property on the method object
*/
msgInfo = duk_push_fixed_buffer(ctx, sizeof(AJS_MsgInfo) + dlen + 1);
msgInfo->secure = secure;
msgInfo->session = AJS_GetIntProp(ctx, -2, "session");
msgInfo->msgId = msg.msgId;
memcpy(msgInfo->dest, dest, dlen);
msgInfo->dest[dlen] = 0;
duk_put_prop_string(ctx, objIdx, "info");
AJ_ASSERT(duk_get_top_index(ctx) == objIdx);
/*
* Remove sessions object and leave the message object on the top of the stack
*/
duk_remove(ctx, -2);
}
开发者ID:anthony-ngu,项目名称:core-alljoyn-js,代码行数:64,代码来源:ajs_sessions.c
示例16: duk_push_java_object
void duk_push_java_object(duk_context *ctx, JNIEnv *env, jobject object){
if(object == NULL){
duk_push_null(ctx);
return;
}
if((*env)->IsInstanceOf(env, object, js_ref_class)){
jint ref = (*env)->CallIntMethod(env, object, js_ref_get_ref_method);
duk_push_js_ref(ctx, ref);
return;
}
if((*env)->IsInstanceOf(env, object, java_number_class)){
jdouble num = (*env)->CallDoubleMethod(env, object, java_number_get_double_value_method);
duk_push_global_object(ctx);
duk_get_prop_string(ctx, -1, "Number");
duk_push_number(ctx, num);
duk_new(ctx, 1);
duk_mark_jsobject_to_java_object(ctx, -1, env, object);
duk_remove(ctx, -2);
return;
}
if((*env)->IsInstanceOf(env, object, java_boolean_class)){
jboolean value = (*env)->CallBooleanMethod(env, object, java_boolean_get_boolean_value_method);
if(value){
duk_push_true(ctx);
}else{
duk_push_false(ctx);
}
return;
}
duk_push_object(ctx); //empty target
duk_mark_jsobject_to_java_object(ctx, -1, env, object);
}
开发者ID:ewrfedf,项目名称:DuktapeJava,代码行数:32,代码来源:DuktapeEngine.c
示例17: test_4
static duk_ret_t test_4(duk_context *ctx, void *udata) {
(void) udata;
prep(ctx);
duk_remove(ctx, DUK_INVALID_INDEX); /* (illegal) */
printf("remove at DUK_INVALID_INDEX ok\n");
return 0;
}
开发者ID:GarethNelson,项目名称:duktape,代码行数:8,代码来源:test-remove.c
示例18: js_Font_get_colorMask
static duk_ret_t
js_Font_get_colorMask(duk_context* ctx)
{
duk_push_this(ctx);
duk_get_prop_string(ctx, -1, "\xFF" "color_mask");
duk_remove(ctx, -2);
return 1;
}
开发者ID:svaarala,项目名称:minisphere,代码行数:8,代码来源:font.c
示例19: duk__console_assert
static duk_ret_t duk__console_assert(duk_context *ctx) {
if (duk_to_boolean(ctx, 0)) {
return 0;
}
duk_remove(ctx, 0);
return duk__console_log_helper(ctx, "AssertionError");
}
开发者ID:svaarala,项目名称:duktape,代码行数:8,代码来源:duk_console.c
示例20: GetStackRaw
static int GetStackRaw(duk_context *ctx)
{
if (!duk_is_object(ctx, -1) || !duk_has_prop_string(ctx, -1, "stack") || !duk_is_error(ctx, -1))
return 1;
duk_get_prop_string(ctx, -1, "stack");
duk_remove(ctx, -2);
return 1;
}
开发者ID:realXtend,项目名称:tundra-urho3d,代码行数:9,代码来源:BindingsHelpers.cpp
注:本文中的duk_remove函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论