std::string get_string(IDxDiagContainer *containerp, WCHAR *wszPropName) { WCHAR wszPropValue[256]; get_wstring(containerp, wszPropName, wszPropValue, 256); return utf16str_to_utf8str(wszPropValue); }
void Credits::load_item(int i) { if (m_item_loaded == i) return; switch (i) { case 0: m_header.setString(L"Max Bäz-Dölle"); m_text.setString(get_wstring(_("credits_text0"))); m_sign.setString(L"„"); break; case 1: m_header.setString("Robert Knauer"); m_text.setString(get_wstring(_("credits_text1"))); m_sign.setString(L"„"); break; case 2: m_header.setString("Robert Falkenstein"); m_text.setString(get_wstring(_("credits_text2"))); m_sign.setString(L"„"); break; case 3: m_header.setString("Vasco Lehmann"); m_text.setString(get_wstring(_("credits_text3"))); m_sign.setString(L"„"); break; case 4: m_header.setString("Robert Worm"); m_text.setString(get_wstring(_("credits_text4"))); m_sign.setString(L"„"); break; case 5: m_header.setString(L"Grünlers Tür"); m_text.setString(get_wstring(_("credits_text5"))); m_sign.setString("!"); break; default: m_header.setString(get_wstring(_("credits_header"))); m_text.setString(get_wstring(_("credits_stdtext"))); m_sign.setString("!"); } m_item_loaded = i; }
static ast::Exp* get_exp(void) { ast::Exp* exp; // std::cerr << "get_exp at pos " << (buf - initial_buf) << std::endl; int code = get_uint8(); // std::cerr << " code = " << code << std::endl; Location *loc = get_location(); int is_verbose = get_bool(); int is_break = get_bool(); int is_breakable = get_bool(); int is_return = get_bool(); int is_returnable = get_bool(); int is_continue = get_bool(); int is_continuable = get_bool(); switch(code){ case 1: { std::list<ast::Exp *>* l_body = get_exps(); exp = new ast::SeqExp(*loc, *l_body); break; } case 2: { std::wstring* s = get_wstring(); exp = new ast::StringExp(*loc, *s); break; } case 3: { std::wstring* s = get_wstring(); exp = new ast::CommentExp(*loc, s); break; } case 4: { ast::IntExp::Prec prec = get_IntExp_Prec(); int value = get_int32(); exp = new ast::IntExp(*loc, prec, value); break; } case 5: { double d = get_double(); exp = new ast::FloatExp(*loc, d); break; } case 6: { double d = get_double(); exp = new ast::DoubleExp(*loc,d); break; } case 7: { bool b = get_bool(); exp = new ast::BoolExp(*loc, b); break; } case 8: { exp = new ast::NilExp(*loc); break; } case 9: { symbol::Symbol *name = get_Symbol(); exp = new ast::SimpleVar(*loc, *name); break; } case 10: { exp = new ast::ColonVar(*loc); break; } case 11: { exp = new ast::DollarVar(*loc); break; } case 12: { std::list<ast::Var*>* vars = get_vars(); exp = new ast::ArrayListVar(*loc, *vars); break; } case 13: { ast::Exp *head = get_exp(); ast::Exp *tail = get_exp(); exp = new ast::FieldExp(*loc, *head, *tail); break; } case 14: { ast::IfExp::Kind kind = get_IfExp_Kind(); bool has_else = get_bool(); ast::Exp* test = get_exp(); ast::Exp* _then = get_exp(); ast::IfExp* ifexp; if( has_else ){ ast::Exp* _else = get_exp(); ifexp = new ast::IfExp(*loc, *test, *_then, *_else); } else { ifexp = new ast::IfExp(*loc, *test, *_then); } ifexp->kind_set(kind); exp = ifexp; break; } case 15: { Location *try_location = get_location(); Location *catch_location = get_location(); std::list<ast::Exp *>* try_exps = get_exps(); std::list<ast::Exp *>* catch_exps = get_exps(); ast::SeqExp *_try = new ast::SeqExp(*try_location, *try_exps); ast::SeqExp *_catch = new ast::SeqExp(*catch_location, *catch_exps); exp = new ast::TryCatchExp(*loc, *_try, *_catch); break; } case 16: { ast::Exp* test = get_exp(); ast::Exp* body = get_exp(); exp = new ast::WhileExp(*loc, *test, *body); break; } case 17: { Location *vardec_location = get_location(); ast::VarDec* vardec = get_VarDec(vardec_location); ast::Exp* body = get_exp(); exp = new ast::ForExp(*loc, *vardec, *body); break; } case 18: { exp = new ast::BreakExp(*loc); break; } case 19: { exp = new ast::ContinueExp(*loc); break; } case 20: { bool is_global = get_bool(); if( is_global ){ exp = new ast::ReturnExp(*loc); } else { ast::Exp* returnExp_exp = get_exp(); exp = new ast::ReturnExp(*loc, returnExp_exp); } break; } case 21: { bool has_default = get_bool(); ast::SeqExp * default_case = NULL; if( has_default ){ Location *default_case_location = get_location(); std::list<ast::Exp *>* default_case_exps = get_exps(); default_case = new ast::SeqExp(*default_case_location, *default_case_exps); } ast::Exp* select = get_exp(); int nitems = get_uint32(); std::list<ast::CaseExp*> *cases = new std::list<ast::CaseExp*>; for(int i = 0; i < nitems; i++){ Location *case_location = get_location(); Location *body_location = get_location(); ast::Exp* test = get_exp(); std::list<ast::Exp *>* body_exps = get_exps(); ast::SeqExp *body = new ast::SeqExp(*body_location, *body_exps); ast::CaseExp* _case = new ast::CaseExp(*case_location, *test, *body); cases->push_back(_case); } if( has_default ){ exp = new ast::SelectExp(*loc, *select, *cases, *default_case); } else { exp = new ast::SelectExp(*loc, *select, *cases); } break; } /* SHOULD NEVER HAPPEN case 22: { exp = new ast::CaseExp(*loc); break; } */ case 23: { std::list<ast::MatrixLineExp *>* lines = get_MatrixLines(); exp = new ast::CellExp(*loc, *lines); break; } case 24: { std::list<ast::Exp *>* exps = get_exps(); exp = new ast::ArrayListExp(*loc, *exps); break; } case 25: { std::list<ast::Exp *>* exps = get_exps(); exp = new ast::AssignListExp(*loc, *exps); break; } case 26: { ast::Exp* notexp = get_exp(); exp = new ast::NotExp(*loc, *notexp); break; } case 27: { ast::TransposeExp::Kind kind = get_TransposeExp_Kind(); ast::Exp* _exp = get_exp(); exp = new ast::TransposeExp(*loc, *_exp, kind); break; } case 28: { exp = get_VarDec(loc); break; } case 29: { symbol::Symbol* name = get_Symbol(); Location *args_loc = get_location(); Location *returns_loc = get_location(); ast::Exp* body = get_exp(); std::list <ast::Var*>* args_list = get_vars(); std::list <ast::Var*>* returns_list = get_vars(); ast::ArrayListVar *args = new ast::ArrayListVar(*args_loc, *args_list); ast::ArrayListVar *returns = new ast::ArrayListVar(*returns_loc, *returns_list); exp = new ast::FunctionDec(*loc, *name, *args, *returns, *body); break; } case 30: { ast::Exp* _start = get_exp(); ast::Exp* _step = get_exp(); ast::Exp* _end = get_exp(); exp = new ast::ListExp(*loc, *_start, *_step, *_end); break; } case 31: { ast::Exp* _left = get_exp(); ast::Exp* _right = get_exp(); exp = new ast::AssignExp(*loc, *_left, *_right); break; } case 32: { ast::OpExp::Kind kind = get_OpExp_Kind(); ast::OpExp::Oper oper = get_OpExp_Oper(); ast::Exp *left = get_exp(); ast::Exp *right = get_exp(); ast::OpExp *_opexp = new ast::OpExp(*loc, *left, oper, *right); exp = _opexp; _opexp->kind_set(kind); break; } case 33: { ast::OpExp::Kind kind = get_OpExp_Kind(); ast::OpExp::Oper oper = get_OpExp_Oper(); ast::Exp *left = get_exp(); ast::Exp *right = get_exp(); ast::LogicalOpExp *_opexp = new ast::LogicalOpExp(*loc, *left, oper, *right); exp = _opexp; _opexp->kind_set(kind); break; } case 34: { std::list<ast::MatrixLineExp *>* lines = get_MatrixLines(); exp = new ast::MatrixExp(*loc, *lines); break; } case 35: { ast::Exp* name = get_exp(); std::list<ast::Exp *> * args = get_exps(); exp = new ast::CallExp(*loc, *name, *args); break; } /* SHOULD NEVER HAPPEN case 36: { exp = new ast::MatrixLineExp(*loc); break; } */ case 37: { ast::Exp* name = get_exp(); std::list<ast::Exp *>* args = get_exps(); exp = new ast::CellCallExp(*loc, *name, *args); break; } default: std::cerr << "Unknown code " << code << std::endl; exit(2); } exp->set_verbose(is_verbose); if(is_break) exp->break_set(); if(is_breakable) exp->breakable_set(); if(is_return) exp->return_set(); if(is_returnable) exp->returnable_set(); if(is_continue) exp->continue_set(); if(is_continuable) exp->continuable_set(); return exp; }
static symbol::Symbol* get_Symbol(void) { std::wstring* s = get_wstring(); return new symbol::Symbol(*s); }
BOOL LLDXHardware::getInfo(BOOL vram_only) { LLTimer hw_timer; BOOL ok = FALSE; HRESULT hr; hr = CoInitialize(NULL); if (FAILED(hr)) { LL_WARNS("AppInit") << "COM library initialization failed!" << LL_ENDL; gWriteDebug("COM library initialization failed!\n"); return FALSE; } IDxDiagProvider *dx_diag_providerp = NULL; IDxDiagContainer *dx_diag_rootp = NULL; IDxDiagContainer *devices_containerp = NULL; // IDxDiagContainer *system_device_containerp= NULL; IDxDiagContainer *device_containerp = NULL; IDxDiagContainer *file_containerp = NULL; IDxDiagContainer *driver_containerp = NULL; // CoCreate a IDxDiagProvider* LL_DEBUGS("AppInit") << "CoCreateInstance IID_IDxDiagProvider" << LL_ENDL; hr = CoCreateInstance(CLSID_DxDiagProvider, NULL, CLSCTX_INPROC_SERVER, IID_IDxDiagProvider, (LPVOID*) &dx_diag_providerp); if (FAILED(hr)) { LL_WARNS("AppInit") << "No DXDiag provider found! DirectX 9 not installed!" << LL_ENDL; gWriteDebug("No DXDiag provider found! DirectX 9 not installed!\n"); goto LCleanup; } if (SUCCEEDED(hr)) // if FAILED(hr) then dx9 is not installed { // Fill out a DXDIAG_INIT_PARAMS struct and pass it to IDxDiagContainer::Initialize // Passing in TRUE for bAllowWHQLChecks, allows dxdiag to check if drivers are // digital signed as logo'd by WHQL which may connect via internet to update // WHQL certificates. DXDIAG_INIT_PARAMS dx_diag_init_params; ZeroMemory(&dx_diag_init_params, sizeof(DXDIAG_INIT_PARAMS)); dx_diag_init_params.dwSize = sizeof(DXDIAG_INIT_PARAMS); dx_diag_init_params.dwDxDiagHeaderVersion = DXDIAG_DX9_SDK_VERSION; dx_diag_init_params.bAllowWHQLChecks = TRUE; dx_diag_init_params.pReserved = NULL; LL_DEBUGS("AppInit") << "dx_diag_providerp->Initialize" << LL_ENDL; hr = dx_diag_providerp->Initialize(&dx_diag_init_params); if(FAILED(hr)) { goto LCleanup; } LL_DEBUGS("AppInit") << "dx_diag_providerp->GetRootContainer" << LL_ENDL; hr = dx_diag_providerp->GetRootContainer( &dx_diag_rootp ); if(FAILED(hr) || !dx_diag_rootp) { goto LCleanup; } HRESULT hr; // Get display driver information LL_DEBUGS("AppInit") << "dx_diag_rootp->GetChildContainer" << LL_ENDL; hr = dx_diag_rootp->GetChildContainer(L"DxDiag_DisplayDevices", &devices_containerp); if(FAILED(hr) || !devices_containerp) { goto LCleanup; } // Get device 0 LL_DEBUGS("AppInit") << "devices_containerp->GetChildContainer" << LL_ENDL; hr = devices_containerp->GetChildContainer(L"0", &device_containerp); if(FAILED(hr) || !device_containerp) { goto LCleanup; } DWORD vram = 0; WCHAR deviceID[512]; get_wstring(device_containerp, L"szDeviceID", deviceID, 512); if (SUCCEEDED(GetVideoMemoryViaWMI(deviceID, &vram))) { mVRAM = vram/(1024*1024); } else { // Get the English VRAM string std::string ram_str = get_string(device_containerp, L"szDisplayMemoryEnglish"); // We don't need the device any more SAFE_RELEASE(device_containerp); // Dump the string as an int into the structure char *stopstring; mVRAM = strtol(ram_str.c_str(), &stopstring, 10); LL_INFOS("AppInit") << "VRAM Detected: " << mVRAM << " DX9 string: " << ram_str << LL_ENDL; } if (vram_only) { ok = TRUE; goto LCleanup; } /* for now, we ONLY do vram_only the rest of this is commented out, to ensure no-one is tempted to use it // Now let's get device and driver information // Get the IDxDiagContainer object called "DxDiag_SystemDevices". // This call may take some time while dxdiag gathers the info. DWORD num_devices = 0; WCHAR wszContainer[256]; LL_DEBUGS("AppInit") << "dx_diag_rootp->GetChildContainer DxDiag_SystemDevices" << LL_ENDL; hr = dx_diag_rootp->GetChildContainer(L"DxDiag_SystemDevices", &system_device_containerp); if (FAILED(hr)) { goto LCleanup; } hr = system_device_containerp->GetNumberOfChildContainers(&num_devices); if (FAILED(hr)) { goto LCleanup; } LL_DEBUGS("AppInit") << "DX9 iterating over devices" << LL_ENDL; S32 device_num = 0; for (device_num = 0; device_num < (S32)num_devices; device_num++) { hr = system_device_containerp->EnumChildContainerNames(device_num, wszContainer, 256); if (FAILED(hr)) { goto LCleanup; } hr = system_device_containerp->GetChildContainer(wszContainer, &device_containerp); if (FAILED(hr) || device_containerp == NULL) { goto LCleanup; } std::string device_name = get_string(device_containerp, L"szDescription"); std::string device_id = get_string(device_containerp, L"szDeviceID"); LLDXDevice *dxdevicep = new LLDXDevice; dxdevicep->mName = device_name; dxdevicep->mPCIString = device_id; mDevices[dxdevicep->mPCIString] = dxdevicep; // Split the PCI string based on vendor, device, subsys, rev. std::string str(device_id); typedef boost::tokenizer<boost::char_separator<char> > tokenizer; boost::char_separator<char> sep("&\\", "", boost::keep_empty_tokens); tokenizer tokens(str, sep); tokenizer::iterator iter = tokens.begin(); S32 count = 0; BOOL valid = TRUE; for (;(iter != tokens.end()) && (count < 3);++iter) { switch (count) { case 0: if (strcmp(iter->c_str(), "PCI")) { valid = FALSE; } break; case 1: dxdevicep->mVendorID = iter->c_str(); break; case 2: dxdevicep->mDeviceID = iter->c_str(); break; default: // Ignore it break; } count++; } // Now, iterate through the related drivers hr = device_containerp->GetChildContainer(L"Drivers", &driver_containerp); if (FAILED(hr) || !driver_containerp) { goto LCleanup; } DWORD num_files = 0; hr = driver_containerp->GetNumberOfChildContainers(&num_files); if (FAILED(hr)) { goto LCleanup; } S32 file_num = 0; for (file_num = 0; file_num < (S32)num_files; file_num++ ) { hr = driver_containerp->EnumChildContainerNames(file_num, wszContainer, 256); if (FAILED(hr)) { goto LCleanup; } hr = driver_containerp->GetChildContainer(wszContainer, &file_containerp); if (FAILED(hr) || file_containerp == NULL) { goto LCleanup; } std::string driver_path = get_string(file_containerp, L"szPath"); std::string driver_name = get_string(file_containerp, L"szName"); std::string driver_version = get_string(file_containerp, L"szVersion"); std::string driver_date = get_string(file_containerp, L"szDatestampEnglish"); LLDXDriverFile *dxdriverfilep = new LLDXDriverFile; dxdriverfilep->mName = driver_name; dxdriverfilep->mFilepath= driver_path; dxdriverfilep->mVersionString = driver_version; dxdriverfilep->mVersion.set(driver_version); dxdriverfilep->mDateString = driver_date; dxdevicep->mDriverFiles[driver_name] = dxdriverfilep; SAFE_RELEASE(file_containerp); } SAFE_RELEASE(device_containerp); } */ } // dumpDevices(); ok = TRUE; LCleanup: if (!ok) { LL_WARNS("AppInit") << "DX9 probe failed" << LL_ENDL; gWriteDebug("DX9 probe failed\n"); } SAFE_RELEASE(file_containerp); SAFE_RELEASE(driver_containerp); SAFE_RELEASE(device_containerp); SAFE_RELEASE(devices_containerp); SAFE_RELEASE(dx_diag_rootp); SAFE_RELEASE(dx_diag_providerp); CoUninitialize(); return ok; }