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


C++ duk_put_prop_string函数代码示例

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


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

示例1: SetValueObject

void SetValueObject(duk_context* ctx, duk_idx_t stackIndex, void* obj, const char* typeName)
{
    if (stackIndex < 0)
        --stackIndex;
    duk_push_pointer(ctx, obj);
    duk_put_prop_string(ctx, stackIndex, "\xff""obj");
    duk_push_pointer(ctx, (void*)typeName);
    duk_put_prop_string(ctx, stackIndex, "\xff""type");
}
开发者ID:realXtend,项目名称:tundra-urho3d,代码行数:9,代码来源:BindingsHelpers.cpp

示例2: dukopen_nsp_texture

duk_ret_t dukopen_nsp_texture(duk_context *ctx) {
    duk_idx_t idx = duk_push_object(ctx);
    duk_idx_t stats_constr = duk_push_c_function(ctx, nsp_texture_constructor, DUK_VARARGS);
    duk_idx_t stats_prot = duk_push_object(ctx);
    duk_put_function_list(ctx, stats_prot, nsp_texture_methods);
    duk_put_prop_string(ctx, stats_constr, "prototype");
    duk_put_prop_string(ctx, idx, "Texture");
    return 1;
}
开发者ID:fgalliat,项目名称:duktape-nspire,代码行数:9,代码来源:nsp_texture.c

示例3: switch

void StyleContext::parseSceneGlobals(const YAML::Node& node, const std::string& key, int seqIndex,
                                     duk_idx_t dukObject) {

    switch(node.Type()) {
        case YAML::NodeType::Scalar:
            if (key.size() == 0) {
                duk_push_string(m_ctx, node.Scalar().c_str());
                duk_put_prop_index(m_ctx, dukObject, seqIndex);
            } else {
                auto nodeValue = node.Scalar();
                if (nodeValue.compare(0, 8, "function") == 0) {
                    duk_push_string(m_ctx, key.c_str()); // push property key
                    duk_push_string(m_ctx, nodeValue.c_str()); // push function string
                    duk_push_string(m_ctx, "");
                    if (duk_pcompile(m_ctx, DUK_COMPILE_FUNCTION) == 0) { // compile function
                        duk_put_prop(m_ctx, -3); // put {key: function()}
                    } else {
                        LOGW("Compile failed in global function: %s\n%s\n---",
                             duk_safe_to_string(m_ctx, -1),
                             nodeValue.c_str());
                        duk_pop(m_ctx); //pop error
                        duk_pop(m_ctx); //pop key
                        // push property as a string
                        duk_push_string(m_ctx, nodeValue.c_str());
                        duk_put_prop_string(m_ctx, dukObject, key.c_str());
                    }
                } else {
                    duk_push_string(m_ctx, nodeValue.c_str());
                    duk_put_prop_string(m_ctx, dukObject, key.c_str());
                }
            }
            break;
        case YAML::NodeType::Sequence:
            {
                auto seqObj = duk_push_array(m_ctx);
                for (int i = 0; i < node.size(); i++) {
                    parseSceneGlobals(node[i], "", i, seqObj);
                }
                duk_put_prop_string(m_ctx, seqObj-1, key.c_str());
                break;
            }
        case YAML::NodeType::Map:
            {
                //duk_push_string(m_ctx, key.c_str());
                auto mapObj = duk_push_object(m_ctx);
                for (auto& mapNode : node) {
                    auto itemKey = mapNode.first.Scalar();
                    parseSceneGlobals(mapNode.second, itemKey, 0, mapObj);
                }
                duk_put_prop_string(m_ctx, mapObj-1, key.c_str());
            }
        default:
            break;
    }

    return;
}
开发者ID:NabilNoaman,项目名称:tangram-es,代码行数:57,代码来源:styleContext.cpp

示例4: NativeIoSpi

static int NativeIoSpi(duk_context* ctx)
{
    uint32_t mosi, miso, cs, clk, clock;
    uint8_t master;
    uint8_t cpol, cpha, data;
    void* spiCtx;
    AJ_Status status;
    int idx;

    mosi = GetPinId(ctx, 0, AJS_IO_FUNCTION_SPI_MOSI);
    miso = GetPinId(ctx, 1, AJS_IO_FUNCTION_SPI_MISO);
    cs = GetPinId(ctx, 2, AJS_IO_FUNCTION_SPI_SS);
    clk = GetPinId(ctx, 3, AJS_IO_FUNCTION_SPI_SCK);

    duk_get_prop_string(ctx, 4, "clock");
    clock = duk_require_int(ctx, -1);
    duk_get_prop_string(ctx, 4, "master");
    if (duk_get_boolean(ctx, -1)) {
        master = TRUE;
    } else {
        master = FALSE;
    }
    duk_get_prop_string(ctx, 4, "cpol");
    cpol = duk_require_int(ctx, -1);
    duk_get_prop_string(ctx, 4, "cpha");
    cpha = duk_require_int(ctx, -1);
    duk_get_prop_string(ctx, 4, "data");
    data = duk_require_int(ctx, -1);
    duk_pop(ctx);

    // Clock polarity must be high (1) or low (0)
    if (cpol != 0 && cpol != 1) {
        duk_error(ctx, DUK_ERR_INTERNAL_ERROR, "cpol must be 0 or 1; you gave %u", cpol);
    }
    // Clock edge phase must be one edge (0) or two edge (1)
    if (cpha != 0 && cpha != 1) {
        duk_error(ctx, DUK_ERR_INTERNAL_ERROR, "cpha must be 0 or 1; you gave %u", cpha);
    }
    // Data bits must be 8, 16, or 32
    if (data != 8 && data != 16 && data != 32) {
        duk_error(ctx, DUK_ERR_INTERNAL_ERROR, "data bits must be 8, 16 or 32; you gave %u", data);
    }

    status = AJS_TargetIO_SpiOpen(mosi, miso, cs, clk, clock, master, cpol, cpha, data, &spiCtx);
    if (status != AJ_OK) {
        duk_error(ctx, DUK_ERR_INTERNAL_ERROR, "Failed to open SPI device");
    }
    idx = NewIOObject(ctx, spiCtx, AJS_IO_FUNCTION_SPI, NativeSpiFinalizer);

    duk_push_c_lightfunc(ctx, NativeSpiRead, 1, 0, 0);
    duk_put_prop_string(ctx, idx, "read");

    duk_push_c_lightfunc(ctx, NativeSpiWrite, 1, 0, 0);
    duk_put_prop_string(ctx, idx, "write");

    return 1;
}
开发者ID:avernon,项目名称:asl_distribution,代码行数:57,代码来源:ajs_io.c

示例5: CHECK_STACK

void DuktapeContext::set(JNIEnv *env, jstring name, jobject object, jobjectArray methods) {
  CHECK_STACK(m_context);
  duk_push_global_object(m_context);
  const JString instanceName(env, name);
  if (duk_has_prop_string(m_context, -1, instanceName)) {
    duk_pop(m_context);
    queueIllegalArgumentException(env,
       "A global object called " + instanceName.str() + " already exists");
    return;
  }
  const duk_idx_t objIndex = duk_require_normalize_index(m_context, duk_push_object(m_context));

  // Hook up a finalizer to decrement the refcount and clean up our JavaMethods.
  duk_push_c_function(m_context, javaObjectFinalizer, 1);
  duk_set_finalizer(m_context, objIndex);

  const jsize numMethods = env->GetArrayLength(methods);
  for (jsize i = 0; i < numMethods; ++i) {
    jobject method = env->GetObjectArrayElement(methods, i);

    const jmethodID getName =
        env->GetMethodID(env->GetObjectClass(method), "getName", "()Ljava/lang/String;");
    const JString methodName(env, static_cast<jstring>(env->CallObjectMethod(method, getName)));

    std::unique_ptr<JavaMethod> javaMethod;
    try {
      javaMethod.reset(new JavaMethod(m_javaValues, env, method));
    } catch (const std::invalid_argument& e) {
      queueIllegalArgumentException(env, "In bound method \"" +
          instanceName.str() + "." + methodName.str() + "\": " + e.what());
      // Pop the object being bound and the duktape global object.
      duk_pop_2(m_context);
      return;
    }

    // Use VARARGS here to allow us to manually validate that the proper number of arguments are
    // given in the call.  If we specify the actual number of arguments needed, Duktape will try to
    // be helpful by discarding extra or providing missing arguments. That's not quite what we want.
    // See http://duktape.org/api.html#duk_push_c_function for details.
    const duk_idx_t func = duk_push_c_function(m_context, javaMethodHandler, DUK_VARARGS);
    duk_push_pointer(m_context, javaMethod.release());
    duk_put_prop_string(m_context, func, JAVA_METHOD_PROP_NAME);

    // Add this method to the bound object.
    duk_put_prop_string(m_context, objIndex, methodName);
  }

  // Keep a reference in JavaScript to the object being bound.
  duk_push_pointer(m_context, env->NewGlobalRef(object));
  duk_put_prop_string(m_context, objIndex, JAVA_THIS_PROP_NAME);

  // Make our bound Java object a property of the Duktape global object (so it's a JS global).
  duk_put_prop_string(m_context, -2, instanceName);
  // Pop the Duktape global object off the stack.
  duk_pop(m_context);
}
开发者ID:michaelmuenzer,项目名称:duktape-android,代码行数:56,代码来源:DuktapeContext.cpp

示例6: sys1_localtime

static int sys1_localtime(duk_context *ctx)
{
	struct tm tm, *tmp;
	time_t timep = duk_to_uint(ctx, 0);

	tmp = localtime_r(&timep, &tm);
	if(!tmp) {
		duk_push_undefined(ctx);
		return 1;
	}

	duk_push_object(ctx);
	duk_push_uint(ctx, tm.tm_sec);
	duk_put_prop_string(ctx, 1, "tm_sec");
	duk_push_uint(ctx, tm.tm_min);
	duk_put_prop_string(ctx, 1, "tm_min");
	duk_push_uint(ctx, tm.tm_hour);
	duk_put_prop_string(ctx, 1, "tm_hour");
	duk_push_uint(ctx, tm.tm_mday);
	duk_put_prop_string(ctx, 1, "tm_mday");
	duk_push_uint(ctx, tm.tm_mon);
	duk_put_prop_string(ctx, 1, "tm_mon");
	duk_push_uint(ctx, tm.tm_year);
	duk_put_prop_string(ctx, 1, "tm_year");
	duk_push_uint(ctx, tm.tm_wday);
	duk_put_prop_string(ctx, 1, "tm_wday");
	duk_push_uint(ctx, tm.tm_yday);
	duk_put_prop_string(ctx, 1, "tm_yday");
	duk_push_uint(ctx, tm.tm_isdst);
	duk_put_prop_string(ctx, 1, "tm_isdst");
	
	return 1;
}
开发者ID:jelaas,项目名称:sysjs,代码行数:33,代码来源:sys1.c

示例7: duk_mark_jsobject_to_java_object

void duk_mark_jsobject_to_java_object(duk_context *ctx, int index, JNIEnv *env, jobject object){
	jobject  ref = ((*env)->NewGlobalRef(env, object));
	duk_push_pointer(ctx, ref);
	DEBUG_LOG("ScriptEngine", "duk_push_pointer success %d", index);
    duk_put_prop_string(ctx, index - 1, JAVA_OBJECT_MARK);
	duk_push_c_function(ctx, java_object_to_string, 0);
	duk_put_prop_string(ctx, index - 1, "toString");
	duk_push_c_function(ctx, java_object_finalizer, 1);
	duk_set_finalizer(ctx, index - 1);
	DEBUG_LOG("ScriptEngine",  "new_java_object success");
}
开发者ID:ewrfedf,项目名称:DuktapeJava,代码行数:11,代码来源:DuktapeEngine.c

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

示例9: dukzip_unz_getfileinfo

static duk_ret_t dukzip_unz_getfileinfo(duk_context *ctx) {
	duk_idx_t info_obj;
	// unz_file_info fileInfo;
	unz_file_info64 fileInfo;
	unzFile archive = dukzip_unz_from_this(ctx);

	// unzGetCurrentFileInfo(archive, &fileInfo, NULL, 0, NULL, 0, NULL, 0);
	unzGetCurrentFileInfo64(archive, &fileInfo, NULL, 0, NULL, 0, NULL, 0);

#if defined(__GNUC__) && !defined(DUK_NO_VLA)
	char fileName[fileInfo.size_filename],
		extraField[fileInfo.size_file_extra],
		commentString[fileInfo.size_file_comment];
#else
	char *fileName = malloc(fileInfo.size_filename); 
	char *extraField = malloc(fileInfo.size_file_extra); 
	char *commentString = malloc(fileInfo.size_file_comment);
#endif

	// unzGetCurrentFileInfo(archive, &fileInfo, 
	// 	fileName, fileInfo.size_filename,
	// 	extraField, fileInfo.size_file_extra,
	// 	commentString, fileInfo.size_file_comment);
	unzGetCurrentFileInfo64(archive, &fileInfo, 
		fileName, fileInfo.size_filename,
		extraField, fileInfo.size_file_extra,
		commentString, fileInfo.size_file_comment);

	info_obj = duk_push_object(ctx);

	duk_push_int(ctx, fileInfo.compressed_size);
	duk_put_prop_string(ctx, info_obj, "compressed");

	duk_push_int(ctx, fileInfo.uncompressed_size);
	duk_put_prop_string(ctx, info_obj, "uncompressed");

	duk_push_lstring(ctx, fileName, fileInfo.size_filename);
	duk_put_prop_string(ctx, info_obj, "filename");

	duk_push_lstring(ctx, extraField, fileInfo.size_file_extra);
	duk_put_prop_string(ctx, info_obj, "extra");

	duk_push_lstring(ctx, commentString, fileInfo.size_file_comment);
	duk_put_prop_string(ctx, info_obj, "comment");

#if !defined(__GNUC__) || defined(DUK_NO_VLA)
	free(fileName);
	free(extraField);
	free(commentString);
#endif

	return 1;
}
开发者ID:armornick,项目名称:duktape-misc,代码行数:53,代码来源:zip.c

示例10: js_GetClippingRectangle

static duk_ret_t
js_GetClippingRectangle(duk_context* ctx)
{
	rect_t clip;

	clip = get_clip_rectangle();
	duk_push_object(ctx);
	duk_push_int(ctx, clip.x1); duk_put_prop_string(ctx, -2, "x");
	duk_push_int(ctx, clip.y1); duk_put_prop_string(ctx, -2, "y");
	duk_push_int(ctx, clip.x2 - clip.x1); duk_put_prop_string(ctx, -2, "width");
	duk_push_int(ctx, clip.y2 - clip.y1); duk_put_prop_string(ctx, -2, "height");
	return 1;
}
开发者ID:caivega,项目名称:minisphere,代码行数:13,代码来源:primitives.c

示例11: jsapi_init_atomic3d

void jsapi_init_atomic3d(JSVM* vm)
{
    duk_context* ctx = vm->GetJSContext();

    js_class_get_prototype(ctx, "Atomic", "StaticModel");
    duk_push_c_function(ctx, StaticModel_SetMaterialIndex, 2);
    duk_put_prop_string(ctx, -2, "setMaterialIndex");
    duk_pop(ctx); // pop AObject prototype

    js_class_get_prototype(ctx, "Atomic", "CustomGeometry");
    duk_push_c_function(ctx, CustomGeometry_SetMaterialIndex, 2);
    duk_put_prop_string(ctx, -2, "setMaterialIndex");
    duk_pop(ctx); // pop AObject prototype
}
开发者ID:galibert,项目名称:AtomicGameEngine,代码行数:14,代码来源:JSAtomic3D.cpp

示例12: dukzip_push_unzfile

static void dukzip_push_unzfile(duk_context *ctx, unzFile archive, const char *filename) {
	/* create object with readable Dukzip archive prototype */
	duk_push_object(ctx);
	duk_get_global_string(ctx, DUKZIP_UNZ_PROTOTYPE);
	duk_set_prototype(ctx, -2);

	/* set the archive pointer data */
	duk_push_pointer(ctx, archive);
	duk_put_prop_string(ctx, -2, ZIPHANDLE_PROP);

	/* set path property */
	duk_push_string(ctx, filename);
	duk_put_prop_string(ctx, -2, ZIPFILENAME_PROP);
}
开发者ID:armornick,项目名称:duktape-misc,代码行数:14,代码来源:zip.c

示例13: register_r2cmd_duktape

static void register_r2cmd_duktape (RLang *lang, duk_context *ctx) {
	Gcore = lang->user;
	duk_push_global_object (ctx);

	duk_push_c_function (ctx, r2cmd, DUK_VARARGS);
	duk_put_prop_string (ctx, -2 /*idx:global*/, "r2cmd");

	duk_push_c_function (ctx, r2plugin, DUK_VARARGS);
	duk_put_prop_string (ctx, -2 /*idx:global*/, "r2plugin");

	duk_pop (ctx);  /* pop global */
//	lang_duktape_file (lang, "/tmp/r2.js"); ///usr/share/radare2/0.9.8.git/www/t/r2.js");
	lang_duktape_file (lang, PREFIX"/share/radare2/last/www/t/r2.js");
}
开发者ID:pleonex,项目名称:radare2-bindings,代码行数:14,代码来源:duktape.c

示例14: duk__push_require_function

static void duk__push_require_function(duk_context *ctx, const char *id) {
	duk_push_c_function(ctx, duk__handle_require, 1);
	duk_push_string(ctx, "name");
	duk_push_string(ctx, "require");
	duk_def_prop(ctx, -3, DUK_DEFPROP_HAVE_VALUE);
	duk_push_string(ctx, id);
	duk_put_prop_string(ctx, -2, "\xff" "moduleId");

	/* require.cache */
	duk_push_global_stash(ctx);
	(void) duk_get_prop_string(ctx, -1, "\xff" "requireCache");
	duk_put_prop_string(ctx, -3, "cache");
	duk_pop(ctx);
}
开发者ID:eliteYang,项目名称:duktape-js-cpp,代码行数:14,代码来源:duk_module_node.c

示例15: ncurses_register

void ncurses_register(duk_context *ctx) {
	duk_push_global_object(ctx);
	duk_push_string(ctx, "Ncurses");
	duk_push_object(ctx);

	duk_push_c_function(ctx, ncurses_initscr, 0);
	duk_put_prop_string(ctx, -2, "initscr");

	duk_push_c_function(ctx, ncurses_endwin, 0);
	duk_put_prop_string(ctx, -2, "endwin");

	duk_push_c_function(ctx, ncurses_delscreen, 0);
	duk_put_prop_string(ctx, -2, "delscreen");

	duk_push_c_function(ctx, ncurses_getmaxyx, 0);
	duk_put_prop_string(ctx, -2, "getmaxyx");

	duk_push_c_function(ctx, ncurses_printw, 1);
	duk_put_prop_string(ctx, -2, "printw");

	duk_push_c_function(ctx, ncurses_mvprintw, 3);
	duk_put_prop_string(ctx, -2, "mvprintw");

	duk_push_c_function(ctx, ncurses_refresh, 0);
	duk_put_prop_string(ctx, -2, "refresh");

	duk_push_c_function(ctx, ncurses_getch, 0);
	duk_put_prop_string(ctx, -2, "getch");

	duk_put_prop(ctx, -3);
	duk_pop(ctx);
}
开发者ID:BpLife,项目名称:duktape,代码行数:32,代码来源:ncurses.c


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