static int Get(platform* p, int No, void* Data, int Size) { int Result = ERR_INVALID_PARAM; switch (No) { case PLATFORM_LANG: GETVALUE(Context()->Lang,int); break; case PLATFORM_TYPE: GETSTRING(p->PlatformType); break; case PLATFORM_WMPVERSION: GETVALUE(p->WMPVersion,int); break; case PLATFORM_CPU: GETSTRING(p->CPU); break; case PLATFORM_OEMINFO: if (p->OemInfo[0]) GETSTRING(p->OemInfo); break; case PLATFORM_VER: GETVALUE(p->Ver,int); break; case PLATFORM_TYPENO: GETVALUE(p->Type,int); break; case PLATFORM_MODEL: GETVALUE(p->Model,int); break; case PLATFORM_CAPS: GETVALUE(p->Caps,int); break; case PLATFORM_ICACHE: GETVALUECOND(p->ICache,int,p->ICache>0); break; case PLATFORM_DCACHE: GETVALUECOND(p->DCache,int,p->DCache>0); break; case PLATFORM_VERSION: GETSTRING(p->Version); break; case PLATFORM_LOWMEMORY: GETVALUE(p->LowMemory,bool_t); break; case PLATFORM_CPUMHZ: assert(Size==sizeof(int)); if ((*(int*)Data = CPUSpeed())>0) Result = ERR_NONE; break; } return Result; }
bool Settings::LoadSettings() //////////////////////////////////////////////////////////////////////// { #define GETSTRING(a,b) if (settingsfile.GetString(a, tempstring)) Set##b(tempstring); #define GETBOOL(a,b) if (settingsfile.GetBool(a, tempbool)) Set##b(tempbool); #define GETINT(a,b) if (settingsfile.GetInteger(a, tempint)) Set##b(tempint); BString tempstring; bool tempbool; int tempint; DataFile settingsfile; if (settingsfile.LoadDataFile(GetSettingsFile())) { if (settingsfile.GetBool("ASKONEXIT", tempbool)) SetAskOnExit(tempbool); if (settingsfile.GetString("LANGUAGE", tempstring)) SetLanguage(tempstring); if (settingsfile.GetInteger("WINDOWLEFT", tempint)) SetWindowLeft(tempint); GETINT("WINDOWTOP", WindowTop); GETINT("WINDOWWIDTH", WindowWidth); GETINT("WINDOWHEIGHT", WindowHeight); GETSTRING("TERMINALWINDOW", TerminalWindow); GETSTRING("LEFTPANELPATH", LeftPanelPath); GETSTRING("RIGHTPANELPATH", RightPanelPath); return true; } else return false; }
static int Get(openfile* p,int No,void* Data,int Size) { int Result = ERR_INVALID_PARAM; switch (No) { case OPENFILE_MULTIPLE: GETVALUE(p->Multiple,bool_t); break; case OPENFILE_CLASS: GETVALUE(p->Class,int); break; case OPENFILE_FLAGS: GETVALUE(p->Flags,int); break; case OPENFILE_FILETYPE: GETVALUE(p->FileType,int); break; case OPENFILE_FILETYPE_SINGLE: GETVALUE(p->FileTypeSingle,int); break; case OPENFILE_FILETYPE_SAVE: GETVALUE(p->FileTypeSave,int); break; case OPENFILE_PATH: GETSTRING(p->Path); break; case OPENFILE_SORTCOL: GETVALUE(p->SortCol,int); break; case OPENFILE_SORTDIR: GETVALUE(p->SortDir,bool_t); break; case OPENFILE_WIDTH_NAME: GETVALUE(p->DlgWidth[0],int); break; case OPENFILE_WIDTH_TYPE: GETVALUE(p->DlgWidth[1],int); break; case OPENFILE_WIDTH_SIZE: GETVALUE(p->DlgWidth[2],int); break; case OPENFILE_WIDTH_DATE: GETVALUE(p->DlgWidth[3],int); break; case OPENFILE_HISTORYCOUNT: GETVALUE(p->HistoryCount,int); break; case OPENFILE_ONLYNAME: GETVALUE(p->OnlyName,bool_t); break; case OPENFILE_SAVE_NAME: GETSTRING(p->SaveName); break; case OPENFILE_SAVE_TYPE: GETVALUE(p->FileTypeSave,int); break; } if (No >= OPENFILE_HISTORY && No < OPENFILE_HISTORY+p->HistoryCount && p->History[No-OPENFILE_HISTORY]) GETSTRING(p->History[No-OPENFILE_HISTORY]); return Result; }
void SListBox::LoadItemAttribute(pugi::xml_node xmlNode, LPLBITEM pItem) { pItem->nImage=xmlNode.attribute(L"icon").as_int(pItem->nImage); pItem->lParam=xmlNode.attribute(L"data").as_uint(pItem->lParam); SStringW strText = tr(GETSTRING(xmlNode.attribute(L"text").value())); pItem->strText = S_CW2T(strText); }
static const char *config_group(gid_t *g) { struct group *grent; GETSTRING(); *g = ((grent = getgrnam(tokbuf)) == 0) ? 0 : grent->gr_gid; return *g ? 0 : e_bad_group; }
static const char *config_user(uid_t *u) { struct passwd *pwent; GETSTRING(); COPY(user_name, tokbuf); *u = ((pwent = getpwnam(tokbuf)) == 0) ? 0 : pwent->pw_uid; return *u ? 0 : e_bad_user; }
static const char *config_address(char **a, struct in_addr *b) { if (*a) return e_addr_set; GETSTRING(); COPY(*a, tokbuf); if ((b->s_addr = inet_addr(tokbuf)) == (unsigned long) -1) return e_bad_addr; return 0; }
virtual void getView(int position, SWindow * pItem, pugi::xml_node xmlTemplate) { int nViewType = getItemViewType(position); if(pItem->GetChildrenCount() == 0) { pugi::xml_node xmlItem; switch(nViewType) { case VT_GROUP: xmlItem = xmlTemplate.child(L"item_group");break; case VT_DATA: xmlItem = xmlTemplate.child(L"item_data");break; } pItem->InitFromXml(xmlItem); } if(nViewType == VT_GROUP) { SToggle * pSwitch=pItem->FindChildByID2<SToggle>(R.id.tgl_tv_expand); pSwitch->SetToggle(position==0?m_bCurrentExpand:m_bExpiredExpand); pSwitch->GetEventSet()->subscribeEvent(EVT_CMD,Subscriber(&CStudentAdapter::OnBtnGroupExpand,this)); pItem->FindChildByID(R.id.txt_group)->SetWindowText(TR(GETSTRING(position==0?R.string.current_student:R.string.expired_student),L"")); pItem->GetEventSet()->subscribeEvent(EVT_ITEMPANEL_DBCLICK,Subscriber(&CStudentAdapter::OnGroupDblClick,this)); SCheckBox *pGroupCheck = pItem->FindChildByID2<SCheckBox>(R.id.chk_select_group); pGroupCheck->GetEventSet()->subscribeEvent(EVT_STATECHANGED,Subscriber(&CStudentAdapter::OnGroupSelectCheckChanged,this)); pGroupCheck->GetEventSet()->setMutedState(true); pGroupCheck->SetCheck(position==0?m_bAllCurrentChecked:m_bAllExpiredChecked); pGroupCheck->GetEventSet()->setMutedState(false); }else { int nBaseCurrent = 1; int nBaseExpired = 1 + (m_bCurrentExpand?m_stuCurrent.GetCount():0) + 1; if(position< nBaseExpired) {//current student StudentInfo & stuInfo = m_stuCurrent[position-nBaseCurrent]; SCheckBox *pCheckBox = pItem->FindChildByID2<SCheckBox>(R.id.txt_nick); pCheckBox->GetEventSet()->subscribeEvent(EVT_STATECHANGED,Subscriber(&CStudentAdapter::OnStudentCheckChanged,this)); pCheckBox->GetEventSet()->setMutedState(true); pCheckBox->SetCheck(stuInfo.bChecked); pCheckBox->GetEventSet()->setMutedState(false); pCheckBox->SetWindowText(SStringT().Format(_T("%s(%u)"),stuInfo.strNick,stuInfo.imid)); pItem->FindChildByID(R.id.txt_loyal_degree)->SetWindowText(SStringT().Format(_T("%d"),stuInfo.nLoyalDegree)); pItem->FindChildByID(R.id.txt_time_span)->SetWindowText(stuInfo.tm1.Format(_T("%Y/%m/%d") + SStringT(_T(" - ")) + stuInfo.tm2.Format(_T("%Y/%m/%d")))); }else {//expired student StudentInfo & stuInfo = m_stuExpired[position-nBaseExpired]; SCheckBox *pCheckBox = pItem->FindChildByID2<SCheckBox>(R.id.txt_nick); pCheckBox->GetEventSet()->subscribeEvent(EVT_STATECHANGED,Subscriber(&CStudentAdapter::OnStudentCheckChanged,this)); pCheckBox->GetEventSet()->setMutedState(true); pCheckBox->SetCheck(stuInfo.bChecked); pCheckBox->GetEventSet()->setMutedState(false); pCheckBox->SetWindowText(SStringT().Format(_T("%s(%u)"),stuInfo.strNick,stuInfo.imid)); pItem->FindChildByID(R.id.txt_loyal_degree)->SetWindowText(SStringT().Format(_T("%d"),stuInfo.nLoyalDegree)); pItem->FindChildByID(R.id.txt_time_span)->SetWindowText(stuInfo.tm1.Format(_T("%Y/%m/%d") + SStringT(_T(" - ")) + stuInfo.tm2.Format(_T("%Y/%m/%d")))); } } }
static const char *config_name(char **a, struct in_addr *b) { struct hostent *h; if (*a) return e_addr_set; GETSTRING(); COPY(*a, tokbuf); if ((h = gethostbyname(tokbuf)) == 0) return e_unknown_host; b->s_addr = *(unsigned long *) h->h_addr; return 0; }
void UninstallForm::setInfo(DesuraId id) { m_uiInternId = id; UserCore::Item::ItemInfoI *item = GetUserCore()->getItemManager()->findItemInfo(id); if (!item) { Warning("Item was null for uninstall!"); Close(); } gcWString name(item->getName()); gcWString title(255, L"{0} {0}", GETSTRING(L"#UNF_TITLE"), name.c_str()); this->SetTitle(title.c_str()); showInfo(); }
int asCBuilder::RegisterClass(asCScriptNode *node, asCScriptCode *file) { asCScriptNode *n = node->firstChild; GETSTRING(name, &file->code[n->tokenPos], n->tokenLength); int r, c; file->ConvertPosToRowCol(n->tokenPos, &r, &c); CheckNameConflict(name.AddressOf(), n, file); sClassDeclaration *decl = new sClassDeclaration; classDeclarations.PushLast(decl); decl->name = name; decl->script = file; decl->validState = 0; decl->node = node; asCObjectType *st = new asCObjectType(engine); st->arrayType = 0; st->flags = asOBJ_CLASS_CDA | asOBJ_SCRIPT_STRUCT; st->size = sizeof(asCScriptStruct); st->name = name; st->tokenType = ttIdentifier; module->classTypes.PushLast(st); engine->classTypes.PushLast(st); st->refCount++; decl->objType = st; // Use the default script class behaviours st->beh.construct = engine->scriptTypeBehaviours.beh.construct; st->beh.constructors.PushLast(st->beh.construct); st->beh.addref = engine->scriptTypeBehaviours.beh.addref; st->beh.release = engine->scriptTypeBehaviours.beh.release; st->beh.copy = engine->scriptTypeBehaviours.beh.copy; st->beh.operators.PushLast(ttAssignment); st->beh.operators.PushLast(st->beh.copy); return 0; }
bool HudPanel::onTrigger(EventCustom *event) { auto data = static_cast<ValueMap*>(event->getUserData()); auto effect = (*data)["effect"].asValueMap(); auto senderName = (*data)["senderName"].asString(); auto type = (*data)["type"].asString(); if(type == "curtain") { auto action = effect["action"].asString(); auto delay = effect["delay"].asFloat(); if(action == "fadeIn") { _layerColor->runAction(FadeIn::create(delay)); } else if(action == "fadeOut") { _layerColor->runAction(FadeOut::create(delay)); } } else if(type == "plotBlock") { auto action = effect["action"].asString(); if(action == "in") { _plotBlock = true; } else if(action == "out") { _plotBlock = false; } } auto player = Detect::shareDetect()->getPlayer(); if(player != nullptr && senderName == player->getName()) { if(type == "setHp") { auto hp = effect["num"].asInt(); /*auto maxHp = effect["maxHp"].asInt(); auto loadingBar = static_cast<LoadingBar*>(Helper::seekWidgetByName(_root, "ProgressBar_hp")); loadingBar->setPercent(hp * 1.00 / maxHp * 100);*/ auto text = static_cast<Text*>(Helper::seekWidgetByName(_root, "Label_hp")); text->setString(StringUtils::format("%d",hp)); } else if(type == "setXp") { auto xp = effect["num"].asInt(); auto lastXp = effect["lastXp"].asInt(); auto nextXp = effect["nextXp"].asInt(); auto loadingBar = static_cast<LoadingBar*>(Helper::seekWidgetByName(_root, "ProgressBar_xp")); auto cur = xp - lastXp; auto max = nextXp - lastXp; //loadingBar->setPercent(cur * 1.00 / max * 100); auto text = static_cast<Text*>(Helper::seekWidgetByName(_root, "Label_xp")); text->setString(StringUtils::format("%d/%d",xp,nextXp)); } else if(type == "setStr") { auto widget = static_cast<Text*>(Helper::seekWidgetByName(_root, "Label_str_num")); widget->setString(effect["num"].asString()); } else if(type == "setDef") { auto widget = static_cast<Text*>(Helper::seekWidgetByName(_root, "Label_def_num")); widget->setString(effect["num"].asString()); } else if(type == "setLevel") { auto widget = static_cast<TextAtlas*>(Helper::seekWidgetByName(_root, "Label_level_num")); widget->setString(effect["num"].asString()); } else if(type == "setGold") { auto widget = static_cast<Text*>(Helper::seekWidgetByName(_root, "Label_gold_num")); widget->setString(effect["num"].asString()); } else if(type == "addHp") { std::string str = "{0,0}"; if(!effect["site"].isNull()) str = effect["site"].asString(); Vec2 site = Detect::shareDetect()->getWorld()->convertToWorldSpace(PointFromString(str)); std::string add = (effect["num"].asInt()>0?"+":"") + effect["num"].asString(); _bubbleLabel->addLabel(GETSTRING("hp") + add,site); if(effect["num"].asInt() > 0) { auto widget = static_cast<Text*>(Helper::seekWidgetByName(_root, "Label_hp")); widget->setScale(1.0f); //widget->runAction(_stress1->clone()); } } else if(type == "addXp") { std::string str = "{0,0}"; if(!effect["site"].isNull()) str = effect["site"].asString(); Vec2 site = Detect::shareDetect()->getWorld()->convertToWorldSpace(PointFromString(str)); std::string add = (effect["num"].asInt()>0?"+":"") + effect["num"].asString(); _bubbleLabel->addLabel(GETSTRING("xp") + add,site); if(effect["num"].asInt() > 0) { auto widget = static_cast<Text*>(Helper::seekWidgetByName(_root, "Label_xp")); widget->setScale(1.0f); //widget->runAction(_stress1->clone()); } } else if(type == "addStr") { std::string str = "{0,0}"; if(!effect["site"].isNull()) str = effect["site"].asString(); Vec2 site = Detect::shareDetect()->getWorld()->convertToWorldSpace(PointFromString(str)); std::string add = (effect["num"].asInt()>0?"+":"") + effect["num"].asString(); _bubbleLabel->addLabel(GETSTRING("str") + add,site); if(effect["num"].asInt() > 0) { auto widget = static_cast<Text*>(Helper::seekWidgetByName(_root, "Label_str_num")); widget->setScale(1.0f); //widget->runAction(_stress1->clone()); } } else if(type == "addDef") { std::string def = "{0,0}"; if(!effect["site"].isNull()) def = effect["site"].asString(); Vec2 site = Detect::shareDetect()->getWorld()->convertToWorldSpace(PointFromString(def)); std::string add = (effect["num"].asInt()>0?"+":"") + effect["num"].asString(); _bubbleLabel->addLabel(GETSTRING("def") + add,site); if(effect["num"].asInt() > 0) { auto widget = static_cast<Text*>(Helper::seekWidgetByName(_root, "Label_def_num")); widget->setScale(1.0f); //widget->runAction(_stress1->clone()); } } else if(type == "addLevel") { std::string level = "{0,0}"; if(!effect["site"].isNull()) level = effect["site"].asString(); Vec2 site = Detect::shareDetect()->getWorld()->convertToWorldSpace(PointFromString(level)); std::string add = (effect["num"].asInt()>0?"+":"") + effect["num"].asString(); _bubbleLabel->addLabel(GETSTRING("level") + add,site); if(effect["num"].asInt() > 0) { auto widget = static_cast<Text*>(Helper::seekWidgetByName(_root, "Label_level_num")); widget->setScale(1.0f); //widget->runAction(_stress1->clone()); } } else if(type == "addGold") { std::string gold = "{0,0}"; if(!effect["site"].isNull()) gold = effect["site"].asString(); Vec2 site = Detect::shareDetect()->getWorld()->convertToWorldSpace(PointFromString(gold)); std::string add = (effect["num"].asInt()>0?"+":"") + effect["num"].asString(); _bubbleLabel->addLabel(GETSTRING("gold") + add,site); if(effect["num"].asInt() > 0) { auto widget = static_cast<Text*>(Helper::seekWidgetByName(_root, "Label_gold_num")); widget->setScale(1.0f); //widget->runAction(_stress1->clone()); } } else if(type == "otherNote") { std::string str = "{0,0}"; if(!effect["site"].isNull()) str = effect["site"].asString(); Vec2 site = Detect::shareDetect()->getWorld()->convertToWorldSpace(PointFromString(str)); std::string text = effect["text"].asString(); _bubbleLabel->addLabel(text,site); } else if(type == "addProp") { auto propType = effect["propType"].asInt(); auto addPropNum = effect["addPropNum"].asInt(); auto propNum = effect["propNum"].asInt(); if(addPropNum != 0) { switch (propType) { case 2002002:case 2002001:case 2002003: std::string str = "{0,0}"; if(!effect["site"].isNull()) str = effect["site"].asString(); Vec2 site = Detect::shareDetect()->getWorld()->convertToWorldSpace(PointFromString(str)); std::string add = GETSTRING("get")+ effect["propName"].asString() + (effect["addPropNum"].asInt()>0?"+":"") + effect["addPropNum"].asString(); _bubbleLabel->addLabel(add,site); break; } } switch (propType) { case 2002002: { auto widget = static_cast<Text*>(Helper::seekWidgetByName(_root, "Label_key_1_num")); widget->setString(effect["propNum"].asString()); widget->setScaleX(1.0f); widget->setScaleY(1.0f); //widget->runAction(_stress1->clone()); } break; case 2002001: { auto widget = static_cast<Text*>(Helper::seekWidgetByName(_root, "Label_key_2_num")); widget->setString(effect["propNum"].asString()); widget->setScaleX(1.0f); widget->setScaleY(1.0f); //widget->runAction(_stress1->clone()); } break; case 2002003: { auto widget = static_cast<Text*>(Helper::seekWidgetByName(_root, "Label_key_3_num")); widget->setString(effect["propNum"].asString()); widget->setScaleX(1.0f); widget->setScaleY(1.0f); //widget->runAction(_stress1->clone()); } break; default: break; } } else if(type == "removeProp") { auto propType = effect["propType"].asInt(); auto addPropNum = effect["addPropNum"].asInt(); auto propNum = effect["propNum"].asInt(); switch (propType) { case 2002002: { auto widget = static_cast<Text*>(Helper::seekWidgetByName(_root, "Label_key_1_num")); widget->setString(effect["propNum"].asString()); } break; case 2002001: { auto widget = static_cast<Text*>(Helper::seekWidgetByName(_root, "Label_key_2_num")); widget->setString(effect["propNum"].asString()); } break; case 2002003: { auto widget = static_cast<Text*>(Helper::seekWidgetByName(_root, "Label_key_3_num")); widget->setString(effect["propNum"].asString()); } break; default: break; } } } if(type == "setCurFloor") { auto widget1 = static_cast<TextAtlas*>(Helper::seekWidgetByName(_root, "Label_floor_num")); widget1->setString(effect["floorId"].asString()); auto widget2 = static_cast<Text*>(Helper::seekWidgetByName(_root, "Label_tower_name")); widget2->setString(effect["towerName"].asString()); } return false; }
int asCBuilder::RegisterScriptFunction(int funcID, asCScriptNode *node, asCScriptCode *file, asCObjectType *objType, bool isInterface) { // Find name bool isConstructor = false; asCScriptNode *n = 0; if( node->firstChild->nodeType == snDataType ) n = node->firstChild->next->next; else { n = node->firstChild; isConstructor = true; } // Check for name conflicts GETSTRING(name, &file->code[n->tokenPos], n->tokenLength); if( !isConstructor ) CheckNameConflict(name.AddressOf(), n, file); else { // Verify that the name of the function is the same as the class if( name != objType->name ) { int r, c; file->ConvertPosToRowCol(n->tokenPos, &r, &c); WriteError(file->name.AddressOf(), TXT_CONSTRUCTOR_NAME_ERROR, r, c); } } if( !isInterface ) { sFunctionDescription *func = new sFunctionDescription; functions.PushLast(func); func->script = file; func->node = node; func->name = name; func->objType = objType; func->funcId = funcID; } // Initialize a script function object for registration asCDataType returnType = asCDataType::CreatePrimitive(ttVoid, false); if( !isConstructor ) { returnType = CreateDataTypeFromNode(node->firstChild, file); returnType = ModifyDataTypeFromNode(returnType, node->firstChild->next, file, 0, 0); module->RefConfigGroupForObjectType(returnType.GetObjectType()); } asCArray<asCDataType> parameterTypes; asCArray<int> inOutFlags; n = n->next->firstChild; while( n ) { int inOutFlag; asCDataType type = CreateDataTypeFromNode(n, file); type = ModifyDataTypeFromNode(type, n->next, file, &inOutFlag, 0); module->RefConfigGroupForObjectType(type.GetObjectType()); // Store the parameter type parameterTypes.PushLast(type); inOutFlags.PushLast(inOutFlag); // Move to next parameter n = n->next->next; if( n && n->nodeType == snIdentifier ) n = n->next; } // Check that the same function hasn't been registered already asCArray<int> funcs; GetFunctionDescriptions(name.AddressOf(), funcs); if( funcs.GetLength() ) { for( asUINT n = 0; n < funcs.GetLength(); ++n ) { asCScriptFunction *func = GetFunctionDescription(funcs[n]); if( parameterTypes.GetLength() == func->parameterTypes.GetLength() ) { bool match = true; for( asUINT p = 0; p < parameterTypes.GetLength(); ++p ) { if( parameterTypes[p] != func->parameterTypes[p] ) { match = false; break; } } if( match ) { int r, c; file->ConvertPosToRowCol(node->tokenPos, &r, &c); WriteError(file->name.AddressOf(), TXT_FUNCTION_ALREADY_EXIST, r, c); break; } } } } // Register the function module->AddScriptFunction(file->idx, funcID, name.AddressOf(), returnType, parameterTypes.AddressOf(), inOutFlags.AddressOf(), (asUINT)parameterTypes.GetLength(), isInterface, objType); if( objType ) { if( isConstructor ) { if( parameterTypes.GetLength() == 0 ) { // Overload the default constructor objType->beh.construct = funcID; objType->beh.constructors[0] = funcID; } else objType->beh.constructors.PushLast(funcID); } else objType->methods.PushLast(funcID); } // We need to delete the node already if this is an interface method if( isInterface && node ) delete node; return 0; }
static const char *config_string(char **a) { GETSTRING(); COPY(*a, tokbuf); return 0; }
ROBJ_IN_CPP int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR /*lpstrCmdLine*/, int /*nCmdShow*/) { //必须要调用OleInitialize来初始化运行环境 HRESULT hRes = OleInitialize(NULL); SASSERT(SUCCEEDED(hRes)); //LoadLibrary(L"E:\\soui.taobao\\richedit\\Debug\\riched20.dll"); /* XML预编译前面加载效率比较 pugi::xml_document doc; LARGE_INTEGER perf; QueryPerformanceFrequency(&perf); LARGE_INTEGER t1,t2; QueryPerformanceCounter(&t1); doc.load_file(L"e:\\play.xml",pugi::parse_default,pugi::encoding_utf8); QueryPerformanceCounter(&t2); doc.save_file(L"e:\\play1.xml"); doc.save_bin(L"e:\\paly.xml.bin"); pugi::xml_document doc2; LARGE_INTEGER t21,t22; QueryPerformanceCounter(&t21); doc2.load_bin_file(L"e:\\paly.xml.bin"); QueryPerformanceCounter(&t22); doc2.save_file(L"e:\\play2.xml"); LONGLONG SP1 = (t2.QuadPart-t1.QuadPart)*1000000/perf.QuadPart; LONGLONG SP2 = (t22.QuadPart-t21.QuadPart)*1000000/perf.QuadPart; SStringW str; str.Format(L"!!!!!sp2=%d,sp1=%d\n",(int)SP2,(int)SP1); MessageBoxW(GetActiveWindow(),str,L"span",MB_OK); return 0; */ int nRet = 0; //使用imgdecoder-png图片解码模块演示apng动画 SComMgr *pComMgr = new SComMgr(_T("imgdecoder-png")); { int nType=MessageBox(GetActiveWindow(),_T("选择渲染类型:\n[yes]: Skia\n[no]:GDI\n[cancel]:Quit"),_T("select a render"),MB_ICONQUESTION|MB_YESNOCANCEL); if(nType == IDCANCEL) { nRet = -1; goto exit; } //定义一组类SOUI系统中使用的类COM组件 //CAutoRefPtr是一个SOUI系统中使用的智能指针类 CAutoRefPtr<IImgDecoderFactory> pImgDecoderFactory; //图片解码器,由imagedecoder-wid.dll模块提供 CAutoRefPtr<IRenderFactory> pRenderFactory; //UI渲染模块,由render-gdi.dll或者render-skia.dll提供 CAutoRefPtr<ITranslatorMgr> trans; //多语言翻译模块,由translator.dll提供 CAutoRefPtr<IScriptFactory> pScriptLua; //lua脚本模块,由scriptmodule-lua.dll提供 CAutoRefPtr<ILog4zManager> pLogMgr; //log4z对象 BOOL bLoaded=FALSE; //从各组件中显式创建上述组件对象 if(nType == IDYES) bLoaded = pComMgr->CreateRender_Skia((IObjRef**)&pRenderFactory); else bLoaded = pComMgr->CreateRender_GDI((IObjRef**)&pRenderFactory); SASSERT_FMT(bLoaded,_T("load interface [%s] failed!"),nType==IDYES?_T("render_skia"):_T("render_gdi")); bLoaded=pComMgr->CreateImgDecoder((IObjRef**)&pImgDecoderFactory); SASSERT_FMT(bLoaded,_T("load interface [%s] failed!"),_T("imgdecoder")); bLoaded=pComMgr->CreateTranslator((IObjRef**)&trans); SASSERT_FMT(bLoaded,_T("load interface [%s] failed!"),_T("translator")); if(pComMgr->CreateLog4z((IObjRef**)&pLogMgr)) if(pLogMgr){ pLogMgr->createLogger("soui");//support output soui trace infomation to log pLogMgr->start(); } //为渲染模块设置它需要引用的图片解码模块 pRenderFactory->SetImgDecoderFactory(pImgDecoderFactory); //定义一个唯一的SApplication对象,SApplication管理整个应用程序的资源 SApplication *theApp=new SApplication(pRenderFactory,hInstance); theApp->SetLogManager(pLogMgr); LOGF("demo","test "<<100 << L"wchar"); SLOGFMTE("log output using ansi format,str=%s, tick=%u","test",GetTickCount()); SLOGFMTE(L"log output using unicode format,str=%s, tick=%u",L"中文",GetTickCount()); //控件注册要放到AddResProvider前: 2016年3月8日 //向SApplication系统中注册由外部扩展的控件及SkinObj类 SWkeLoader wkeLoader; if(wkeLoader.Init(_T("wke.dll"))) { theApp->RegisterWndFactory(TplSWindowFactory<SWkeWebkit>());//注册WKE浏览器 } theApp->RegisterWindowClass<SMatrixWindow>();// theApp->RegisterWindowClass<SFreeMoveWindow>();// theApp->RegisterWindowClass<SClock>();// theApp->RegisterWindowClass<SGifPlayer>();//theApp中增加方法:RegisterWindowClass,替换RegisterWndFactory(TplSWindowFactory<SGifPlayer>()) theApp->RegisterSkinFactory(TplSkinFactory<SSkinGif>());//注册SkinGif theApp->RegisterSkinFactory(TplSkinFactory<SSkinAPNG>());//注册SSkinAPNG theApp->RegisterSkinFactory(TplSkinFactory<SSkinVScrollbar>());//注册纵向滚动条皮肤 theApp->RegisterWndFactory(TplSWindowFactory<SIPAddressCtrl>());//注册IP控件 theApp->RegisterWndFactory(TplSWindowFactory<SPropertyGrid>());//注册属性表控件 theApp->RegisterWndFactory(TplSWindowFactory<SChromeTabCtrl>());//注册ChromeTabCtrl theApp->RegisterWndFactory(TplSWindowFactory<SIECtrl>());//注册IECtrl theApp->RegisterWndFactory(TplSWindowFactory<SChatEdit>());//注册ChatEdit theApp->RegisterWndFactory(TplSWindowFactory<SScrollText>());//注册SScrollText theApp->RegisterWndFactory(TplSWindowFactory<SDesktopDock>());//注册SDesktopDock theApp->RegisterWndFactory(TplSWindowFactory<SImageMaskWnd>());//注册SImageMaskWnd theApp->RegisterWndFactory(TplSWindowFactory<SRatingBar>());//注册SRatingBar if(SUCCEEDED(CUiAnimation::Init())) { theApp->RegisterWndFactory(TplSWindowFactory<SUiAnimationWnd>());//注册动画控件 } theApp->RegisterWndFactory(TplSWindowFactory<SFlyWnd>());//注册飞行动画控件 theApp->RegisterWndFactory(TplSWindowFactory<SFadeFrame>());//注册渐显隐动画控件 theApp->RegisterWndFactory(TplSWindowFactory<SRadioBox2>());//注册RadioBox2 theApp->RegisterWndFactory(TplSWindowFactory<SCalendar2>());//注册SCalendar2 SSkinGif::Gdiplus_Startup(); //如果需要在代码中使用R::id::namedid这种方式来使用控件必须要这一行代码:2016年2月2日,R::id::namedXmlID是由uiresbuilder 增加-h .\res\resource.h idtable 这3个参数后生成的。 theApp->InitXmlNamedID(namedXmlID,ARRAYSIZE(namedXmlID),TRUE); //将程序的运行路径修改到demo所在的目录 SStringT strResDir = theApp->GetAppDir(); strResDir += _T("\\..\\demos\\demo"); SetCurrentDirectory(strResDir); //SOUI系统总是从appdir去查找资源 theApp->SetAppDir(strResDir); //定义一人个资源提供对象,SOUI系统中实现了3种资源加载方式,分别是从文件加载,从EXE的资源加载及从ZIP压缩包加载 CAutoRefPtr<IResProvider> pResProvider; #if (RES_TYPE == 0)//从文件加载 CreateResProvider(RES_FILE,(IObjRef**)&pResProvider); if(!pResProvider->Init((LPARAM)_T("uires"),0)) { CreateResProvider(RES_PE,(IObjRef**)&pResProvider); if(!pResProvider->Init((WPARAM)hInstance,0)) { SASSERT(0); delete theApp; nRet = 1; goto exit; } } #elif (RES_TYPE==1)//从EXE资源加载 CreateResProvider(RES_PE,(IObjRef**)&pResProvider); pResProvider->Init((WPARAM)hInstance,0); #elif (RES_TYPE==2)//从ZIP包加载 bLoaded=pComMgr->CreateResProvider_ZIP((IObjRef**)&pResProvider); SASSERT_FMT(bLoaded,_T("load interface [%s] failed!"),_T("resprovider_zip")); ZIPRES_PARAM param; param.ZipFile(pRenderFactory, _T("uires.zip"),"souizip"); bLoaded = pResProvider->Init((WPARAM)¶m,0); SASSERT(bLoaded); #endif //将创建的IResProvider交给SApplication对象 theApp->AddResProvider(pResProvider); //创建一个http服务器,用来从资源中加载flash CMemFlash memFlash; CHTTPServer flashSvr(&memFlash); flashSvr.Start(CMemFlash::HomeDir(),"",82,0); if(trans) {//加载语言翻译包 theApp->SetTranslator(trans); pugi::xml_document xmlLang; if(theApp->LoadXmlDocment(xmlLang,_T("lang_cn"),_T("translator"))) { CAutoRefPtr<ITranslator> langCN; trans->CreateTranslator(&langCN); langCN->Load(&xmlLang.child(L"language"),1);//1=LD_XML trans->InstallTranslator(langCN); } } #if defined(DLL_CORE) && !defined(_WIN64) //加载LUA脚本模块,注意,脚本模块只有在SOUI内核是以DLL方式编译时才能使用。 bLoaded=pComMgr->CreateScrpit_Lua((IObjRef**)&pScriptLua); SASSERT_FMT(bLoaded,_T("load interface [%s] failed!"),_T("scirpt_lua")); theApp->SetScriptFactory(pScriptLua); #endif//DLL_CORE //加载系统资源 HMODULE hSysResource=LoadLibrary(SYS_NAMED_RESOURCE); if(hSysResource) { CAutoRefPtr<IResProvider> sysSesProvider; CreateResProvider(RES_PE,(IObjRef**)&sysSesProvider); sysSesProvider->Init((WPARAM)hSysResource,0); theApp->LoadSystemNamedResource(sysSesProvider); } //采用hook绘制菜单的边框 CMenuWndHook::InstallHook(hInstance,L"_skin.sys.menu.border"); //加载全局资源描述XML //theApp->Init(_T("xml_init")); 不再需要这句,在AddResProvider时自动执行初始化 //演示R.color.xxx,R.string.xxx在代码中的使用。 COLORREF crRed = GETCOLOR(R.color.red); SStringW strTitle = GETSTRING(R.string.title); SNotifyCenter *pNotifyCenter = new SNotifyCenter; { //创建并显示使用SOUI布局应用程序窗口,为了保存窗口对象的析构先于其它对象,把它们缩进一层。 CMainDlg dlgMain; dlgMain.Create(GetActiveWindow(),0,0,800,650); dlgMain.GetNative()->SendMessage(WM_INITDIALOG); dlgMain.CenterWindow(); dlgMain.ShowWindow(SW_SHOWNORMAL); SmileyCreateHook smileyHook; //不知道MainDlg里哪块和mhook冲突了,在win10中,如果hook放到dlgmain.create前会导致hook失败。 nRet=theApp->Run(dlgMain.m_hWnd); } delete pNotifyCenter; theApp->UnregisterWindowClass<SGifPlayer>(); //应用程序退出 delete theApp; if(pLogMgr) { pLogMgr->stop(); } flashSvr.Shutdown(); //卸载菜单边框绘制hook CMenuWndHook::UnInstallHook(); CUiAnimation::Free(); SSkinGif::Gdiplus_Shutdown(); } exit: delete pComMgr; OleUninitialize(); return nRet; }
int asCBuilder::RegisterImportedFunction(int importID, asCScriptNode *node, asCScriptCode *file) { // Find name asCScriptNode *f = node->firstChild; asCScriptNode *n = f->firstChild->next->next; // Check for name conflicts GETSTRING(name, &file->code[n->tokenPos], n->tokenLength); CheckNameConflict(name.AddressOf(), n, file); // Initialize a script function object for registration asCDataType returnType; returnType = CreateDataTypeFromNode(f->firstChild, file); returnType = ModifyDataTypeFromNode(returnType, f->firstChild->next, file, 0, 0); asCArray<asCDataType> parameterTypes; asCArray<int> inOutFlags; n = n->next->firstChild; while( n ) { int inOutFlag; asCDataType type = CreateDataTypeFromNode(n, file); type = ModifyDataTypeFromNode(type, n->next, file, &inOutFlag, 0); // Store the parameter type n = n->next->next; parameterTypes.PushLast(type); inOutFlags.PushLast(inOutFlag); // Move to next parameter if( n && n->nodeType == snIdentifier ) n = n->next; } // Check that the same function hasn't been registered already asCArray<int> funcs; GetFunctionDescriptions(name.AddressOf(), funcs); if( funcs.GetLength() ) { for( asUINT n = 0; n < funcs.GetLength(); ++n ) { asCScriptFunction *func = GetFunctionDescription(funcs[n]); // TODO: Isn't the name guaranteed to be equal, because of GetFunctionDescriptions()? if( name == func->name && parameterTypes.GetLength() == func->parameterTypes.GetLength() ) { bool match = true; for( asUINT p = 0; p < parameterTypes.GetLength(); ++p ) { if( parameterTypes[p] != func->parameterTypes[p] ) { match = false; break; } } if( match ) { int r, c; file->ConvertPosToRowCol(node->tokenPos, &r, &c); WriteError(file->name.AddressOf(), TXT_FUNCTION_ALREADY_EXIST, r, c); break; } } } } // Read the module name as well n = node->firstChild->next; int moduleNameString = module->AddConstantString(&file->code[n->tokenPos+1], n->tokenLength-2); delete node; // Register the function module->AddImportedFunction(importID, name.AddressOf(), returnType, parameterTypes.AddressOf(), inOutFlags.AddressOf(), (asUINT)parameterTypes.GetLength(), moduleNameString); return 0; }
int asCBuilder::RegisterGlobalVar(asCScriptNode *node, asCScriptCode *file) { // What data type is it? asCDataType type = CreateDataTypeFromNode(node->firstChild, file); if( type.GetSizeOnStackDWords() == 0 || (type.IsObject() && !type.IsObjectHandle() && type.GetSizeInMemoryBytes() == 0) ) { asCString str; // TODO: Change to "'type' cannot be declared as variable" str.Format(TXT_DATA_TYPE_CANT_BE_s, type.Format().AddressOf()); int r, c; file->ConvertPosToRowCol(node->tokenPos, &r, &c); WriteError(file->name.AddressOf(), str.AddressOf(), r, c); } asCScriptNode *n = node->firstChild->next; while( n ) { // Verify that the name isn't taken GETSTRING(name, &file->code[n->tokenPos], n->tokenLength); CheckNameConflict(name.AddressOf(), n, file); // Register the global variable sGlobalVariableDescription *gvar = new sGlobalVariableDescription; globVariables.PushLast(gvar); gvar->script = file; gvar->name = name; gvar->isCompiled = false; gvar->datatype = type; // TODO: Give error message if wrong assert(!gvar->datatype.IsReference()); // Allocate space on the global memory stack gvar->index = module->AllocGlobalMemory(gvar->datatype.GetSizeOnStackDWords()); gvar->node = 0; if( n->next && (n->next->nodeType == snAssignment || n->next->nodeType == snArgList || n->next->nodeType == snInitList ) ) { gvar->node = n->next; n->next->DisconnectParent(); } // Add script variable to engine asCProperty *prop = new asCProperty; prop->index = gvar->index; prop->name = name; prop->type = gvar->datatype; module->scriptGlobals.PushLast(prop); gvar->property = prop; n = n->next; } delete node; return 0; }
uint convM2W(uchar *p, uint n, Wsysmsg *m) { int nn; if(n < 6) return 0; GET(p, nn); if(nn > n) return 0; m->tag = p[4]; m->type = p[5]; switch(m->type){ default: return 0; case Trdmouse: case Rbouncemouse: case Rmoveto: case Rcursor: case Trdkbd: case Rlabel: case Rinit: case Trdsnarf: case Rwrsnarf: case Ttop: case Rtop: case Rresize: break; case Rerror: GETSTRING(p+6, &m->error); break; case Rrdmouse: GET(p+6, m->mouse.xy.x); GET(p+10, m->mouse.xy.y); GET(p+14, m->mouse.buttons); GET(p+18, m->mouse.msec); m->resized = p[19]; break; case Tbouncemouse: GET(p+6, m->mouse.xy.x); GET(p+10, m->mouse.xy.y); GET(p+14, m->mouse.buttons); break; case Tmoveto: GET(p+6, m->mouse.xy.x); GET(p+10, m->mouse.xy.y); break; case Tcursor: GET(p+6, m->cursor.offset.x); GET(p+10, m->cursor.offset.y); memmove(m->cursor.clr, p+14, sizeof m->cursor.clr); memmove(m->cursor.set, p+46, sizeof m->cursor.set); GET(p+78, m->cursor2.offset.x); GET(p+82, m->cursor2.offset.y); memmove(m->cursor2.clr, p+86, sizeof m->cursor2.clr); memmove(m->cursor2.set, p+214, sizeof m->cursor2.set); m->arrowcursor = p[342]; break; case Rrdkbd: GET2(p+6, m->rune); break; case Tlabel: GETSTRING(p+6, &m->label); break; case Tinit: p += 6; p += GETSTRING(p, &m->winsize); p += GETSTRING(p, &m->label); break; case Rrdsnarf: case Twrsnarf: GETSTRING(p+6, &m->snarf); break; case Rrddraw: case Twrdraw: GET(p+6, m->count); m->data = p+10; break; case Trddraw: case Rwrdraw: GET(p+6, m->count); break; case Tresize: GET(p+6, m->rect.min.x); GET(p+10, m->rect.min.y); GET(p+14, m->rect.max.x); GET(p+18, m->rect.max.y); break; } return nn; }
void asCBuilder::CompileClasses() { asUINT n; asCArray<sClassDeclaration*> toValidate; // Go through each of the classes and register the object type descriptions for( n = 0; n < classDeclarations.GetLength(); n++ ) { sClassDeclaration *decl = classDeclarations[n]; // Enumerate each of the declared properties asCScriptNode *node = decl->node->firstChild->next; // Skip list of classes and interfaces while( node && node->nodeType == snIdentifier ) node = node->next; while( node ) { if( node->nodeType == snDeclaration ) { asCScriptCode *file = decl->script; asCDataType dt = CreateDataTypeFromNode(node->firstChild, file); GETSTRING(name, &file->code[node->lastChild->tokenPos], node->lastChild->tokenLength); if( dt.IsReadOnly() ) { int r, c; file->ConvertPosToRowCol(node->tokenPos, &r, &c); WriteError(file->name.AddressOf(), TXT_PROPERTY_CANT_BE_CONST, r, c); } asCDataType st; st.SetObjectType(decl->objType); CheckNameConflictMember(st, name.AddressOf(), node->lastChild, file); // Store the properties in the object type descriptor asCProperty *prop = new asCProperty; prop->name = name; prop->type = dt; int propSize; if( dt.IsObject() ) { propSize = dt.GetSizeOnStackDWords()*4; if( !dt.IsObjectHandle() ) { if( dt.GetSizeInMemoryBytes() == 0 ) { int r, c; file->ConvertPosToRowCol(node->tokenPos, &r, &c); asCString str; str.Format(TXT_DATA_TYPE_CANT_BE_s, dt.Format().AddressOf()); WriteError(file->name.AddressOf(), str.AddressOf(), r, c); } prop->type.MakeReference(true); } } else { propSize = dt.GetSizeInMemoryBytes(); if( propSize == 0 ) { int r, c; file->ConvertPosToRowCol(node->tokenPos, &r, &c); asCString str; str.Format(TXT_DATA_TYPE_CANT_BE_s, dt.Format()); WriteError(file->name.AddressOf(), str.AddressOf(), r, c); } } // Add extra bytes so that the property will be properly aligned if( propSize == 2 && (decl->objType->size & 1) ) decl->objType->size += 1; if( propSize > 2 && (decl->objType->size & 3) ) decl->objType->size += 3 - (decl->objType->size & 3); prop->byteOffset = decl->objType->size; decl->objType->size += propSize; decl->objType->properties.PushLast(prop); // Make sure the module holds a reference to the config group where the object is registered module->RefConfigGroupForObjectType(dt.GetObjectType()); } else if( node->nodeType == snFunction ) { // TODO: Register the method and add it to the list of functions to compile later } else assert(false); node = node->next; } toValidate.PushLast(decl); } // Verify that the declared structures are valid, e.g. that the structure // doesn't contain a member of its own type directly or indirectly while( toValidate.GetLength() > 0 ) { asUINT numClasses = (asUINT)toValidate.GetLength(); asCArray<sClassDeclaration*> toValidateNext; while( toValidate.GetLength() > 0 ) { sClassDeclaration *decl = toValidate[toValidate.GetLength()-1]; int validState = 1; for( asUINT n = 0; n < decl->objType->properties.GetLength(); n++ ) { // A valid structure is one that uses only primitives or other valid objects asCProperty *prop = decl->objType->properties[n]; asCDataType dt = prop->type; if( dt.IsScriptArray() ) { asCDataType sub = dt; while( sub.IsScriptArray() && !sub.IsObjectHandle() ) sub = sub.GetSubType(); dt = sub; } if( dt.IsObject() && !dt.IsObjectHandle() ) { // Find the class declaration sClassDeclaration *pdecl = 0; for( asUINT p = 0; p < classDeclarations.GetLength(); p++ ) { if( classDeclarations[p]->objType == dt.GetObjectType() ) { pdecl = classDeclarations[p]; break; } } if( pdecl ) { if( pdecl->objType == decl->objType ) { int r, c; decl->script->ConvertPosToRowCol(decl->node->tokenPos, &r, &c); WriteError(decl->script->name.AddressOf(), TXT_ILLEGAL_MEMBER_TYPE, r, c); validState = 2; break; } else if( pdecl->validState != 1 ) { validState = pdecl->validState; break; } } } } if( validState == 1 ) { decl->validState = 1; toValidate.PopLast(); } else if( validState == 2 ) { decl->validState = 2; toValidate.PopLast(); } else { toValidateNext.PushLast(toValidate.PopLast()); } } toValidate = toValidateNext; toValidateNext.SetLength(0); if( numClasses == toValidate.GetLength() ) { int r, c; toValidate[0]->script->ConvertPosToRowCol(toValidate[0]->node->tokenPos, &r, &c); WriteError(toValidate[0]->script->name.AddressOf(), TXT_ILLEGAL_MEMBER_TYPE, r, c); break; } } if( numErrors > 0 ) return; // TODO: The declarations form a graph, all circles in // the graph must be flagged as potential circles // Verify potential circular references for( n = 0; n < classDeclarations.GetLength(); n++ ) { sClassDeclaration *decl = classDeclarations[n]; asCObjectType *ot = decl->objType; // Is there some path in which this structure is involved in circular references? for( asUINT p = 0; p < ot->properties.GetLength(); p++ ) { asCDataType dt = ot->properties[p]->type; if( dt.IsObject() ) { // Any structure that contains an any type can generate circular references if( dt.GetObjectType()->flags & asOBJ_CONTAINS_ANY ) { ot->flags |= asOBJ_POTENTIAL_CIRCLE | asOBJ_CONTAINS_ANY; } if( dt.IsObjectHandle() ) { // TODO: // Can this handle really generate a circular reference ot->flags |= asOBJ_POTENTIAL_CIRCLE; } else if( dt.GetObjectType()->flags & asOBJ_POTENTIAL_CIRCLE ) { // TODO: // Just because the member type is a potential circle doesn't mean that this one is ot->flags |= asOBJ_POTENTIAL_CIRCLE; } if( dt.IsArrayType() ) { asCDataType sub = dt.GetSubType(); while( sub.IsObject() ) { if( sub.IsObjectHandle() || (sub.GetObjectType()->flags & asOBJ_POTENTIAL_CIRCLE) ) { decl->objType->flags |= asOBJ_POTENTIAL_CIRCLE; // Make sure the array object is also marked as potential circle sub = dt; while( sub.IsScriptArray() ) { sub.GetObjectType()->flags |= asOBJ_POTENTIAL_CIRCLE; sub = sub.GetSubType(); } break; } if( sub.IsScriptArray() ) sub = sub.GetSubType(); else break; } } } } } // Verify that the class implements all the methods from the interfaces it implements for( n = 0; n < classDeclarations.GetLength(); n++ ) { sClassDeclaration *decl = classDeclarations[n]; asCScriptCode *file = decl->script; // Enumerate each of the implemented interfaces asCScriptNode *node = decl->node->firstChild->next; while( node && node->nodeType == snIdentifier ) { // Get the interface name from the node GETSTRING(name, &file->code[node->tokenPos], node->tokenLength); // Find the object type for the interface asCObjectType *objType = GetObjectType(name.AddressOf()); if( decl->objType->Implements(objType) ) { int r, c; file->ConvertPosToRowCol(node->tokenPos, &r, &c); WriteWarning(file->name.AddressOf(), TXT_INTERFACE_ALREADY_IMPLEMENTED, r, c); } else { decl->objType->interfaces.PushLast(objType); // Make sure all the methods of the interface are implemented for( asUINT i = 0; i < objType->methods.GetLength(); i++ ) { if( !DoesMethodExist(decl->objType, objType->methods[i]) ) { int r, c; file->ConvertPosToRowCol(decl->node->tokenPos, &r, &c); asCString str; str.Format(TXT_MISSING_IMPLEMENTATION_OF_s, engine->GetFunctionDeclaration(objType->methods[i]).AddressOf()); WriteError(file->name.AddressOf(), str.AddressOf(), r, c); } } } node = node->next; } } }
static const char *config_control(struct control **as) { const char *t = 0; struct control *a, *b; struct simple_list *l; b = *as; while (b && b->locations) b = b->next; MAKE(a, struct control); a->locations = 0; a->alias = 0; a->clients = 0; if (b) { a->index_names = b->index_names; a->accesses = b->accesses; a->mimes = b->mimes; a->symlinksok = b->symlinksok; a->path_args_ok = b->path_args_ok; a->loglevel = b->loglevel; a->admin = b->admin; a->refresh = b->refresh; } else { a->index_names = 0; a->accesses = 0; a->mimes = 0; a->symlinksok = 0; a->path_args_ok = 0; a->loglevel = 0; a->admin = 0; a->refresh = 0; } a->next = *as; *as = a; GETOPEN(); while (NOTCLOSE()) { REQWORD(); if (strceq(tokbuf, c_location)) { MAKE(l, struct simple_list); GETSTRING(); chopslash(tokbuf); COPY(l->name, tokbuf); if (a->locations) { l->next = a->locations->next; a->locations->next = l; } else { l->next = l; a->locations = l; } } else if (strceq(tokbuf, c_alias)) { GETSTRING(); chopslash(tokbuf); COPY(a->alias, tokbuf); } else if (strceq(tokbuf, c_symlinks)) t = config_flag(&a->symlinksok); else if (strceq(tokbuf, c_path_args)) t = config_flag(&a->path_args_ok); else if (strceq(tokbuf, c_loglevel)) t = config_int(&a->loglevel); else if (strceq(tokbuf, c_index_names)) t = config_list(&a->index_names); else if (strceq(tokbuf, c_access)) t = config_access(&a->accesses); else if (strceq(tokbuf, c_clients)) t = config_access(&a->clients); else if (strceq(tokbuf, c_types)) t = config_mime(&a->mimes, M_TYPE); else if (strceq(tokbuf, c_specials)) t = config_mime(&a->mimes, M_SPECIAL); else if (strceq(tokbuf, c_admin)) t = config_string(&a->admin); else if (strceq(tokbuf, c_refresh)) t = config_int(&a->refresh); else t = e_keyword; if (t) return t; } if (a->alias && (a->locations == 0)) return e_bad_alias; return 0; }
int asCBuilder::RegisterScriptFunction(int funcID, asCScriptNode *node, asCScriptCode *file) { // Find name asCScriptNode *n = node->firstChild->next->next; // Check for name conflicts GETSTRING(name, &file->code[n->tokenPos], n->tokenLength); CheckNameConflict(name.AddressOf(), n, file); sFunctionDescription *func = new sFunctionDescription; functions.PushLast(func); func->script = file; func->node = node; func->name = name; // Initialize a script function object for registration asCDataType returnType; returnType = CreateDataTypeFromNode(node->firstChild, file); returnType = ModifyDataTypeFromNode(returnType, node->firstChild->next, 0, 0); module->RefConfigGroupForObjectType(returnType.GetObjectType()); asCArray<asCDataType> parameterTypes; asCArray<int> inOutFlags; n = n->next->firstChild; while( n ) { int inOutFlag; asCDataType type = CreateDataTypeFromNode(n, file); type = ModifyDataTypeFromNode(type, n->next, &inOutFlag, 0); module->RefConfigGroupForObjectType(type.GetObjectType()); // Store the parameter type parameterTypes.PushLast(type); inOutFlags.PushLast(inOutFlag); // Move to next parameter n = n->next->next; if( n && n->nodeType == snIdentifier ) n = n->next; } // Check that the same function hasn't been registered already asCArray<int> funcs; GetFunctionDescriptions(name.AddressOf(), funcs); if( funcs.GetLength() ) { for( asUINT n = 0; n < funcs.GetLength(); ++n ) { asCScriptFunction *func = GetFunctionDescription(funcs[n]); if( parameterTypes.GetLength() == func->parameterTypes.GetLength() ) { bool match = true; for( asUINT p = 0; p < parameterTypes.GetLength(); ++p ) { if( parameterTypes[p] != func->parameterTypes[p] ) { match = false; break; } } if( match ) { int r, c; file->ConvertPosToRowCol(node->tokenPos, &r, &c); WriteError(file->name.AddressOf(), TXT_FUNCTION_ALREADY_EXIST, r, c); break; } } } } // Register the function module->AddScriptFunction(file->idx, funcID, func->name.AddressOf(), returnType, parameterTypes.AddressOf(), inOutFlags.AddressOf(), parameterTypes.GetLength()); return 0; }