BOOL CPropSheet::OnInitDialog() { BOOL bResult = CPropertySheet::OnInitDialog(); // TODO: Add your specialized code here CRect rect, tabrect;// = CRect (800, 440, 950, 645);//, tabrect; int width; //Get button sizes and positions GetDlgItem(IDCANCEL)->GetWindowRect(rect); GetTabControl()->GetWindowRect(tabrect); ScreenToClient(rect); ScreenToClient(tabrect); //New button - width, height and Y-coordiate of IDOK // - X-coordinate of tab control width = rect.Width(); rect.left = tabrect.left; rect.right = tabrect.left + width; CString FeedbackChoice = GetGlobal("FeedbackChoice"); CString FeedbackButtonName = GetGlobal("FeedbackButtonName"); if (FeedbackChoice.Compare("Yes") == 0) { //Create new "Add" button and set standard font m_ButtonCopy.Create(FeedbackButtonName, BS_PUSHBUTTON|WS_CHILD|WS_VISIBLE|WS_TABSTOP, rect, this, IDC_FEEDBACK_BUTTON); m_ButtonCopy.SetFont(GetFont()); } else ; SetIcon(AfxGetApp()->LoadIcon(IDR_MAINFRAME), FALSE); SetIcon(AfxGetApp()->LoadIcon(IDR_MAINFRAME), TRUE); return bResult; }
U1 System::UpdataSurface( ITexture* pSrcTexture,RECT* rect,ITexture* pDstTexture,POINT& p ){ if(GetGlobal().m_bReseting) return false; Texture* pSrc = dynamic_cast<Texture*>(pSrcTexture); Texture* pDst = dynamic_cast<Texture*>(pDstTexture); if(pSrc==NULL || pDst==NULL) return false; DxTexture* pSrcTex = pSrc->GetObjectT<DxTexture*>(); DxTexture* pDstTex = pDst->GetObjectT<DxTexture*>(); if(pSrcTex==NULL || pDstTex==NULL) return false; DxSurface* pSrcSurface = NULL; DxSurface* pDstSurface = NULL; pSrcTex->GetSurfaceLevel(0,&pSrcSurface); pDstTex->GetSurfaceLevel(0,&pDstSurface); if(pSrcSurface==NULL || pDstSurface==NULL) return false; GetGlobal().m_pDevice->UpdateSurface(pSrcSurface,rect,pDstSurface,&p); SAF_R(pSrcSurface); SAF_R(pDstSurface); return true; }
void CreateRshell (void) { CString root = GetGlobal("Root"); CString config = GetGlobal("CustomizationList"); CString destPath = root + "\\Configs\\" + config + "\\Rshell"; CWnd Mywnd; // Mywnd.MessageBox(CString(iniFilePath),iniFilePath,MB_OK); // Mywnd.MessageBox(CString(customizationPath),customizationPath,MB_OK); ifstream part1("part1.ini"); ifstream part2("part2.ini"); _mkdir (destPath); CString Rsh = destPath + "\\" +"rshell.ini"; // FILE* rshell = theApp.OpenAFile(CDdir +"rshell.ini", "w"); ofstream rshell(Rsh); CString fvalue1=GetGlobal("ShellTitleText"); CString fvalue2=GetGlobal("ShellBgBitmap"); // char *fvalue3=GetGlobal("dialog_title_text"); CString fvalue4=GetGlobal("ShellInstallTextFile"); char jsprefname[200]; if(!part1) { cout << "cannot open the file \n"; } while (!part1.eof()) { part1.getline(jsprefname,200); // fprintf(globs, jsprefname); // fprintf(globs, "\n"); rshell <<jsprefname<<"\n"; } rshell <<"caption="<<fvalue1<<"\n"; rshell <<"bk_bitmap="<<fvalue2<<"\n"; rshell <<"button2_cmdline="<<fvalue4<<"\n"; // rshell <<"dialog_title_txt="<<fvalue3<<"\n"; if(!part2) { cout << "cannot open the file \n"; } while (!part2.eof()) { part2.getline(jsprefname,200); rshell <<jsprefname<<"\n"; } rshell.close(); }
Air::U1 System::DrawOpt( const DrawOption& opt ) { IDirect3DDevice9* pDev = GetGlobal().m_pDevice; D3DPRIMITIVETYPE drawType = (D3DPRIMITIVETYPE)opt.m_DrawType; if(opt.m_uiInstanceCount!=0){ SetStreamSourceFreq( 0, D3DSTREAMSOURCE_INDEXEDDATA | opt.m_uiInstanceCount); SetStreamSourceFreq( 1, D3DSTREAMSOURCE_INSTANCEDATA | 1ul ); } switch(opt.m_DrawFuncType){ case Draw::FUNC_TYPE_DP:{ pDev->DrawPrimitive(drawType, opt.m_uiBaseVertexIndex, opt.m_uiFaceCount); break;} case Draw::FUNC_TYPE_DIP:{ pDev->DrawIndexedPrimitive(drawType, opt.m_uiBaseVertexIndex, 0, opt.m_uiVertexCount, opt.m_uiStartIndex, opt.m_uiFaceCount); break;} } if(opt.m_uiInstanceCount!=0){ SetStreamSourceFreq(0,1); SetStreamSourceFreq(1,1); } return true; }
static void prog_main_setparams(qc_program_t *prog) { size_t i; qcany_t *arg; for (i = 0; i < vec_size(main_params); ++i) { arg = GetGlobal(OFS_PARM0 + 3*i); arg->vector[0] = 0; arg->vector[1] = 0; arg->vector[2] = 0; switch (main_params[i].vtype) { case TYPE_VECTOR: (void)util_sscanf(main_params[i].value, " %f %f %f ", &arg->vector[0], &arg->vector[1], &arg->vector[2]); break; case TYPE_FLOAT: arg->_float = atof(main_params[i].value); break; case TYPE_STRING: arg->string = prog_tempstring(prog, main_params[i].value); break; default: fprintf(stderr, "error: unhandled parameter type: %i\n", main_params[i].vtype); break; } } }
void CPropSheet::OnButtonCopy() { CString Feedback = GetGlobal("Feedback"); theInterpreter->OpenBrowser((char*)(LPCTSTR)Feedback); }
//*,{ // "type":"function", // "name":"setConfig(callback,[filename])", // "text":"读取或设置配置文件,配置文件是一个 Json 格式的文本文件,可以是 utf-8 获取 ansi 编码。", // "param":[ // { // "type":"function", // "name":"callback(cfg)", // "text":"setConfig 函数如果成功,会触发这个回调函数,cfg 是一个对象,它的属性就是配置内容,对这个对象的任何更改最后都会作为 Json 格式保存到配置文件。" // }, // { // "type":"string", // "name":"[filename]", // "text":"配置文件名,缺省是和脚本同路径同名的一个后缀为“.json”的文本文件,如果指定了文件名,则读取和保存对应的文件。" // } // ], // "return":{ // "type":"boolean", // "text":"如果成功打开了配置文件,函数返回 true,否则返回 undefined。" // } //}//* Handle<Value> setConfig(const Arguments& args){ HandleScope stack; while(true){ if(args.Length()<1) break; if(!args[0]->IsFunction()) break; cs::String file; if(args.Length()>1) GetString(args[1],file); cs::Config cfg(file); cs::Json* json = cfg.Lock(); if(!json) break; json->ToString(file,false); Handle<Object> glb = GetGlobal(); Handle<Object> JSON = glb->Get(NEW_STR(JSON))->ToObject(); Handle<Function> parse = Handle<Function>::Cast(JSON->Get(NEW_STR(parse))); Handle<Function> stringify = Handle<Function>::Cast(JSON->Get(NEW_STR(stringify))); Handle<Function> callback = Handle<Function>::Cast(args[0]); Handle<Value> argv[3]; argv[0] = NEW_WSTR(file.Handle()); Handle<Value> v = parse->Call(JSON,1,argv); if(v.IsEmpty()||!v->IsObject()) v = Object::New(); argv[0] = v; CallFunc(glb,callback,1,argv); v = stringify->Call(JSON,1,argv); GetString(v,file); json->Parse(file); return True(); } return Undefined(); }
bool System::RepetitionRun(){ Device9::Info info = GetGlobalSetting().m_DisplayParam; Device9*& pDevice = GetGlobal().m_pRenderDevice; pDevice = new Device9(&info); pDevice->Create(); MSG msg; ::ZeroMemory(&msg, sizeof(MSG)); SetCursor(LoadCursor(0, IDC_ARROW)); while(!m_bExit){ while(!m_bPause){ if(::PeekMessage(&msg, 0, 0, 0, PM_REMOVE)){ ::TranslateMessage(&msg); ::DispatchMessage(&msg); }else{ pDevice->RenderOneFrame(); } m_bHasPause = false; if(msg.message == WM_QUIT){ GetGlobalSetting().m_bQuit = true; m_bPause = true; } } m_bHasPause = true; Sleep(10); } pDevice->Destroy(); SAF_D(pDevice); return true; }
Handle<Value> CreateJSResult(v8::Handle<v8::Context>& ctx, const Quaternion& src) { Handle<Function> quat_constructor = FunctionCast( ObjectCast(GetGlobal(ctx, JSSystemNames::UTIL_OBJECT_NAME))->Get(JS_STRING(Quaternion)) ); Handle<Object> result = quat_constructor->NewInstance(); QuaternionFill(result, src); return result; }
static void singlevar (LexState *ls, expdesc *var) { TString *varname = str_checkname(ls); FuncState *fs = ls->fs; if (singlevaraux(fs, varname, var, 1) == VGLOBAL) { var->u.s.info = luaK_stringK(fs, varname); /* info points to global name */ #ifdef LUA_UTILITIES_NET GetGlobal(varname, ls); #endif } }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Operand* ConstantFolder::LoadFromGlobal(Operand* op, const Type* loadType, __int64 offset) { // If the operand is not a reference to a global variable then we can't do anything, // even if the variable may be a constant. auto variableRef = op->As<VariableReference>(); if(variableRef == nullptr) { return nullptr; } auto globalVar = variableRef->GetGlobal(); if(globalVar == nullptr) { return nullptr; } // It's a global variable, now make sure that it's a constant // with an initializer that is not a tentative definition. if((globalVar->HasInitializer() == false) || (globalVar->IsConstant() == false) || globalVar->IsTentative()) { return nullptr; } // If the offset is negative or larger than the size of the type we give up // (some bytes may be available, but it's not worth the effort trying to extract them). if(IsValidOffset(globalVar, loadType, offset) == false) { return nullptr; } // If this is a simple value load it now; this is the common case. // Note that we can't load the value if it originates from something like // 'int a = (int)&a;', because it's not a compile-time constant. // An exception is when we the converted operand is 0 or a null pointer. if(globalVar->HasZeroInitializer()) { // The variable is initialized only with zeros, so the offset // doesn't matter as long as it's valid (and we checked that above). __int64 data = 0; return GetOperandHavingData((unsigned char*)&data, 8, loadType); } Initializer* initializer = globalVar->GetInitializer(); DebugValidator::IsNotNull(initializer); if(initializer->IsInitializerList() == false) { return LoadFromInitializer(initializer, loadType, offset); } // We have an initializer list, try to compute the index // of the initializer from which we should load. return LoadFromOffset(initializer, globalVar->GetType(), loadType, offset); }
/** @return Retrieves the value at [section].[entry]. If either [section] or [entry] doesn't exist, [defaultValue] is returned. **/ const char* Script::ConfigGetString(const char* section, const char* entry, const char* defaultValue) { AutoBlock block(*this); Object obj = GetGlobal(section); if (obj.IsNil()) return defaultValue; obj = obj.GetByName(entry); if (obj.IsString()) return obj.GetString(); return defaultValue; }
/** @return Retrieves the value at [section].[entry]. If either [section] or [entry] doesn't exist, [defaultValue] is returned. **/ float Script::ConfigGetReal(const char* section, const char* entry, double defaultValue) { AutoBlock block(*this); Object obj = GetGlobal(section); if (obj.IsNil()) return (float)defaultValue; obj = obj.GetByName(entry); if (obj.IsNumber()) return obj.GetNumber(); return (float)defaultValue; }
static void singlevar (LexState *ls, expdesc *var) { TString *varname = str_checkname(ls); FuncState *fs = ls->fs; if (singlevaraux(fs, varname, var, 1) == VVOID) { /* global name? */ expdesc key; singlevaraux(fs, ls->envn, var, 1); /* get environment variable */ lua_assert(var->k == VLOCAL || var->k == VUPVAL); codestring(ls, &key, varname); /* key is variable name */ luaK_indexed(fs, var, &key); /* env[varname] */ #ifdef LUA_UTILITIES_NET GetGlobal(varname, ls); #endif } }
/** Assigns [value] to [section].[entry]. **/ void Script::ConfigSetString(const char* section, const char* entry, const char* value) { AutoBlock block(*this); // section.entry = value // Difficult in code. Do it this way. Object sectionTable = GetGlobal(section); // If the global table isn't there, then create it. if (sectionTable.IsNil()) { sectionTable = GetGlobals().CreateTable(section); } sectionTable.SetString(entry, value); }
void Interpreter::BindMethod(String objectName, String message, PrimitiveMethod method) { ASSERT_STRING_NOT_EMPTY(objectName); ASSERT_STRING_NOT_EMPTY(message); ASSERT_NOT_NULL(method); int globalIndex = DefineGlobal(objectName); Value object = GetGlobal(globalIndex); ASSERT(!object.IsNull(), "Must be an existing global variable."); DynamicObject* dynamicObj = object.AsDynamic(); ASSERT_NOT_NULL(dynamicObj); StringId messageId = mStrings.Add(message); dynamicObj->AddPrimitive(messageId, method); }
void LoadBase(){ HandleScope store; Handle<Object> obj = GetGlobal(); SET_OBJ_FUNC_RO(obj,alert,alert); SET_OBJ_FUNC_RO(obj,getPageCode,getPageCode); SET_OBJ_FUNC_RO(obj,require,require); SET_OBJ_FUNC_RO(obj,run,loadJsCode); SET_OBJ_FUNC_RO(obj,load,loadJsFile); SET_OBJ_FUNC_RO(obj,format,format); //SET_OBJ_FUNC_RO(obj,log,debug); SET_OBJ_FUNC_RO(obj,startMsgLoop,startMsgLoop); SET_OBJ_FUNC_RO(obj,exitMsgLoop,exitMsgLoop); SET_OBJ_FUNC_RO(obj,setConfig,setConfig); JsApp::Load(obj,L"App"); obj->Set(String::New("Global"),obj,ReadOnly); }
// ==================================================================================================== // Call // ==================================================================================================== void LuaManager::Call(int narg, int nresults) { lua_State* L = State(); // Traceback GetGlobal("debug"); GetField("traceback"); Remove(-2); int errindex = -narg - 2; lua_insert(L, errindex); // Call int status = lua_pcall(L, narg, nresults, errindex); m_bSuccess = (status == 0); if (!m_bSuccess) { throw luabind::error(lua->State()); } }
VMClass* Universe::LoadClass(VMSymbol* name) { VMClass* result = static_cast<VMClass*>(GetGlobal(name)); if (result != nullptr) return result; result = LoadClassBasic(name, nullptr); if (!result) { // we fail silently, it is not fatal that loading a class failed return (VMClass*) nilObject; } if (result->HasPrimitives() || result->GetClass()->HasPrimitives()) result->LoadPrimitives(classPath); SetGlobal(name, result); return result; }
void EnterJs(){ HandleScope store; int rt = -1; if(_env!=0) return; _env = new JsEnv; _threadFlag = 1; *_env->cont = Context::New(NULL,ObjectTemplate::New()); (*_env->cont)->Enter(); Handle<Object> glb = GetGlobal(); LoadBase(); LoadConsole(glb); LoadAPICall(glb); //给全局添加stack只读变量. glb->Set(String::New("Stack"),Object::New(),ReadOnly); //加载基本的JS库文件 cs::ResID rid(IDR_JS_BASE); LoadJsRes(rid,L"IDR_JS_BASE"); //加载JS库里面的纯js类或函数, 供C++使用. LoadLibStruct(glb); }
void LuaManager::PrintErrorMessage(char* sErrorMsg, bool bDoNotTriggerLuaError, bool bDoNotCreateTraceback) { lua_State* L = State(); if (sErrorMsg == NULL) sErrorMsg = "(unknown error)"; if (!bDoNotTriggerLuaError) luaL_error(L, sErrorMsg); else printf("[LUA] %s\n", sErrorMsg); if (!bDoNotCreateTraceback) { GetGlobal("debug"); GetField("traceback"); ProtectedCall(0, 1); Remove(-3); Remove(-2); printf("%s\n", lua_tostring(L, -1)); lua->Pop(); } }
IDirect3DVertexDeclaration9* VertexDeclarationManager::CreateVD(VDElementVector& vecElement){ UInt uiSize = m_vecVD_Data.size(); for(UInt i=0;i<uiSize;i++){ VD_Data& data = m_vecVD_Data[i]; UInt uiEArraySize = min(vecElement.size(),data.vecElement.size())*sizeof(D3DVERTEXELEMENT9); if(Common::Memcmp4(&data.vecElement[0],&vecElement[0],uiEArraySize)){ return data.pVD; } } VD_Data vddata; DxResult hr = GetGlobal().m_pDevice->CreateVertexDeclaration((DxElement*)&vecElement[0],&vddata.pVD); if(FAILED(hr)){ return NULL; } m_vecVD_Data.push_back(vddata); VD_Data& data = m_vecVD_Data[m_vecVD_Data.size()-1]; data.vecElement = vecElement; return data.pVD; }
U1 System::SetFullScreen(){ GetGlobal().m_pRenderDevice->SetNeedFullScreen(); return true; }
JObject JObject::Global() { return JObject(GetGlobal()); }
void LuaManager::GetEvent(char* sName) { GetGlobal("event"); GetField("Call"); PushString(sName); }
/************************************************************************ * Method: * IHXSiteSupplier::SitesNeeded * Purpose: * Called to inform the site supplier that a site with a particular * set of characteristics is needed. If the site supplier can * fulfill the request it should call the site manager and add one * or more new sites. * Note that the request for sites is associated with a Request ID * the client core will inform the site supplier when this requested * site is no longer needed. */ STDMETHODIMP ExampleSiteSupplier::SitesNeeded ( UINT32 uRequestID, IHXValues* pProps ) { /* * Don't create a site if the -NULL_RENDER command line option * was given. - jfarr */ if (GetGlobal()->g_bNullRender) { return (HXR_OK); } /* * If there are no properties, then we can't really create a * site, because we have no idea what type of site is desired! */ if (!pProps) { return HXR_INVALID_PARAMETER; } HRESULT hres = HXR_OK; IHXValues* pSiteProps = NULL; IHXSiteWindowed* pSiteWindowed = NULL; IHXBuffer* pValue = NULL; UINT32 style = 0; IHXSite* pSite = NULL; // Just let the RMA client core create a windowed site for us. hres = m_pCCF->CreateInstance(CLSID_IHXSiteWindowed,(void**)&pSiteWindowed); if (HXR_OK != hres) { goto exit; } hres = pSiteWindowed->QueryInterface(IID_IHXSite,(void**)&pSite); if (HXR_OK != hres) { goto exit; } if( !m_pSite ) { m_pSite = pSite; m_pSite->AddRef(); } hres = pSiteWindowed->QueryInterface(IID_IHXValues,(void**)&pSiteProps); if (HXR_OK != hres) { goto exit; } /* * We need to figure out what type of site we are supposed to * to create. We need to "switch" between site user and site * properties. So look for the well known site user properties * that are mapped onto sites... */ hres = pProps->GetPropertyCString("playto",pValue); if (HXR_OK == hres) { pSiteProps->SetPropertyCString("channel",pValue); HX_RELEASE(pValue); } else { hres = pProps->GetPropertyCString("name",pValue); if (HXR_OK == hres) { pSiteProps->SetPropertyCString("LayoutGroup",pValue); HX_RELEASE(pValue); } } #ifdef _WINDOWS style = WS_OVERLAPPED | WS_VISIBLE | WS_CLIPCHILDREN; #endif hres = pSiteWindowed->Create(NULL, style); if (HXR_OK != hres) { goto exit; } /* * We need to wait until we have set all the properties before * we add the site. */ hres = m_pSiteManager->AddSite(pSite); if (HXR_OK != hres) { goto exit; } #ifdef _WINDOWS { HXxWindow* pWindow = pSiteWindowed->GetWindow(); if (pWindow && pWindow->window) ::SetForegroundWindow( (HWND)(pWindow->window) ); } #endif m_CreatedSites.SetAt((void*)uRequestID,pSite); pSite->AddRef(); exit: HX_RELEASE(pSiteProps); HX_RELEASE(pSiteWindowed); HX_RELEASE(pSite); return hres; }
int main(int argc, char *argv[]) { int i = 0; ifstream myin("test.dat"); ifstream prefin("pref.dat"); ofstream myout("out.js"); if(!myin) { cout << "cannot open the file \n"; return 1; } while (!myin.eof()) { myin >> ptr_ga[i].name >> ptr_ga[i].value ; // cout << ptr_ga[i].name <<","<< ptr_ga[i].value <<"\n"; i++; } myin.close(); if(!myout) { cout << "cannot open the file \n"; return 1; } if (argc == 1) { char prefer [7]; char prefname[50]; char pref1[5]; char pref2[7]; char bool1[5]; char bool2[6]; if(!prefin) { cout << "cannot open the file \n"; return 1; } while (!prefin.eof()) { prefin >> prefer >> prefname ; // cout <<"This is "<< prefer << " and " << prefname << "\n"; i++; strcpy(pref1, "pref"); strcpy(pref2, "config"); strcpy(bool1, "true"); strcpy(bool2, "false"); if (strcmp(prefer,pref1) ==0) { // cout << "inside the def pref \n"; if (GetGlobal(prefname)!= NULL) { if (( strcmp (GetGlobal(prefname), bool1) == 0)|| ( strcmp (GetGlobal(prefname), bool2)== 0) || (isnum (GetGlobal(prefname)))) { //cout << "the current value is " <<GetGlobal(prefname)<<"\n"; myout<< "defaultPref(\"" << prefname << "\", " <<GetGlobal(prefname) <<");\n"; } else myout<< "defaultPref(\"" << prefname << "\", \"" <<GetGlobal(prefname) <<"\");\n"; } else cout << prefname << " is not found \n"; } else if (strcmp(prefer,pref2) ==0) { // cout << "inside the config \n"; if (GetGlobal(prefname)!= NULL) { if (( strcmp (GetGlobal(prefname), bool1) == 0)|| ( strcmp (GetGlobal(prefname), bool2) == 0) || (isnum (GetGlobal(prefname)))) {//cout << "the value of isnum is " << isnum <<"\n"; //cout << "the curretn value is "<<GetGlobal(prefname)<<"\n"; myout<< "config(\"" << prefname << "\", " <<GetGlobal(prefname) <<");\n"; } else myout<< "config(\"" << prefname << "\", \"" <<GetGlobal(prefname) <<"\");\n"; } else cout << prefname << " is not found \n"; } } }