bool ofxSnorkel::addURICallback(std::string sURI, ofxSnorkelCallback* pCallback, encodingtype_t nEncodingType) { // add to the callback lists for the given uri. std::vector<ofxSnorkelCallback*>* call = getCallbacks(sURI); if(call == NULL) { std::vector<ofxSnorkelCallback*>* uri_callbacks = new std::vector<ofxSnorkelCallback*>(); uri_callbacks->push_back(pCallback); callbacks[sURI] = uri_callbacks; } else { call->push_back(pCallback); OFXLOG("ofxSnorkel: number of callbacks:" << call->size()); } // request for a uri callback on snorkel. if(snorkel_obj_set( http ,snorkel_attrib_uri ,GET ,sURI.c_str() ,nEncodingType ,ofxSnorkel::snorkelURICallback) != SNORKEL_SUCCESS) { OFXLOG("ofxSnorkel: Error, cannot set callback handler for: " << sURI); return false; } return true; }
// We don't currently support return values as this makes it the responsibility // of the caller to clean up the stack, this can be changed if we automate void NativeDelegate::invoke() const { // Don't do this from non-main thread. assertMainThread(); // if we have no callbacks defined, the VM state will be NULL if (!L) { // Even if we don't do anything, need to reset arg count. _argumentCount = 0; return; } int top = lua_gettop(L); int numArgs = _argumentCount; // Reset argument count, so recursion is properly handled _argumentCount = 0; getCallbacks(L); int tidx = lua_gettop(L); if (!lua_istable(L, tidx)) { LSError("Error getting native delegate callback table"); } for (int i = 0; i < _callbackCount; i++) { lua_pushnumber(L, (double)i); lua_gettable(L, tidx); int t = lua_gettop(L); for (int i = top - numArgs; i < top; i++) { lua_pushvalue(L, i + 1); } lua_call(L, numArgs, 1); lua_settop(L, t); /* removes last lua_function called */ lua_pop(L, 1); } lua_settop(L, top); // clean up arguments off stack lua_pop(L, numArgs); }
Value Interpreter::Evaluate(const char* expr, DeclContext* DC, bool ValuePrinterReq) { Sema& TheSema = getCI()->getSema(); // The evaluation should happen on the global scope, because of the wrapper // that is created. // // We can't PushDeclContext, because we don't have scope. Sema::ContextRAII pushDC(TheSema, TheSema.getASTContext().getTranslationUnitDecl()); Value Result; getCallbacks()->SetIsRuntime(true); if (ValuePrinterReq) echo(expr, &Result); else evaluate(expr, Result); getCallbacks()->SetIsRuntime(false); return Result; }
void Interpreter::unload(unsigned numberOfTransactions) { while(true) { cling::Transaction* T = m_IncrParser->getLastTransaction(); if (InterpreterCallbacks* callbacks = getCallbacks()) callbacks->TransactionUnloaded(*T); if (m_Executor) // we also might be in fsyntax-only mode. m_Executor->runAndRemoveStaticDestructors(T); m_IncrParser->rollbackTransaction(T); if (!--numberOfTransactions) break; } }
/** * After all shapes have been generated, we write the actual STL file by looping over the * finalized geometry instances. */ void STLEncoder::finish(prtx::GenerateContext& /*context*/) { prt::SimpleOutputCallbacks* soh = dynamic_cast<prt::SimpleOutputCallbacks*>(getCallbacks()); const std::wstring baseName = getOptions()->getString(EO_BASE_NAME); std::vector<prtx::EncodePreparator::FinalizedInstance> finalizedInstances; mEncodePreparator->fetchFinalizedInstances(finalizedInstances, ENC_PREP_FLAGS); std::wostringstream out; out << std::scientific; out << L"solid " << baseName << L"\n"; for (const auto& instance: finalizedInstances) { for (const prtx::MeshPtr& m: instance.getGeometry()->getMeshes()) { for (uint32_t fi = 0, n = m->getFaceCount(); fi < n; fi++) { const prtx::DoubleVector& vc = m->getVertexCoords(); const uint32_t* fvi = m->getFaceVertexIndices(fi); assert(m->getFaceVertexCount(fi) == 3); // we enabled triangulation above uint32_t vi0 = 3 * fvi[0]; uint32_t vi1 = 3 * fvi[1]; uint32_t vi2 = 3 * fvi[2]; // using first vertex normal as face normal, see call to processVertexNormals() above const uint32_t* fvni = m->getFaceVertexNormalIndices(fi); const double* fn = &m->getVertexNormalsCoords()[3 * fvni[0]]; out << L"facet normal " << fn[0] << L" " << fn[1] << L" " << fn[2] << WNL; out << L" outer loop" << WNL; out << L" vertex " << vc[vi0] << L" " << vc[vi0+1] << L" " << vc[vi0+2] << WNL; out << L" vertex " << vc[vi1] << L" " << vc[vi1+1] << L" " << vc[vi1+2] << WNL; out << L" vertex " << vc[vi2] << L" " << vc[vi2+1] << L" " << vc[vi2+2] << WNL; out << L" endloop" << WNL; out << L"endfacet" << WNL; } } } out << L"endsolid" << WNL; // let the client application write the file via callback std::wstring fileName = baseName + STL_EXT; uint64_t h = soh->open(ID.c_str(), prt::CT_GEOMETRY, fileName.c_str(), prt::SimpleOutputCallbacks::SE_UTF8); soh->write(h, out.str().c_str()); soh->close(h, 0, 0); }
void ofxSnorkel::handleURICallback(std::string sURI, snorkel_obj_t oHTTP, snorkel_obj_t oOutputStream) { OFXLOG("ofxSnorkel: handling an uri callback for: " << sURI); std::vector<ofxSnorkelCallback*>* uri_callbacks = getCallbacks(sURI); if(uri_callbacks == NULL) { OFXLOG("ofxSnorkel: error, no callbacks found for the uri: " << sURI); return; } std::vector<ofxSnorkelCallback*>::iterator it = uri_callbacks->begin(); ofxSnorkelResponse response(oHTTP, oOutputStream); while(it != uri_callbacks->end()) { if((*it) != NULL) { (*it)->execute(&response); } else { OFXLOG("ofxSnorkel: error while executing a callback... "); } ++it; } }
void clang_registerCheckers(clang::ento::CheckerRegistry ®istry) { auto callbacks = getCallbacks(); for(std::vector<register_checker_callback_t>::iterator it = callbacks.begin(); it != callbacks.end(); ++it) { (*it)(registry); } }
void add_register_checker_callback(register_checker_callback_t f) { getCallbacks().push_back(f); }