void VM::PrintUnhandledError(Thread *const thread) { Value &error = thread->currentError; PrintInternal(stderr, L"Unhandled error: %ls: ", error.type->fullName); String *message = nullptr; // If the member exists and is a readable instance property, // we can actually try to invoke the 'message' getter! Member *msgMember = error.type->FindMember(strings->members.message, nullptr); if (msgMember && !msgMember->IsStatic() && msgMember->IsProperty()) { Property *msgProp = static_cast<Property*>(msgMember); if (msgProp->getter != nullptr) { thread->Push(&error); Value result; int r = thread->InvokeMethod(msgProp->getter, 0, &result); if (r == OVUM_SUCCESS && result.type == types.String) message = result.v.string; } } if (message == nullptr) message = error.v.error->message; if (message != nullptr) PrintErrLn(message); if (error.v.error->stackTrace) PrintErrLn(error.v.error->stackTrace); }
Function *VirtualMachine::GetRuntimeFunction(const std::string &name, bool isStatic) { // Find the module member. Member *member = runtimeModule->GetMember(name); if(!member || !member->IsFunction() || member->IsStatic() != isStatic) throw VirtualMachineException("Using incompatible runtime, cannot find: " + name); // Cast and declare the function. Function *function = static_cast<Function*> (member); function->DeclarePass(); return function; }
int main ( int argc, char *argv[] ) { std::cout << "\nReflex C++ Test...\n"; std::string className("MyClass"); std::cout << "\nAnalyzing class: " << className; std::cout << "\n-----------------"; Type myType = Type::ByName ( className ); std::cout << "\nListing out all functions that contain Annotations... " << std::endl; int numberOfMembers = myType.FunctionMemberSize ( INHERITEDMEMBERS_NO ); // FunctionMember_Begin for ( int i=0; i < numberOfMembers; i++ ) { Member member = myType.FunctionMemberAt ( i, INHERITEDMEMBERS_NO ); if ( member.IsStatic ( ) == true ) { AnnotationList annotationList = member.Annotations(); if ( annotationList.AnnotationSize() > 0 ) { if ( annotationList.HasAnnotation ( typeid(ExcelFunction) ) ) { const ExcelFunction* func = annotationList.AnnotationWithType<ExcelFunction> ( ); std::cout << "\n"; std::cout << "\nfunc.name: " << func->getName(); std::cout << "\nfunc.help: " << func->getHelp (); std::cout << "\nfunc.category: " << func->getCategory (); std::cout << "\nfunc.argHelp: " << func->getArgHelp (); /* int result = 0; std::vector<void *> parameters; int age_parm = 33; float mul_parm = 0.5; parameters.push_back ( &age_parm ); parameters.push_back ( &mul_parm ); member.Invoke <int &> ( result, parameters ); std::cout << "\nResult of invoking: " << result; std::cout << "\nPlus 7 = " << result + 7; */ } } } } return (0); }