DistortionMapT *NewDistortionMap(size_t width, size_t height, DistortionMapTypeT type, size_t textureW, size_t textureH) { DistortionMapT *map = NewInstance(DistortionMapT); size_t size = 0; switch (type) { case DMAP_OPTIMIZED: size = sizeof(uint16_t); break; case DMAP_ACCURATE: size = sizeof(UV16T); break; } map->map = MemNew(size * width * height); map->type = type; map->width = width; map->height = height; map->textureW = textureW; map->textureH = textureH; return map; }
GlImage* GlNode1dAddOn::NewImage() const { int32 w = Prefs().GetInt32(GL_NODE_IMAGE_X), h = Prefs().GetInt32(GL_NODE_IMAGE_Y); if (w < 1 || h < 1) return 0; GlImage* img = new GlImage(w, h); if (!img || img->InitCheck() != B_OK) { delete img; return 0; } img->SetColor(0, 0, 0, 0); GlNode* node = NewInstance(0); if (!node) return img; node->IncRefs(); gl_generate_args args; args.flags = GL_NODE_ICON_F; GlAlgo* a = node->Generate(args); node->MakeEmpty(); node->DecRefs(); GlAlgo1d* a1d = (a) ? a->As1d() : 0; if (a1d) { GlCache1d cache; cache.Render(a1d, img, GlRect(0, 0, w, h), GlRect(0, 0, w, h)); } delete a; return img; }
UVMapT *NewUVMap(size_t width, size_t height, UVMapTypeT type, size_t textureW, size_t textureH) { UVMapT *map = NewInstance(UVMapT); map->type = type; map->width = width; map->height = height; if (type == UV_FAST) { ASSERT(textureW == 256 && textureH == 256, "In optimized mode texture size has to be 256x256."); map->map.fast.u = NewTable(uint8_t, width * height); map->map.fast.v = NewTable(uint8_t, width * height); } else if (type == UV_NORMAL) { map->map.normal.u = NewTable(int16_t, width * height); map->map.normal.v = NewTable(int16_t, width * height); } else if (type == UV_ACCURATE) { map->map.accurate.u = NewTable(FP16, width * height); map->map.accurate.v = NewTable(FP16, width * height); } /* initially there's no texture attached */ map->textureW = textureW; map->textureH = textureH; return map; }
static NodeT *NodeAlloc(TreeT *parent, PtrT data) { TreeT *item = NewInstance(TreeT); NodeInitGuard(GetChildren(item)); item->parent = parent; item->data = data; return GetNode(item); }
StackT *NewStack(size_t size, size_t elemSize) { StackT *stack = NewInstance(StackT); stack->data = MemNewTable(elemSize, size); stack->top = -1; return stack; }
inline Class &SingletonHolder<Class>::Instance() { // create instance only if instance is not created if (!instance) NewInstance(); return *instance; }
PaletteT *NewPalette(size_t count) { PaletteT *palette = NewInstance(PaletteT); palette->count = count; palette->colors = NewTable(RGB, count); return palette; }
Crc::Crc(const Config &config) : m_seed(config.seed), m_is_init(true) { Sim::SetEnableClockGate(Sim::ClockGate::kCrc, true); NewInstance(config.seed); CRC0->CTRL = 0 | CRC_CTRL_TCRC_MASK | CRC_CTRL_TOT(1) | CRC_CTRL_TOTR(1) | CRC_CTRL_FXOR_MASK; CRC0->GPOLY = config.polynomial; }
AtomPoolT *NewAtomPool(size_t atomSize, size_t perChunk) { AtomPoolT *atomPool = NewInstance(AtomPoolT); atomPool->atomSize = atomSize; atomPool->perChunk = perChunk; ResetAtomPool(atomPool); return atomPool; }
__declspec(dllexport) void main() { Init(); __try { switch ( *(DWORD *)(0x00DDDC00) ) { /*case 0x508B018B : // 1.7.7.0 (2012) { break; } */ case 0x5FFFF2DD : // 1.8.151.0 (2012) { break; } default : { ShowVersion(); return; } } if(!EasySteam::Interface::GetInstance() || !EasySteam::Interface::GetInstance()->GetUser()->IsLoggedOn()) { Debug::ShowMessageBox("Unable to retrieve steam."); return; } Skyrim::RegisterOnlineScript(); srand((unsigned int)time(NULL)); PrintNote("To play Skyrim Online, press F3"); while(!Skyrim::TheGameWorld) { if(GetKeyPressed(VK_F3)) { NewInstance(); Skyrim::TheGameWorld->Setup(); break; } Wait(0); } if(Skyrim::TheGameWorld) Skyrim::TheGameWorld->Run(); } __except(GenerateDump(GetExceptionInformation())) { } }
MeshT *NewMesh(uint32_t vertices, uint32_t polygons, uint32_t surfaces) { MeshT *mesh = NewInstance(MeshT); mesh->vertexNum = vertices; mesh->polygonNum = polygons; mesh->surfaceNum = surfaces; mesh->vertex = NewTable(Vector3D, vertices); mesh->polygon = NewTable(TriangleT, polygons); mesh->surface = NewTableOfType(SurfaceT, surfaces); return mesh; }
void main() { Init(); srand((unsigned int)time(NULL)); NewInstance(); Skyrim::TheGameWorld->Setup(); boost::thread t(ChatSystem); boost::thread t2(PositionSystem); Skyrim::TheGameWorld->Run(); }
void dynFilter::Init( const std::string &filterName, dynFilterFunction funcNameConstructor, dynFilterFunction funcNameDestructor, const char* filterDynLib ) { m_Name = filterName; m_FuncNameConstructor = funcNameConstructor; m_FuncNameDestructor = funcNameDestructor; m_DynamicLib = new dynLib( ); m_DynamicLib->SetLibraryPath( filterDynLib ); NewInstance(); }
// static XPCNativeSet* XPCNativeSet::GetNewOrUsed(XPCCallContext& ccx, const nsIID* iid) { AutoMarkingNativeSetPtr set(ccx); AutoMarkingNativeInterfacePtr iface(ccx); iface = XPCNativeInterface::GetNewOrUsed(ccx, iid); if(!iface) return nsnull; XPCNativeSetKey key(nsnull, iface, 0); XPCJSRuntime* rt = ccx.GetRuntime(); NativeSetMap* map = rt->GetNativeSetMap(); if(!map) return nsnull; { // scoped lock XPCAutoLock lock(rt->GetMapLock()); set = map->Find(&key); } if(set) return set; // hacky way to get a XPCNativeInterface** using the AutoPtr XPCNativeInterface* temp[] = {iface}; set = NewInstance(ccx, temp, 1); if(!set) return nsnull; { // scoped lock XPCAutoLock lock(rt->GetMapLock()); XPCNativeSet* set2 = map->Add(&key, set); if(!set2) { NS_ERROR("failed to add our set!"); DestroyInstance(set); set = nsnull; } else if(set2 != set) { DestroyInstance(set); set = set2; } } return set; }
void main() { Init(); __try { NewInstance(); Skyrim::TheGameWorld->Setup(); Skyrim::TheGameWorld->Run(); } __except(GenerateDump(GetExceptionInformation())) { } }
// static XPCNativeSet* XPCNativeSet::GetNewOrUsed(XPCCallContext& ccx, XPCNativeSet* otherSet, XPCNativeInterface* newInterface, PRUint16 position) { AutoMarkingNativeSetPtr set(ccx); XPCJSRuntime* rt = ccx.GetRuntime(); NativeSetMap* map = rt->GetNativeSetMap(); if(!map) return nsnull; XPCNativeSetKey key(otherSet, newInterface, position); { // scoped lock XPCAutoLock lock(rt->GetMapLock()); set = map->Find(&key); } if(set) return set; if(otherSet) set = NewInstanceMutate(otherSet, newInterface, position); else set = NewInstance(ccx, &newInterface, 1); if(!set) return nsnull; { // scoped lock XPCAutoLock lock(rt->GetMapLock()); XPCNativeSet* set2 = map->Add(&key, set); if(!set2) { NS_ERROR("failed to add our set!"); DestroyInstance(set); set = nsnull; } else if(set2 != set) { DestroyInstance(set); set = set2; } } return set; }
// static XPCNativeInterface* XPCNativeInterface::GetNewOrUsed(XPCCallContext& ccx, const nsIID* iid) { AutoMarkingNativeInterfacePtr iface(ccx); XPCJSRuntime* rt = ccx.GetRuntime(); IID2NativeInterfaceMap* map = rt->GetIID2NativeInterfaceMap(); if(!map) return nsnull; { // scoped lock XPCAutoLock lock(rt->GetMapLock()); iface = map->Find(*iid); } if(iface) return iface; nsCOMPtr<nsIInterfaceInfo> info; ccx.GetXPConnect()->GetInfoForIID(iid, getter_AddRefs(info)); if(!info) return nsnull; iface = NewInstance(ccx, info); if(!iface) return nsnull; { // scoped lock XPCAutoLock lock(rt->GetMapLock()); XPCNativeInterface* iface2 = map->Add(iface); if(!iface2) { NS_ERROR("failed to add our interface!"); DestroyInstance(ccx, rt, iface); iface = nsnull; } else if(iface2 != iface) { DestroyInstance(ccx, rt, iface); iface = iface2; } } return iface; }
// static XPCNativeInterface* XPCNativeInterface::GetNewOrUsed(XPCCallContext& ccx, nsIInterfaceInfo* info) { AutoMarkingNativeInterfacePtr iface(ccx); const nsIID* iid; if(NS_FAILED(info->GetIIDShared(&iid)) || !iid) return nsnull; XPCJSRuntime* rt = ccx.GetRuntime(); IID2NativeInterfaceMap* map = rt->GetIID2NativeInterfaceMap(); if(!map) return nsnull; { // scoped lock XPCAutoLock lock(rt->GetMapLock()); iface = map->Find(*iid); } if(iface) return iface; iface = NewInstance(ccx, info); if(!iface) return nsnull; { // scoped lock XPCAutoLock lock(rt->GetMapLock()); XPCNativeInterface* iface2 = map->Add(iface); if(!iface2) { NS_ERROR("failed to add our interface!"); DestroyInstance(ccx, rt, iface); iface = nsnull; } else if(iface2 != iface) { DestroyInstance(ccx, rt, iface); iface = iface2; } } return iface; }
GlImage* GlValueAddOn::NewImage() const { int32 w = Prefs().GetInt32(GL_NODE_IMAGE_X), h = Prefs().GetInt32(GL_NODE_IMAGE_Y); if (w < 1 || h < 1) return 0; GlImage* img = new GlImage(w, h); if (!img || img->InitCheck() != B_OK) { delete img; return 0; } GlNode* node = NewInstance(0); if (!node) return img; node->IncRefs(); gl_generate_args args; args.flags = GL_NODE_ICON_F; GlAlgo* a = node->Generate(args); node->MakeEmpty(); node->DecRefs(); GlAlgo2d* s = (a) ? a->As2d() : 0; GlPlanes* p = img->LockPixels(GL_PIXEL_RGBA, true); if (p) { GlFillType fill = GL_FILL_NONE; if (s) fill = s->FillType(); if (fill == GL_FILL_BLACK) p->Black(); else if (fill == GL_FILL_COLORWHEEL) p->ColorWheel(0, 0, w, h); GlMask mask; uint8* data; if (s && (data = mask.Make(*p, s)) != 0) { /* Render the surface. */ for (int32 pix = 0; pix < p->w * p->h; pix++) { if (p->a[pix] > 0) p->a[pix] = data[pix]; } } img->UnlockPixels(p); } delete a; return img; }
PngT *PngLoadFromFile(const char *path) { RwOpsT *stream; if ((stream = RwOpsFromFile(path, "r"))) { PngT *png = NewInstance(PngT); if (ReadPNG(png, stream)) { LOG("Loaded '%s' file.", path); } else { MemUnref(png); png = NULL; } IoClose(stream); return png; } return NULL; }
bool ParseValue(ParserT *parser, JsonNodeT **node_p) { TokenT *token; JsonNodeT *node = *node_p; if (!node) (*node_p) = node = NewInstance(JsonNodeT); if ((token = ParserMatch(parser, TOK_LBRACE))) { node->type = JSON_OBJECT; node->u.object.num = token->size; if (token->size) node->u.object.item = NewTable(JsonPairT, token->size); return ParseObject(parser, node); } else if ((token = ParserMatch(parser, TOK_LBRACKET))) { node->type = JSON_ARRAY; node->u.array.num = token->size; if (token->size) node->u.array.item = NewTable(JsonNodeT *, token->size); return ParseArray(parser, node); }
HashMapT *NewHashMap(size_t initialSize) { HashMapT *self = NewInstance(HashMapT); { size_t n = 0; size_t i; for (i = 0; i < sizeof(HashTableSize) / sizeof(size_t); i++) { if (HashTableSize[i] > initialSize) { n = HashTableSize[i]; break; } } if (n == 0) PANIC("Table too large (%ld)", initialSize); self->map = NewTable(EntryT, n); } return self; }
// Creates a new instance of this class static void Create (const v8::FunctionCallbackInfo<v8::Value>& args) { auto isolate = args.GetIsolate (); v8::HandleScope scope (isolate); if (args.IsConstructCall ()) { // invoked as constructor: 'new Object(...)' auto module = new TDerivedLokiModule (); module->Wrap (args.This ()); args.GetReturnValue ().Set (args.This ()); } else { // invoked as a plain function 'Object(...)', turn into function call const int argc = 1; v8::Local<v8::Value> argv [argc] = {args [0]}; auto ctor = v8::Local<v8::Function>::New (isolate, constructor); args.GetReturnValue ().Set (ctor->NewInstance (argc, argv)); } }
//------------------------------------------------------------------------------- // //------------------------------------------------------------------------------- void tDataSourcesDialog::CreateActions() { /* Create these in order of importance. As many as possible will be added to the softkey bar in this order */ m_pSelectAct = new tAction( tr( "Select" ), this ); Connect( m_pSelectAct, SIGNAL( triggered() ), this, SLOT( Select() ) ); m_ActionList << m_pSelectAct; m_pConfigureAct = new tAction( tr( "Configure device" ), this ); Connect( m_pConfigureAct, SIGNAL( triggered() ), this, SLOT( ConfigureDevice() ) ); m_ActionList << m_pConfigureAct; QString scopeName = tProductSettings::Instance().FullSimnetAllowed() ? tr( "Group", "The extent or effective range of a selection or setting" ) : tr( "Scope", "The extent or effective range of a selection or setting" ); m_pScopeAct = new tListAction( scopeName, QStringList(), 0, Action::AutoShowPopup, this ); SetScopeList( m_pScopeAct, true, true, true ); Connect( m_pScopeAct, SIGNAL( ValueFinalised( int ) ), this, SLOT( OnScopeChanged( int ) ) ); if (tHAL::Instance()->FeaturePresent(tHAL::ePF_NMEA2000) == true) { m_ActionList << m_pScopeAct; } m_pRenameAct = new tAction( tr( "Rename" ), this ); Connect( m_pRenameAct, SIGNAL( triggered() ), this, SLOT( RenameInst() ) ); m_ActionList << m_pRenameAct; m_pNewInstanceAct = new tAction( tr( "New" ), this ); Connect( m_pNewInstanceAct, SIGNAL( triggered() ), this, SLOT( NewInstance() ) ); m_ActionList << m_pNewInstanceAct; m_pRemoveAct = new tAction( tr( "Remove" ), this ); Connect( m_pRemoveAct, SIGNAL( triggered() ), this, SLOT( RemoveInst() ) ); m_ActionList << m_pRemoveAct; QStringList numEnginesList = NumericStringList( 8 ); m_pEngineNumSetAct = new tListAction( tr("Number of Engines"), numEnginesList, 0, Action::AutoShowPopup, this); Connect( m_pEngineNumSetAct, SIGNAL( ValueFinalised( int ) ), this, SLOT( OnUINumEnginesChanged( int ) ) ); m_ActionList << m_pEngineNumSetAct; m_pTransNumSetAct = new tListAction( tr("Number of Transmissions"), numEnginesList, 0, Action::AutoShowPopup, this); Connect( m_pTransNumSetAct, SIGNAL( ValueFinalised( int ) ), this, SLOT( OnUINumTransChanged( int ) ) ); m_ActionList << m_pTransNumSetAct; QStringList numTanksList = NumericStringList( 5 ); m_pTankNumSetAct = new tListAction( tr("Number of Tanks"), numTanksList, 0, Action::AutoShowPopup, this); Connect( m_pTankNumSetAct, SIGNAL( ValueFinalised( int ) ), this, SLOT( OnUINumTanksChanged( int ) ) ); m_ActionList << m_pTankNumSetAct; QStringList numTrimTabsList = NumericStringList( 3 ); m_pTrimTabsNumSetAct = new tListAction( tr("Number of Trim Tabs"), numTrimTabsList, 0, Action::AutoShowPopup, this); Connect( m_pTrimTabsNumSetAct, SIGNAL( ValueFinalised( int ) ), this, SLOT( OnNumTrimTabsChanged( int ) ) ); m_ActionList << m_pTrimTabsNumSetAct; if( tProductSettings::Instance().FullSimnetAllowed() ) { m_pAutoSelectAct = new tAction( tr( "Auto Select" ), this ); Connect( m_pAutoSelectAct, SIGNAL( triggered() ), this, SLOT( OnAutoSelect() ) ); if (tHAL::Instance()->FeaturePresent(tHAL::ePF_NMEA2000) == true) { m_ActionList << m_pAutoSelectAct; } } else { m_pAutoConfigureAct = new tAction( tr( "Auto Configure" ), this ); Connect( m_pAutoConfigureAct, SIGNAL( triggered() ), this, SLOT( AutoConfigure() ) ); if (tHAL::Instance()->FeaturePresent(tHAL::ePF_NMEA2000) == true) { m_ActionList << m_pAutoConfigureAct; } } m_pGlobalResetAct = new tAction( tr( "Reset Global" ), this ); Connect( m_pGlobalResetAct, SIGNAL( triggered() ), this, SLOT( ResetGlobal() ) ); if (tHAL::Instance()->FeaturePresent(tHAL::ePF_NMEA2000) == true) { m_ActionList << m_pGlobalResetAct; } m_pLocalResetAct = new tAction( tr( "Reset Local" ), this ); Connect( m_pLocalResetAct, SIGNAL( triggered() ), this, SLOT( ResetLocal() ) ); if (tHAL::Instance()->FeaturePresent(tHAL::ePF_NMEA2000) == true) { m_ActionList << m_pLocalResetAct; } // Add as many actions as possible to the softkey bar m_KeyList.clear(); for( int i = 0; (i < m_NumKeys - 1) && (i < m_ActionList.size()); i++ ) { m_KeyList << m_ActionList[i]; } if ( HasTitleCloseButton() == false ) { m_pCloseAct = new tAction( tr( "Close", "Text of the exit dialog button." ), this ); Connect( m_pCloseAct, SIGNAL( triggered() ), this, SIGNAL( CloseRequested() ) ); m_KeyList << m_pCloseAct; } // NSW-10765 // Change what actions are displayed for Cougar // This should be done a better way - this will do for now. // // Configure Device // Scope // Rename // New // Remove // Auto Configure // Reset -> Sub menu // Global // Local if( tProductSettings::Instance().GetProductFamily() == tProductSettings::HDSGen2TouchFamily || tProductSettings::Instance().GetProductFamily() == tProductSettings::HDSGen3TouchFamily ) { m_KeyList.clear(); m_KeyList << m_pConfigureAct; m_KeyList << m_pScopeAct; m_KeyList << m_pRenameAct; m_KeyList << m_pNewInstanceAct; m_KeyList << m_pRemoveAct; m_KeyList << m_pAutoConfigureAct; QList<tAction*> resetSubActions; resetSubActions << m_pGlobalResetAct; resetSubActions << m_pLocalResetAct; m_pResetAct = new tAction( tr("Reset") ); m_pResetAct->SetSubActions(resetSubActions); m_ActionList << m_pSelectAct; m_KeyList << m_pResetAct; } }
TSharedPtr<FEnvQueryInstance> UEnvQueryManager::CreateQueryInstance(const UEnvQuery* Template, EEnvQueryRunMode::Type RunMode) { if (Template == nullptr || Template->Options.Num() == 0) { UE_CLOG(Template != nullptr && Template->Options.Num() == 0, LogEQS, Warning, TEXT("Query [%s] doesn't have any valid options!"), *Template->GetName()); return nullptr; } // try to find entry in cache FEnvQueryInstance* InstanceTemplate = NULL; for (int32 InstanceIndex = 0; InstanceIndex < InstanceCache.Num(); InstanceIndex++) { if (InstanceCache[InstanceIndex].Template->GetFName() == Template->GetFName() && InstanceCache[InstanceIndex].Instance.Mode == RunMode) { InstanceTemplate = &InstanceCache[InstanceIndex].Instance; break; } } // and create one if can't be found if (InstanceTemplate == NULL) { SCOPE_CYCLE_COUNTER(STAT_AI_EQS_LoadTime); // duplicate template in manager's world for BP based nodes UEnvQuery* LocalTemplate = (UEnvQuery*)StaticDuplicateObject(Template, this, *Template->GetName()); { // memory stat tracking: temporary variable will exist only inside this section FEnvQueryInstanceCache NewCacheEntry; NewCacheEntry.Template = LocalTemplate; NewCacheEntry.Instance.QueryName = LocalTemplate->GetName(); NewCacheEntry.Instance.Mode = RunMode; const int32 Idx = InstanceCache.Add(NewCacheEntry); InstanceTemplate = &InstanceCache[Idx].Instance; } // NOTE: We must iterate over this from 0->Num because we are copying the options from the template into the // instance, and order matters! Since we also may need to remove invalid or null options, we must decrement // the iteration pointer when doing so to avoid problems. for (int32 OptionIndex = 0; OptionIndex < LocalTemplate->Options.Num(); ++OptionIndex) { UEnvQueryOption* MyOption = LocalTemplate->Options[OptionIndex]; if (MyOption == nullptr || MyOption->Generator == nullptr || MyOption->Generator->ItemType == nullptr) { UE_LOG(LogEQS, Error, TEXT("Trying to spawn a query with broken Template (generator:%s itemType:%s): %s, option %d"), MyOption ? (MyOption->Generator ? TEXT("ok") : TEXT("MISSING")) : TEXT("N/A"), (MyOption && MyOption->Generator) ? (MyOption->Generator->ItemType ? TEXT("ok") : TEXT("MISSING")) : TEXT("N/A"), *GetNameSafe(LocalTemplate), OptionIndex); LocalTemplate->Options.RemoveAt(OptionIndex, 1, false); --OptionIndex; // See note at top of for loop. We cannot iterate backwards here. continue; } UEnvQueryOption* LocalOption = (UEnvQueryOption*)StaticDuplicateObject(MyOption, this, TEXT("None")); UEnvQueryGenerator* LocalGenerator = (UEnvQueryGenerator*)StaticDuplicateObject(MyOption->Generator, this, TEXT("None")); LocalTemplate->Options[OptionIndex] = LocalOption; LocalOption->Generator = LocalGenerator; EEnvTestCost::Type HighestCost(EEnvTestCost::Low); TArray<UEnvQueryTest*> SortedTests = MyOption->Tests; TSubclassOf<UEnvQueryItemType> GeneratedType = MyOption->Generator->ItemType; for (int32 TestIndex = SortedTests.Num() - 1; TestIndex >= 0; TestIndex--) { UEnvQueryTest* TestOb = SortedTests[TestIndex]; if (TestOb == NULL || !TestOb->IsSupportedItem(GeneratedType)) { UE_LOG(LogEQS, Warning, TEXT("Query [%s] can't use test [%s] in option %d [%s], removing it"), *GetNameSafe(LocalTemplate), *GetNameSafe(TestOb), OptionIndex, *MyOption->Generator->OptionName); SortedTests.RemoveAt(TestIndex, 1, false); } else if (HighestCost < TestOb->Cost) { HighestCost = TestOb->Cost; } } if (SortedTests.Num() == 0) { UE_LOG(LogEQS, Warning, TEXT("Query [%s] doesn't have any tests in option %d [%s]"), *GetNameSafe(LocalTemplate), OptionIndex, *MyOption->Generator->OptionName); LocalTemplate->Options.RemoveAt(OptionIndex, 1, false); --OptionIndex; // See note at top of for loop. We cannot iterate backwards here. continue; } LocalOption->Tests.Reset(SortedTests.Num()); for (int32 TestIdx = 0; TestIdx < SortedTests.Num(); TestIdx++) { UEnvQueryTest* LocalTest = (UEnvQueryTest*)StaticDuplicateObject(SortedTests[TestIdx], this, TEXT("None")); LocalOption->Tests.Add(LocalTest); } // use locally referenced duplicates SortedTests = LocalOption->Tests; if (SortedTests.Num() && LocalGenerator->bAutoSortTests) { switch (RunMode) { case EEnvQueryRunMode::SingleResult: SortedTests.Sort(EnvQueryTestSort::FSingleResult(HighestCost)); break; case EEnvQueryRunMode::RandomBest5Pct: case EEnvQueryRunMode::RandomBest25Pct: case EEnvQueryRunMode::AllMatching: SortedTests.Sort(EnvQueryTestSort::FAllMatching()); break; default: { UEnum* RunModeEnum = FindObject<UEnum>(ANY_PACKAGE, TEXT("EEnvQueryRunMode")); UE_LOG(LogEQS, Warning, TEXT("Query [%s] can't be sorted for RunMode: %d [%s]"), *GetNameSafe(LocalTemplate), (int32)RunMode, RunModeEnum ? *RunModeEnum->GetEnumName(RunMode) : TEXT("??")); } } } CreateOptionInstance(LocalOption, SortedTests, *InstanceTemplate); } } if (InstanceTemplate->Options.Num() == 0) { return nullptr; } // create new instance TSharedPtr<FEnvQueryInstance> NewInstance(new FEnvQueryInstance(*InstanceTemplate)); return NewInstance; }
SceneT *NewScene() { SceneT *self = NewInstance(SceneT); self->objects = NewList(); return self; }
void Universe::InitializeGlobals() { set_vt_to_null(); # warning is _store_ptr sufficient? // //allocate nil object // VMObject* nil = new (GetHeap<HEAP_CLS>()) VMObject; nilObject = _store_ptr(nil); nil->SetClass((VMClass*) nil); metaClassClass = _store_ptr(NewMetaclassClass()); objectClass = _store_ptr(NewSystemClass()); nilClass = _store_ptr(NewSystemClass()); classClass = _store_ptr(NewSystemClass()); arrayClass = _store_ptr(NewSystemClass()); symbolClass = _store_ptr(NewSystemClass()); methodClass = _store_ptr(NewSystemClass()); integerClass = _store_ptr(NewSystemClass()); primitiveClass = _store_ptr(NewSystemClass()); stringClass = _store_ptr(NewSystemClass()); doubleClass = _store_ptr(NewSystemClass()); nil->SetClass(load_ptr(nilClass)); InitializeSystemClass(load_ptr(objectClass), nullptr, "Object"); InitializeSystemClass(load_ptr(classClass), load_ptr(objectClass), "Class"); InitializeSystemClass(load_ptr(metaClassClass), load_ptr(classClass), "Metaclass"); InitializeSystemClass(load_ptr(nilClass), load_ptr(objectClass), "Nil"); InitializeSystemClass(load_ptr(arrayClass), load_ptr(objectClass), "Array"); InitializeSystemClass(load_ptr(methodClass), load_ptr(arrayClass), "Method"); InitializeSystemClass(load_ptr(stringClass), load_ptr(objectClass), "String"); InitializeSystemClass(load_ptr(symbolClass), load_ptr(stringClass), "Symbol"); InitializeSystemClass(load_ptr(integerClass), load_ptr(objectClass), "Integer"); InitializeSystemClass(load_ptr(primitiveClass), load_ptr(objectClass), "Primitive"); InitializeSystemClass(load_ptr(doubleClass), load_ptr(objectClass), "Double"); // Fix up objectClass load_ptr(objectClass)->SetSuperClass((VMClass*) nil); obtain_vtables_of_known_classes(nil->GetClass()->GetName()); #if USE_TAGGING GlobalBox::updateIntegerBox(NewInteger(1)); #endif LoadSystemClass(load_ptr(objectClass)); LoadSystemClass(load_ptr(classClass)); LoadSystemClass(load_ptr(metaClassClass)); LoadSystemClass(load_ptr(nilClass)); LoadSystemClass(load_ptr(arrayClass)); LoadSystemClass(load_ptr(methodClass)); LoadSystemClass(load_ptr(symbolClass)); LoadSystemClass(load_ptr(integerClass)); LoadSystemClass(load_ptr(primitiveClass)); LoadSystemClass(load_ptr(stringClass)); LoadSystemClass(load_ptr(doubleClass)); blockClass = _store_ptr(LoadClass(SymbolForChars("Block"))); VMSymbol* trueClassName = SymbolForChars("True"); trueClass = _store_ptr(LoadClass(trueClassName)); trueObject = _store_ptr(NewInstance(load_ptr(trueClass))); VMSymbol* falseClassName = SymbolForChars("False"); falseClass = _store_ptr(LoadClass(falseClassName)); falseObject = _store_ptr(NewInstance(load_ptr(falseClass))); systemClass = _store_ptr(LoadClass(SymbolForChars("System"))); }
void Universe::initialize(long _argc, char** _argv) { #ifdef GENERATE_ALLOCATION_STATISTICS allocationStats["VMArray"] = {0,0}; #endif heapSize = 1 * 1024 * 1024; vector<StdString> argv = handleArguments(_argc, _argv); // remember file that was executed (for writing statistics) if (argv.size() > 0) bm_name = argv[0]; Heap<HEAP_CLS>::InitializeHeap(heapSize); interpreter = new Interpreter(); #if CACHE_INTEGER # warning is _store_ptr sufficient/correct here? // create prebuilt integers for (long it = INT_CACHE_MIN_VALUE; it <= INT_CACHE_MAX_VALUE; ++it) { prebuildInts[(unsigned long)(it - INT_CACHE_MIN_VALUE)] = _store_ptr(new (GetHeap<HEAP_CLS>()) VMInteger(it)); } #endif InitializeGlobals(); VMObject* systemObject = NewInstance(load_ptr(systemClass)); SetGlobal(SymbolForChars("nil"), load_ptr(nilObject)); SetGlobal(SymbolForChars("true"), load_ptr(trueObject)); SetGlobal(SymbolForChars("false"), load_ptr(falseObject)); SetGlobal(SymbolForChars("system"), systemObject); SetGlobal(SymbolForChars("System"), load_ptr(systemClass)); SetGlobal(SymbolForChars("Block"), load_ptr(blockClass)); symbolIfTrue = _store_ptr(SymbolForChars("ifTrue:")); symbolIfFalse = _store_ptr(SymbolForChars("ifFalse:")); VMMethod* bootstrapMethod = NewMethod(SymbolForChars("bootstrap"), 1, 0); bootstrapMethod->SetBytecode(0, BC_HALT); bootstrapMethod->SetNumberOfLocals(0); bootstrapMethod->SetMaximumNumberOfStackElements(2); bootstrapMethod->SetHolder(load_ptr(systemClass)); if (argv.size() == 0) { Shell* shell = new Shell(bootstrapMethod); shell->Start(); return; } /* only trace bootstrap if the number of cmd-line "-d"s is > 2 */ short trace = 2 - dumpBytecodes; if (!(trace > 0)) dumpBytecodes = 1; VMArray* argumentsArray = NewArrayFromStrings(argv); VMFrame* bootstrapFrame = interpreter->PushNewFrame(bootstrapMethod); bootstrapFrame->Push(systemObject); bootstrapFrame->Push(argumentsArray); VMInvokable* initialize = load_ptr(systemClass)->LookupInvokable( SymbolForChars("initialize:")); (*initialize)(bootstrapFrame); // reset "-d" indicator if (!(trace > 0)) dumpBytecodes = 2 - trace; interpreter->Start(); }
// static XPCNativeSet* XPCNativeSet::GetNewOrUsed(XPCCallContext& ccx, nsIClassInfo* classInfo) { AutoMarkingNativeSetPtr set(ccx); XPCJSRuntime* rt = ccx.GetRuntime(); ClassInfo2NativeSetMap* map = rt->GetClassInfo2NativeSetMap(); if (!map) return nsnull; { // scoped lock XPCAutoLock lock(rt->GetMapLock()); set = map->Find(classInfo); } if (set) return set; nsIID** iidArray = nsnull; AutoMarkingNativeInterfacePtrArrayPtr interfaceArray(ccx); PRUint32 iidCount = 0; if (NS_FAILED(classInfo->GetInterfaces(&iidCount, &iidArray))) { // Note: I'm making it OK for this call to fail so that one can add // nsIClassInfo to classes implemented in script without requiring this // method to be implemented. // Make sure these are set correctly... iidArray = nsnull; iidCount = 0; } NS_ASSERTION((iidCount && iidArray) || !(iidCount || iidArray), "GetInterfaces returned bad array"); // !!! from here on we only exit through the 'out' label !!! if (iidCount) { AutoMarkingNativeInterfacePtrArrayPtr arr(ccx, new XPCNativeInterface*[iidCount], iidCount, true); if (!arr) goto out; interfaceArray = arr; XPCNativeInterface** currentInterface = interfaceArray; nsIID** currentIID = iidArray; PRUint16 interfaceCount = 0; for (PRUint32 i = 0; i < iidCount; i++) { nsIID* iid = *(currentIID++); if (!iid) { NS_ERROR("Null found in classinfo interface list"); continue; } XPCNativeInterface* iface = XPCNativeInterface::GetNewOrUsed(ccx, iid); if (!iface) { // XXX warn here continue; } *(currentInterface++) = iface; interfaceCount++; } if (interfaceCount) { set = NewInstance(ccx, interfaceArray, interfaceCount); if (set) { NativeSetMap* map2 = rt->GetNativeSetMap(); if (!map2) goto out; XPCNativeSetKey key(set, nsnull, 0); { // scoped lock XPCAutoLock lock(rt->GetMapLock()); XPCNativeSet* set2 = map2->Add(&key, set); if (!set2) { NS_ERROR("failed to add our set!"); DestroyInstance(set); set = nsnull; goto out; } if (set2 != set) { DestroyInstance(set); set = set2; } } } } else set = GetNewOrUsed(ccx, &NS_GET_IID(nsISupports)); } else set = GetNewOrUsed(ccx, &NS_GET_IID(nsISupports)); if (set) { // scoped lock XPCAutoLock lock(rt->GetMapLock()); #ifdef DEBUG XPCNativeSet* set2 = #endif map->Add(classInfo, set); NS_ASSERTION(set2, "failed to add our set!"); NS_ASSERTION(set2 == set, "hashtables inconsistent!"); } out: if (iidArray) NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(iidCount, iidArray); if (interfaceArray) delete [] interfaceArray.get(); return set; }
TreeT *NewTree(PtrT data) { TreeT *tree = NewInstance(TreeT); /* TODO: Delete it recursively. */ NodeInitGuard(GetChildren(tree)); tree->data = data; return data; }