UPnpCMGR::UPnpCMGR ( UPnpDevice *pDevice, const QString &sSharePath, const QString &sSourceProtocols, const QString &sSinkProtocols ) : Eventing( "UPnpCMGR", "CMGR_Event", sSharePath) { AddVariable( new StateVariable< QString >( "SourceProtocolInfo" , true ) ); AddVariable( new StateVariable< QString >( "SinkProtocolInfo" , true ) ); AddVariable( new StateVariable< QString >( "CurrentConnectionIDs", true ) ); AddVariable( new StateVariable< QString >( "FeatureList" , true ) ); SetValue< QString >( "CurrentConnectionIDs", "0" ); SetValue< QString >( "SourceProtocolInfo" , sSourceProtocols ); SetValue< QString >( "SinkProtocolInfo" , sSinkProtocols ); SetValue< QString >( "FeatureList" , "" ); QString sUPnpDescPath = UPnp::GetConfiguration()->GetValue( "UPnP/DescXmlPath", m_sSharePath ); m_sServiceDescFileName = sUPnpDescPath + "CMGR_scpd.xml"; m_sControlUrl = "/CMGR_Control"; // Add our Service Definition to the device. RegisterService( pDevice ); }
UPnpCDS::UPnpCDS( UPnpDevice *pDevice, const QString &sSharePath ) : Eventing( "UPnpCDS", "CDS_Event" ) { m_extensions.setAutoDelete( true ); m_root.m_eType = OT_Container; m_root.m_sId = "0"; m_root.m_sParentId = "-1"; m_root.m_sTitle = "MythTv"; m_root.m_sClass = "object.container"; m_root.m_bRestricted= true; m_root.m_bSearchable= true; AddVariable( new StateVariable< QString >( "TransferIDs" , true ) ); AddVariable( new StateVariable< QString >( "ContainerUpdateIDs", true ) ); AddVariable( new StateVariable< unsigned short >( "SystemUpdateID" , true ) ); SetValue< unsigned short >( "SystemUpdateID", 1 ); QString sUPnpDescPath = UPnp::g_pConfig->GetValue( "UPnP/DescXmlPath", sSharePath ); m_sSharePath = sSharePath; m_sServiceDescFileName = sUPnpDescPath + "CDS_scpd.xml"; m_sControlUrl = "/CDS_Control"; // Add our Service Definition to the device. RegisterService( pDevice ); }
void IBActionDef_FindPath::Define() { AddVariable("Start"); AddVariable("Target"); AddVariable("Path"); AddVariable("Dist"); AddPostCondition("IBFactDef_HasValidPath", "Path", "Start", "Target", "Dist"); }
void IBActionDef_UnblockProp::Define() { AddVariable("Obj"); // BLObject AddVariable("ObjPos"); // IBVector2 AddVariable("Dist"); // IBInt = 1 AddPreCondition("IBFactDef_BotNearPos", "ObjPos", "Dist"); AddPreCondition("IBFactDef_PropIsBlock", "Obj"); AddPostCondition("IBFactDef_PropIsUnblock", "Obj"); }
int CExpressionCaculator::DealVariableDefine(int start,CBolanStack& ScriptList) { int pos=start; CVariable * pVar; while(pos<ScriptList.GetSize()) { switch(ScriptList.GetAt(pos)->type) { case BOLAN_TYPE_VARIABLE: pVar=m_VarList.GetObject(ScriptList.GetAt(pos)->StrValue); if(pVar==NULL) return 4012; ScriptList.GetAt(pos)->index=pVar->ID; ScriptList.GetAt(pos)->level=pVar->type; pos++; break; case BOLAN_TYPE_KEYWORD: switch((int)(ScriptList.GetAt(pos)->index)) { case KW_NUMBER: pos++; if(ScriptList.GetAt(pos)->type!=BOLAN_TYPE_VARIABLE) return 4010; pVar=m_VarList.GetObject(ScriptList.GetAt(pos)->StrValue); if(pVar==NULL) AddVariable(ScriptList.GetAt(pos)->StrValue,VALUE_TYPE_NUMBER,0,NULL); pos++; break; case KW_STRING: pos++; if(ScriptList.GetAt(pos)->type!=BOLAN_TYPE_VARIABLE) return 4011; pVar=m_VarList.GetObject(ScriptList.GetAt(pos)->StrValue); if(pVar==NULL) AddVariable(ScriptList.GetAt(pos)->StrValue,VALUE_TYPE_STRING,0,NULL); pos++; break; default: pos++; } break; default: pos++; } } return 0; }
GVarList::GVarList ( istream& input ) : JVariableList() { GVarListX(); input >> ws; while (input.peek() != '*') { JCharacter type; input >> type >> ws; if (type == 'N') { JString name = JReadUntilws(input); if (name.GetLastCharacter() != ']') { JFloat value; input >> value; AddVariable(name, value); } else {
void Y_add_variable(int nArgs) { Operand op; IOStream *file; long address; char *name; StructDef *base; Symbol *stack= sp-nArgs+1; if (nArgs<4) YError("add_variable requires at least four arguments"); file= YGetFile(stack++); address= YGetInteger(stack++); name= YGetString(stack++); stack->ops->FormOperand(stack, &op); if (op.ops==&structDefOps) base= op.value; else if (op.ops==&stringOps && !op.type.dims) { char *typeName= ((char **)op.value)[0]; if (!typeName || !HashFind(&file->structTable, typeName, 0L)) YError("4th argument refers to non-existent data type"); base= file->structList[hashIndex]; } else { YError("4th argument must be either string or struct definition"); base= 0; } nArgs-= 4; stack++; BuildDimList(stack, nArgs); AddVariable(file, address, name, base, tmpDims); }
//----------------------------------------------------------------------------- // Sets the value of an existing variable in the script. //----------------------------------------------------------------------------- void Script::SetVariable( char *name, void *value ) { // Find the variable. Variable *variable = NULL; m_variables->Iterate( true ); while( m_variables->Iterate() != NULL ) { if( strcmp( m_variables->GetCurrent()->GetName(), name ) == 0 ) { variable = m_variables->GetCurrent(); break; } } // Ensure the variable was found. if( variable == NULL ) return; // Get the variable's type. char type = variable->GetType(); // Destroy the variable. m_variables->Remove( &variable ); // Add the variable back in with the new value. AddVariable( name, type, value ); }
static int ParseIdentifier(EvalState *c, PVAL *pval) { char id[ID_MAX]; char *p = id; Function *fcn; /* parse the identifier */ while (*c->linePtr != '\0' && (isalnum(*c->linePtr) || *c->linePtr == '_')) { if (p < id + ID_MAX - 1) *p++ = *c->linePtr; ++c->linePtr; } *p = '\0'; /* check for a function name */ for (fcn = functions; fcn->name != NULL; ++fcn) if (strcasecmp(id, fcn->name) == 0) { pval->type = TYPE_FUNCTION; pval->v.fcn = fcn; return TKN_FCALL; } /* check for an application symbol reference */ if ((*c->findSymbol)(c->cookie, id, &pval->v.value)) pval->type = TYPE_NUMBER; /* check for a variable reference */ else if (!AddVariable(c, id, pval)) Error(c, "insufficient variable space"); /* return an identifier */ return TKN_IDENTIFIER; }
// Set the value of an existing variable in the script void Script::SetVariable( char *name, void *value ) { // Find variable Variable *variable = NULL; m_variables ->Iterate( true ); // Iterate through linked list while( m_variables ->Iterate() != NULL ) { // Get the current existing variables if( strcmp( m_variables ->GetCurrent() ->GetName() , name ) == 0 ) { variable = m_variables ->GetCurrent(); break; } } // Make sure variable was found if( variable == NULL ) return; // Get variable's type char type = variable ->GetType(); // Destroy variable m_variables ->Remove( &variable ); // Add variable back with new value AddVariable( name, type, value ); }
////////////////////////////////////////////////////////////////////////// // FStructureEditorUtils UUserDefinedStruct* FStructureEditorUtils::CreateUserDefinedStruct(UObject* InParent, FName Name, EObjectFlags Flags) { UUserDefinedStruct* Struct = NULL; if (UserDefinedStructEnabled()) { Struct = NewObject<UUserDefinedStruct>(InParent, Name, Flags); check(Struct); Struct->EditorData = NewObject<UUserDefinedStructEditorData>(Struct, NAME_None, RF_Transactional); check(Struct->EditorData); Struct->Guid = FGuid::NewGuid(); Struct->SetMetaData(TEXT("BlueprintType"), TEXT("true")); Struct->Bind(); Struct->StaticLink(true); Struct->Status = UDSS_Error; { const UEdGraphSchema_K2* K2Schema = GetDefault<UEdGraphSchema_K2>(); AddVariable(Struct, FEdGraphPinType(K2Schema->PC_Boolean, FString(), NULL, false, false)); } } return Struct; }
bool _HYDistributionChartWindow::_ProcessMenuSelection (long msel) { switch (msel) { case HY_CHARTD_WIN32_MENU_BASE: { AddVariable (); return true; } case HY_CHARTD_WIN32_MENU_BASE+1: { RemoveVariable (); return true; } case HY_CHARTD_WIN32_MENU_BASE+2: { ShowMarginals (); return true; } default: { if (msel>=HY_CHARTD_WIN32_MENU_BASE+3) { HandleCatPostProcessor (msel-HY_CHARTD_WIN32_MENU_BASE-3); return true; } } } return _HYChartWindow::_ProcessMenuSelection(msel); }
void IBActionDef_PushProp::Define() { AddVariable("Obj"); // BLObject AddVariable("PushPos"); // IBVector2 AddVariable("ObjPos"); // IBVector2 AddVariable("DestPos"); // IBVector2 AddVariable("Dist"); // IBInt = 0 AddPreCondition("IBFactDef_PosIsFree", "DestPos"); AddPreCondition("IBFactDef_ObjectAtPos", "Obj", "ObjPos"); AddPreCondition("IBFactDef_PropIsMovable", "Obj"); AddPreCondition("IBFactDef_BotNearPos", "PushPos", "Dist"); AddPreCondition("IBFactDef_PosIsFree", "PushPos"); AddPostCondition("IBFactDef_ObjectAtPos", "Obj", "DestPos"); AddPostCondition("IBFactDef_PosIsFree", "ObjPos"); AddCounterPostCondition("IBFactDef_PosIsFree", "DestPos"); }
CodeGen::GenState* CodeGen::GenerateDefaultState() { auto state = GenState::CreateNewState(); auto _print_fun_ = Context::GetGC()->New<Function>(Context::_print_); auto _fun_id = state->AddConstant(_print_fun_->toValue()); auto var_id = state->AddVariable(u"print"); state->AddInstruction(VM_CODE::LOAD_C, _fun_id); state->AddInstruction(VM_CODE::STORE_V, var_id); return state; }
void ScreenRender::Init() { Add("data/shaders/2d_vert.txt", GL_VERTEX_SHADER); Add("data/shaders/2d_frag.txt", GL_FRAGMENT_SHADER); Link(); AddVariable("texture"); AddVariable("texture1"); AddVariable("texture2"); AddVariable("use_dof"); AddVariable("white_point"); this->quad = new Quad(); }
void Effect::ExtractGlobalVars(D3DX11_EFFECT_DESC& effectDesc) { for(U32 i = 0; i < effectDesc.GlobalVariables; ++i) { ID3DX11EffectVariable* pVar = dx11Effect->GetVariableByIndex(i); D3DX11_EFFECT_VARIABLE_DESC varDesc; DXCall(pVar->GetDesc(&varDesc)); ID3DX11EffectType* pType = pVar->GetType(); D3DX11_EFFECT_TYPE_DESC typeDesc; DXCall(pType->GetDesc(&typeDesc)); AddVariable(pVar, &varDesc, &typeDesc); } }
UPnpMSRR::UPnpMSRR( UPnpDevice *pDevice, const QString &sSharePath ) : Eventing( "UPnpMSRR", "MSRR_Event", sSharePath) { AddVariable( new StateVariable< unsigned short >( "AuthorizationGrantedUpdateID", true ) ); AddVariable( new StateVariable< unsigned short >( "AuthorizationDeniedUpdateID" , true ) ); AddVariable( new StateVariable< unsigned short >( "ValidationSucceededUpdateID" , true ) ); AddVariable( new StateVariable< unsigned short >( "ValidationRevokedUpdateID" , true ) ); SetValue< unsigned short >( "AuthorizationGrantedUpdateID", 0 ); SetValue< unsigned short >( "AuthorizationDeniedUpdateID" , 0 ); SetValue< unsigned short >( "ValidationSucceededUpdateID" , 0 ); SetValue< unsigned short >( "ValidationRevokedUpdateID" , 0 ); QString sUPnpDescPath = UPnp::GetConfiguration()->GetValue( "UPnP/DescXmlPath", m_sSharePath ); m_sServiceDescFileName = sUPnpDescPath + "MSRR_scpd.xml"; m_sControlUrl = "/MSRR_Control"; // Add our Service Definition to the device. RegisterService( pDevice ); }
/** * Check primary expression */ static AstExpression CheckPrimaryExpression(AstExpression expr) { Symbol p; if (expr->op == OP_CONST) return expr; if (expr->op == OP_STR) { expr->op = OP_ID; expr->val.p = AddString(expr->ty, expr->val.p); expr->lvalue = 1; return expr; } p = LookupID(expr->val.p); if (p == NULL) { Error(&expr->coord, "Undeclared identifier: %s", expr->val.p); p = AddVariable(expr->val.p, T(INT), Level == 0 ? 0 : TK_AUTO); expr->ty = T(INT); expr->lvalue = 1; } else if (p->kind == SK_TypedefName) { Error(&expr->coord, "Typedef name cannot be used as variable"); expr->ty = T(INT); } else if (p->kind == SK_EnumConstant) { expr->op = OP_CONST; expr->val = p->val; expr->ty = T(INT); } else { expr->ty = p->ty; expr->val.p = p; expr->inreg = p->sclass == TK_REGISTER; expr->lvalue = expr->ty->categ != FUNCTION; } return expr; }
void ScriptEngine::parseVar(char * c, char ** args) { // $VARIABLE = value NamedVar var; if (_numVars == MAX_VARIABLES) { WriteLine(PSTR("Maximum variables in use.\r\n")); return; } if ( var = GetVariableByName((++c)), !strcmp(var.name,"!FOUND")) { // new variable var = GetNextAvailVariable(); StringCopy(var.name,c); var.val.val16 = atol(args[1]); if (!AddVariable(var)) WriteLine(PSTR("Problem writing variable to EEPROM.")); } else { // reassigning an instantiated variable var.val.val16 = atoi(args[1]); eeprom_write_block((const void*)&var,(void*)&Variables[var.slot], sizeof(NamedVar)); } }
void ParseFrame(FILE* Handle, frame* Frame) { char Token[MAX_NAME]; char VarName[MAX_NAME]; char VarValue[MAX_NAME]; do fscanf(Handle, "%s", Token); while(!feof(Handle) && strcmp(Token, "Frame")); if(feof(Handle)) exit(1); fscanf(Handle, "%ld", &(Frame->Number)); fscanf(Handle, "%s", Token); if(strcmp(Token, "Begin")) fprintf(stderr, "No 'Begin' at frame %ld\n", Frame->Number); fscanf(Handle, "%s", Token); Frame->Vars.Count=0; while(strcmp(Token, "End") && !feof(Handle)) { int i; strcpy(VarName, Token); ScanValue(Handle, VarValue); AddVariable(Frame, VarName, VarValue); fscanf(Handle, "%s", Token); } }
CExpressionCaculator::CExpressionCaculator(int MaxVariableCount,int MaxFactionCount) { m_VarList.Create(MaxVariableCount); m_FactionList.Create(MaxFactionCount); ZeroMemory(m_InterruptDataBuff,sizeof(m_InterruptDataBuff)); m_CurInterrupt=IPT_NONE; m_StackUseStatus=0; AddFaction("IFF",3,0,IfFN); AddFaction("SIN",1,0,SinFN); AddFaction("COS",1,0,CosFN); AddFaction("ROUND",2,0,RoundFN); AddFaction("STRCMP",2,0,StrCmpFN); AddFaction("NumToStr",1,0,NumToStrFN); AddFaction("Random",1,0,RandomFN); AddVariable("PI",VALUE_TYPE_NUMBER,3.141592653589793238462643383280,NULL); }
void RandBipartiteGraph::GenerateGraph() { // make n left-vertices for(unsigned int i = 0; i < n; i++){ AddVariable(i); } vector<Vertex*> availableVertexList; availableVertexList.reserve(n); gen.seed(time(NULL)); if (c%d != 0){ // make c/d n right-vertices for(unsigned int i = 0; i < GetRightVerticesNumber(); i++){ availableVertexList.push_back(static_cast<Vertex*>(AddConstraint(i))); } } for (unsigned int i = 0; i < n; i++){ for(unsigned int j = 0; j < c; j++){ AddEdge(static_cast<Vertex*>(variables[i]), GetRandRightVertex(availableVertexList)); } } }
SCCircuitVarList::SCCircuitVarList() : JVariableList() { SCCircuitVarListX(); // we always need the frequency variables f,w,s JBoolean ok = AddVariable("f", 0.0, kJTrue); assert( ok ); JFunction* f; ok = JParseFunction("2*pi*f", this, &f); assert( ok ); ok = AddFunction("`w", *f, kJFalse); assert( ok ); delete f; ok = JParseFunction("j*`w", this, &f); assert( ok ); ok = AddFunction("s", *f, kJFalse); assert( ok ); delete f; }
BOOL FASTCALL comProc_VarDeclare(U16 flags, S16 *brackCnt) { int cast,arraySize,elementsSize,braceCnt; S32 offset=-1,elementsEnd; S32 num; U16 varflags = 0; char *label=NULL; VAR *castvar=NULL; VAR *var=NULL,*pvar; BOOL VARSET, SEEKED = FALSE; if(!STRCMP(szTemp,"typedef")) { varflags |= VARFLAG_TYPECAST; GetNextWord(); } if(!STRCMP(szTemp,"shared")) { varflags |= VARFLAG_SHARED; GetNextWord(); } if((cast=IsVarCast(szTemp,&castvar))==VARCAST_NULL) { if(varflags&VARFLAG_TYPECAST) { error(ERR_NOTTYPECAST,szTemp); return TRUE; } return FALSE; } if(curVar&&(curVar->flags&VARFLAG_TYPECAST)) varflags |= VARFLAG_TYPECAST; for(;;) { if(!IsStringLabel(GetNextWord())) { error(ERR_BADLABEL,szTemp); sprintf(szTemp, "invlabel_%04X", invlabel++); } else { if(PRECOMPILING && IsLabelUsed(szTemp,curVar?curVar->childVars:vars)) sprintf(szTemp, "invlabel_%04X", invlabel++); } label = strdup(szTemp); if(PeekNextWord()[0]==':') { GetNextWord(); if(IsStrNum(GetNextWord())) { offset = ConfirmWord(StrToInt(szTemp)); varflags |= VARFLAG_FIXED; } else error(ERR_INTEXP); VARSET = TRUE; } else { if(varflags&VARFLAG_TYPECAST) VARSET = TRUE; else if(!curBank) fatal(FTL_VARNOTROMBANK); if(cast == VARCAST_STRUCT && !(varflags & VARFLAG_TYPECAST) && !PRECOMPILING) { offset = GetBankOffset(); VARSET = TRUE; } else VARSET = FALSE; } if(PRECOMPILING) { var = AddVariable(label, cast, castvar, varflags, offset); if(varflags&VARFLAG_TYPECAST) { if(curVar) { var->offset = VarSize(curVar); } } } else { var = FindVariable(curVar?curVar->childVars:(varflags&VARFLAG_TYPECAST)?typedefs:vars, label); if(!(var->flags&VARFLAG_TYPECAST) && (!(var->flags&VARFLAG_DEFCASTED) || cast!=VARCAST_STRUCT) && (var->offset==-1)) SetVarOffsets(var,GetBankOffset(),FALSE); } if(castvar) { var->size = castvar->size; } arraySize = 0; if(PeekNextWord()[0]=='[') { GetNextWord(); if(PeekNextWord()[0]==']') { arraySize=-1;//autosize GetNextWord(); } else { /* if(IsStrNum(szTemp)) { if(((var->flags&VARFLAG_TYPECAST) && PRECOMPILING) || (!(var->flags&VARFLAG_TYPECAST))) { arraySize = ConfirmWord(StrToInt(szTemp)); var->arraySize = arraySize; } } else error(ERR_INTEXP); */ CompileImmediateInteger(0, &num, -1, 0); if(((var->flags&VARFLAG_TYPECAST) && PRECOMPILING) || (!(var->flags&VARFLAG_TYPECAST))) { arraySize = ConfirmWord(num); var->arraySize = arraySize; } if(GetNextWord()[0]!=']') error(ERR_ARRAYENDEXP,szTemp); } } if(!(var->flags&VARFLAG_DEFCASTED) && (cast==VARCAST_STRUCT)) { SetCurVar(var); GetCode(flags|CF_BRACEOK|CF_GETNEXTWORD, brackCnt); ReleaseCurVar(); } else { if(PeekNextWord()[0]=='=') { GetNextWord(); if(var->flags&VARFLAG_TYPECAST) { error(ERR_VARCASTASSIGN,label); SeekPastBraceBlock(); } else if(curBank->type==BANKTYPE_RAM) { error(ERR_VARDECLAREINRAM); SeekPastBraceBlock(); } else { elementsSize = 0; elementsEnd = (GetBankOffset()-curBank->org) + ((arraySize==-1)? var->size:var->size*arraySize); if(GetNextWord()[0]=='{') { if(!arraySize) { error(ERR_NOTARRAY,var->label); } braceCnt = 1; GetNextWord(); } else braceCnt = 0; do { braceCnt = CompileVarBody(flags,brackCnt, var, &elementsSize, braceCnt, cast); } while(braceCnt); if(!PRECOMPILING) { if(arraySize==-1) { arraySize=elementsSize/VarSize(var); SEEKED = TRUE; } else { if(elementsSize>VarSize(var)) error(ERR_ELEMENTSTOOLARGE,var->label,elementsSize-VarSize(var)); BankSeek(elementsEnd); SEEKED = TRUE; } var->arraySize = arraySize; } } } else { if(((var->flags&VARFLAG_TYPECAST) && PRECOMPILING) || (!(var->flags&VARFLAG_TYPECAST) && !PRECOMPILING && !VARSET)) { if(arraySize==-1) arraySize = 1; if(arraySize!=0) var->arraySize = arraySize; if(!PRECOMPILING) { BankSeekFwd(VarSize(var)); SEEKED = TRUE; } } } if(((var->flags&VARFLAG_TYPECAST) && PRECOMPILING) || (!(var->flags&VARFLAG_TYPECAST) && !PRECOMPILING)) { // adjust all the var sizes for structs arraySize = VarSize(var); pvar = var->parent; while(pvar) { pvar->size += arraySize; pvar = pvar->parent; } } } if(!(var->flags&VARFLAG_TYPECAST) && (cast==VARCAST_STRUCT)) SetVarOffsets(var,offset,FALSE); // removed 2004-05-22, if problems occurs, check if(!SEEKED && (var->flags&(VARFLAG_TYPECAST|VARFLAG_DEFCASTED))==VARFLAG_DEFCASTED && (cast==VARCAST_STRUCT)) { CheckCurBank(); if((var->flags&VARFLAG_TYPECAST) || !PRECOMPILING) BankSeekFwd(VarSize(var)); } ssFree(label); if(PeekNextWord()[0]!=',') break; GetNextWord(); } return TRUE; }
void CServerPage::Create() { AddChild(new CButton(w-140,h-55,120,35,this,M_BACK,1)); #define AddServerChild(x) { CWnd* w=x; AddChild(w); if (!game->IsServer)w->canfocus=FALSE; } int x=30; const int plus=35; const int minus=70; const int breite=200; const PCHAR pPlus="+"; const PCHAR pMinus="-"; { // Hühner const int y=70; AddChild(new CCountGroupBox(x,y,breite,55,M_CHICKEN,this,IDChicken)); AddServerChild(new CButton(x+breite-plus,y+20,25,25,this,pPlus,2)); AddServerChild(new CButton(x+breite-minus,y+20,25,25,this,pMinus,3)); } { // Bauern const int y=135; AddChild(new CCountGroupBox(x,y,breite,55,M_FARMER,this,IDBauer)); AddServerChild(new CButton(x+breite-plus,y+20,25,25,this,pPlus,16)); AddServerChild(new CButton(x+breite-minus,y+20,25,25,this,pMinus,17)); } { // Ställe const int y=200; AddChild(new CCountGroupBox(x,y,breite,55,M_STAELLE,this,IDStall)); AddServerChild(new CButton(x+breite-plus,y+20,25,25,this,pPlus,4)); AddServerChild(new CButton(x+breite-minus,y+20,25,25,this,pMinus,5)); } { // Bäume const int y=265; AddChild(new CCountGroupBox(x,y,breite,55,M_TREES,this,IDTree)); AddServerChild(new CButton(x+breite-plus,y+20,25,25,this,pPlus,6)); AddServerChild(new CButton(x+breite-minus,y+20,25,25,this,pMinus,7)); } { // Gartenkrallen const int y=330; AddChild(new CCountGroupBox(x,y,breite,55,M_GARTENKRALLEN,this,IDGartenkralle)); AddServerChild(new CButton(x+breite-plus,y+20,25,25,this,pPlus,8)); AddServerChild(new CButton(x+breite-minus,y+20,25,25,this,pMinus,9)); } { // Golfschläger const int y=395; AddChild(new CCountGroupBox(x,y,breite,55,M_GOLFSCHLAEGER,this,IDGolfer)); AddServerChild(new CButton(x+breite-plus,y+20,25,25,this,pPlus,10)); AddServerChild(new CButton(x+breite-minus,y+20,25,25,this,pMinus,11)); } { // Mähdrescher const int y=460; AddChild(new CCountGroupBox(x,y,breite,55,M_DRESCHER,this,IDDrescher)); AddServerChild(new CButton(x+breite-plus,y+20,25,25,this,pPlus,12)); AddServerChild(new CButton(x+breite-minus,y+20,25,25,this,pMinus,13)); } { // Plasmakanonen const int y=525; AddChild(new CCountGroupBox(x,y,breite,55,M_PLASMACANNONS,this,IDPlasmaCannon)); AddServerChild(new CButton(x+breite-plus,y+20,25,25,this,pPlus,14)); AddServerChild(new CButton(x+breite-minus,y+20,25,25,this,pMinus,15)); } AddServerChild(new CCheckBox(260,490,breite,25,this,M_KI,50,Config.KI)); AddServerChild(new CCheckBox(260,520,breite+15,25,this,M_PRESSURE,51,game->PlasmaBallPressure)); x=260; { // Variablen CHAR c[100]; sprintf(&c[0],M_EINSTELLUNGEN); AddChild(new CGroupBox(x,70,800-x-20,410,&c[0],this)); #define AddVariable(xpos,ypos,title,min,max,pos,step,command) \ AddChild(new CStaticText(x+20+(xpos-1)*250,90-60+ypos*60,230,25,this,title)); \ AddServerChild(new CSlider(x+20+(xpos-1)*250,90-60+ypos*60+25,230,35,this,min,max,pos,step,command,TRUE,FALSE)); { AddVariable(1,1,M_AIRCONTROL,0.0f,3.0f,game->aircontrol,0.2f,20); AddVariable(1,2,M_EGGDAMAGE,1.0f,50.0f,game->damage,2.0f,21); AddVariable(1,3,M_GRAVITY,1.0f,20.0f,game->gravity,1.0f,22); AddVariable(1,4,M_JUMPMULTIPLIER,0.0f,3.0f,game->jumpspeed,0.2f,23); } { AddVariable(1,5,M_PLASMARATE,0.2f,3.0f,game->plasmarate,0.2f,24); AddVariable(1,6,M_PLASMAREGENERATION,0.05f,1.0f,game->plasmaregeneration,0.05f,25); } { AddVariable(2,1,M_REGENERATEPOWER,1.0f,10.0f,game->replenishpower,0.5f,26); AddVariable(2,2,M_SITSPEED,1.0f,15.0f,game->sittime,0.5f,27); AddVariable(2,3,M_TAKEPOWER,1.0f,20.0f,game->takepower,1.0f,28); AddVariable(2,4,M_THROWTIME,0.1f,2.0f,game->throwtime,0.1f,29); AddVariable(2,5,M_RESPAWNTIME,1.0f,10.0f,game->respawntime,0.5f,30); } } }
void csShaderManager::AddDefaultVariables() { AddVariable (sv_time); }
static int ReadCommands(CurPos &cp, const char *Name) { STARTFUNC("ReadCommands"); LOG << "Name = " << (Name != NULL ? Name : "(null)") << ENDLINE; unsigned char obj; unsigned short len; long Cmd = NewCommand(Name); long cmdno; if (GetObj(cp, len) != CF_INT) ENDFUNCRC(-1); if (GetNum(cp, cmdno) == 0) ENDFUNCRC(-1); if (cmdno != (Cmd | CMD_EXT)) { fprintf(stderr, "Bad Command map %s -> %ld != %ld\n", Name, Cmd, cmdno); ENDFUNCRC(-1); } while ((obj = GetObj(cp, len)) != 0xFF) { switch (obj) { case CF_COMMAND: { // char *s; long cnt; long ign; long cmd; // if ((s = GetCharStr(cp, len)) == 0) return -1; if (GetNum(cp, cmd) == 0) ENDFUNCRC(-1); if (GetObj(cp, len) != CF_INT) ENDFUNCRC(-1); if (GetNum(cp, cnt) == 0) ENDFUNCRC(-1); if (GetObj(cp, len) != CF_INT) ENDFUNCRC(-1); if (GetNum(cp, ign) == 0) ENDFUNCRC(-1); // if (cmd != CmdNum(s)) { // fprintf(stderr, "Bad Command Id: %s -> %d\n", s, cmd); // return -1; // } if (AddCommand(Cmd, cmd, cnt, ign) == 0) { if (Name == 0 || strcmp(Name, "xx") != 0) { fprintf(stderr, "Bad Command Id: %ld\n", cmd); ENDFUNCRC(-1); } } } break; case CF_STRING: { const char *s = GetCharStr(cp, len); if (s == 0) ENDFUNCRC(-1); if (AddString(Cmd, s) == 0) ENDFUNCRC(-1); } break; case CF_INT: { long num; if (GetNum(cp, num) == 0) ENDFUNCRC(-1); if (AddNumber(Cmd, num) == 0) ENDFUNCRC(-1); } break; case CF_VARIABLE: { long num; if (GetNum(cp, num) == 0) ENDFUNCRC(-1); if (AddVariable(Cmd, num) == 0) ENDFUNCRC(-1); } break; case CF_CONCAT: if (AddConcat(Cmd) == 0) ENDFUNCRC(-1); break; case CF_END: ENDFUNCRC(Cmd); default: ENDFUNCRC(-1); } } ENDFUNCRC(-1); }
static int ProcessCommandLine (int argument_count, char* argument_list[]) { char** scan_arguments; char* constant_env_data; char* env_data; int remaining_argument_count; argument_count--; argument_list++; if(argument_count == 0) goto print_help; remaining_argument_count = argument_count; scan_arguments = argument_list; while(remaining_argument_count--) { char* argument; argument = *scan_arguments; scan_arguments++; if(strncmp(argument, "-P", sizeof("-P")-1) == 0) continue; else if(strncmp(argument, "-I", sizeof("-I")-1) == 0) { int error; error = TSUtil_AppendPath(&argument[sizeof("-I")-1], &tsi_search_paths); if(error != TSUTIL_ERROR_NONE) goto append_path_failed; } else if(strncmp(argument, "-v", sizeof("-v")-1) == 0) { int error; error = AddVariable(&argument[sizeof("-v")-1]); if(error != 0) goto add_variable_failed; } else if(strncmp(argument, "-c", sizeof("-c")-1) == 0) tsi_flags |= TSI_FLAG_COMPILE_ONLY; else if(strncmp(argument, "-d", sizeof("-d")-1) == 0) tsi_flags |= TSI_FLAG_DEBUG; else if(strcmp(argument, "--help") == 0) goto print_help; else { if(isalpha(*argument) == 0) { printf("\nInvalid command line option '%s', proper usage described below\n", argument); goto print_help; } tsi_unit_invocation = argument; } } constant_env_data = getenv("ts_include"); if(constant_env_data != NULL) { char* scan_env; char* start_env; int error; env_data = strdup(constant_env_data); if(env_data == NULL) goto duplicate_env_failed; start_env = env_data; do { scan_env = strchr(start_env, ';'); if(scan_env != NULL) *scan_env = 0; error = TSUtil_AppendPath(start_env, &tsi_search_paths); if(error != TSUTIL_ERROR_NONE) goto env_append_path_failed; if(scan_env == NULL) break; scan_env++; start_env = scan_env; }while(*start_env != 0); free(env_data); } constant_env_data = getenv("ts_variable"); if(constant_env_data != NULL) { char* scan_env; char* start_env; int error; env_data = strdup(constant_env_data); if(env_data == NULL) goto duplicate_env_failed; start_env = env_data; do { scan_env = strchr(start_env, ';'); if(scan_env != NULL) *scan_env = 0; error = AddVariable(start_env); if(error != 0) goto env_add_variable_failed; if(scan_env == NULL) break; scan_env++; start_env = scan_env; }while(*start_env != 0); free(env_data); } remaining_argument_count = argument_count; scan_arguments = argument_list; while(remaining_argument_count--) { char* argument; argument = *scan_arguments; scan_arguments++; if(strncmp(argument, "-P", sizeof("-P")-1) == 0) { int error; error = TSI_RegisterFFI(&argument[sizeof("-P")-1], &tsi_module); if(error != TSI_ERROR_NONE) goto register_ffi_failed; } } constant_env_data = getenv("ts_plugin"); if(constant_env_data != NULL) { char* scan_env; char* start_env; int error; env_data = strdup(constant_env_data); if(env_data == NULL) goto duplicate_env_failed; start_env = env_data; do { scan_env = strchr(start_env, ';'); if(scan_env != NULL) *scan_env = 0; error = TSI_RegisterFFI(start_env, &tsi_module); if(error != TSI_ERROR_NONE) goto env_register_ffi_failed; if(scan_env == NULL) break; scan_env++; start_env = scan_env; }while(*start_env != 0); free(env_data); } return 0; env_register_ffi_failed: env_add_variable_failed: env_append_path_failed: free(env_data); duplicate_env_failed: register_ffi_failed: add_variable_failed: append_path_failed: printf("\nAn error has occurred while processing the supplied command line, verify the syntax is correct\n"); return -1; print_help: printf( "\n" "Usage: tsi [options] function(...)\n" "Options:\n" " --help\t\tDisplay this information\n" " -I<path>\t\tSpecify a path to search when resolving functions\n" " -P<path>\t\tSpeciy a path containg TS plugins to be loaded\n" " -v<name>=<value>\tSpecify a variable to be communicated to all loaded TS plugins\n" " -c\t\t\tCompile but don't execute\n" " -d\t\t\tStep into source and debug upon beginning execution \n" "\n" "Options specifying search paths are listed in priority order. Paths listed first will\n" " be searched first. If multiple functions are specified, the last specified function\n" " is chosen.\n" "\n" "Search paths and plugin variables can be set using an environment variable and will be\n" " inheritted by tsi upon startup. Supported environment variables are listed below.\n" " ts_include\t\tA semicolon seperated list of paths used to resolve functions\n" " ts_plugin\t\tA semicolon seperated list of paths containing plugins to be loaded\n" " ts_variable\t\tA semicolon seperated list of variable assignments to be\n" " \t\tcommunicated to TS plugins\n" "\n" "About:\n" " The TS language, compiler, and interpreter, along with the\n" " corresponding TS command line interface and TS IDE, were\n" " architected and implemented by Andrew Gottemoller between\n" " late March and early June of 2011.\n" "\n" "License:\n" " Copyright 2011 Andrew Gottemoller.\n" "\n" " Trigger Script is free software: you can redistribute it and/or modify\n" " it under the terms of the GNU General Public License as published by\n" " the Free Software Foundation, either version 3 of the License, or\n" " (at your option) any later version.\n" "\n" " Trigger Script is distributed in the hope that it will be useful,\n" " but WITHOUT ANY WARRANTY; without even the implied warranty of\n" " MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" " GNU General Public License for more details.\n" "\n" " You should have received a copy of the GNU General Public License\n" " along with Trigger Script. If not, see <http://www.gnu.org/licenses/>.\n" "\n" "Examples:\n" " tsi -Imy_funcs/ -Iothers_funcs/ -Pextra_plugins/ -vusername=agottem my_function()\n" " tsi -d -vmode=xt \"my_function(5, 9.0)\"\n" " tsi -c \"my_function(\\\"hello world\\\")\"\n" "\n" ); return 1; }
//================================================================== static void resolveFunctionCalls( TokNode *pNode, const DVec<Function> &funcs ) { for (size_t i=0; i < pNode->mpChilds.size(); ++i) { resolveFunctionCalls( pNode->mpChilds[i], funcs ); } if ( pNode->mNodeType == TokNode::TYPE_FUNCCALL ) { // do we have any params ? if ( pNode->mpChilds.size() ) { const TokNode *pParamsList = pNode->mpChilds[0]; // bogus params ? for (size_t i=0; i < pParamsList->mpChilds.size(); ++i) { VarType vtype = pParamsList->mpChilds[i]->GetVarType(); if ( vtype == VT_UNKNOWN ) { throw Exception( pNode, "Unknown type for parameter %i", i+1 ); //break; } } } const Function *pFunc = NULL; // is asm func ? If so, then no need to process anything else here if ( IsAsmFunc( pNode->GetTokStr() ) ) return; // find the function by its name and it's parameters types pFunc = MatchFunctionByParams( pNode, funcs ); if NOT( pFunc ) { // if not, then throw an exception throw Exception( DUT::SSPrintFS( "Could not find the function: %s", pNode->GetTokStr() ), pNode ); } TokNode *pClonedParamsHooks = cloneBranch( pFunc->mpParamsNode ); TokNode *pFollowingStatement = NULL; if ( pFunc->mpRetTypeTok->id == T_KW___funcop ) { pFollowingStatement = pNode->GetRight(); } // place the params block where the function call (name) currently is pClonedParamsHooks->ReplaceNode( pNode ); // don't add the return value for "void" functions ! if ( pFunc->mRetVarType != VT_VOID ) { // add a return node/variable AddVariable( pClonedParamsHooks->mpParent, DNEW TokNode( DNEW Token( *pFunc->mpRetTypeTok ) ), DNEW TokNode( "varying", T_DE_varying, T_TYPE_DETAIL, pClonedParamsHooks ), // %%% forced varying for now ! NULL, pClonedParamsHooks, false, true ); } const TokNode *pPassParams = pNode->GetChildTry( 0 ); assignPassingParams( pClonedParamsHooks, pPassParams ); // a funcop ? if ( pFunc->mpRetTypeTok->id == T_KW___funcop ) { // NOTE: do re really need to do this reparenting ??! if NOT( pFollowingStatement ) throw Exception( "Missing statement !", pNode ); pClonedParamsHooks->mIsFuncOp = true; handleFuncopEndForIfElse( pClonedParamsHooks ); } } }
void csShaderManager::LoadDefaultVariables() { csRef<iVFS> vfs = csQueryRegistry<iVFS> (objectreg); CS_ASSERT(vfs); csRef<iSyntaxService> synldr = csQueryRegistry<iSyntaxService> (objectreg); if (!synldr.IsValid()) { Report (CS_REPORTER_SEVERITY_WARNING, "Can not load default shader vars, no iSyntaxService available"); return; } csRef<iLoader> loader = csQueryRegistryOrLoad<iLoader> (objectreg, "crystalspace.level.loader", true); if (!loader.IsValid()) { Report (CS_REPORTER_SEVERITY_WARNING, "Can not load default shader vars, no iLoader available"); return; } csRef<iGraphics3D> g3d = csQueryRegistry<iGraphics3D> (objectreg); csRef<iTextureManager> tm; if (g3d.IsValid()) tm = g3d->GetTextureManager(); csRef<iLoaderContext> ldr_context; ldr_context.AttachNew (new LoaderContext (loader, tm)); // @@@ TODO: Should allow for more than one hardcoded defaults file const char* defaultsFile = "/config/shadermgr-defaults.xml"; csRef<iDataBuffer> buf = vfs->ReadFile (defaultsFile, false); if (!buf.IsValid()) { Report (CS_REPORTER_SEVERITY_WARNING, "Could not open default shadervars file %s", defaultsFile); return; } csRef<iDocumentSystem> docsys = csQueryRegistry<iDocumentSystem> (objectreg); if (!docsys.IsValid()) docsys.AttachNew (new csTinyDocumentSystem); csRef<iDocument> doc = docsys->CreateDocument(); const char* err = doc->Parse (buf); if (err != 0) { Report (CS_REPORTER_SEVERITY_WARNING, "Error parsing default shadervars file %s: %s", defaultsFile, err); return; } csRef<iDocumentNode> docRoot = doc->GetRoot(); csRef<iDocumentNode> docShaderVars = docRoot->GetNode ("shadervars"); if (!docShaderVars.IsValid()) return; csRef<iDocumentNodeIterator> nodes = docShaderVars->GetNodes(); while (nodes->HasNext ()) { csRef<iDocumentNode> child = nodes->Next (); if (child->GetType() != CS_NODE_ELEMENT) continue; csStringID id = xmltokens.Request (child->GetValue()); switch (id) { case XMLTOKEN_SHADERVAR: { csRef<csShaderVariable> sv; sv.AttachNew (new csShaderVariable); if (synldr->ParseShaderVar (ldr_context, child, *sv)) AddVariable (sv); } break; default: synldr->ReportBadToken (child); } } }