void invokeDelegate(const char* fName, const char* name, int intVal, int argc) {
        if (!s_cx) {
            return;
        }

        //cocos2d::CCDirector::getInstance()->getScheduler()->performFunctionInCocosThread([=](){
        JSContext* cx = s_cx;
        const char* func_name = fName;

        JS::RootedObject obj(cx, mJsDelegate);
        JSAutoCompartment ac(cx, obj);

#if defined(MOZJS_MAJOR_VERSION)
#if MOZJS_MAJOR_VERSION >= 33
        bool hasAction;
        JS::RootedValue retval(cx);
        JS::RootedValue func_handle(cx);
#else
        bool hasAction;
        jsval retval;
        JS::RootedValue func_handle(cx);
#endif
#elif defined(JS_VERSION)
        JSBool hasAction;
        jsval retval;
        jsval func_handle;
#endif
        jsval dataVal[2];

        if (2 == argc) {
            dataVal[0] = c_string_to_jsval(cx, name);
            dataVal[1] = INT_TO_JSVAL(intVal);
        } else if (1 == argc) {
            dataVal[0] = c_string_to_jsval(cx, name);
        }

        if (JS_HasProperty(cx, obj, func_name, &hasAction) && hasAction) {
            if(!JS_GetProperty(cx, obj, func_name, &func_handle)) {
                return;
            }
            if(func_handle == JSVAL_VOID) {
                return;
            }

#if MOZJS_MAJOR_VERSION >= 31
            if (0 == argc) {
                JS_CallFunctionName(cx, obj, func_name, JS::HandleValueArray::empty(), &retval);
            } else {
                JS_CallFunctionName(cx, obj, func_name, JS::HandleValueArray::fromMarkedLocation(argc, dataVal), &retval);
            }
#else
            if (0 == argc) {
                JS_CallFunctionName(cx, obj, func_name, 0, nullptr, &retval);
            } else {
                JS_CallFunctionName(cx, obj, func_name, argc, dataVal, &retval);
            }
#endif
        }
        //});
    }
    void invokeJS(const char* func, IMCallbackJS* cb) {
        if (!s_cx) {
            return;
        }
        JSContext* cx = s_cx;
        const char* func_name = func;
        JS::RootedObject obj(cx, _JSDelegate);
        JSAutoCompartment ac(cx, obj);

#if defined(MOZJS_MAJOR_VERSION)
#if MOZJS_MAJOR_VERSION >= 33
        bool hasAction;
        JS::RootedValue retval(cx);
        JS::RootedValue func_handle(cx);
#else
        bool hasAction;
        jsval retval;
        JS::RootedValue func_handle(cx);
#endif
#elif defined(JS_VERSION)
        JSBool hasAction;
        jsval retval;
        jsval func_handle;
#endif
        int valueSize = 0;
        jsval* pVals = nullptr;
        valueSize = cb->transParams(&pVals);

        if (JS_HasProperty(cx, obj, func_name, &hasAction) && hasAction) {
            if(!JS_GetProperty(cx, obj, func_name, &func_handle)) {
                return;
            }
            if(func_handle == JSVAL_VOID) {
                return;
            }

#if MOZJS_MAJOR_VERSION >= 31
            if (0 == valueSize) {
                JS_CallFunctionName(cx, obj, func_name, JS::HandleValueArray::empty(), &retval);
            } else {
                JS_CallFunctionName(cx, obj, func_name, JS::HandleValueArray::fromMarkedLocation(valueSize, pVals), &retval);
            }
#else
            if (0 == valueSize) {
                JS_CallFunctionName(cx, obj, func_name, 0, nullptr, &retval);
            } else {
                JS_CallFunctionName(cx, obj, func_name, valueSize, pVals, &retval);
            }
#endif
        }
    }
static OMX_ERRORTYPE IMGDEC_GetImagePlugin (omx_jpegdec_component_PrivateType *p, const char* std)
{
    FuncPtr func_handle;
    char libname[12] = "id_";
    strcat(libname, std);
    strcat(libname, ".so");
    p->p_so_handle = dlopen(libname, RTLD_NOW);
    if (p->p_so_handle == NULL){
        return OMX_ErrorBadParameter;
    }
    func_handle = (FuncPtr)dlsym(p->p_so_handle , "get_plugin_info");
	if(func_handle == NULL) {
		return OMX_ErrorBadParameter;
	}
    p->p_imgPluginInfo = (void*)func_handle();
    if(p->p_imgPluginInfo == NULL) {
        dlclose(p->p_so_handle);
        p->p_so_handle = NULL;
        return OMX_ErrorBadParameter;
    }
    int rt = OMX_ActImageDecoder_Open(p);
    if(rt != 0) {
    	return OMX_ErrorBadParameter;
    }
    return OMX_ErrorNone;
}
Ejemplo n.º 4
0
 virtual bool handle( ::boost::shared_ptr< osiris::HttpSession > session, ::osiris::HttpPath const & path ){
     ::osiris::PythonState __pystate(getPythonThreadState());
     if( ::osiris::PythonOverride func_handle = this->get_override( "handle" ) )
         return func_handle( session, boost::ref(path) );
     else{
         __pystate.leave();
         return this->::osiris::HttpVirtualDirectory::handle( session, boost::ref(path) );
     }
 }
Ejemplo n.º 5
0
    void onFailure(const sdkbox::Product& info, const std::string& msg)
    {
        if (!s_cx)
        {
            return;
        }
        JSContext* cx = s_cx;
        const char* func_name = "onFailure";
        
        JS::RootedObject obj(cx, _JSDelegate);
        JSAutoCompartment ac(cx, obj);
        
#if MOZJS_MAJOR_VERSION >= 31
        bool hasAction;
        JS::RootedValue retval(cx);
        JS::RootedValue func_handle(cx);
#else
        JSBool hasAction;
        jsval retval;
        jsval func_handle;
#endif
        jsval dataVal[2];
        jsval value = OBJECT_TO_JSVAL(product_to_obj(s_cx, info));

        dataVal[0] = value;
        dataVal[1] = std_string_to_jsval(cx, msg);
        
        if (JS_HasProperty(cx, obj, func_name, &hasAction) && hasAction) {
            if(!JS_GetProperty(cx, obj, func_name, &func_handle)) {
                return;
            }
            if(func_handle == JSVAL_VOID) {
                return;
            }
            
#if MOZJS_MAJOR_VERSION >= 31
            JS_CallFunctionName(cx, obj, func_name, JS::HandleValueArray::fromMarkedLocation(sizeof(dataVal)/sizeof(*dataVal), dataVal), &retval);
#else
            JS_CallFunctionName(cx, obj, func_name, sizeof(dataVal)/sizeof(*dataVal), dataVal, &retval);
#endif
        }
    }
Ejemplo n.º 6
0
    void onProductRequestSuccess(const std::vector<sdkbox::Product>& products)
    {
        if (!s_cx)
        {
            return;
        }
        JSContext* cx = s_cx;
        const char* func_name = "onProductRequestSuccess";
        
        JS::RootedObject obj(cx, _JSDelegate);
        JSAutoCompartment ac(cx, obj);
        
#if MOZJS_MAJOR_VERSION >= 31
        bool hasAction;
        JS::RootedValue retval(cx);
        JS::RootedValue func_handle(cx);
#else
        JSBool hasAction;
        jsval retval;
        jsval func_handle;
#endif
        jsval dataVal[1];
        jsval value = std_vector_product_to_jsval(s_cx, products);

        dataVal[0] = value;
        
        if (JS_HasProperty(cx, obj, func_name, &hasAction) && hasAction) {
            if(!JS_GetProperty(cx, obj, func_name, &func_handle)) {
                return;
            }
            if(func_handle == JSVAL_VOID) {
                return;
            }
            
#if MOZJS_MAJOR_VERSION >= 31
            JS_CallFunctionName(cx, obj, func_name, JS::HandleValueArray::fromMarkedLocation(sizeof(dataVal)/sizeof(*dataVal), dataVal), &retval);
#else
            JS_CallFunctionName(cx, obj, func_name, sizeof(dataVal)/sizeof(*dataVal), dataVal, &retval);
#endif
        }
    }
Ejemplo n.º 7
0
int main()
{
    func_handle();
    Base X1;
    //Base X2{X1}; Default Copy & move constructor 
    //and assignment operator deleted
    func_template_delete(new shape);
    /* Local variable that cannot be destoryed...
    Not_on_stack no_stack;*/
    Not_on_stack *no_stack_p = new Not_on_stack;
    no_stack_p->fun_dest();    
    
    Not_on_free_store no_free_store;
    no_free_store.func_new();
    /* Cannot allocate object on free store when
     * class memory allocation operator is deleted
    Not_on_free_store *no_free_store_p = new Not_on_free_store;*/
    Enum_Test::X test_enum = Enum_Test::b;
    Enum_Test::Y second_enum = Enum_Test::Y::d;
    if( second_enum == Enum_Test::Y::d)
        std::cout<<test_enum<<std::endl;
    return 0;
}
Ejemplo n.º 8
0
 virtual bool handle( ::boost::shared_ptr< osiris::HttpSession > session, ::osiris::HttpPath const & path ){
     ::osiris::PythonState __pystate(getPythonThreadState());
     ::osiris::PythonOverride func_handle = this->get_override( "handle" );
     return func_handle( session, boost::ref(path) );
 }