void JSMisc::addClassProperties(JSContext * cx, JSObject * theClassProto) { JSBASE::addClassProperties(cx, theClassProto); JSA_AddFunctions(cx, theClassProto, Functions()); JSA_AddProperties(cx, theClassProto, Properties()); createClassModuleDocumentation("gtk", ClassName(), Properties(), Functions(), 0, 0, 0, JSBASE::ClassName()); }
void QgsScaleExpression::init() { bool ok; if ( !rootNode() ) return; const NodeFunction * f = dynamic_cast<const NodeFunction*>( rootNode() ); if ( !f ) return; QList<Node*> args = f->args()->list(); if ( "scale_linear" == Functions()[f->fnIndex()]->name() ) { mType = Linear; } else if ( "scale_exp" == Functions()[f->fnIndex()]->name() ) { const double exp = QgsExpression( args[5]->dump() ).evaluate().toDouble( &ok ); if ( ! ok ) return; if ( qgsDoubleNear( exp, 0.57, 0.001 ) ) mType = Flannery; else if ( qgsDoubleNear( exp, 0.5, 0.001 ) ) mType = Area; else { mType = Unknown; return; } } else { mType = Unknown; return; } bool expOk = true; mMinValue = QgsExpression( args[1]->dump() ).evaluate().toDouble( &ok ); expOk &= ok; mMaxValue = QgsExpression( args[2]->dump() ).evaluate().toDouble( &ok ); expOk &= ok; mMinSize = QgsExpression( args[3]->dump() ).evaluate().toDouble( &ok ); expOk &= ok; mMaxSize = QgsExpression( args[4]->dump() ).evaluate().toDouble( &ok ); expOk &= ok; if ( !expOk ) { mType = Unknown; return; } mExpression = args[0]->dump(); }
bool rs::jsapi::Object::Create(JSContext* cx, const std::vector<const char*>& properties, GetCallback getter, SetCallback setter, const std::vector<std::pair<const char*, FunctionCallback>>& functions, FinalizeCallback finalizer, Value& obj) { JSAutoRequest ar(cx); JS::RootedObject newObj(cx, JS_NewObject(cx, &class_, JS::NullPtr())); if (newObj) { auto state = new ObjectState { getter, setter, finalizer, Functions(), 0, nullptr }; for (auto p : properties) { JS_DefineProperty(cx, newObj, p, JS::NullHandleValue, JSPROP_ENUMERATE); } for (auto f : functions) { JS_DefineFunction(cx, newObj, f.first, Object::CallFunction, 0, JSPROP_ENUMERATE | JSFUN_STUB_GSOPS); state->functions.emplace(f.first, f.second); } Object::SetState(newObj, state); obj.set(newObj); } return newObj; }
const QStringList &QgsExpression::BuiltinFunctions() { if ( sBuiltinFunctions.isEmpty() ) { Functions(); // this method builds the gmBuiltinFunctions as well } return sBuiltinFunctions; }
JSObject * JSSigConnection::initClass(JSContext *cx, JSObject *theGlobalObject) { JSObject * myClassObject = Base::initClass(cx, theGlobalObject, ClassName(), Constructor, Properties(), Functions()); jsval myConstructorFuncObjVal; if (JS_GetProperty(cx, theGlobalObject, ClassName(), &myConstructorFuncObjVal)) { // /*JSObject * myConstructorFuncObj =*/ JSVAL_TO_OBJECT(myConstructorFuncObjVal); //JSA_DefineConstInts(cx, myConstructorFuncObj, ConstIntProperties()); } else { cerr << "JSSigConnection::initClass: constructor function object not found, could not initialize static members"<<endl; } createClassModuleDocumentation("gtk", ClassName(), Properties(), Functions(), 0, 0, 0, 0); return myClassObject; }
void ControlFlowAnalysis::Analyse() { dputs("Starting analysis..."); DWORD ticks = GetTickCount(); BasicBlockStarts(); dprintf("Basic block starts in %ums!\n", GetTickCount() - ticks); ticks = GetTickCount(); BasicBlocks(); dprintf("Basic blocks in %ums!\n", GetTickCount() - ticks); ticks = GetTickCount(); Functions(); dprintf("Functions in %ums!\n", GetTickCount() - ticks); dprintf("Analysis finished!\n"); }
QString CSMesEmma::exportEMMAStatistic(const QString &filename,int coverage_level,Instrumentation::coverage_method_t method) const { const ExecutionNames executions=selectedExecutions(); int nb_executions=executions.count(); if (nb_executions==0) return QObject::tr("No executions selected"); QFile f; f.setFileName(filename); if (f.open(QFile::WriteOnly)) { bool is_test_count_mode_selected=isTestCountModeSelected(); CSMesInstrumentations _instrumentations ; copyInstrumentation(_instrumentations,instrumentations); selectExecutionsComparaison(_instrumentations,executions,ExecutionNames(),is_test_count_mode_selected,method,false); CSMesInstrumentations _instrumentations_block ; copyInstrumentation(_instrumentations_block,instrumentations); selectExecutionsComparaison(_instrumentations_block,executions,ExecutionNames(),is_test_count_mode_selected,Instrumentation::COVERAGE_BRANCH,false); ExecutionNames::const_iterator it_fct; const QList<CSMesFunctionInfo::functionskey_t> functions= Functions(); int nb_functions=functions.count(); QHash<CSMesFunctionInfo::functionskey_t,int> nb_tested_function_list; QHash<CSMesFunctionInfo::functionskey_t,int> nb_untested_function_list; QSet<QString> classes; if ( statisticFunctionsExecution(executions,coverage_level,method,nb_tested_function_list,nb_untested_function_list,_instrumentations) ) { for ( QList<CSMesFunctionInfo::functionskey_t>::const_iterator itFunction=functions.begin();itFunction<functions.end();++itFunction++) { const CSMesFunctionInfo::functionskey_t &f=*itFunction; if (nb_tested_function_list.contains(f) && nb_untested_function_list.contains(f) ) { const QString &func=f.method.getScopedName(); classes+=classFromFunction(func); } } } int nb_class=classes.count(); QHash<ExecutionName,int> nb_tested_source_list; QHash<ExecutionName,int> nb_untested_source_list; const SourceFiles sources= Sources(NON_EMPTY); int nb_sources=sources.count(); statisticSourcesExecution(sources,executions,coverage_level,method,nb_tested_source_list,nb_untested_source_list,_instrumentations) ; int nb_tested,nb_untested; statistic(coverage_level,method,nb_tested,nb_untested,_instrumentations) ; int nb_tested_block,nb_untested_block; statistic(coverage_level,Instrumentation::COVERAGE_BRANCH,nb_tested_block,nb_untested_block,_instrumentations_block) ; QHash<ExecutionName,int> nb_tested_source_block_list; QHash<ExecutionName,int> nb_untested_source_block_list; statisticSourcesExecution(sources,executions,coverage_level,Instrumentation::COVERAGE_BRANCH,nb_tested_source_block_list,nb_untested_source_block_list,_instrumentations_block) ; QHash<CSMesFunctionInfo::functionskey_t,int> nb_tested_function_block_list; QHash<CSMesFunctionInfo::functionskey_t,int> nb_untested_function_block_list; statisticFunctionsExecution(executions,coverage_level,Instrumentation::COVERAGE_BRANCH,nb_tested_function_block_list,nb_untested_function_block_list,_instrumentations_block) ; int nb_instrumentation=0; for (CSMesInstrumentations::Modules::const_iterator mod_it=_instrumentations.modules.begin();mod_it!=_instrumentations.modules.end();++mod_it) nb_instrumentation += mod_it->nb_measurements_items; QXmlStreamWriter stream(&f); stream.setAutoFormatting(true); stream.writeStartDocument(); stream.writeStartElement("report"); stream.writeStartElement("stats"); stream.writeEmptyElement("packages"); stream.writeAttribute("value",QString::number(1)); stream.writeEmptyElement("methods"); stream.writeAttribute("value",QString::number(nb_functions)); stream.writeEmptyElement("srcfiles"); stream.writeAttribute("value",QString::number(nb_sources)); stream.writeEmptyElement("srclines"); stream.writeAttribute("value",QString::number(nb_tested+nb_untested)); stream.writeEmptyElement("classes"); stream.writeAttribute("value",QString::number(nb_class)); stream.writeEndElement(); stream.writeStartElement("data"); stream.writeStartElement("all"); stream.writeAttribute("name","all classes"); { int nb_tested_line=nb_tested; int nb_untested_line=nb_untested; int nb_tested_method; int nb_untested_method; int nb_tested_class; int nb_untested_class; int nb_tested_blocks=nb_tested_block; int nb_untested_blocks=nb_untested_block; emmaStatisticMethods(nb_tested_function_list,nb_tested_method,nb_untested_method); emmaStatisticClasses(nb_tested_function_list,nb_tested_class,nb_untested_class); exportEmmaStatistics(stream,nb_tested_line,nb_untested_line,nb_tested_method,nb_untested_method,nb_tested_class,nb_untested_class,nb_tested_blocks,nb_untested_blocks); } stream.writeStartElement("packages"); stream.writeAttribute("name",getFilename()); for (SourceFiles::const_iterator itSrc=sources.begin();itSrc!=sources.end();++itSrc) { stream.writeStartElement("srcfile"); stream.writeAttribute("name",*itSrc); QList<CSMesFunctionInfo::functionskey_t> functions_source; QSet<QString> classes_source; for (QList<CSMesFunctionInfo::functionskey_t>::const_iterator itMeth=functions.begin();itMeth!=functions.end();++itMeth) { if ((*itMeth).source==*itSrc) { functions_source+=*itMeth; const QString &func=(*itMeth).method.getScopedName(); classes_source+=classFromFunction(func); } } { int nb_tested_line=0; int nb_untested_line=0; if (nb_tested_source_list.contains(*itSrc) && nb_untested_source_list.contains(*itSrc) ) { nb_tested_line=nb_tested_source_list[*itSrc]; nb_untested_line=nb_untested_source_list[*itSrc]; } QHash<CSMesFunctionInfo::functionskey_t,int> nb_tested_functions; for (QHash<CSMesFunctionInfo::functionskey_t,int>::const_iterator itFunc=nb_tested_function_list.begin();itFunc!=nb_tested_function_list.end();++itFunc) { if (itFunc.key().source==*itSrc) nb_tested_functions[itFunc.key()]=itFunc.value(); } int nb_tested_method=0; int nb_untested_method=0; int nb_tested_class=0; int nb_untested_class=0; int nb_tested_blocks=0; int nb_untested_blocks=0; if (nb_tested_source_block_list.contains(*itSrc) && nb_untested_source_block_list.contains(*itSrc) ) { nb_tested_blocks=nb_tested_source_block_list[*itSrc]; nb_untested_blocks=nb_untested_source_block_list[*itSrc]; } emmaStatisticMethods(nb_tested_functions,nb_tested_method,nb_untested_method); emmaStatisticClasses(nb_tested_functions,nb_tested_class,nb_untested_class); exportEmmaStatistics(stream,nb_tested_line,nb_untested_line,nb_tested_method,nb_untested_method,nb_tested_class,nb_untested_class,nb_tested_blocks,nb_untested_blocks); } for (QSet<QString>::const_iterator itClass=classes_source.begin();itClass!=classes_source.end();++itClass) { stream.writeStartElement("class"); stream.writeAttribute("name",*itClass); { int nb_tested_line=0; int nb_untested_line=0; int nb_tested_blocks=0; int nb_untested_blocks=0; QHash<CSMesFunctionInfo::functionskey_t,int> nb_tested_functions; for (QHash<CSMesFunctionInfo::functionskey_t,int>::const_iterator itFunc=nb_tested_function_list.begin();itFunc!=nb_tested_function_list.end();++itFunc) { if ( (itFunc.key().source==*itSrc) && (classFromFunction(itFunc.key().method.getScopedName())==*itClass)) { nb_tested_functions[itFunc.key()]=itFunc.value(); nb_tested_line+=itFunc.value(); nb_untested_line+=nb_untested_function_list[itFunc.key()]; nb_tested_blocks+=nb_tested_function_block_list[itFunc.key()]; nb_untested_blocks+=nb_untested_function_block_list[itFunc.key()]; } } int nb_tested_method=0; int nb_untested_method=0; int nb_tested_class=0; int nb_untested_class=0; emmaStatisticMethods(nb_tested_functions,nb_tested_method,nb_untested_method); emmaStatisticClasses(nb_tested_functions,nb_tested_class,nb_untested_class); exportEmmaStatistics(stream,nb_tested_line,nb_untested_line,nb_tested_method,nb_untested_method,nb_tested_class,nb_untested_class,nb_tested_blocks,nb_untested_blocks); } for (QList<CSMesFunctionInfo::functionskey_t>::const_iterator itMeth=functions_source.begin();itMeth!=functions_source.end();++itMeth) { if ( classFromFunction(itMeth->method.getScopedName())==*itClass) { stream.writeStartElement("method"); stream.writeAttribute("name",(*itMeth).method.getScopedName()); { int nb_tested_line=0; int nb_untested_line=0; int nb_tested_blocks=0; int nb_untested_blocks=0; QHash<CSMesFunctionInfo::functionskey_t,int> nb_tested_functions; for (QHash<CSMesFunctionInfo::functionskey_t,int>::const_iterator itFunc=nb_tested_function_list.begin();itFunc!=nb_tested_function_list.end();++itFunc) { if ( itFunc.key()==*itMeth ) { nb_tested_functions[itFunc.key()]=itFunc.value(); nb_tested_line+=itFunc.value(); nb_untested_line+=nb_untested_function_list[itFunc.key()]; nb_tested_blocks+=nb_tested_function_block_list[itFunc.key()]; nb_untested_blocks+=nb_untested_function_block_list[itFunc.key()]; } } int nb_tested_method=0; int nb_untested_method=0; emmaStatisticMethods(nb_tested_functions,nb_tested_method,nb_untested_method); exportEmmaStatistics(stream,nb_tested_line,nb_untested_line,nb_tested_method,nb_untested_method,-1,-1,nb_tested_blocks,nb_untested_blocks); } stream.writeEndElement(); } } stream.writeEndElement(); } stream.writeEndElement(); } stream.writeEndElement(); stream.writeEndElement(); stream.writeEndElement(); stream.writeEndDocument(); f.close(); return QString(); } else return QObject::tr("Error opening file '%1':%2").arg(filename).arg(f.errorString()); }
int QgsExpression::functionCount() { return Functions().size(); }
JSObject * JSSphere::initClass(JSContext *cx, JSObject *theGlobalObject) { JSObject * myClass = Base::initClass(cx, theGlobalObject, ClassName(), Constructor, Properties(), Functions()); DOC_MODULE_CREATE("Math",JSSphere); return myClass; }
void LSH_DFE::hash_set_dimensions(){ // set the dimension of hash function m_hash = Functions(DOUT, in_d.size2()); }
void pango::JSContext::addClassProperties(::JSContext * cx, JSObject * theClassProto) { JSA_AddFunctions(cx, theClassProto, Functions()); JSA_AddProperties(cx, theClassProto, Properties()); createClassModuleDocumentation("Cairo", ClassName(), Properties(), Functions(), 0, 0, 0); }
* Filename: open-test.c * * Author: Adriaan, * Company: Uppsala IT * * ===================================================================================== */ #include "open.h" #include "unit.h" int tests_run = 0; int tests_set = 2; TEST(getModule) MODDATA temp = Functions(); CHECK("Did not get the functions module",temp.t == STRUCTURE); DONE TEST(getGettr) DATA temp = simple_test(); CHECK("Did not get the boolean",temp.t == BOOLEAN); CHECK("Result is not true",temp.value == 1); DONE LIST RUN(getModule); RUN(getGettr); DONE INCLUDE_MAIN
void QgsScaleExpression::init() { bool ok; mType = Unknown; if ( !rootNode() ) return; const NodeFunction * f = dynamic_cast<const NodeFunction*>( rootNode() ); if ( !f ) return; QList<Node*> args = f->args()->list(); // the scale function may be enclosed in a coalesce(expr, 0) to avoid NULL value // to be drawn with the default size if ( "coalesce" == Functions()[f->fnIndex()]->name() ) { f = dynamic_cast<const NodeFunction*>( args[0] ); if ( !f ) return; mNullSize = QgsExpression( args[1]->dump() ).evaluate().toDouble( &ok ); if ( ! ok ) return; args = f->args()->list(); } if ( "scale_linear" == Functions()[f->fnIndex()]->name() ) { mType = Linear; } else if ( "scale_exp" == Functions()[f->fnIndex()]->name() ) { mExponent = QgsExpression( args[5]->dump() ).evaluate().toDouble( &ok ); if ( ! ok ) return; if ( qgsDoubleNear( mExponent, 0.57, 0.001 ) ) mType = Flannery; else if ( qgsDoubleNear( mExponent, 0.5, 0.001 ) ) mType = Area; else mType = Exponential; } else { return; } bool expOk = true; mMinValue = QgsExpression( args[1]->dump() ).evaluate().toDouble( &ok ); expOk &= ok; mMaxValue = QgsExpression( args[2]->dump() ).evaluate().toDouble( &ok ); expOk &= ok; mMinSize = QgsExpression( args[3]->dump() ).evaluate().toDouble( &ok ); expOk &= ok; mMaxSize = QgsExpression( args[4]->dump() ).evaluate().toDouble( &ok ); expOk &= ok; if ( !expOk ) { mType = Unknown; return; } mExpression = args[0]->dump(); }
void IScriptablePlugin::initClasses(JSContext * theContext, JSObject *theGlobalObject) { JSScriptablePlugin::initClass(theContext, theGlobalObject, ClassName(), Functions(), StaticFunctions(), ConstIntProperties(), StaticProperties()); }