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

C++ duk_require_string函数代码示例

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

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



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

示例1: AssetDatabase_GetAssetsByImporterType

static int AssetDatabase_GetAssetsByImporterType(duk_context* ctx)
{
    JSVM* vm = JSVM::GetJSVM(ctx);
    ToolSystem* ts = vm->GetSubsystem<ToolSystem>();
    AssetDatabase* db = vm->GetSubsystem<AssetDatabase>();
    Project* project = ts->GetProject();

    StringHash type = duk_require_string(ctx, 0);
    String resourceType = duk_require_string(ctx, 1);

    duk_push_array(ctx);

    if (!project)
        return 1;

    PODVector<Asset*> assets;
    db->GetAssetsByImporterType(type, resourceType, assets);

    for(unsigned i = 0; i < assets.Size(); i++)
    {
        js_push_class_object_instance(ctx, assets[i], 0);
        duk_put_prop_index(ctx, -2, i);
    }

    return 1;
}
开发者ID:GREYFOXRGR,项目名称:AtomicGameEngine,代码行数:26,代码来源:ToolCoreJS.cpp


示例2: cb_load_module

static duk_ret_t cb_load_module(duk_context *ctx) {
	const char *filename;
	const char *module_id;

	module_id = duk_require_string(ctx, 0);
	duk_get_prop_string(ctx, 2, "filename");
	filename = duk_require_string(ctx, -1);

	printf("load_cb: id:'%s', filename:'%s'\n", module_id, filename);

	if (strcmp(module_id, "pig.js") == 0) {
		duk_push_sprintf(ctx, "module.exports = 'you\\'re about to get eaten by %s';",
			module_id);
	} else if (strcmp(module_id, "cow.js") == 0) {
		duk_push_string(ctx, "module.exports = require('pig');");
	} else if (strcmp(module_id, "ape.js") == 0) {
		duk_push_string(ctx, "module.exports = { module: module, __filename: __filename, wasLoaded: module.loaded };");
	} else if (strcmp(module_id, "badger.js") == 0) {
		duk_push_string(ctx, "exports.foo = 123; exports.bar = 234;");
	} else if (strcmp(module_id, "comment.js") == 0) {
		duk_push_string(ctx, "exports.foo = 123; exports.bar = 234; // comment");
	} else if (strcmp(module_id, "shebang.js") == 0) {
		duk_push_string(ctx, "#!ignored\nexports.foo = 123; exports.bar = 234;");
	} else {
		duk_error(ctx, DUK_ERR_TYPE_ERROR, "cannot find module: %s", module_id);
	}

	return 1;
}
开发者ID:zimbabao,项目名称:duktape,代码行数:29,代码来源:test.c


示例3: test_1

static duk_ret_t test_1(duk_context *ctx) {
	duk_set_top(ctx, 0);
	duk_push_string(ctx, "foo");
	duk_push_string(ctx, "");
	dump_string(duk_require_string(ctx, 0));
	dump_string(duk_require_string(ctx, 1));
	return 0;
}
开发者ID:OakLabsInc,项目名称:duktape,代码行数:8,代码来源:test-require-string.c


示例4: test_1

int test_1(duk_context *ctx) {
	duk_set_top(ctx, 0);
	duk_push_string(ctx, "foo");
	duk_push_string(ctx, "");
	printf("string: %s\n", duk_require_string(ctx, 0));
	printf("string: %s\n", duk_require_string(ctx, 1));
	return 0;
}
开发者ID:BpLife,项目名称:duktape,代码行数:8,代码来源:test-require-string.c


示例5: 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


示例6: SignalWrapper_Terrain_ComponentNameChanged_Emit

static duk_ret_t SignalWrapper_Terrain_ComponentNameChanged_Emit(duk_context* ctx)
{
    SignalWrapper_Terrain_ComponentNameChanged* wrapper = GetThisValueObject<SignalWrapper_Terrain_ComponentNameChanged>(ctx, SignalWrapper_Terrain_ComponentNameChanged_ID);
    if (!wrapper->owner_) return 0;
    String param0 = duk_require_string(ctx, 0);
    String param1 = duk_require_string(ctx, 1);
    wrapper->signal_->Emit(param0, param1);
    return 0;
}
开发者ID:realXtend,项目名称:tundra-urho3d,代码行数:9,代码来源:TerrainBindings.cpp


示例7: IAsset_SaveToFile_String_String

static duk_ret_t IAsset_SaveToFile_String_String(duk_context* ctx)
{
    int numArgs = duk_get_top(ctx);
    IAsset* thisObj = GetThisWeakObject<IAsset>(ctx);
    String filename = duk_require_string(ctx, 0);
    String serializationParameters = numArgs > 1 ? duk_require_string(ctx, 1) : "";
    bool ret = thisObj->SaveToFile(filename, serializationParameters);
    duk_push_boolean(ctx, ret);
    return 1;
}
开发者ID:realXtend,项目名称:tundra-urho3d,代码行数:10,代码来源:IAssetBindings.cpp


示例8: SignalWrapper_IAssetStorage_AssetChanged_Emit

static duk_ret_t SignalWrapper_IAssetStorage_AssetChanged_Emit(duk_context* ctx)
{
    SignalWrapper_IAssetStorage_AssetChanged* wrapper = GetThisValueObject<SignalWrapper_IAssetStorage_AssetChanged>(ctx, SignalWrapper_IAssetStorage_AssetChanged_ID);
    if (!wrapper->owner_) return 0;
    IAssetStorage* param0 = GetWeakObject<IAssetStorage>(ctx, 0);
    String param1 = duk_require_string(ctx, 1);
    String param2 = duk_require_string(ctx, 2);
    IAssetStorage::ChangeType param3 = (IAssetStorage::ChangeType)(int)duk_require_number(ctx, 3);
    wrapper->signal_->Emit(param0, param1, param2, param3);
    return 0;
}
开发者ID:realXtend,项目名称:tundra-urho3d,代码行数:11,代码来源:IAssetStorageBindings.cpp


示例9: FindInterfaceForMember

/*
 * Looks for an interface that defines a specific member.
 *
 * TODO - check for ambiguity - same member defined on multiple interfaces
 */
static const char* FindInterfaceForMember(duk_context* ctx, duk_idx_t mbrIdx, const char** member)
{
    const char* iface = NULL;
    uint8_t found = FALSE;
    size_t numInterfaces;
    duk_idx_t listIdx;

    duk_get_prop_string(ctx, -1, "interfaces");
    numInterfaces = duk_get_length(ctx, -1);
    listIdx = AJS_GetAllJoynProperty(ctx, "interfaceDefinition");

    if (duk_is_object(ctx, mbrIdx)) {
        /*
         * Expect an object of form { member:"org.foo.interface" }
         */
        duk_enum(ctx, mbrIdx, DUK_ENUM_OWN_PROPERTIES_ONLY);
        if (!duk_next(ctx, -1, 1)) {
            duk_error(ctx, DUK_ERR_TYPE_ERROR, "Require object of form { 'member-name':'interface-name' }");
        }
        iface = duk_require_string(ctx, -1);
        if (!AJ_StringFindFirstOf(iface, ".") == -1) {
            duk_error(ctx, DUK_ERR_TYPE_ERROR, "Interface name '%s' is not a dotted name", iface);
        }
        *member = duk_require_string(ctx, -2);
        duk_get_prop_string(ctx, listIdx, iface);
        if (duk_is_undefined(ctx, -1)) {
            duk_error(ctx, DUK_ERR_REFERENCE_ERROR, "Unknown interface: '%s'", iface);
        }
        found = duk_has_prop_string(ctx, -1, *member);
        duk_pop_n(ctx, 4);
    } else {
        size_t i;
        /*
         * Expect a string
         */
        *member = duk_require_string(ctx, mbrIdx);
        for (i = 0; !found && (i < numInterfaces); ++i) {
            duk_get_prop_index(ctx, -2, i);
            iface = duk_require_string(ctx, -1);
            duk_get_prop_string(ctx, listIdx, iface);
            /*
             * See if the requested member exists on this interface
             */
            found = duk_has_prop_string(ctx, -1, *member);
            duk_pop_2(ctx);
        }
    }
    duk_pop_2(ctx);
    if (!found) {
        duk_error(ctx, DUK_ERR_REFERENCE_ERROR, "Unknown member: '%s'", *member);
    }
    return iface;
}
开发者ID:anthony-ngu,项目名称:core-alljoyn-js,代码行数:58,代码来源:ajs_sessions.c


示例10: cb_resolve_module

static duk_ret_t cb_resolve_module(duk_context *ctx) {
	const char *module_id;
	const char *parent_id;

	module_id = duk_require_string(ctx, 0);
	parent_id = duk_require_string(ctx, 1);

	duk_push_sprintf(ctx, "%s.js", module_id);
	printf("resolve_cb: id:'%s', parent-id:'%s', resolve-to:'%s'\n",
		module_id, parent_id, duk_get_string(ctx, -1));

	return 1;
}
开发者ID:zimbabao,项目名称:duktape,代码行数:13,代码来源:test.c


示例11: dukzip_zip_newfile

static duk_ret_t dukzip_zip_newfile(duk_context *ctx) {
	zip_fileinfo zi = {0};
	int res = ZIP_OK;
	zipFile archive = dukzip_zip_from_this(ctx);
	
	const char *filename = "";
	duk_int_t level = Z_DEFAULT_COMPRESSION;
	duk_int_t method = Z_DEFLATED;
	const char *comment = "";


	if (duk_is_object(ctx, 0)) {
		dukzip_zip_checkoptions(ctx, 0, &filename, &level, &method, &comment);
	} else {
		filename = duk_require_string(ctx, 0);

		if (duk_is_number(ctx, 1)) {
			level = duk_get_int(ctx, 1);
		}
	}

	res = zipOpenNewFileInZip64(archive, filename, &zi, NULL, 0, NULL, 0, comment, method, level, 1);

	if (res == ZIP_OK) {
		duk_push_true(ctx);
	} else {
		duk_push_false(ctx);
	}
	return 1;
}
开发者ID:armornick,项目名称:duktape-misc,代码行数:30,代码来源:zip.c


示例12: _gum_duk_parse_protection

gboolean
_gum_duk_parse_protection (duk_context * ctx,
                           duk_idx_t index,
                           GumPageProtection * prot)
{
  const gchar * prot_str, * ch;

  if (!duk_is_string (ctx, index))
    return FALSE;

  prot_str = duk_require_string (ctx, index);

  *prot = GUM_PAGE_NO_ACCESS;
  for (ch = prot_str; *ch != '\0'; ch++)
  {
    switch (*ch)
    {
      case 'r':
        *prot |= GUM_PAGE_READ;
        break;
      case 'w':
        *prot |= GUM_PAGE_WRITE;
        break;
      case 'x':
        *prot |= GUM_PAGE_EXECUTE;
        break;
      case '-':
        break;
      default:
        return FALSE;
    }
  }

  return TRUE;
}
开发者ID:TechLord-Forever,项目名称:frida-gum,代码行数:35,代码来源:gumdukvalue.c


示例13: _gum_duk_parse_uint64

gboolean
_gum_duk_parse_uint64 (duk_context * ctx,
                       duk_idx_t index,
                       GumDukCore * core,
                       guint64 * u)
{
  if (duk_is_string (ctx, index))
  {
    const gchar * value_as_string, * end;
    gboolean valid;

    value_as_string = duk_require_string (ctx, index);

    if (g_str_has_prefix (value_as_string, "0x"))
    {
      *u = g_ascii_strtoull (value_as_string + 2, (gchar **) &end, 16);
      valid = end != value_as_string + 2;
    }
    else
    {
      *u = g_ascii_strtoull (value_as_string, (gchar **) &end, 10);
      valid = end != value_as_string;
    }

    return valid;
  }

  return _gum_duk_get_uint64 (ctx, index, core, u);
}
开发者ID:TechLord-Forever,项目名称:frida-gum,代码行数:29,代码来源:gumdukvalue.c


示例14: duv_loadfile

// Sync readfile using libuv APIs as an API function.
static duk_ret_t duv_loadfile(duk_context *ctx) {
  const char* path = duk_require_string(ctx, 0);
  uv_fs_t req;
  int fd = 0;
  uint64_t size;
  char* chunk;
  uv_buf_t buf;

  if (uv_fs_open(&loop, &req, path, O_RDONLY, 0644, NULL) < 0) goto fail;
  fd = req.result;
  if (uv_fs_fstat(&loop, &req, fd, NULL) < 0) goto fail;
  size = req.statbuf.st_size;
  chunk = duk_alloc(ctx, size);
  buf = uv_buf_init(chunk, size);
  if (uv_fs_read(&loop, &req, fd, &buf, 1, 0, NULL) < 0) goto fail;
  duk_push_lstring(ctx, chunk, size);
  duk_free(ctx, chunk);
  uv_fs_close(&loop, &req, fd, NULL);
  uv_fs_req_cleanup(&req);

  return 1;

  fail:
  if (fd) uv_fs_close(&loop, &req, fd, NULL);
  uv_fs_req_cleanup(&req);
  duk_error(ctx, DUK_ERR_ERROR, "%s: %s: %s", uv_err_name(req.result), uv_strerror(req.result), path);
}
开发者ID:RobertoMalatesta,项目名称:dukluv,代码行数:28,代码来源:main.c


示例15: Line_FromString_Static_string

static duk_ret_t Line_FromString_Static_string(duk_context* ctx)
{
    string str = duk_require_string(ctx, 0);
    Line ret = Line::FromString(str);
    PushValueObjectCopy<Line>(ctx, ret, Line_ID, Line_Finalizer);
    return 1;
}
开发者ID:realXtend,项目名称:tundra-urho3d,代码行数:7,代码来源:LineBindings.cpp


示例16: IAssetTransfer_EmitAssetFailed_String

static duk_ret_t IAssetTransfer_EmitAssetFailed_String(duk_context* ctx)
{
    IAssetTransfer* thisObj = GetThisWeakObject<IAssetTransfer>(ctx);
    String reason = duk_require_string(ctx, 0);
    thisObj->EmitAssetFailed(reason);
    return 0;
}
开发者ID:realXtend,项目名称:tundra-urho3d,代码行数:7,代码来源:IAssetTransferBindings.cpp


示例17: IAssetTransfer_Set_internalResourceName

static duk_ret_t IAssetTransfer_Set_internalResourceName(duk_context* ctx)
{
    IAssetTransfer* thisObj = GetThisWeakObject<IAssetTransfer>(ctx);
    String internalResourceName = duk_require_string(ctx, 0);
    thisObj->internalResourceName = internalResourceName;
    return 0;
}
开发者ID:realXtend,项目名称:tundra-urho3d,代码行数:7,代码来源:IAssetTransferBindings.cpp


示例18: Terrain_EnsureTypeNameWithoutPrefix_Static_String

static duk_ret_t Terrain_EnsureTypeNameWithoutPrefix_Static_String(duk_context* ctx)
{
    String tn = duk_require_string(ctx, 0);
    String ret = Terrain::EnsureTypeNameWithoutPrefix(tn);
    duk_push_string(ctx, ret.CString());
    return 1;
}
开发者ID:realXtend,项目名称:tundra-urho3d,代码行数:7,代码来源:TerrainBindings.cpp


示例19: EntityReference_Ctor_String

static duk_ret_t EntityReference_Ctor_String(duk_context* ctx)
{
    String entityName = duk_require_string(ctx, 0);
    EntityReference* newObj = new EntityReference(entityName);
    PushConstructorResult<EntityReference>(ctx, newObj, EntityReference_ID, EntityReference_Finalizer);
    return 0;
}
开发者ID:realXtend,项目名称:tundra-urho3d,代码行数:7,代码来源:EntityReferenceBindings.cpp


示例20: EntityReference_Set_ref

static duk_ret_t EntityReference_Set_ref(duk_context* ctx)
{
    EntityReference* thisObj = GetThisValueObject<EntityReference>(ctx, EntityReference_ID);
    String ref = duk_require_string(ctx, 0);
    thisObj->ref = ref;
    return 0;
}
开发者ID:realXtend,项目名称:tundra-urho3d,代码行数:7,代码来源:EntityReferenceBindings.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ duk_safe_call函数代码示例发布时间:2022-05-30
下一篇:
C++ duk_require_number函数代码示例发布时间: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