• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ duk_push_boolean函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中duk_push_boolean函数的典型用法代码示例。如果您正苦于以下问题:C++ duk_push_boolean函数的具体用法?C++ duk_push_boolean怎么用?C++ duk_push_boolean使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: duk_btnp

static duk_ret_t duk_btnp(duk_context* duk)
{
	tic_machine* machine = getDukMachine(duk);
	tic_mem* memory = (tic_mem*)machine;

	if (duk_is_null_or_undefined(duk, 0))
	{
		duk_push_uint(duk, memory->api.btnp(memory, -1, -1, -1));
	}
	else if(duk_is_null_or_undefined(duk, 1) && duk_is_null_or_undefined(duk, 2))
	{
		s32 index = duk_to_int(duk, 0) & 0x1f;

		duk_push_boolean(duk, memory->api.btnp(memory, index, -1, -1));
	}
	else
	{
		s32 index = duk_to_int(duk, 0) & 0x1f;
		u32 hold = duk_to_int(duk, 1);
		u32 period = duk_to_int(duk, 2);

		duk_push_boolean(duk, memory->api.btnp(memory, index, hold, period));
	}

	return 1;
}
开发者ID:rdrpenguin04,项目名称:TIC-80,代码行数:26,代码来源:jsapi.c


示例2: duk_keyp

static s32 duk_keyp(duk_context* duk)
{
	tic_machine* machine = getDukMachine(duk);
	tic_mem* tic = &machine->memory;

	if (duk_is_null_or_undefined(duk, 0))
	{
		duk_push_boolean(duk, tic->api.keyp(tic, tic_key_unknown, -1, -1));
	}
	else
	{
		tic_key key = duk_to_int(duk, 0);

		if(key >= tic_key_escape)
		{
			return duk_error(duk, DUK_ERR_ERROR, "unknown keyboard code\n");
		}
		else
		{
			if(duk_is_null_or_undefined(duk, 1) && duk_is_null_or_undefined(duk, 2))
			{
				duk_push_boolean(duk, tic->api.keyp(tic, key, -1, -1));
			}
			else
			{
				u32 hold = duk_to_int(duk, 1);
				u32 period = duk_to_int(duk, 2);

				duk_push_boolean(duk, tic->api.keyp(tic, key, hold, period));
			}
		}
	}

	return 1;
}
开发者ID:rdrpenguin04,项目名称:TIC-80,代码行数:35,代码来源:jsapi.c


示例3: Serializer_Write

static int Serializer_Write(duk_context* ctx)
{
    duk_int_t magic = duk_get_current_magic(ctx);

    duk_push_this(ctx);

    // safe cast based on type check above
    Serializer* serial = CastToSerializer(ctx, duk_get_top_index(ctx));

    duk_pop(ctx);

    if (!serial)
    {
        duk_push_boolean(ctx, 0);
        return 1;
    }

    const char* str;
    size_t length;

    IO_MAGIC_TYPE v = (IO_MAGIC_TYPE) magic;

    bool success = false;

    switch(v)
    {
        case IO_MAGIC_INT:
            success = serial->WriteInt((int) duk_require_number(ctx, 0));
            break;
        case IO_MAGIC_STRING:
             str = duk_require_string(ctx, 0);
             length = strlen(str);
             success = serial->Write(str, length);
             /*
             if (length)
             {
                buffer.Resize(length);

                for (size_t i = 0; i < length; i++)
                    buffer[i] = str[i];

                serial->WriteBuffer(buffer);
             }
             */
            break;
        case IO_MAGIC_ZEROSTRING:
            success = serial->WriteString(duk_require_string(ctx, 0));
            break;
        default:
            break;
    }

    duk_push_boolean(ctx, success ? 1 : 0);

    return 1;

}
开发者ID:nonconforme,项目名称:AtomicGameEngine,代码行数:57,代码来源:JSIO.cpp


示例4: AJS_UnmarshalMessage

duk_idx_t AJS_UnmarshalMessage(duk_context* ctx, AJ_Message* msg, uint8_t accessor)
{
    duk_idx_t objIndex = duk_push_object(ctx);

    duk_push_string(ctx, msg->sender);
    duk_put_prop_string(ctx, objIndex, "sender");

    if ((msg->hdr->msgType == AJ_MSG_METHOD_CALL) || (msg->hdr->msgType == AJ_MSG_SIGNAL)) {
        duk_push_string(ctx, msg->member);
        duk_put_prop_string(ctx, objIndex, "member");
        duk_push_string(ctx, msg->iface);
        duk_put_prop_string(ctx, objIndex, "iface");
        duk_push_string(ctx, msg->objPath);
        duk_put_prop_string(ctx, objIndex, "path");
        /* If sender == unique name then true, otherwise false */
        duk_push_boolean(ctx, !abs(strcmp(msg->sender, AJS_GetBusAttachment()->uniqueName)));
        duk_put_prop_string(ctx, objIndex, "fromSelf");

        if (msg->hdr->msgType == AJ_MSG_METHOD_CALL) {
            AJS_ReplyInternal* msgReply;
            /*
             * Private read-only information needed for composing the reply
             */
            duk_push_string(ctx, AJS_HIDDEN_PROP("reply"));
            msgReply = duk_push_fixed_buffer(ctx, sizeof(AJS_ReplyInternal));
            msgReply->msgId = msg->msgId;
            msgReply->flags = msg->hdr->flags;
            msgReply->serialNum = msg->hdr->serialNum;
            msgReply->sessionId = msg->sessionId;
            msgReply->accessor = accessor;
            duk_def_prop(ctx, objIndex, DUK_DEFPROP_HAVE_VALUE | DUK_DEFPROP_HAVE_WRITABLE);
            /*
             * Register the reply functions
             */
            duk_push_c_lightfunc(ctx, AJS_MethodCallReply, DUK_VARARGS, 0, 0);
            duk_put_prop_string(ctx, objIndex, "reply");
            duk_push_c_lightfunc(ctx, AJS_MethodCallError, DUK_VARARGS, 0, 0);
            duk_put_prop_string(ctx, objIndex, "errorReply");
        }
    } else {
        int isError = (msg->hdr->msgType == AJ_MSG_ERROR);

        AJ_InfoPrintf(("Reply serial %d\n", msg->replySerial));
        duk_push_int(ctx, msg->replySerial);
        duk_put_prop_string(ctx, objIndex, "replySerial");
        if (isError) {
            duk_push_string(ctx, msg->error);
            duk_put_prop_string(ctx, objIndex, "error");
        }
        duk_push_boolean(ctx, isError);
        duk_put_prop_string(ctx, objIndex, "isErrorReply");
    }
    return objIndex;
}
开发者ID:avernon,项目名称:asl_distribution,代码行数:54,代码来源:ajs_unmarshal.c


示例5: test

void test(duk_context *ctx) {
	duk_idx_t i, n;

	duk_push_undefined(ctx);
	duk_push_null(ctx);
	duk_push_boolean(ctx, 0);
	duk_push_boolean(ctx, 123);
	duk_push_number(ctx, 234);
	duk_push_string(ctx, "foo");
	duk_push_object(ctx);
	duk_push_array(ctx);
	duk_push_c_function(ctx, my_c_func, DUK_VARARGS);
	duk_push_fixed_buffer(ctx, 1024);
	duk_push_dynamic_buffer(ctx, 1024);
	duk_push_pointer(ctx, (void *) 0xdeadbeefUL);

	n = duk_get_top(ctx);
	for (i = 0; i < n + 1; i++) {  /* end on invalid index on purpose */
		duk_int_t typeval, typemask;

		typeval = duk_get_type(ctx, i);
		typemask = duk_get_type_mask(ctx, i);

		printf("stack[%ld] --> type=%ld mask=0x%08lx ",
		       (long) i, (long) typeval, (long) typemask);

		switch(duk_get_type(ctx, i)) {
		case DUK_TYPE_NONE:       printf("none"); break;
		case DUK_TYPE_UNDEFINED:  printf("undefined"); break;
		case DUK_TYPE_NULL:       printf("null"); break;
		case DUK_TYPE_BOOLEAN:    printf("boolean"); break;
		case DUK_TYPE_NUMBER:     printf("number"); break;
		case DUK_TYPE_STRING:     printf("string"); break;
		case DUK_TYPE_OBJECT:     printf("object"); break;
		case DUK_TYPE_BUFFER:     printf("buffer"); break;
		case DUK_TYPE_POINTER:    printf("pointer"); break;
		default:                  printf("unknown(%d)", (int) duk_get_type(ctx, i)); break;
		}

		printf(" bool=%d num=%lf str=%s buf-is-null=%d ptr=%p",
		       (int) duk_get_boolean(ctx, i),
		       (double) duk_get_number(ctx, i),
		       duk_get_string(ctx, i),
		       (duk_get_buffer(ctx, i, NULL) == NULL ? 1 : 0),
		       duk_get_pointer(ctx, i));

		printf(" isobj=%d isarr=%d isfunc=%d",
		       (int) duk_is_object(ctx, i),
		       (int) duk_is_array(ctx, i),
		       (int) duk_is_function(ctx, i));

		printf("\n");
	}
}
开发者ID:fatcerberus,项目名称:duktape,代码行数:54,代码来源:test-types.c


示例6: duk_regexp_create_instance

DUK_INTERNAL void duk_regexp_create_instance(duk_hthread *thr) {
    duk_context *ctx = (duk_context *) thr;
    duk_hobject *h;
    duk_hstring *h_bc;
    duk_small_int_t re_flags;

    /* [ ... escape_source bytecode ] */

    h_bc = duk_get_hstring(ctx, -1);
    DUK_ASSERT(h_bc != NULL);
    DUK_ASSERT(DUK_HSTRING_GET_BYTELEN(h_bc) >= 1);          /* always at least the header */
    DUK_ASSERT(DUK_HSTRING_GET_CHARLEN(h_bc) >= 1);
    DUK_ASSERT((duk_small_int_t) DUK_HSTRING_GET_DATA(h_bc)[0] < 0x80);  /* flags always encodes to 1 byte */
    re_flags = (duk_small_int_t) DUK_HSTRING_GET_DATA(h_bc)[0];

    /* [ ... escaped_source bytecode ] */

    duk_push_object(ctx);
    h = duk_get_hobject(ctx, -1);
    DUK_ASSERT(h != NULL);
    duk_insert(ctx, -3);

    /* [ ... regexp_object escaped_source bytecode ] */

    DUK_HOBJECT_SET_CLASS_NUMBER(h, DUK_HOBJECT_CLASS_REGEXP);
    DUK_HOBJECT_SET_PROTOTYPE_UPDREF(thr, h, thr->builtins[DUK_BIDX_REGEXP_PROTOTYPE]);

    duk_xdef_prop_stridx(ctx, -3, DUK_STRIDX_INT_BYTECODE, DUK_PROPDESC_FLAGS_NONE);

    /* [ ... regexp_object escaped_source ] */

    duk_xdef_prop_stridx(ctx, -2, DUK_STRIDX_SOURCE, DUK_PROPDESC_FLAGS_NONE);

    /* [ ... regexp_object ] */

    duk_push_boolean(ctx, (re_flags & DUK_RE_FLAG_GLOBAL));
    duk_xdef_prop_stridx(ctx, -2, DUK_STRIDX_GLOBAL, DUK_PROPDESC_FLAGS_NONE);

    duk_push_boolean(ctx, (re_flags & DUK_RE_FLAG_IGNORE_CASE));
    duk_xdef_prop_stridx(ctx, -2, DUK_STRIDX_IGNORE_CASE, DUK_PROPDESC_FLAGS_NONE);

    duk_push_boolean(ctx, (re_flags & DUK_RE_FLAG_MULTILINE));
    duk_xdef_prop_stridx(ctx, -2, DUK_STRIDX_MULTILINE, DUK_PROPDESC_FLAGS_NONE);

    duk_push_int(ctx, 0);
    duk_xdef_prop_stridx(ctx, -2, DUK_STRIDX_LAST_INDEX, DUK_PROPDESC_FLAGS_W);

    /* [ ... regexp_object ] */
}
开发者ID:eliteYang,项目名称:duktape-js-cpp,代码行数:49,代码来源:duk_regexp_compiler.c


示例7: IAssetStorage_Trusted

static duk_ret_t IAssetStorage_Trusted(duk_context* ctx)
{
    IAssetStorage* thisObj = GetThisWeakObject<IAssetStorage>(ctx);
    bool ret = thisObj->Trusted();
    duk_push_boolean(ctx, ret);
    return 1;
}
开发者ID:realXtend,项目名称:tundra-urho3d,代码行数:7,代码来源:IAssetStorageBindings.cpp


示例8: duk__finalize_helper

DUK_LOCAL duk_ret_t duk__finalize_helper(duk_context *ctx, void *udata) {
	duk_hthread *thr;

	DUK_ASSERT(ctx != NULL);
	thr = (duk_hthread *) ctx;
	DUK_UNREF(udata);

	DUK_DDD(DUK_DDDPRINT("protected finalization helper running"));

	/* [... obj] */

	/* XXX: Finalizer lookup should traverse the prototype chain (to allow
	 * inherited finalizers) but should not invoke accessors or proxy object
	 * behavior.  At the moment this lookup will invoke proxy behavior, so
	 * caller must ensure that this function is not called if the target is
	 * a Proxy.
	 */

	duk_get_prop_stridx_short(ctx, -1, DUK_STRIDX_INT_FINALIZER);  /* -> [... obj finalizer] */
	if (!duk_is_callable(ctx, -1)) {
		DUK_DDD(DUK_DDDPRINT("-> no finalizer or finalizer not callable"));
		return 0;
	}
	duk_dup_m2(ctx);
	duk_push_boolean(ctx, DUK_HEAP_HAS_FINALIZER_NORESCUE(thr->heap));
	DUK_DDD(DUK_DDDPRINT("-> finalizer found, calling finalizer"));
	duk_call(ctx, 2);  /* [ ... obj finalizer obj heapDestruct ]  -> [ ... obj retval ] */
	DUK_DDD(DUK_DDDPRINT("finalizer finished successfully"));
	return 0;

	/* Note: we rely on duk_safe_call() to fix up the stack for the caller,
	 * so we don't need to pop stuff here.  There is no return value;
	 * caller determines rescued status based on object refcount.
	 */
}
开发者ID:harold-b,项目名称:duktape,代码行数:35,代码来源:duk_hobject_finalizer.c


示例9: js_myPlugin_ctor

// Constructor of the JS Object
duk_ret_t js_myPlugin_ctor(duk_context *ctx)
{
    slog(DEBUG,DEBUG, "Creating new object of "PLUGIN_SCOPE);

    myPluginStructure *mps = malloc(sizeof(myPluginStructure));
    mps->name = duk_require_string(ctx, 0);
    
    // Push special this binding to the function being constructed
    duk_push_this(ctx);

    // Store the underlying object
    duk_push_pointer(ctx, mps);
    duk_put_prop_string(ctx, -2, "\xff""\xff""data");

    // TODO : - if not existand create a hash_map
    //        - store structure to a hash_map('name');
    //          so that it can be reached from JS and C
    
    // Store a boolean flag to mark the object as deleted because the destructor may be called several times
    duk_push_boolean(ctx, false);
    duk_put_prop_string(ctx, -2, "\xff""\xff""deleted");

    // Store the function destructor
    duk_push_c_function(ctx, js_myPlugin_dtor, 1);
    duk_set_finalizer(ctx, -2);

    return 0;
}
开发者ID:FreshXOpenSource,项目名称:wallyd,代码行数:29,代码来源:myPlugin.c


示例10: Avatar_IsTemporary

static duk_ret_t Avatar_IsTemporary(duk_context* ctx)
{
    Avatar* thisObj = GetThisWeakObject<Avatar>(ctx);
    bool ret = thisObj->IsTemporary();
    duk_push_boolean(ctx, ret);
    return 1;
}
开发者ID:realXtend,项目名称:tundra-urho3d,代码行数:7,代码来源:AvatarBindings.cpp


示例11: duk_bi_array_constructor_is_array

DUK_INTERNAL duk_ret_t duk_bi_array_constructor_is_array(duk_context *ctx) {
	duk_hobject *h;

	h = duk_get_hobject_with_class(ctx, 0, DUK_HOBJECT_CLASS_ARRAY);
	duk_push_boolean(ctx, (h != NULL));
	return 1;
}
开发者ID:OakLabsInc,项目名称:duktape,代码行数:7,代码来源:duk_bi_array.c


示例12: Terrain_AllPatchesLoaded

static duk_ret_t Terrain_AllPatchesLoaded(duk_context* ctx)
{
    Terrain* thisObj = GetThisWeakObject<Terrain>(ctx);
    bool ret = thisObj->AllPatchesLoaded();
    duk_push_boolean(ctx, ret);
    return 1;
}
开发者ID:realXtend,项目名称:tundra-urho3d,代码行数:7,代码来源:TerrainBindings.cpp


示例13: IAssetStorage_HasLiveUpdate

static duk_ret_t IAssetStorage_HasLiveUpdate(duk_context* ctx)
{
    IAssetStorage* thisObj = GetThisWeakObject<IAssetStorage>(ctx);
    bool ret = thisObj->HasLiveUpdate();
    duk_push_boolean(ctx, ret);
    return 1;
}
开发者ID:realXtend,项目名称:tundra-urho3d,代码行数:7,代码来源:IAssetStorageBindings.cpp


示例14: dukky_html_table_cell_element_noWrap_getter

static duk_ret_t dukky_html_table_cell_element_noWrap_getter(duk_context *ctx)
{
	/* Get private data for method */
	html_table_cell_element_private_t *priv = NULL;
	duk_push_this(ctx);
	duk_get_prop_string(ctx, -1, dukky_magic_string_private);
	priv = duk_get_pointer(ctx, -1);
	duk_pop_2(ctx);
	if (priv == NULL) {
		return 0; /* can do? No can do. */
	}

#line 31 "HTMLTableCellElement.bnd"
	dom_exception exc;
	bool b;

	exc = dom_html_table_cell_element_get_no_wrap((struct dom_html_table_cell_element *)((node_private_t*)priv)->node, &b);
	if (exc != DOM_NO_ERR) {
		return 0;
	}

	duk_push_boolean(ctx, b);

	return 1;
}
开发者ID:EyMenZ,项目名称:NetSurf-OS3,代码行数:25,代码来源:html_table_cell_element.c


示例15: PhysicsWorld_IsDebugGeometryEnabled

static duk_ret_t PhysicsWorld_IsDebugGeometryEnabled(duk_context* ctx)
{
    PhysicsWorld* thisObj = GetThisWeakObject<PhysicsWorld>(ctx);
    bool ret = thisObj->IsDebugGeometryEnabled();
    duk_push_boolean(ctx, ret);
    return 1;
}
开发者ID:realXtend,项目名称:tundra-urho3d,代码行数:7,代码来源:PhysicsWorldBindings.cpp


示例16: IAssetTransfer_CachingAllowed

static duk_ret_t IAssetTransfer_CachingAllowed(duk_context* ctx)
{
    IAssetTransfer* thisObj = GetThisWeakObject<IAssetTransfer>(ctx);
    bool ret = thisObj->CachingAllowed();
    duk_push_boolean(ctx, ret);
    return 1;
}
开发者ID:realXtend,项目名称:tundra-urho3d,代码行数:7,代码来源:IAssetTransferBindings.cpp


示例17: IAssetTransfer_Abort

static duk_ret_t IAssetTransfer_Abort(duk_context* ctx)
{
    IAssetTransfer* thisObj = GetThisWeakObject<IAssetTransfer>(ctx);
    bool ret = thisObj->Abort();
    duk_push_boolean(ctx, ret);
    return 1;
}
开发者ID:realXtend,项目名称:tundra-urho3d,代码行数:7,代码来源:IAssetTransferBindings.cpp


示例18: Avatar_ViewEnabled

static duk_ret_t Avatar_ViewEnabled(duk_context* ctx)
{
    Avatar* thisObj = GetThisWeakObject<Avatar>(ctx);
    bool ret = thisObj->ViewEnabled();
    duk_push_boolean(ctx, ret);
    return 1;
}
开发者ID:realXtend,项目名称:tundra-urho3d,代码行数:7,代码来源:AvatarBindings.cpp


示例19: Line_IsFinite

static duk_ret_t Line_IsFinite(duk_context* ctx)
{
    Line* thisObj = GetThisValueObject<Line>(ctx, Line_ID);
    bool ret = thisObj->IsFinite();
    duk_push_boolean(ctx, ret);
    return 1;
}
开发者ID:realXtend,项目名称:tundra-urho3d,代码行数:7,代码来源:LineBindings.cpp


示例20: Terrain_IsTemporary

static duk_ret_t Terrain_IsTemporary(duk_context* ctx)
{
    Terrain* thisObj = GetThisWeakObject<Terrain>(ctx);
    bool ret = thisObj->IsTemporary();
    duk_push_boolean(ctx, ret);
    return 1;
}
开发者ID:realXtend,项目名称:tundra-urho3d,代码行数:7,代码来源:TerrainBindings.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ duk_push_c_function函数代码示例发布时间:2022-05-30
下一篇:
C++ duk_push_array函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap