int ExportScript::call_long( unsigned PC, BObjectImp* p0, BObjectImp* p1 ) { try { //build backup if function is called inside the same script BackupStruct backup; SaveStack( backup ); uoexec.initForFnCall( PC ); uoexec.pushArg( p0 ); uoexec.pushArg( p1 ); uoexec.exec(); int ret; if ( uoexec.error() ) ret = 0; else if ( uoexec.ValueStack.empty() ) ret = 0; else { BObjectImp* imp = uoexec.ValueStack.back().get()->impptr(); if ( imp->isa( BObjectImp::OTLong ) ) { BLong* pLong = static_cast<BLong*>( imp ); ret = pLong->value(); } else { ret = 0; } uoexec.ValueStack.pop_back(); } // delete current state and reenable backup LoadStack( backup ); return ret; } catch ( std::exception& )//... { return 0; } }
long ExportScript::call_long( unsigned PC, BObjectImp* p0, BObjectImp* p1 ) { try { uoexec.initForFnCall( PC ); uoexec.pushArg(p0); uoexec.pushArg(p1); uoexec.exec(); if (uoexec.error()) return 0; if (uoexec.ValueStack.empty()) return 0; long ret; BObjectImp* imp = uoexec.ValueStack.top().get()->impptr(); if (imp->isa( BObjectImp::OTLong )) { BLong* pLong = static_cast<BLong*>(imp); ret = pLong->value(); } else { ret = 0; } uoexec.ValueStack.pop(); return ret; } catch(std::exception&)//... { return 0; } }