int setup_nss_functions(void *nss_handle, void *nspr_handle, void *plc_handle) { if (nss_handle == nullptr || nspr_handle == nullptr || plc_handle == nullptr) { LOG("Missing handle\n"); return FAILURE; } #define GETFUNC(name) f_ ## name = (name ## _t) (uintptr_t) __wrap_dlsym(nss_handle, #name); \ if (!f_ ##name) { __android_log_print(ANDROID_LOG_ERROR, "GeckoJNI", "missing %s", #name); return FAILURE; } GETFUNC(NSS_Initialize); GETFUNC(NSS_Shutdown); GETFUNC(PK11SDR_Encrypt); GETFUNC(PK11SDR_Decrypt); GETFUNC(PK11_GetInternalKeySlot); GETFUNC(PK11_NeedUserInit); GETFUNC(PK11_InitPin); GETFUNC(SECITEM_ZfreeItem); #undef GETFUNC #define NSPRFUNC(name) f_ ## name = (name ## _t) (uintptr_t) __wrap_dlsym(nspr_handle, #name); \ if (!f_ ##name) { __android_log_print(ANDROID_LOG_ERROR, "GeckoJNI", "missing %s", #name); return FAILURE; } NSPRFUNC(PR_ErrorToString); NSPRFUNC(PR_GetError); NSPRFUNC(PR_Free); #undef NSPRFUNC #define PLCFUNC(name) f_ ## name = (name ## _t) (uintptr_t) __wrap_dlsym(plc_handle, #name); \ if (!f_ ##name) { __android_log_print(ANDROID_LOG_ERROR, "GeckoJNI", "missing %s", #name); return FAILURE; } PLCFUNC(PL_Base64Encode); PLCFUNC(PL_Base64Decode); PLCFUNC(PL_strfree); #undef PLCFUNC return SUCCESS; }
void MarcPostDB::node(int index,PyNode *pNode) { GETFUNC(m_pFile,"node",Func_Node,"**ERROR** Function node() not found"); PyObject *pParam = Py_BuildValue("(i)",index); PyObject * ret = PyEval_CallObject((PyObject *)m_pFunc[Func_Node],pParam); CHECKERR(); PyObject *val = PyObject_GetAttrString(ret,"id"); pNode->id = PyInt_AsLong(val); Py_DECREF(val); val = PyObject_GetAttrString(ret,"x"); *(pNode->coord)= PyFloat_AsDouble(val); Py_DECREF(val); val = PyObject_GetAttrString(ret,"y"); *(pNode->coord+1)= PyFloat_AsDouble(val); Py_DECREF(val); val = PyObject_GetAttrString(ret,"z"); *(pNode->coord+2)= PyFloat_AsDouble(val); Py_DECREF(val); Py_DECREF(pParam); Py_DECREF(ret); }
void MarcPostDB::node_vector(int indexN,int indexV,PyVector *pVec) { GETFUNC(m_pFile,"node_vector",Func_NodeVector,"**ERROR** Function node_vector() not found"); PyObject *pParam = Py_BuildValue("(i,i)",indexN,indexV); PyObject * ret = PyEval_CallObject((PyObject *)m_pFunc[Func_NodeVector],pParam); CHECKERR(); PyObject *val = PyObject_GetAttrString(ret,"id"); pVec->id = PyInt_AsLong(val); Py_DECREF(val); val = PyObject_GetAttrString(ret,"x"); *(pVec->val)= PyFloat_AsDouble(val); Py_DECREF(val); val = PyObject_GetAttrString(ret,"y"); *(pVec->val+1)= PyFloat_AsDouble(val); Py_DECREF(val); val = PyObject_GetAttrString(ret,"z"); *(pVec->val+2)= PyFloat_AsDouble(val); Py_DECREF(val); Py_DECREF(ret); Py_DECREF(pParam); }
void MarcPostDB::extrapolation(char *method) { GETFUNC(m_pFile,"extrapolation",Func_Extrapolation,"**ERROR** Function extrapolation() not found"); PyObject *pParam = Py_BuildValue("(s)",method); PyEval_CallObject((PyObject *)m_pFunc[Func_Extrapolation],pParam); Py_DECREF(pParam); }
int MarcPostDB::element_scalar(int indexE,int indexS,PyScalar **ppScalar) { GETFUNC(m_pFile,"element_scalar",Func_ElementScalar,"**ERROR** Function element_scalar() not found"); PyObject *pParam = Py_BuildValue("(i,i)",indexE,indexS); PyObject * ret = PyEval_CallObject((PyObject *)m_pFunc[Func_ElementScalar],pParam); CHECKERR(); int len = 0; if (PyList_Check(ret)) { len = PyList_Size(ret); PyObject *item = 0; for (int i = 0; i < len; i++) { item = PyList_GetItem(ret,i); PyObject *val = PyObject_GetAttrString(item,"id"); m_oScalar[i].nId = PyInt_AsLong(val); Py_DECREF(val); val = PyObject_GetAttrString(item,"value"); m_oScalar[i].val = PyFloat_AsDouble(val); Py_DECREF(val); //Py_DECREF(item); } } Py_DECREF(ret); Py_DECREF(pParam); *ppScalar = m_oScalar; return len; }
void MarcPostDB::moveto(int i) { GETFUNC(m_pFile,"moveto",Func_MoveTo,"**ERROR** Function moveto() not found"); PyObject *pParam = Py_BuildValue("(i)",i); PyEval_CallObject((PyObject *)m_pFunc[Func_MoveTo],pParam); CHECKERR(); Py_DECREF(pParam); }
int MarcPostDB::increments() { GETFUNC(m_pFile,"increments",Func_Increments,"**ERROR** Function increments() not found"); PyObject * ret = PyEval_CallObject((PyObject *)m_pFunc[Func_Increments],NULL); CHECKERR(); int i = PyInt_AsLong(ret); Py_DECREF(ret); return i; }
int MarcPostDB::element_tensors() { GETFUNC(m_pFile,"element_tensors",Func_ElementTensors,"**ERROR** Function element_tensors() not found"); PyObject * ret = PyEval_CallObject((PyObject *)m_pFunc[Func_ElementTensors],NULL); CHECKERR(); int i = PyInt_AsLong(ret); Py_DECREF(ret); return i; }
char* MarcPostDB::version() { GETFUNC(m_pMod,"version",Func_Version,"**ERROR** Function version() not found"); PyObject * ret = PyEval_CallObject((PyObject *)m_pFunc[Func_Version],NULL); CHECKERR(); strcpy_s(m_cStr,128,PyString_AsString(ret)); Py_DECREF(ret); return m_cStr; }
char* MarcPostDB::title() { GETFUNC(m_pFile,"title",Func_Title,"**ERROR** Function title() not found"); PyObject * ret = PyEval_CallObject((PyObject *)m_pFunc[Func_Title],NULL); CHECKERR(); strcpy_s(m_cStr,128,PyString_AsString(ret)); Py_DECREF(ret); return m_cStr; }
int MarcPostDB::node_vectors() { GETFUNC(m_pFile,"node_vectors",Func_NodeVectors,"**ERROR** Function node_vectors() not found"); PyObject * ret = PyEval_CallObject((PyObject *)m_pFunc[Func_NodeVectors],NULL); CHECKERR(); int i = PyInt_AsLong(ret); Py_DECREF(ret); return i; }
char* MarcPostDB::element_tensor_label(int index) { GETFUNC(m_pFile,"element_tensor_label",Func_ElementTensorLabel,"**ERROR** Function element_tensor_label() not found"); PyObject *pParam = Py_BuildValue("(i)",index); PyObject * ret = PyEval_CallObject((PyObject *)m_pFunc[Func_ElementTensorLabel],pParam); CHECKERR(); strcpy_s(m_cStr,128,PyString_AsString(ret)); Py_DECREF(ret); Py_DECREF(pParam); return m_cStr; }
int MarcPostDB::element_id(int index) { GETFUNC(m_pFile,"element_id",Func_ElementId,"**ERROR** Function element_id() not found"); PyObject *pParam = Py_BuildValue("(i)",index); PyObject * ret = PyEval_CallObject((PyObject *)m_pFunc[Func_ElementId],pParam); CHECKERR(); int i = PyInt_AsLong(ret); Py_DECREF(ret); Py_DECREF(pParam); return i; }
double MarcPostDB::node_scalar(int indexN,int indexS) { GETFUNC(m_pFile,"node_scalar",Func_NodeScalar,"**ERROR** Function node_scalar() not found"); PyObject *pParam = Py_BuildValue("(i,i)",indexN,indexS); PyObject * ret = PyEval_CallObject((PyObject *)m_pFunc[Func_NodeScalar],pParam); CHECKERR(); double d = PyFloat_AsDouble(ret); Py_DECREF(ret); Py_DECREF(pParam); return d; }
bool MarcPostDB::open(char *fname) { GETFUNC(m_pMod,"post_open",Func_PostOpen,"**ERROR** Function post_open() not found"); PyObject *pParam = Py_BuildValue("(s)",fname); m_pFile = (void *)PyEval_CallObject((PyObject *)m_pFunc[Func_PostOpen],pParam); CHECKERR(); Py_DECREF(pParam); if (m_pFile == 0) { printf("%s\n","**ERROR** DB open failed"); return false; } return true; }
void MarcPostDB::close() { GETFUNC(m_pFile,"close",Func_Close,"**ERROR** Function close() not found"); PyEval_CallObject((PyObject *)m_pFunc[Func_Close],NULL); if (m_pFile != 0) { Py_DECREF(m_pFile); m_pFile = 0; } for (int i = 0; i < FuncCount; i++) { if (m_pFunc[i] != 0) { Py_DECREF(m_pFunc[i]); m_pFunc[i] = 0; } } }
int MarcPostDB::element_vector(int indexE,int indexV,PyVector **ppVector) { GETFUNC(m_pFile,"element_vector",Func_ElementVector,"**ERROR** Function element_vector() not found"); PyObject *pParam = Py_BuildValue("(i,i)",indexE,indexV); PyObject * ret = PyEval_CallObject((PyObject *)m_pFunc[Func_ElementVector],pParam); CHECKERR(); int len = 0; if (PyList_Check(ret)) { len = PyList_Size(ret); PyObject *item = 0; for (int i = 0; i < len; i++) { item = PyList_GetItem(ret,i); PyObject *val = PyObject_GetAttrString(item,"id"); m_oVector[i].id = PyInt_AsLong(val); Py_DECREF(val); val = PyObject_GetAttrString(item,"x"); m_oVector[i].val[0] = PyFloat_AsDouble(val); Py_DECREF(val); val = PyObject_GetAttrString(item,"y"); m_oVector[i].val[1] = PyFloat_AsDouble(val); Py_DECREF(val); val = PyObject_GetAttrString(item,"z"); m_oVector[i].val[2] = PyFloat_AsDouble(val); Py_DECREF(val); //Py_DECREF(item); } } Py_DECREF(ret); Py_DECREF(pParam); *ppVector = m_oVector; return len; }
/** \fn initGl */ bool vdpauVideoFilterDeint::initOnceGl(void) { ADM_info("Initializing VDPAU<->openGl\n"); if(vdpauGlInited) { ADM_info("Already done..\n"); return true; } GETFUNC(VDPAUInitNV); GETFUNC(VDPAURegisterOutputSurfaceNV); GETFUNC(VDPAURegisterVideoSurfaceNV); GETFUNC(VDPAUUnregisterSurfaceNV); GETFUNC(VDPAUMapSurfacesNV); GETFUNC(VDPAUUnmapSurfacesNV); GETFUNC(VDPAUSurfaceAccessNV); GETFUNC(VDPAUFiniNV); const void *device=admVdpau::getVdpDevice(); const void *proc=admVdpau::getProcAddress(); ADM_info("VDPAU InitNv with device=%lx, proc=%lx\n",(long int)device,(long int)proc); VDPAUInitNV(device,proc); if(false==processError("InitNv")) return false; vdpauGlInited=true; return true; }
void MarcPostDB::element(int index,PyElement *pElement) { GETFUNC(m_pFile,"element",Func_Element,"**ERROR** Function element() not found"); PyObject *pParam = Py_BuildValue("(i)",index); PyObject * ret = PyEval_CallObject((PyObject *)m_pFunc[Func_Element],pParam); CHECKERR(); PyObject *val = PyObject_GetAttrString(ret,"id"); pElement->id = PyInt_AsLong(val); Py_DECREF(val); CHECKERR(); val = PyObject_GetAttrString(ret,"type"); pElement->elemType = PyInt_AsLong(val); Py_DECREF(val); val = PyObject_GetAttrString(ret,"len"); pElement->nodeCnt = PyInt_AsLong(val); Py_DECREF(val); val = PyObject_GetAttrString(ret,"items"); if (PyList_Check(val)) { int len = PyList_Size(val); PyObject *item = 0; for (int i = 0; i < len; i++) { item = PyList_GetItem(val,i); pElement->nodeId[i] = PyInt_AsLong(item); //Py_DECREF(item); } } Py_DECREF(val); CHECKERR(); Py_DECREF(ret); Py_DECREF(pParam); }
int initGLExtensions(myGetProcAdress func) { if (_glUseProgram) return 0; int missing = 0; //!--getfunc-begin--! GETFUNC(_glShaderSource, def_glShaderSource, PFNGLSHADERSOURCEPROC, "glShaderSource"); GETFUNC(_glUseProgram, def_glUseProgram, PFNGLUSEPROGRAMPROC, "glUseProgram"); GETFUNC(_glVertexAttribPointer, def_glVertexAttribPointer, PFNGLVERTEXATTRIBPOINTERPROC, "glVertexAttribPointer"); GETFUNC(_glActiveTexture, def_glActiveTexture, PFNGLACTIVETEXTUREPROC, "glActiveTexture"); GETFUNC(_glEnableVertexAttribArray, def_glEnableVertexAttribArray, PFNGLENABLEVERTEXATTRIBARRAYPROC, "glEnableVertexAttribArray"); GETFUNC(_glDisableVertexAttribArray, def_glDisableVertexAttribArray, PFNGLDISABLEVERTEXATTRIBARRAYPROC, "glDisableVertexAttribArray"); GETFUNC(_glDeleteProgram, def_glDeleteProgram, PFNGLDELETEPROGRAMPROC, "glDeleteProgram"); GETFUNC(_glGetShaderiv, def_glGetShaderiv, PFNGLGETSHADERIVPROC, "glGetShaderiv"); GETFUNC(_glGetShaderInfoLog, def_glGetShaderInfoLog, PFNGLGETSHADERINFOLOGPROC, "glGetShaderInfoLog"); GETFUNC(_glCreateShader, def_glCreateShader, PFNGLCREATESHADERPROC, "glCreateShader"); GETFUNC(_glCreateProgram, def_glCreateProgram, PFNGLCREATEPROGRAMPROC, "glCreateProgram"); GETFUNC(_glAttachShader, def_glAttachShader, PFNGLATTACHSHADERPROC, "glAttachShader"); GETFUNC(_glCompileShader, def_glCompileShader, PFNGLCOMPILESHADERPROC, "glCompileShader"); GETFUNC(_glDetachShader, def_glDetachShader, PFNGLDETACHSHADERPROC, "glDetachShader"); GETFUNC(_glBindAttribLocation, def_glBindAttribLocation, PFNGLBINDATTRIBLOCATIONPROC, "glBindAttribLocation"); GETFUNC(_glLinkProgram, def_glLinkProgram, PFNGLLINKPROGRAMPROC, "glLinkProgram"); GETFUNC(_glUniform1i, def_glUniform1i, PFNGLUNIFORM1IPROC, "glUniform1i"); GETFUNC(_glUniform2f, def_glUniform2f, PFNGLUNIFORM2FPROC, "glUniform2f"); GETFUNC(_glUniform2fv, def_glUniform2fv, PFNGLUNIFORM2FVPROC, "glUniform2fv"); GETFUNC(_glUniform3fv, def_glUniform3fv, PFNGLUNIFORM3FVPROC, "glUniform3fv"); GETFUNC(_glUniform3f, def_glUniform3f, PFNGLUNIFORM3FPROC, "glUniform3f"); GETFUNC(_glUniform4fv, def_glUniform4fv, PFNGLUNIFORM4FVPROC, "glUniform4fv"); GETFUNC(_glUniform1f, def_glUniform1f, PFNGLUNIFORM1FPROC, "glUniform1f"); GETFUNC(_glUniformMatrix4fv, def_glUniformMatrix4fv, PFNGLUNIFORMMATRIX4FVPROC, "glUniformMatrix4fv"); GETFUNC(_glBindFramebuffer, def_glBindFramebuffer, PFNGLBINDFRAMEBUFFERPROC, "glBindFramebuffer"); GETFUNC(_glGenFramebuffers, def_glGenFramebuffers, PFNGLGENFRAMEBUFFERSPROC, "glGenFramebuffers"); GETFUNC(_glCheckFramebufferStatus, def_glCheckFramebufferStatus, PFNGLCHECKFRAMEBUFFERSTATUSPROC, "glCheckFramebufferStatus"); GETFUNC(_glDeleteFramebuffers, def_glDeleteFramebuffers, PFNGLDELETEFRAMEBUFFERSPROC, "glDeleteFramebuffers"); GETFUNC(_glGetUniformLocation, def_glGetUniformLocation, PFNGLGETUNIFORMLOCATIONPROC, "glGetUniformLocation"); GETFUNC(_glFramebufferTexture2D, def_glFramebufferTexture2D, PFNGLFRAMEBUFFERTEXTURE2DPROC, "glFramebufferTexture2D"); GETFUNC(_glCompressedTexImage2D, def_glCompressedTexImage2D, PFNGLCOMPRESSEDTEXIMAGE2DPROC, "glCompressedTexImage2D"); GETFUNC(_glBindBuffer, def_glBindBuffer, PFNGLBINDBUFFERPROC, "glBindBuffer"); GETFUNC(_glGenBuffers, def_glGenBuffers, PFNGLGENBUFFERSPROC, "glGenBuffers"); GETFUNC(_glBufferData, def_glBufferData, PFNGLBUFFERDATAPROC, "glBufferData"); GETFUNC(_glDrawBuffers, def_glDrawBuffers, PFNGLDRAWBUFFERSPROC, "glDrawBuffers"); GETFUNC(_glGetProgramiv, def_glGetProgramiv, PFNGLGETPROGRAMIVPROC, "glGetProgramiv"); GETFUNC(_glGenerateMipmap, def_glGenerateMipmap, PFNGLGENERATEMIPMAPPROC, "glGenerateMipmap"); GETFUNC(_glStencilOpSeparate, def_glStencilOpSeparate, PFNGLSTENCILOPSEPARATEPROC, "glStencilOpSeparate"); GETFUNC(_glGenRenderbuffers, def_glGenRenderbuffers, PFNGLGENRENDERBUFFERSPROC, "glGenRenderbuffers"); GETFUNC(_glBindRenderbuffer, def_glBindRenderbuffer, PFNGLBINDRENDERBUFFERPROC, "glBindRenderbuffer"); GETFUNC(_glRenderbufferStorage, def_glRenderbufferStorage, PFNGLRENDERBUFFERSTORAGEPROC, "glRenderbufferStorage"); GETFUNC(_glFramebufferRenderbuffer, def_glFramebufferRenderbuffer, PFNGLFRAMEBUFFERRENDERBUFFERPROC, "glFramebufferRenderbuffer"); GETFUNC(_glDeleteRenderbuffers, def_glDeleteRenderbuffers, PFNGLDELETERENDERBUFFERSPROC, "glDeleteRenderbuffers"); GETFUNC(_glDeleteShader, def_glDeleteShader, PFNGLDELETESHADERPROC, "glDeleteShader"); GETFUNC(_glDeleteBuffers, def_glDeleteBuffers, PFNGLDELETEBUFFERSPROC, "glDeleteBuffers"); GETFUNC(_glGetProgramInfoLog, def_glGetProgramInfoLog, PFNGLGETPROGRAMINFOLOGPROC, "glGetProgramInfoLog"); GETFUNC(_glBlendEquation, def_glBlendEquation, PFNGLBLENDEQUATIONPROC, "glBlendEquation"); GETFUNC(_glBlendFuncSeparate, def_glBlendFuncSeparate, PFNGLBLENDFUNCSEPARATEPROC, "glBlendFuncSeparate"); GETFUNC(_glBlendEquationSeparate, def_glBlendEquationSeparate, PFNGLBLENDEQUATIONSEPARATEPROC, "glBlendEquationSeparate"); GETFUNC(_glGetAttribLocation, def_glGetAttribLocation, PFNGLGETATTRIBLOCATIONPROC, "glGetAttribLocation"); //!--getfunc-end--! return missing; }
void setup_sqlite_functions(void *sqlite_handle) { #define GETFUNC(name) f_ ## name = (name ## _t) (uintptr_t) __wrap_dlsym(sqlite_handle, #name) GETFUNC(sqlite3_open); GETFUNC(sqlite3_errmsg); GETFUNC(sqlite3_prepare_v2); GETFUNC(sqlite3_bind_parameter_count); GETFUNC(sqlite3_bind_text); GETFUNC(sqlite3_step); GETFUNC(sqlite3_column_count); GETFUNC(sqlite3_finalize); GETFUNC(sqlite3_close); GETFUNC(sqlite3_column_name); GETFUNC(sqlite3_column_type); GETFUNC(sqlite3_column_blob); GETFUNC(sqlite3_column_bytes); GETFUNC(sqlite3_column_text); GETFUNC(sqlite3_changes); GETFUNC(sqlite3_last_insert_rowid); #undef GETFUNC }
void *hwSym(const char *funcName,void *handle) { void *funcPointer = NULL; #ifdef HWRENDER if (0 == strcmp("SetPalette", funcName)) funcPointer = &OglSdlSetPalette; GETFUNC(Init); GETFUNC(Draw2DLine); GETFUNC(DrawPolygon); GETFUNC(SetBlend); GETFUNC(ClearBuffer); GETFUNC(SetTexture); GETFUNC(ReadRect); GETFUNC(GClipRect); GETFUNC(ClearMipMapCache); GETFUNC(SetSpecialState); GETFUNC(GetTextureUsed); GETFUNC(DrawMD2); GETFUNC(DrawMD2i); GETFUNC(SetTransform); GETFUNC(GetRenderVersion); #ifdef SHUFFLE GETFUNC(PostImgRedraw); #endif //SHUFFLE GETFUNC(StartScreenWipe); GETFUNC(EndScreenWipe); GETFUNC(DoScreenWipe); GETFUNC(DrawIntermissionBG); GETFUNC(MakeScreenTexture); GETFUNC(MakeScreenFinalTexture); GETFUNC(DrawScreenFinalTexture); #else //HWRENDER if (0 == strcmp("FinishUpdate", funcName)) return funcPointer; //&FinishUpdate; #endif //!HWRENDER #ifdef STATIC3DS GETFUNC(Startup); GETFUNC(AddSfx); GETFUNC(AddSource); GETFUNC(StartSource); GETFUNC(StopSource); GETFUNC(GetHW3DSVersion); GETFUNC(BeginFrameUpdate); GETFUNC(EndFrameUpdate); GETFUNC(IsPlaying); GETFUNC(UpdateListener); GETFUNC(UpdateSourceParms); GETFUNC(SetGlobalSfxVolume); GETFUNC(SetCone); GETFUNC(Update3DSource); GETFUNC(ReloadSource); GETFUNC(KillSource); GETFUNC(Shutdown); GETFUNC(GetHW3DSTitle); #endif #ifdef NOLOADSO else
int MarcPostDB::element_tensor(int indexE,int indexT,PyTensor **ppTensor) { GETFUNC(m_pFile,"element_tensor",Func_ElementTensor,"**ERROR** Function element_tensor() not found"); PyObject *pParam = Py_BuildValue("(i,i)",indexE,indexT); PyObject * ret = PyEval_CallObject((PyObject *)m_pFunc[Func_ElementTensor],pParam); CHECKERR(); int len = 0; if (PyList_Check(ret)) { len = PyList_Size(ret); PyObject *item = 0; for (int i = 0; i < len; i++) { item = PyList_GetItem(ret,i); PyObject *val = PyObject_GetAttrString(item,"id"); m_oTensor[i].nodeId = PyInt_AsLong(val); Py_DECREF(val); val = PyObject_GetAttrString(item,"intensity"); m_oTensor[i].intensity = PyFloat_AsDouble(val); Py_DECREF(val); val = PyObject_GetAttrString(item,"t11"); m_oTensor[i].val[0] = PyFloat_AsDouble(val); Py_DECREF(val); val = PyObject_GetAttrString(item,"t12"); m_oTensor[i].val[1] = PyFloat_AsDouble(val); Py_DECREF(val); val = PyObject_GetAttrString(item,"t13"); m_oTensor[i].val[2] = PyFloat_AsDouble(val); Py_DECREF(val); val = PyObject_GetAttrString(item,"t22"); m_oTensor[i].val[3] = PyFloat_AsDouble(val); Py_DECREF(val); val = PyObject_GetAttrString(item,"t23"); m_oTensor[i].val[4] = PyFloat_AsDouble(val); Py_DECREF(val); val = PyObject_GetAttrString(item,"t33"); m_oTensor[i].val[5] = PyFloat_AsDouble(val); Py_DECREF(val); //Py_DECREF(item); } } Py_DECREF(ret); Py_DECREF(pParam); *ppTensor = m_oTensor; return len; //printf("%s\n",PyString_AsString(PyObject_Str(ret))); //if (PyTuple_Check(ret)) //{ // printf("%s\n","Type of tuple"); //} //else if (PyList_Check(ret)) //{ // printf("%s\n","Type of list"); //} //else if (PyDict_Check(ret)) //{ // printf("%s\n","Type of dict"); //} //else if (PyString_Check(ret)) //{ // printf("%s\n","Type of string"); //} //else if (PySet_Check(ret)) //{ // printf("%s\n","Type of set"); //} //else if (PySequence_Check(ret)) //{ // printf("%s\n","Type of sequence"); //} //else if (PyMapping_Check(ret)) //{ // printf("%s\n","Type of map"); //} }
static void loadLibs(const char *apkName) { chdir(getenv("GRE_HOME")); simple_linker_init(); struct stat status; if (!stat(apkName, &status)) apk_mtime = status.st_mtime; struct timeval t0, t1; gettimeofday(&t0, 0); struct rusage usage1; getrusage(RUSAGE_SELF, &usage1); void *zip = map_file(apkName); struct cdir_end *dirend = (struct cdir_end *)((char *)zip + zip_size - sizeof(*dirend)); while ((void *)dirend > zip && letoh32(dirend->signature) != CDIR_END_SIG) dirend = (struct cdir_end *)((char *)dirend - 1); if (letoh32(dirend->signature) != CDIR_END_SIG) { __android_log_print(ANDROID_LOG_ERROR, "GeckoLibLoad", "Couldn't find end of central directory record"); return; } uint32_t cdir_offset = letoh32(dirend->cdir_offset); uint16_t cdir_entries = letoh16(dirend->cdir_entries); struct cdir_entry *cdir_start = (struct cdir_entry *)((char *)zip + cdir_offset); lib_mapping = (struct mapping_info *)calloc(MAX_MAPPING_INFO, sizeof(*lib_mapping)); #ifdef MOZ_CRASHREPORTER file_ids = (char *)extractBuf("lib.id", zip, cdir_start, cdir_entries); #endif #define MOZLOAD(name) mozload("lib" name ".so", zip, cdir_start, cdir_entries) MOZLOAD("mozalloc"); MOZLOAD("nspr4"); MOZLOAD("plc4"); MOZLOAD("plds4"); MOZLOAD("mozsqlite3"); MOZLOAD("nssutil3"); MOZLOAD("nss3"); MOZLOAD("ssl3"); MOZLOAD("smime3"); xul_handle = MOZLOAD("xul"); MOZLOAD("xpcom"); MOZLOAD("nssckbi"); MOZLOAD("freebl3"); MOZLOAD("softokn3"); #undef MOZLOAD close(zip_fd); #ifdef MOZ_CRASHREPORTER free(file_ids); file_ids = NULL; #endif if (!xul_handle) __android_log_print(ANDROID_LOG_ERROR, "GeckoLibLoad", "Couldn't get a handle to libxul!"); #define GETFUNC(name) f_ ## name = (name ## _t) __wrap_dlsym(xul_handle, "Java_org_mozilla_gecko_GeckoAppShell_" #name) GETFUNC(nativeInit); GETFUNC(nativeRun); GETFUNC(notifyGeckoOfEvent); GETFUNC(processNextNativeEvent); GETFUNC(setSurfaceView); GETFUNC(onResume); GETFUNC(onLowMemory); GETFUNC(callObserver); GETFUNC(removeObserver); GETFUNC(onChangeNetworkLinkStatus); GETFUNC(reportJavaCrash); GETFUNC(executeNextRunnable); GETFUNC(cameraCallbackBridge); GETFUNC(notifyBatteryChange); #undef GETFUNC gettimeofday(&t1, 0); struct rusage usage2; getrusage(RUSAGE_SELF, &usage2); __android_log_print(ANDROID_LOG_ERROR, "GeckoLibLoad", "Loaded libs in %dms total, %dms user, %dms system, %d faults", (t1.tv_sec - t0.tv_sec)*1000 + (t1.tv_usec - t0.tv_usec)/1000, (usage2.ru_utime.tv_sec - usage1.ru_utime.tv_sec)*1000 + (usage2.ru_utime.tv_usec - usage1.ru_utime.tv_usec)/1000, (usage2.ru_stime.tv_sec - usage1.ru_stime.tv_sec)*1000 + (usage2.ru_stime.tv_usec - usage1.ru_stime.tv_usec)/1000, usage2.ru_majflt-usage1.ru_majflt); }
int initGLExtensions(myGetProcAdress func) { if (_glUseProgram) return 0; int missing = 0; GETFUNC(_glShaderSource, def_glShaderSource, PFNGLSHADERSOURCEPROC, "glShaderSource"); GETFUNC(_glUseProgram, def_glUseProgram, PFNGLUSEPROGRAMPROC, "glUseProgram"); GETFUNC(_glVertexAttribPointer, def_glVertexAttribPointer, PFNGLVERTEXATTRIBPOINTERPROC, "glVertexAttribPointer"); GETFUNC(_glActiveTexture, def_glActiveTexture, PFNGLACTIVETEXTUREPROC, "glActiveTexture"); GETFUNC(_glEnableVertexAttribArray, def_glEnableVertexAttribArray, PFNGLENABLEVERTEXATTRIBARRAYPROC, "glEnableVertexAttribArray"); GETFUNC(_glDisableVertexAttribArray, def_glDisableVertexAttribArray, PFNGLDISABLEVERTEXATTRIBARRAYPROC, "glDisableVertexAttribArray"); GETFUNC(_glDeleteProgram, def_glDeleteProgram, PFNGLDELETEPROGRAMPROC, "glDeleteProgram"); GETFUNC(_glGetShaderiv, def_glGetShaderiv, PFNGLGETSHADERIVPROC, "glGetShaderiv"); GETFUNC(_glGetShaderInfoLog, def_glGetShaderInfoLog, PFNGLGETSHADERINFOLOGPROC, "glGetShaderInfoLog"); GETFUNC(_glCreateShader, def_glCreateShader, PFNGLCREATESHADERPROC, "glCreateShader"); GETFUNC(_glCreateProgram, def_glCreateProgram, PFNGLCREATEPROGRAMPROC, "glCreateProgram"); GETFUNC(_glAttachShader, def_glAttachShader, PFNGLATTACHSHADERPROC, "glAttachShader"); GETFUNC(_glCompileShader, def_glCompileShader, PFNGLCOMPILESHADERPROC, "glCompileShader"); GETFUNC(_glBindAttribLocation, def_glBindAttribLocation, PFNGLBINDATTRIBLOCATIONPROC, "glBindAttribLocation"); GETFUNC(_glLinkProgram, def_glLinkProgram, PFNGLLINKPROGRAMPROC, "glLinkProgram"); GETFUNC(_glUniform1i, def_glUniform1i, PFNGLUNIFORM1IPROC, "glUniform1i"); GETFUNC(_glUniform2fv, def_glUniform2fv, PFNGLUNIFORM2FVPROC, "glUniform2fv"); GETFUNC(_glUniform3fv, def_glUniform3fv, PFNGLUNIFORM3FVPROC, "glUniform3fv"); GETFUNC(_glUniform4fv, def_glUniform4fv, PFNGLUNIFORM4FVPROC, "glUniform4fv"); GETFUNC(_glUniform1f, def_glUniform1f, PFNGLUNIFORM1FPROC, "glUniform1f"); GETFUNC(_glUniformMatrix4fv, def_glUniformMatrix4fv, PFNGLUNIFORMMATRIX4FVPROC, "glUniformMatrix4fv"); GETFUNC(_glBindFramebuffer, def_glBindFramebuffer, PFNGLBINDFRAMEBUFFERPROC, "glBindFramebuffer"); GETFUNC(_glGenFramebuffers, def_glGenFramebuffers, PFNGLGENFRAMEBUFFERSPROC, "glGenFramebuffers"); GETFUNC(_glCheckFramebufferStatus, def_glCheckFramebufferStatus, PFNGLCHECKFRAMEBUFFERSTATUSPROC, "glCheckFramebufferStatus"); GETFUNC(_glDeleteFramebuffers, def_glDeleteFramebuffers, PFNGLDELETEFRAMEBUFFERSPROC, "glDeleteFramebuffers"); GETFUNC(_glGetUniformLocation, def_glGetUniformLocation, PFNGLGETUNIFORMLOCATIONPROC, "glGetUniformLocation"); GETFUNC(_glFramebufferTexture2D, def_glFramebufferTexture2D, PFNGLFRAMEBUFFERTEXTURE2DPROC, "glFramebufferTexture2D"); GETFUNC(_glCompressedTexImage2D, def_glCompressedTexImage2D, PFNGLCOMPRESSEDTEXIMAGE2DPROC, "glCompressedTexImage2D"); GETFUNC(_glBindBuffer, def_glBindBuffer, PFNGLBINDBUFFERPROC, "glBindBuffer"); GETFUNC(_glGenBuffers, def_glGenBuffers, PFNGLGENBUFFERSPROC, "glGenBuffers"); GETFUNC(_glBufferData, def_glBufferData, PFNGLBUFFERDATAPROC, "glBufferData"); GETFUNC(_glDeleteBuffers, def_glDeleteBuffers, PFNGLDELETEBUFFERSPROC, "glDeleteBuffers"); return missing; }