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


C++ duk_push_number函数代码示例

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


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

示例1: pushBuffer

static void pushBuffer(const ut8 *buf, int len) {
	int i;
	duk_push_fixed_buffer (ctx, len);
	for (i=0; i<len; i++) {
		duk_push_number (ctx, buf[i]);
		duk_put_prop_index (ctx, -2, i);
	}
	// buffer is in stack[-1]
}
开发者ID:pleonex,项目名称:radare2-bindings,代码行数:9,代码来源:duktape.c

示例2: Line_Distance_float3_float

static duk_ret_t Line_Distance_float3_float(duk_context* ctx)
{
    Line* thisObj = GetThisValueObject<Line>(ctx, Line_ID);
    float3& point = *GetCheckedValueObject<float3>(ctx, 0, float3_ID);
    float d = (float)duk_require_number(ctx, 1);
    float ret = thisObj->Distance(point, d);
    duk_push_number(ctx, ret);
    return 1;
}
开发者ID:realXtend,项目名称:tundra-urho3d,代码行数:9,代码来源:LineBindings.cpp

示例3: Push

    void Push( duk_context * ctx, const float value, const float * )
    {
        dukbind_assert(
            ( (float)(duk_double_t) value ) == value,
            "Value does not fit into a duk_double_t"
            );

         duk_push_number( ctx, (duk_double_t)value );
    }
开发者ID:crazyjul,项目名称:dukbind,代码行数:9,代码来源:dukbind.cpp

示例4: sys1_close

static int sys1_close(duk_context *ctx)
{
	int fd = duk_to_int(ctx, 0);
	
	int rc  = close(fd);
	
	duk_push_number(ctx, rc);
	return 1;
}
开发者ID:jelaas,项目名称:sysjs,代码行数:9,代码来源:sys1.c

示例5: Line_Distance_LineSegment_float

static duk_ret_t Line_Distance_LineSegment_float(duk_context* ctx)
{
    Line* thisObj = GetThisValueObject<Line>(ctx, Line_ID);
    LineSegment& other = *GetCheckedValueObject<LineSegment>(ctx, 0, LineSegment_ID);
    float d = (float)duk_require_number(ctx, 1);
    float ret = thisObj->Distance(other, d);
    duk_push_number(ctx, ret);
    return 1;
}
开发者ID:realXtend,项目名称:tundra-urho3d,代码行数:9,代码来源:LineBindings.cpp

示例6: Terrain_GetPoint_uint_uint

static duk_ret_t Terrain_GetPoint_uint_uint(duk_context* ctx)
{
    Terrain* thisObj = GetThisWeakObject<Terrain>(ctx);
    uint x = (uint)duk_require_number(ctx, 0);
    uint y = (uint)duk_require_number(ctx, 1);
    float ret = thisObj->GetPoint(x, y);
    duk_push_number(ctx, ret);
    return 1;
}
开发者ID:realXtend,项目名称:tundra-urho3d,代码行数:9,代码来源:TerrainBindings.cpp

示例7: push_htsmsg_field

static void
push_htsmsg_field(duk_context *ctx, const htsmsg_field_t *f)
{
  switch(f->hmf_type) {
  case HMF_STR:
    duk_push_string(ctx, f->hmf_str);
    break;
  case HMF_S64:
    duk_push_number(ctx, f->hmf_s64);
    break;
  case HMF_DBL:
    duk_push_number(ctx, f->hmf_dbl);
    break;
  default:
    duk_push_undefined(ctx);
    break;
  }
}
开发者ID:leonidborisenko,项目名称:showtime,代码行数:18,代码来源:es_htsmsg.c

示例8: Deserializer_Read

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

    duk_push_this(ctx);

    // safe cast based on type check above
    Deserializer* deserial = CastToDeserializer(ctx, duk_get_top_index(ctx));

    duk_pop(ctx);

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

    char* data;
    String str;
    size_t length;

    IO_MAGIC_TYPE v = (IO_MAGIC_TYPE) magic;

    bool success = false;

    switch(v)
    {
        case IO_MAGIC_INT:
            duk_push_number(ctx, (double) deserial->ReadInt());
            return 1;
        case IO_MAGIC_STRING:
            length = deserial->GetSize() - deserial->GetPosition();
            str.Resize(length + 1);
            deserial->Read(&str[0], length);
            str[length] = '\0';
            duk_push_string(ctx, str.CString());
            return 1;
        case IO_MAGIC_ZEROSTRING:
            success = duk_push_string(ctx, deserial->ReadString().CString());
            return 1;
        case IO_MAGIC_BINARY:
            length = deserial->GetSize() - deserial->GetPosition();
            duk_push_fixed_buffer(ctx, length);
            duk_push_buffer_object(ctx, -1, 0, length, DUK_BUFOBJ_UINT8ARRAY);
            duk_replace(ctx, -2);
            data = (char*) duk_require_buffer_data(ctx, 0, &length);
            success = deserial->Read(data, length);
            return 1;
        default:
            break;
    }

    duk_push_undefined(ctx);

    return 1;

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

示例9: duk_builtin_math_object_twoarg_shared

int duk_builtin_math_object_twoarg_shared(duk_context *ctx) {
	int fun_idx = duk_get_magic(ctx);
	two_arg_func fun;

	DUK_ASSERT(fun_idx >= 0 && fun_idx < sizeof(two_arg_funcs) / sizeof(two_arg_func));
	fun = two_arg_funcs[fun_idx];
	duk_push_number(ctx, fun(duk_to_number(ctx, 0), duk_to_number(ctx, 1)));
	return 1;
}
开发者ID:JoshEngebretson,项目名称:duktape,代码行数:9,代码来源:duk_builtin_math.c

示例10: es_sqlite_step

static int
es_sqlite_step(duk_context *ctx)
{
    es_sqlite_t *es = es_resource_get(ctx, 0, &es_resource_sqlite);

    if(es->es_stmt == NULL) {
        duk_push_null(ctx);
        return 1;
    }

    const int cols = sqlite3_data_count(es->es_stmt);

    duk_push_object(ctx);

    for(int i = 0; i < cols; i++) {

        int64_t i64;

        switch(sqlite3_column_type(es->es_stmt, i)) {

        case SQLITE_INTEGER:
            i64 = sqlite3_column_int64(es->es_stmt, i);
            if(i64 >= INT32_MIN && i64 <= INT32_MAX)
                duk_push_int(ctx, i64);
            else if(i64 >= 0 && i64 <= UINT32_MAX)
                duk_push_uint(ctx, i64);
            else
                duk_push_number(ctx, i64);
            break;
        case SQLITE_TEXT:
            duk_push_string(ctx, (const char *)sqlite3_column_text(es->es_stmt, i));
            break;
        case SQLITE_FLOAT:
            duk_push_number(ctx, sqlite3_column_double(es->es_stmt, i));
            break;
        default:
            continue;
        }
        duk_put_prop_string(ctx, -2, sqlite3_column_name(es->es_stmt, i));
    }
    es_sqlite_stmt_step(ctx, es);
    return 1;
}
开发者ID:bguerreiro,项目名称:movian,代码行数:43,代码来源:es_sqlite.c

示例11: Expose_IAsset

void Expose_IAsset(duk_context* ctx)
{
    duk_push_object(ctx);
    duk_push_number(ctx, 0);
    duk_put_prop_string(ctx, -2, "Original");
    duk_push_number(ctx, 1);
    duk_put_prop_string(ctx, -2, "Cached");
    duk_push_number(ctx, 2);
    duk_put_prop_string(ctx, -2, "Programmatic");
    duk_push_number(ctx, 3);
    duk_put_prop_string(ctx, -2, "Bundle");
    duk_push_object(ctx);
    duk_put_function_list(ctx, -1, IAsset_Functions);
    DefineProperty(ctx, "Unloaded", IAsset_Get_Unloaded, nullptr);
    DefineProperty(ctx, "Loaded", IAsset_Get_Loaded, nullptr);
    DefineProperty(ctx, "PropertyStatusChanged", IAsset_Get_PropertyStatusChanged, nullptr);
    duk_put_prop_string(ctx, -2, "prototype");
    duk_put_global_string(ctx, IAsset_ID);
}
开发者ID:realXtend,项目名称:tundra-urho3d,代码行数:19,代码来源:IAssetBindings.cpp

示例12: Line_Distance_Ray_float_float

static duk_ret_t Line_Distance_Ray_float_float(duk_context* ctx)
{
    Line* thisObj = GetThisValueObject<Line>(ctx, Line_ID);
    Ray& other = *GetCheckedValueObject<Ray>(ctx, 0, Ray_ID);
    float d = (float)duk_require_number(ctx, 1);
    float d2 = (float)duk_require_number(ctx, 2);
    float ret = thisObj->Distance(other, d, d2);
    duk_push_number(ctx, ret);
    return 1;
}
开发者ID:realXtend,项目名称:tundra-urho3d,代码行数:10,代码来源:LineBindings.cpp

示例13: duk_push_number

int SnssFileAPI::readInt64(duk_context* ctx)
{
    long long value = 0;
    m_SnssFile.read(reinterpret_cast<char*>(&value), 8);
    if( m_SnssFile.eof() )
        return 0;

    duk_push_number(ctx, (duk_double_t)value);
    return 1;
}
开发者ID:stoodx,项目名称:jspp,代码行数:10,代码来源:SnssFileAPI.cpp

示例14: duk_builtin_date_prototype_value_of

int duk_builtin_date_prototype_value_of(duk_context *ctx) {
	/* This native function is also used for Date.prototype.getTime()
	 * as their behavior is identical.
	 */

	double d = push_this_and_get_timeval(ctx, 0 /*flags*/);  /* -> [ this ] */
	DUK_ASSERT(DUK_ISFINITE(d) || DUK_ISNAN(d));
	duk_push_number(ctx, d);
	return 1;
}
开发者ID:JoshEngebretson,项目名称:duktape,代码行数:10,代码来源:duk_builtin_date.c

示例15: test_1

static duk_ret_t test_1(duk_context *ctx, void *udata) {
	duk_idx_t i, n;

	(void) udata;

	duk_set_top(ctx, 0);
	duk_push_undefined(ctx);
	duk_push_null(ctx);
	duk_push_true(ctx);
	duk_push_false(ctx);
	duk_push_int(ctx, 0);
	duk_push_int(ctx, 1);
	duk_push_nan(ctx);
	duk_push_number(ctx, INFINITY);
	duk_push_string(ctx, "");
	duk_push_string(ctx, "foo");
	duk_push_object(ctx);
	duk_push_number(ctx, 123.456);
	duk_to_object(ctx, -1);  /* Number(123.456) */
	duk_push_thread(ctx);
	duk_push_fixed_buffer(ctx, 0);
	duk_push_fixed_buffer(ctx, 1024);
	duk_push_dynamic_buffer(ctx, 0);
	duk_push_dynamic_buffer(ctx, 1024);
	duk_push_pointer(ctx, (void *) NULL);
	duk_push_pointer(ctx, (void *) 0xdeadbeef);

	n = duk_get_top(ctx);
	printf("top: %ld\n", (long) n);
	for (i = 0; i < n; i++) {
		duk_int_t t1, t2;

		t1 = duk_get_type(ctx, i);
		duk_to_primitive(ctx, i, DUK_HINT_NONE);
		t2 = duk_get_type(ctx, i);

		printf("index %ld, ToString(result): '%s', type: %ld -> %ld\n",
		       (long) i, duk_to_string(ctx, i), (long) t1, (long) t2);
	}

	return 0;
}
开发者ID:harold-b,项目名称:duktape,代码行数:42,代码来源:test-to-primitive.c


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