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

C++ EJSVAL_TO_OBJECT函数代码示例

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

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



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

示例1: _ejs_function_specop_has_instance

// ECMA262: 15.3.5.3
static EJSBool
_ejs_function_specop_has_instance (ejsval F, ejsval V)
{
    /* 1. If V is not an object, return false. */
    if (!EJSVAL_IS_OBJECT(V))
        return EJS_FALSE;

    /* 2. Let O be the result of calling the [[Get]] internal method of F with property name "prototype". */
    ejsval O = OP(EJSVAL_TO_OBJECT(F),Get)(F, _ejs_atom_prototype, F);

    /* 3. If Type(O) is not Object, throw a TypeError exception. */
    if (!EJSVAL_IS_OBJECT(O)) {
        printf ("throw TypeError, O is not an object\n");
        EJS_NOT_IMPLEMENTED();
    }

    /* 4. Repeat */
    while (1) {
        /*    a. Let V be the value of the [[Prototype]] internal property of V. */
        V = EJSVAL_TO_OBJECT(V)->proto;
        /*    b. If V is null, return false. */
        if (EJSVAL_IS_NULL(V)) return EJS_FALSE;
        /*    c. If O and V refer to the same object, return true. */
        if (EJSVAL_EQ(O, V)) return EJS_TRUE;
    }
}
开发者ID:JulianoSousa,项目名称:echojs,代码行数:27,代码来源:ejs-function.c


示例2: _ejs_typedarray_new_from_array

ejsval
_ejs_typedarray_new_from_array (EJSTypedArrayType element_type, ejsval arrayObj)
{
    EJSObject *arr = EJSVAL_TO_OBJECT(arrayObj);
    int arrlen = EJSARRAY_LEN(arr);
    ejsval typedarr = _ejs_typedarray_new (element_type, arrlen);
    int i;

    void* data = _ejs_typedarray_get_data (EJSVAL_TO_OBJECT(typedarr));

    // this is woefully underoptimized...

    for (i = 0; i < arrlen; i ++) {
        ejsval item = _ejs_object_getprop (arrayObj, NUMBER_TO_EJSVAL(i));
        switch (element_type) {
        case EJS_TYPEDARRAY_INT8: ((int8_t*)data)[i] = (int8_t)EJSVAL_TO_NUMBER(item); break;
        case EJS_TYPEDARRAY_UINT8: ((uint8_t*)data)[i] = (uint8_t)EJSVAL_TO_NUMBER(item); break;
        case EJS_TYPEDARRAY_UINT8CLAMPED: EJS_NOT_IMPLEMENTED();
        case EJS_TYPEDARRAY_INT16: ((int16_t*)data)[i] = (int16_t)EJSVAL_TO_NUMBER(item); break;
        case EJS_TYPEDARRAY_UINT16: ((uint16_t*)data)[i] = (uint16_t)EJSVAL_TO_NUMBER(item); break;
        case EJS_TYPEDARRAY_INT32: ((int32_t*)data)[i] = (int32_t)EJSVAL_TO_NUMBER(item); break;
        case EJS_TYPEDARRAY_UINT32: ((uint32_t*)data)[i] = (uint32_t)EJSVAL_TO_NUMBER(item); break;
        case EJS_TYPEDARRAY_FLOAT32: ((float*)data)[i] = (float)EJSVAL_TO_NUMBER(item); break;
        case EJS_TYPEDARRAY_FLOAT64: ((double*)data)[i] = (double)EJSVAL_TO_NUMBER(item); break;
        default: EJS_NOT_REACHED();
        }
    }

    return typedarr;
}
开发者ID:gongfuPanada,项目名称:echo-js,代码行数:30,代码来源:ejs-typedarrays.c


示例3: _ejs_module_import_batch

void
_ejs_module_import_batch(ejsval fromImport, ejsval specifiers, ejsval toExport)
{
    EJSObject* fromObj = EJSVAL_TO_OBJECT(fromImport);
    EJSObject* toObj = EJSVAL_TO_OBJECT(toExport);
    EJSArray*  specArray = (EJSArray*)EJSVAL_TO_OBJECT(specifiers);

    ImportBatchData data;
    data.toObj = toObj;
    data.specifiers = EJSARRAY_LEN(specArray) == 0 ? NULL : specArray;

    _ejs_propertymap_foreach_property(&fromObj->map, import_batch_foreach, &data);
}
开发者ID:eddid,项目名称:jslang,代码行数:13,代码来源:ejs-require.c


示例4: DIBuilder_prototype_createFunction

    static ejsval
    DIBuilder_prototype_createFunction (ejsval env, ejsval _this, int argc, ejsval *args)
    {
        REQ_LLVM_DISCOPE_ARG(0, discope);
        REQ_UTF8_ARG(1, name);
        REQ_UTF8_ARG(2, linkageName);
        REQ_LLVM_DIFILE_ARG(3, file);
        REQ_INT_ARG(4, line_no);
        REQ_BOOL_ARG(5, isLocalToUnit);
        REQ_BOOL_ARG(6, isDefinition);
        REQ_INT_ARG(7, scopeLine);
        REQ_INT_ARG(8, flags);
        REQ_BOOL_ARG(9, isOptimized);
        REQ_LLVM_FUN_ARG(10, fn);

        DIBuilder* dib = ((DIBuilder*)EJSVAL_TO_OBJECT(_this));

        return DISubprogram_new(dib->llvm_dibuilder->createFunction (discope,
                                                                     name,
                                                                     linkageName,
                                                                     file,
                                                                     line_no,
                                                                     createDIFunctionType(dib->llvm_dibuilder, file, fn->getFunctionType()),
                                                                     isLocalToUnit,
                                                                     isDefinition,
                                                                     scopeLine,
                                                                     flags,
                                                                     isOptimized,
                                                                     fn));
    }
开发者ID:kangaroo,项目名称:echojs,代码行数:30,代码来源:dibuilder.cpp


示例5: ArrayType_new

 ejsval
 ArrayType_new(llvm::ArrayType* llvm_ty)
 {
     ejsval result = _ejs_object_new (_ejs_ArrayType_prototype, &_ejs_ArrayType_specops);
     ((ArrayType*)EJSVAL_TO_OBJECT(result))->type = llvm_ty;
     return result;
 }
开发者ID:kenny-y,项目名称:echojs,代码行数:7,代码来源:arraytype.cpp


示例6: Call_prototype_setDoesNotThrow

 ejsval
 Call_prototype_setDoesNotThrow(ejsval env, ejsval _this, int argc, ejsval *args)
 {
     Call* call = ((Call*)EJSVAL_TO_OBJECT(_this));
     call->llvm_call->setDoesNotThrow();
     return _ejs_undefined;
 }
开发者ID:JulianoSousa,项目名称:echojs,代码行数:7,代码来源:callinvoke.cpp


示例7: _ejs_Reflect_get

// ECMA262: 26.1.6 Reflect.get ( target, propertyKey [ , receiver ]) 
static ejsval
_ejs_Reflect_get (ejsval env, ejsval _this, uint32_t argc, ejsval *args)
{
    ejsval target = _ejs_undefined;
    ejsval propertyKey = _ejs_undefined;
    ejsval receiver = _ejs_undefined;

    if (argc > 0) target       = args[0];
    if (argc > 1) propertyKey  = args[1];
    if (argc > 2) receiver     = args[2];

    // 1. Let obj be ToObject(target). 
    // 2. ReturnIfAbrupt(obj). 
    ejsval obj = ToObject(target);

    // 3. Let key be ToPropertyKey(propertyKey). 
    // 4. ReturnIfAbrupt(key). 
    ejsval key = ToPropertyKey(propertyKey);

    // 5. If receiver is not present, then 
    //    a. Let receiver be target. 
    if (argc <= 2)
        receiver = target;

    // 6. Return the result of calling the [[Get]] internal method of obj with arguments key, and receiver
    return OP(EJSVAL_TO_OBJECT(obj),Get)(obj, key, receiver);
}
开发者ID:JulianoSousa,项目名称:echojs,代码行数:28,代码来源:ejs-reflect.c


示例8: Invoke_prototype_setOnlyReadsMemory

 ejsval
 Invoke_prototype_setOnlyReadsMemory(ejsval env, ejsval _this, int argc, ejsval *args)
 {
     Invoke* invoke = ((Invoke*)EJSVAL_TO_OBJECT(_this));
     invoke->llvm_invoke->setOnlyReadsMemory();
     return _ejs_undefined;
 }
开发者ID:JulianoSousa,项目名称:echojs,代码行数:7,代码来源:callinvoke.cpp


示例9: Call_new

 ejsval
 Call_new(llvm::CallInst* llvm_call)
 {
     ejsval result = _ejs_object_new (_ejs_Call_prototype, &_ejs_Call_specops);
     ((Call*)EJSVAL_TO_OBJECT(result))->llvm_call = llvm_call;
     return result;
 }
开发者ID:JulianoSousa,项目名称:echojs,代码行数:7,代码来源:callinvoke.cpp


示例10: Function_prototype_setOnlyReadsMemory

 ejsval
 Function_prototype_setOnlyReadsMemory(ejsval env, ejsval _this, int argc, ejsval *args)
 {
     Function* fun = ((Function*)EJSVAL_TO_OBJECT(_this));
     fun->llvm_fun->setOnlyReadsMemory();
     return _ejs_undefined;
 }
开发者ID:gongfuPanada,项目名称:echo-js,代码行数:7,代码来源:function.cpp


示例11: _ejs_dataview_specop_put

static void
_ejs_dataview_specop_put (ejsval obj, ejsval propertyName, ejsval val, ejsval receiver, EJSBool flag)
{
     EJSBool is_index = EJS_FALSE;
     ejsval idx_val = ToNumber(propertyName);
     int idx;
     if (EJSVAL_IS_NUMBER(idx_val)) {
         double n = EJSVAL_TO_NUMBER(idx_val);
         if (floor(n) == n) {
             idx = (int)n;
             is_index = EJS_TRUE;
         }
     }

     if (is_index) {
         if (idx < 0 || idx >= EJS_DATA_VIEW_BYTE_LEN(obj))
             return;

         void* data = _ejs_dataview_get_data (EJSVAL_TO_OBJECT(obj));
         ((unsigned char*)data)[idx] = (unsigned char)EJSVAL_TO_NUMBER(val);

         return;
     }

     _ejs_Object_specops.put (obj, propertyName, val, receiver, flag);
}
开发者ID:gongfuPanada,项目名称:echo-js,代码行数:26,代码来源:ejs-typedarrays.c


示例12: Function_prototype_get_name

 ejsval
 Function_prototype_get_name(ejsval env, ejsval _this, int argc, ejsval *args)
 {
     Function* fun = ((Function*)EJSVAL_TO_OBJECT(_this));
     std::string fun_name = fun->llvm_fun->getName();
     return _ejs_string_new_utf8(fun_name.c_str());
 }
开发者ID:gongfuPanada,项目名称:echo-js,代码行数:7,代码来源:function.cpp


示例13: Function_new

 ejsval
 Function_new(llvm::Function* llvm_fun)
 {
     ejsval result = _ejs_object_new (_ejs_Function_proto, &function_specops);
     ((Function*)EJSVAL_TO_OBJECT(result))->llvm_fun = llvm_fun;
     return result;
 }
开发者ID:gongfuPanada,项目名称:echo-js,代码行数:7,代码来源:function.cpp


示例14: Function_prototype_setInternalLinkage

 ejsval
 Function_prototype_setInternalLinkage(ejsval env, ejsval _this, int argc, ejsval *args)
 {
     Function* fun = ((Function*)EJSVAL_TO_OBJECT(_this));
     fun->llvm_fun->setLinkage (llvm::Function::InternalLinkage);
     return _ejs_undefined;
 }
开发者ID:gongfuPanada,项目名称:echo-js,代码行数:7,代码来源:function.cpp


示例15: _ejs_Promise_create

// ECMA262 25.4.4.6 Promise [ @@create ] ( )
static ejsval
_ejs_Promise_create (ejsval env, ejsval _this, uint32_t argc, ejsval *args)
{
    // 1. Let F be the this value
    ejsval F = _this;

    // 2. Return AllocatePromise(F). 
    //    1. Let obj be OrdinaryCreateFromConstructor(constructor, "%PromisePrototype%", ([[PromiseState]], [[PromiseConstructor]], [[PromiseResult]], [[PromiseFulfillReactions]], [[PromiseRejectReactions]]) ). 
    ejsval proto = _ejs_undefined;
    if (!EJSVAL_IS_UNDEFINED(F)) {
        if (!EJSVAL_IS_CONSTRUCTOR(F))
            _ejs_throw_nativeerror_utf8 (EJS_TYPE_ERROR, "'this' in Promise[Symbol.create] is not a constructor");

        EJSObject* F_ = EJSVAL_TO_OBJECT(F);

        proto = OP(F_,Get)(F, _ejs_atom_prototype, F);
    }
    if (EJSVAL_IS_UNDEFINED(proto))
        proto = _ejs_Promise_prototype;

    EJSObject* obj = (EJSObject*)_ejs_gc_new (EJSPromise);
    _ejs_init_object (obj, proto, &_ejs_Promise_specops);

    //    2. Set the value of obj’s [[PromiseConstructor]] internal slot to constructor. 
    ((EJSPromise*)obj)->constructor = F;

    //    3. Return obj. 
    return OBJECT_TO_EJSVAL(obj);
}
开发者ID:dilijev,项目名称:echo-js,代码行数:30,代码来源:ejs-promise.c


示例16: DIBuilder_prototype_finalize

 static ejsval
 DIBuilder_prototype_finalize (ejsval env, ejsval _this, int argc, ejsval *args)
 {
     DIBuilder* dib = ((DIBuilder*)EJSVAL_TO_OBJECT(_this));
     dib->llvm_dibuilder->finalize();
     return _ejs_undefined;
 }
开发者ID:kangaroo,项目名称:echojs,代码行数:7,代码来源:dibuilder.cpp


示例17: EJS_NATIVE_FUNC

    static EJS_NATIVE_FUNC(ArrayType_prototype_toString) {
        std::string str;
        llvm::raw_string_ostream str_ostream(str);
        ((ArrayType*)EJSVAL_TO_OBJECT(*_this))->type->print(str_ostream);

        return _ejs_string_new_utf8(trim(str_ostream.str()).c_str());
    }
开发者ID:kenny-y,项目名称:echojs,代码行数:7,代码来源:arraytype.cpp


示例18: Function_prototype_setDoesNotThrow

 ejsval
 Function_prototype_setDoesNotThrow(ejsval env, ejsval _this, int argc, ejsval *args)
 {
     Function* fun = ((Function*)EJSVAL_TO_OBJECT(_this));
     fun->llvm_fun->setDoesNotThrow();
     return _ejs_undefined;
 }
开发者ID:gongfuPanada,项目名称:echo-js,代码行数:7,代码来源:function.cpp


示例19: _ejs_invoke_closure

ejsval
_ejs_invoke_closure (ejsval closure, ejsval _this, uint32_t argc, ejsval* args)
{
    if (!EJSVAL_IS_FUNCTION(closure)) {
#if DEBUG_LAST_LOOKUP
        extern jschar* last_lookup;
        if (last_lookup) {
            char *last_utf8 = ucs2_to_utf8(last_lookup);
            _ejs_log ("last property lookup was for: %s\n", last_utf8);
            free (last_utf8);
        }
#endif
        
        _ejs_throw_nativeerror_utf8 (EJS_TYPE_ERROR, "object not a function");
    }

#if 0
    if (!EJSVAL_IS_NULL_OR_UNDEFINED(_this) && EJSVAL_IS_PRIMITIVE(_this)) {
        _this = ToObject(_this);
    }
#endif

    EJSFunction *fun = (EJSFunction*)EJSVAL_TO_OBJECT(closure);
    return fun->func (fun->env, _this, argc, args);
}
开发者ID:JulianoSousa,项目名称:echojs,代码行数:25,代码来源:ejs-function.c


示例20: LoadInst_new

 ejsval
 LoadInst_new(llvm::LoadInst* llvm_load)
 {
     ejsval result = _ejs_object_new (_ejs_LoadInst_prototype, &_ejs_LoadInst_specops);
     ((LoadInst*)EJSVAL_TO_OBJECT(result))->llvm_load = llvm_load;
     return result;
 }
开发者ID:JulianoSousa,项目名称:echojs,代码行数:7,代码来源:loadinst.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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