void Action_Port_Set(char *Str) { char *P=Str,*T; GPIO_TypeDef *GPIOx; uint16 GPIO_Pin_x; T=Strstr(P,"p"); if(T) { switch(T[1]) { case 'a':GPIOx=GPIOA;break; case 'b':GPIOx=GPIOB;break; case 'c':GPIOx=GPIOC;break; case 'd':GPIOx=GPIOD;break; case 'e':GPIOx=GPIOE;break; case 'f':GPIOx=GPIOF;break; } GPIO_Pin_x=1<<(T[2]-'0'); T=Strstr(T,","); if(T[1]=='0')GPIO_ResetBits(GPIOx,GPIO_Pin_x); if(T[1]=='1')GPIO_SetBits(GPIOx,GPIO_Pin_x); } }
String *SwigType_manglestr(const SwigType *s) { #if 0 /* Debugging checks to ensure a proper SwigType is passed in and not a stringified type */ String *angle = Strstr(s, "<"); if (angle && Strncmp(angle, "<(", 2) != 0) Printf(stderr, "SwigType_manglestr error: %s\n", s); else if (Strstr(s, "*") || Strstr(s, "&") || Strstr(s, "[")) Printf(stderr, "SwigType_manglestr error: %s\n", s); #endif return manglestr_default(s); }
String * Swig_scopename_last(String *s) { char tmp[1024]; char *c, *cc; if (!Strstr(s,"::")) return NewString(s); strcpy(tmp,Char(s)); c = tmp; cc = c; while (*c) { if (strncmp(c,"::",2) == 0) { cc = c; c += 2; } else { if (*c == '<') { int level = 1; c++; while (*c && level) { if (*c == '<') level++; if (*c == '>') level--; c++; } } else { c++; } } } return NewString(cc+2); }
String *Swig_wrapped_var_type(SwigType *t, int varcref) { SwigType *ty; if (!Strstr(t, "enum $unnamed")) { ty = Copy(t); } else { /* Change the type for unnamed enum instance variables */ ty = NewString("int"); } if (SwigType_isclass(t)) { if (varcref) { if (cparse_cplusplus) { if (!SwigType_isconst(ty)) SwigType_add_qualifier(ty, "const"); SwigType_add_reference(ty); } else { return Copy(ty); } } else { SwigType_add_pointer(ty); } } return ty; }
void Action_Delay(char *Str) { char *P=Str,*T; T=Strstr(P,"ms"); if(T) { Action_Delay_Ms(T); return; } T=Strstr(P,"s"); if(T) { Action_Delay_S(T); return; } }
void Action_Port(char *Str) { char *P=Str,*T; T=Strstr(P,"set"); if(T) { Action_Port_Set(T); return; } T=Strstr(P,"cfg"); if(T) { Action_Port_Cfg(T); return; } }
void Bast_Export(char *Str) { char *P=Str,*T; T=Strstr(P,"port"); if(T) { Action_Port(T); return; } T=Strstr(P,"delay"); if(T) { Action_Delay(T); return; } }
String * Swig_scopename_suffix(String *s) { char tmp[1024]; char *c; if (!Strstr(s,"::")) return 0; strcpy(tmp,Char(s)); c = tmp; while (*c) { if (strncmp(c,"::",2) == 0) { break; } else { if (*c == '<') { int level = 1; c++; while (*c && level) { if (*c == '<') level++; if (*c == '>') level--; c++; } } else { c++; } } } if (*c && (c != tmp)) { return NewString(c+2); } else { return 0; } }
void Action_Delay_Ms(char *Str) { char *P=Str,*T; uint32 Delay; T=Strstr(P,"."); Delay=GetStringToNumber((uint8*)&T[1]); Tos_TaskDelay(Delay); }
void Action_Port_Cfg(char *Str) { char *P=Str,*T; GPIO_InitTypeDef GPIO_InitStructure; uint32_t RCC_APB2Periph_GPIOx; GPIO_InitStruct List; List.GPIO_Pin=12; T=Strstr(P,"p"); if(T) { switch(T[1]) { case 'a':List.GPIOx=GPIOA;RCC_APB2Periph_GPIOx=RCC_APB2Periph_GPIOA;break; case 'b':List.GPIOx=GPIOB;RCC_APB2Periph_GPIOx=RCC_APB2Periph_GPIOB;break; case 'c':List.GPIOx=GPIOC;RCC_APB2Periph_GPIOx=RCC_APB2Periph_GPIOC;break; case 'd':List.GPIOx=GPIOD;RCC_APB2Periph_GPIOx=RCC_APB2Periph_GPIOD;break; case 'e':List.GPIOx=GPIOE;RCC_APB2Periph_GPIOx=RCC_APB2Periph_GPIOE;break; case 'f':List.GPIOx=GPIOF;RCC_APB2Periph_GPIOx=RCC_APB2Periph_GPIOF;break; } List.GPIO_Pin=1<<(T[2]-'0'); if(Strstr(T,"out"))List.GPIO_Mode=GPIO_Mode_Out_PP; else if(Strstr(T,"ipd"))List.GPIO_Mode=GPIO_Mode_IPD; else if(Strstr(T,"ipu"))List.GPIO_Mode=GPIO_Mode_IPU; else if(Strstr(T,"ain"))List.GPIO_Mode=GPIO_Mode_AIN; else if(Strstr(T,"inf"))List.GPIO_Mode=GPIO_Mode_IN_FLOATING; RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOx|RCC_APB2Periph_AFIO,ENABLE); GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Pin=List.GPIO_Pin; GPIO_InitStructure.GPIO_Mode=List.GPIO_Mode; GPIO_Init(List.GPIOx, &GPIO_InitStructure); } }
uint8 COM_Menu_Enter(uint8 Index,uint8 *Buf) { typedef void (*FuncUint8)(uint8); const COM_MenuStruct *CurMenu; if(Index>=Menu_OptionLength(MenuList))return 0; CurMenu=&MenuList[Index]; USART_WriteDatas(USART2,&Buf[0],20); switch(CurMenu->Type) { case VT_Task:if(CurMenu->Value)((Func)CurMenu->Value)();break; // case VT_TaskUint8:if(CurMenu->Value)((FuncUint8)CurMenu->Value)(CurMenu->Note);break; case VT_Uint8:*(uint8 *)(CurMenu->Value)=GetStringToNumber(Buf);break; case VT_Int8:*(int8 *)(CurMenu->Value)=GetStringToNumber(Buf);break; case VT_Uint16:*(uint16 *)(CurMenu->Value)=GetStringToNumber(Buf);break; case VT_ROMUint32:*(uint32 *)(CurMenu->Value)=GetStringToNumber(Buf);break; case VT_Float:*(float *)(CurMenu->Value)=GetStringToNumber(Buf);break; case VT_U32BIT:if(Strstr((const char *)Buf,"T")>0)*(uint32 *)(CurMenu->Value)|=BIT(CurMenu->Note);else *(uint32 *)(CurMenu->Value)&=~BIT(CurMenu->Note);break; case VT_BOOL:if(Strstr((const char *)Buf,"T")>0)*(uint8 *)(CurMenu->Value)=True;else *(uint8 *)(CurMenu->Value)=False;break; // case VT_IP:*(uint32 *)(CurMenu->Value)=MUI_GetIP(*(uint32 *)(CurMenu->Value),IT_Num|IT_Dot);break; // case VT_Color:*(uint16 *)(CurMenu->Value)=MUI_GetColor(*(uint16 *)(CurMenu->Value),IT_Num|IT_Dot);break; case VT_Str:BufferCoppy(&Buf[0],(uint8 *)(CurMenu->Value),CurMenu->Note);break; } return 1; }
String * Swig_cmethod_call(String_or_char *name, ParmList *parms, String_or_char *self) { String *func, *nname; int i = 0; Parm *p = parms; SwigType *pt; int comma = 0; if (!self) self = (char *) "(this)->"; func = NewString(""); nname = SwigType_namestr(name); if (!p) return func; Append(func,self); pt = Getattr(p,"type"); /* If the method is invoked through a dereferenced pointer, we don't add any casts (needed for smart pointers). Otherwise, we cast to the appropriate type */ if (Strstr(func,"*this")) { Replaceall(func,"this", Swig_cparm_name(p,0)); } else { Replaceall(func,"this", SwigType_rcaststr(pt, Swig_cparm_name(p,0))); } if (SwigType_istemplate(name)) { Printf(func,"template %s(", nname); } else { Printf(func,"%s(", nname); } i++; p = nextSibling(p); while (p) { String *pname; pt = Getattr(p,"type"); if ((SwigType_type(pt) != T_VOID)) { if (comma) Printf(func,","); pname = Swig_cparm_name(p,i); Printf(func,"%s", SwigType_rcaststr(pt, pname)); comma = 1; i++; } p = nextSibling(p); } Printf(func,")"); Delete(nname); return func; }
int Swig_VarsetToFunction(Node *n, int flags) { String *name, *nname; ParmList *parms; SwigType *type, *ty; int varcref = flags & CWRAP_NATURAL_VAR; name = Getattr(n, "name"); type = Getattr(n, "type"); nname = SwigType_namestr(name); ty = Swig_wrapped_var_type(type, varcref); parms = NewParm(ty, name); if (flags & CWRAP_EXTEND) { String *sname = Swig_name_set(name); String *mangled = Swig_name_mangle(sname); String *call = Swig_cfunction_call(mangled, parms); String *cres = NewStringf("%s;", call); Setattr(n, "wrap:action", cres); Delete(cres); Delete(call); Delete(mangled); Delete(sname); } else { if (!Strstr(type, "enum $unnamed")) { String *pname = Swig_cparm_name(0, 0); String *dref = Swig_wrapped_var_deref(type, pname, varcref); String *call = NewStringf("%s = %s;", nname, dref); Setattr(n, "wrap:action", call); Delete(call); Delete(dref); Delete(pname); } else { String *pname = Swig_cparm_name(0, 0); String *call = NewStringf("if (sizeof(int) == sizeof(%s)) *(int*)(void*)&(%s) = %s;", nname, nname, pname); Setattr(n, "wrap:action", call); Delete(pname); Delete(call); } } Setattr(n, "type", "void"); Setattr(n, "parms", parms); Delete(parms); Delete(ty); Delete(nname); return SWIG_OK; }
int Swig_scopename_check(String *s) { char *c = Char(s); if (!Strstr(s,"::")) return 0; while (*c) { if (strncmp(c,"::",2) == 0) { return 1; } else { if (*c == '<') { int level = 1; c++; while (*c && level) { if (*c == '<') level++; if (*c == '>') level--; c++; } } else { c++; } } } return 0; }
String *Swig_cmemberset_call(String_or_char *name, SwigType *type, String_or_char *self, int varcref) { String *func; String *pname0 = Swig_cparm_name(0, 0); String *pname1 = Swig_cparm_name(0, 1); func = NewStringEmpty(); if (!self) self = NewString("(this)->"); else self = NewString(self); Replaceall(self, "this", pname0); if (SwigType_type(type) != T_ARRAY) { if (!Strstr(type, "enum $unnamed")) { String *dref = Swig_wrapped_var_deref(type, pname1, varcref); Printf(func, "if (%s) %s%s = %s", pname0, self, name, dref); Delete(dref); } else { Printf(func, "if (%s && sizeof(int) == sizeof(%s%s)) *(int*)(void*)&(%s%s) = %s", pname0, self, name, self, name, pname1); } } Delete(self); Delete(pname0); Delete(pname1); return (func); }
int Swig_VarsetToFunction(Node *n, int flags) { String *name, *nname; ParmList *parms; SwigType *type, *ty; int varcref = flags & CWRAP_NATURAL_VAR; name = Getattr(n, k_name); type = Getattr(n, k_type); nname = SwigType_namestr(name); ty = Swig_wrapped_var_type(type, varcref); parms = NewParm(ty, name); Delete(ty); if (!Strstr(type, "enum $unnamed")) { String *pname = Swig_cparm_name(0, 0); String *dref = Swig_wrapped_var_deref(type, pname, varcref); String *call = NewStringf("%s = %s;\n", nname, dref); Setattr(n, k_wrapaction, call); Delete(call); Delete(dref); Delete(pname); } else { String *pname = Swig_cparm_name(0, 0); String *call = NewStringf("if (sizeof(int) == sizeof(%s)) *(int*)(void*)&(%s) = %s;\n", nname, nname, pname); Setattr(n, k_wrapaction, call); Delete(call); } Setattr(n, k_type, "void"); Setattr(n, k_parms, parms); Delete(parms); Delete(nname); return SWIG_OK; }
static void cparse_template_expand(Node *templnode, Node *n, String *tname, String *rname, String *templateargs, List *patchlist, List *typelist, List *cpatchlist) { static int expanded = 0; String *nodeType; if (!n) return; nodeType = nodeType(n); if (Getattr(n, "error")) return; if (Equal(nodeType, "template")) { /* Change the node type back to normal */ if (!expanded) { expanded = 1; set_nodeType(n, Getattr(n, "templatetype")); cparse_template_expand(templnode, n, tname, rname, templateargs, patchlist, typelist, cpatchlist); expanded = 0; return; } else { /* Called when template appears inside another template */ /* Member templates */ set_nodeType(n, Getattr(n, "templatetype")); cparse_template_expand(templnode, n, tname, rname, templateargs, patchlist, typelist, cpatchlist); set_nodeType(n, "template"); return; } } else if (Equal(nodeType, "cdecl")) { /* A simple C declaration */ SwigType *t, *v, *d; String *code; t = Getattr(n, "type"); v = Getattr(n, "value"); d = Getattr(n, "decl"); code = Getattr(n, "code"); Append(typelist, t); Append(typelist, d); Append(patchlist, v); Append(cpatchlist, code); if (Getattr(n, "conversion_operator")) { Append(cpatchlist, Getattr(n, "name")); if (Getattr(n, "sym:name")) { Append(cpatchlist, Getattr(n, "sym:name")); } } if (checkAttribute(n, "storage", "friend")) { String *symname = Getattr(n, "sym:name"); if (symname) { String *stripped_name = SwigType_templateprefix(symname); Setattr(n, "sym:name", stripped_name); Delete(stripped_name); } Append(typelist, Getattr(n, "name")); } add_parms(Getattr(n, "parms"), cpatchlist, typelist); add_parms(Getattr(n, "throws"), cpatchlist, typelist); } else if (Equal(nodeType, "class")) { /* Patch base classes */ { int b = 0; for (b = 0; b < 3; ++b) { List *bases = Getattr(n, baselists[b]); if (bases) { int i; int ilen = Len(bases); for (i = 0; i < ilen; i++) { String *name = Copy(Getitem(bases, i)); Setitem(bases, i, name); Append(typelist, name); } } } } /* Patch children */ { Node *cn = firstChild(n); while (cn) { cparse_template_expand(templnode, cn, tname, rname, templateargs, patchlist, typelist, cpatchlist); cn = nextSibling(cn); } } } else if (Equal(nodeType, "constructor")) { String *name = Getattr(n, "name"); if (!(Getattr(n, "templatetype"))) { String *symname; String *stripped_name = SwigType_templateprefix(name); if (Strstr(tname, stripped_name)) { Replaceid(name, stripped_name, tname); } Delete(stripped_name); symname = Getattr(n, "sym:name"); if (symname) { stripped_name = SwigType_templateprefix(symname); if (Strstr(tname, stripped_name)) { Replaceid(symname, stripped_name, tname); } Delete(stripped_name); } if (strchr(Char(name), '<')) { Append(patchlist, Getattr(n, "name")); } else { Append(name, templateargs); } name = Getattr(n, "sym:name"); if (name) { if (strchr(Char(name), '<')) { Clear(name); Append(name, rname); } else { String *tmp = Copy(name); Replace(tmp, tname, rname, DOH_REPLACE_ANY); Clear(name); Append(name, tmp); Delete(tmp); } } /* Setattr(n,"sym:name",name); */ } Append(cpatchlist, Getattr(n, "code")); Append(typelist, Getattr(n, "decl")); add_parms(Getattr(n, "parms"), cpatchlist, typelist); add_parms(Getattr(n, "throws"), cpatchlist, typelist); } else if (Equal(nodeType, "destructor")) { /* We only need to patch the dtor of the template itself, not the destructors of any nested classes, so check that the parent of this node is the root * template node, with the special exception for %extend which adds its methods under an intermediate node. */ Node* parent = parentNode(n); if (parent == templnode || (parentNode(parent) == templnode && Equal(nodeType(parent), "extend"))) { String *name = Getattr(n, "name"); if (name) { if (strchr(Char(name), '<')) Append(patchlist, Getattr(n, "name")); else Append(name, templateargs); } name = Getattr(n, "sym:name"); if (name) { if (strchr(Char(name), '<')) { String *sn = Copy(tname); Setattr(n, "sym:name", sn); Delete(sn); } else { Replace(name, tname, rname, DOH_REPLACE_ANY); } } /* Setattr(n,"sym:name",name); */ Append(cpatchlist, Getattr(n, "code")); } } else if (Equal(nodeType, "using")) { String *uname = Getattr(n, "uname"); if (uname && strchr(Char(uname), '<')) { Append(patchlist, uname); } if (Getattr(n, "namespace")) { /* Namespace link. This is nasty. Is other namespace defined? */ } } else { /* Look for obvious parameters */ Node *cn; Append(cpatchlist, Getattr(n, "code")); Append(typelist, Getattr(n, "type")); Append(typelist, Getattr(n, "decl")); add_parms(Getattr(n, "parms"), cpatchlist, typelist); add_parms(Getattr(n, "kwargs"), cpatchlist, typelist); add_parms(Getattr(n, "pattern"), cpatchlist, typelist); add_parms(Getattr(n, "throws"), cpatchlist, typelist); cn = firstChild(n); while (cn) { cparse_template_expand(templnode, cn, tname, rname, templateargs, patchlist, typelist, cpatchlist); cn = nextSibling(cn); } } }
static String *Swig_cmethod_call(String_or_char *name, ParmList *parms, String_or_char *self, String *explicit_qualifier, SwigType *director_type) { String *func, *nname; int i = 0; Parm *p = parms; SwigType *pt; int comma = 0; func = NewStringEmpty(); if (!p) return func; if (!self) self = (char *) "(this)->"; Append(func, self); if (SwigType_istemplate(name) && (strncmp(Char(name), "operator ", 9) == 0)) { /* fix for template + operators and compilers like gcc 3.3.5 */ String *tprefix = SwigType_templateprefix(name); nname = tprefix; } else { nname = SwigType_namestr(name); } if (director_type) { const char *pname = "darg"; String *rcaststr = SwigType_rcaststr(director_type, pname); Replaceall(func, "this", rcaststr); Delete(rcaststr); } else { pt = Getattr(p, k_type); /* If the method is invoked through a dereferenced pointer, we don't add any casts (needed for smart pointers). Otherwise, we cast to the appropriate type */ if (Strstr(func, "*this")) { String *pname = Swig_cparm_name(p, 0); Replaceall(func, "this", pname); Delete(pname); } else { String *pname = Swig_cparm_name(p, 0); String *rcaststr = SwigType_rcaststr(pt, pname); Replaceall(func, "this", rcaststr); Delete(rcaststr); Delete(pname); } /* SWIGTEMPLATEDESIMBUAGATOR is compiler dependent (swiglabels.swg), - SUN Studio 9 requires 'template', - gcc-3.4 forbids the use of 'template' (correctly implementing the ISO C++ standard) the others don't seem to care, */ if (SwigType_istemplate(name)) Printf(func, "SWIGTEMPLATEDISAMBIGUATOR "); if (explicit_qualifier) { Printv(func, explicit_qualifier, "::", NIL); } } Printf(func, "%s(", nname); i++; p = nextSibling(p); while (p) { pt = Getattr(p, k_type); if ((SwigType_type(pt) != T_VOID)) { String *pname = Swig_cparm_name(p, i); String *rcaststr = SwigType_rcaststr(pt, pname); if (comma) Append(func, ","); Append(func, rcaststr); Delete(rcaststr); Delete(pname); comma = 1; i++; } p = nextSibling(p); } Append(func, ")"); Delete(nname); return func; }
int SwigType_istemplate(const SwigType *t) { if (Strstr(t,"<(")) return 1; return 0; }
static int cparse_template_expand(Node *n, String *tname, String *rname, String *templateargs, List *patchlist, List *typelist, List *cpatchlist) { static int expanded = 0; int ret; String *nodeType; if (!n) return 0; nodeType = nodeType(n); if (Getattr(n, "error")) return 0; if (Equal(nodeType, "template")) { /* Change the node type back to normal */ if (!expanded) { expanded = 1; set_nodeType(n, Getattr(n, "templatetype")); ret = cparse_template_expand(n, tname, rname, templateargs, patchlist, typelist, cpatchlist); expanded = 0; return ret; } else { /* Called when template appears inside another template */ /* Member templates */ set_nodeType(n, Getattr(n, "templatetype")); ret = cparse_template_expand(n, tname, rname, templateargs, patchlist, typelist, cpatchlist); set_nodeType(n, "template"); return ret; } } else if (Equal(nodeType, "cdecl")) { /* A simple C declaration */ SwigType *t, *v, *d; String *code; t = Getattr(n, "type"); v = Getattr(n, "value"); d = Getattr(n, "decl"); code = Getattr(n, "code"); Append(typelist, t); Append(typelist, d); Append(patchlist, v); Append(cpatchlist, code); if (Getattr(n, "conversion_operator")) { Append(cpatchlist, Getattr(n, "name")); if (Getattr(n, "sym:name")) { Append(cpatchlist, Getattr(n, "sym:name")); } } add_parms(Getattr(n, "parms"), cpatchlist, typelist); add_parms(Getattr(n, "throws"), cpatchlist, typelist); } else if (Equal(nodeType, "class")) { /* Patch base classes */ { int b = 0; for (b = 0; b < 3; ++b) { List *bases = Getattr(n, baselists[b]); if (bases) { int i; int ilen = Len(bases); for (i = 0; i < ilen; i++) { String *name = Copy(Getitem(bases, i)); Setitem(bases, i, name); Append(typelist, name); } } } } /* Patch children */ { Node *cn = firstChild(n); while (cn) { cparse_template_expand(cn, tname, rname, templateargs, patchlist, typelist, cpatchlist); cn = nextSibling(cn); } } } else if (Equal(nodeType, "constructor")) { String *name = Getattr(n, "name"); if (!(Getattr(n, "templatetype"))) { String *symname; String *stripped_name = SwigType_templateprefix(name); if (Strstr(tname, stripped_name)) { Replaceid(name, stripped_name, tname); } Delete(stripped_name); symname = Getattr(n, "sym:name"); if (symname) { stripped_name = SwigType_templateprefix(symname); if (Strstr(tname, stripped_name)) { Replaceid(symname, stripped_name, tname); } Delete(stripped_name); } if (strchr(Char(name), '<')) { Append(patchlist, Getattr(n, "name")); } else { Append(name, templateargs); } name = Getattr(n, "sym:name"); if (name) { if (strchr(Char(name), '<')) { Clear(name); Append(name, rname); } else { String *tmp = Copy(name); Replace(tmp, tname, rname, DOH_REPLACE_ANY); Clear(name); Append(name, tmp); Delete(tmp); } } /* Setattr(n,"sym:name",name); */ } Append(cpatchlist, Getattr(n, "code")); Append(typelist, Getattr(n, "decl")); add_parms(Getattr(n, "parms"), cpatchlist, typelist); add_parms(Getattr(n, "throws"), cpatchlist, typelist); } else if (Equal(nodeType, "destructor")) { String *name = Getattr(n, "name"); if (name) { if (strchr(Char(name), '<')) Append(patchlist, Getattr(n, "name")); else Append(name, templateargs); } name = Getattr(n, "sym:name"); if (name) { if (strchr(Char(name), '<')) { String *sn = Copy(tname); Setattr(n, "sym:name", sn); Delete(sn); } else { Replace(name, tname, rname, DOH_REPLACE_ANY); } } /* Setattr(n,"sym:name",name); */ Append(cpatchlist, Getattr(n, "code")); } else if (Equal(nodeType, "using")) { String *uname = Getattr(n, "uname"); if (uname && strchr(Char(uname), '<')) { Append(patchlist, uname); } if (Getattr(n, "namespace")) { /* Namespace link. This is nasty. Is other namespace defined? */ } } else { /* Look for obvious parameters */ Node *cn; Append(cpatchlist, Getattr(n, "code")); Append(typelist, Getattr(n, "type")); Append(typelist, Getattr(n, "decl")); add_parms(Getattr(n, "parms"), cpatchlist, typelist); add_parms(Getattr(n, "kwargs"), cpatchlist, typelist); add_parms(Getattr(n, "pattern"), cpatchlist, typelist); add_parms(Getattr(n, "throws"), cpatchlist, typelist); cn = firstChild(n); while (cn) { cparse_template_expand(cn, tname, rname, templateargs, patchlist, typelist, cpatchlist); cn = nextSibling(cn); } } return 0; }
void SwigType_typename_replace(SwigType *t, String *pat, String *rep) { String *nt; int i, ilen; List *elem; if (!Strstr(t, pat)) return; if (Equal(t, pat)) { Replace(t, pat, rep, DOH_REPLACE_ANY); return; } nt = NewStringEmpty(); elem = SwigType_split(t); ilen = Len(elem); for (i = 0; i < ilen; i++) { String *e = Getitem(elem, i); if (SwigType_issimple(e)) { if (Equal(e, pat)) { /* Replaces a type of the form 'pat' with 'rep<args>' */ Replace(e, pat, rep, DOH_REPLACE_ANY); } else if (SwigType_istemplate(e)) { /* Replaces a type of the form 'pat<args>' with 'rep' */ if (Equal(e, pat)) { String *repbase = SwigType_templateprefix(rep); Replace(e, pat, repbase, DOH_REPLACE_ID | DOH_REPLACE_FIRST); Delete(repbase); } { String *tsuffix; List *tparms = SwigType_parmlist(e); int j, jlen; String *nt = SwigType_templateprefix(e); Append(nt, "<("); jlen = Len(tparms); for (j = 0; j < jlen; j++) { SwigType_typename_replace(Getitem(tparms, j), pat, rep); Append(nt, Getitem(tparms, j)); if (j < (jlen - 1)) Putc(',', nt); } tsuffix = SwigType_templatesuffix(e); Printf(nt, ")>%s", tsuffix); Delete(tsuffix); Clear(e); Append(e, nt); Delete(nt); Delete(tparms); } } else if (Swig_scopename_check(e)) { String *first, *rest; first = Swig_scopename_first(e); rest = Swig_scopename_suffix(e); SwigType_typename_replace(rest, pat, rep); SwigType_typename_replace(first, pat, rep); Clear(e); Printv(e, first, "::", rest, NIL); Delete(first); Delete(rest); } } else if (SwigType_isfunction(e)) { int j, jlen; List *fparms = SwigType_parmlist(e); Clear(e); Append(e, "f("); jlen = Len(fparms); for (j = 0; j < jlen; j++) { SwigType_typename_replace(Getitem(fparms, j), pat, rep); Append(e, Getitem(fparms, j)); if (j < (jlen - 1)) Putc(',', e); } Append(e, ")."); Delete(fparms); } else if (SwigType_isarray(e)) { Replace(e, pat, rep, DOH_REPLACE_ID); } Append(nt, e); } Clear(t); Append(t, nt); Delete(nt); Delete(elem); }
static void setDolp(Char *cp) { Char *dp; size_t i; if (dolmod.len == 0 || dolmcnt == 0) { dolp = cp; return; } cp = Strsave(cp); for (i = 0; i < dolmod.len; i++) { int didmod = 0; /* handle s// [eichin:19910926.0510EST] */ if(dolmod.s[i] == 's') { Char delim; Char *lhsub, *rhsub, *np; size_t lhlen = 0, rhlen = 0; delim = dolmod.s[++i]; if (!delim || letter(delim) || Isdigit(delim) || any(" \t\n", delim)) { seterror(ERR_BADSUBST); break; } lhsub = &dolmod.s[++i]; while(dolmod.s[i] != delim && dolmod.s[++i]) { lhlen++; } dolmod.s[i] = 0; rhsub = &dolmod.s[++i]; while(dolmod.s[i] != delim && dolmod.s[++i]) { rhlen++; } dolmod.s[i] = 0; strip(lhsub); strip(rhsub); strip(cp); dp = cp; do { dp = Strstr(dp, lhsub); if (dp) { ptrdiff_t diff = dp - cp; size_t len = (Strlen(cp) + 1 - lhlen + rhlen); np = xmalloc(len * sizeof(Char)); (void) Strncpy(np, cp, diff); (void) Strcpy(np + diff, rhsub); (void) Strcpy(np + diff + rhlen, dp + lhlen); xfree(cp); dp = cp = np; cp[--len] = '\0'; didmod = 1; if (diff >= (ssize_t)len) break; } else { /* should this do a seterror? */ break; } } while (dol_flag_a != 0); /* * restore dolmod for additional words */ dolmod.s[i] = rhsub[-1] = (Char) delim; } else { do { if ((dp = domod(cp, dolmod.s[i])) != NULL) { didmod = 1; if (Strcmp(cp, dp) == 0) { xfree(cp); cp = dp; break; } else { xfree(cp); cp = dp; } } else break; } while (dol_flag_a != 0); } if (didmod && dolmcnt != INT_MAX) dolmcnt--; #ifdef notdef else break; #endif } addla(cp); dolp = STRNULL; if (seterr) stderror(ERR_OLD); }
static void GetEnvironment(void) { static char envDISPLAY[]="DISPLAY"; static char envSESSION_MANAGER[]="SESSION_MANAGER"; static char envAUDIOSERVER[]="AUDIOSERVER"; char *p, *temp; remote_allowed = 1; display_env = NULL; if((p = cmd_line_display) || (p = (char *) getenv(envDISPLAY))) { display_env = (char *) XtMalloc(strlen(envDISPLAY)+1+strlen(p)+1); if(!display_env) nomem(); sprintf(display_env, "%s=%s", envDISPLAY, p); /* * When we restart a remote client, we have to make sure the * display environment we give it has the SM's hostname. */ if ((temp = strchr (p, '/')) == 0) temp = p; else temp++; if (*temp != ':') { /* we have a host name */ non_local_display_env = (char *) XtMalloc ( strlen (display_env) + 1); if (!non_local_display_env) nomem(); strcpy (non_local_display_env, display_env); } else { char hostnamebuf[256]; gethostname (hostnamebuf, sizeof hostnamebuf); non_local_display_env = (char *) XtMalloc ( strlen (envDISPLAY) + 1 + strlen (hostnamebuf) + strlen (temp) + 1); if (!non_local_display_env) nomem(); sprintf(non_local_display_env, "%s=%s%s", envDISPLAY, hostnamebuf, temp); } } session_env = NULL; if((p = (char *) getenv(envSESSION_MANAGER))) { session_env = (char *) XtMalloc( strlen(envSESSION_MANAGER)+1+strlen(p)+1); if(!session_env) nomem(); sprintf(session_env, "%s=%s", envSESSION_MANAGER, p); /* * When we restart a remote client, we have to make sure the * session environment does not have the SM's local connection port. */ non_local_session_env = (char *) XtMalloc (strlen (session_env) + 1); if (!non_local_session_env) nomem(); strcpy (non_local_session_env, session_env); if ((temp = Strstr (non_local_session_env, "local/")) != NULL) { char *delim = strchr (temp, ','); if (delim == NULL) { if (temp == non_local_session_env + strlen (envSESSION_MANAGER) + 1) { *temp = '\0'; remote_allowed = 0; } else *(temp - 1) = '\0'; } else { int bytes = strlen (delim + 1); memmove (temp, delim + 1, bytes); *(temp + bytes) = '\0'; } } } audio_env = NULL; if((p = (char *) getenv(envAUDIOSERVER))) { audio_env = (char *) XtMalloc(strlen(envAUDIOSERVER)+1+strlen(p)+1); if(!audio_env) nomem(); sprintf(audio_env, "%s=%s", envAUDIOSERVER, p); } }
static void setDolp(Char *cp) { Char *dp; int i; if (dolnmod == 0 || dolmcnt == 0) { dolp = cp; return; } dp = cp = Strsave(cp); for (i = 0; i < dolnmod; i++) { /* handle s// [eichin:19910926.0510EST] */ if(dolmod[i] == 's') { int delim; Char *lhsub, *rhsub, *np; size_t lhlen = 0, rhlen = 0; int didmod = 0; delim = dolmod[++i]; if (!delim || letter(delim) || Isdigit(delim) || any(" \t\n", delim)) { seterror(ERR_BADSUBST); break; } lhsub = &dolmod[++i]; while(dolmod[i] != delim && dolmod[++i]) { lhlen++; } dolmod[i] = 0; rhsub = &dolmod[++i]; while(dolmod[i] != delim && dolmod[++i]) { rhlen++; } dolmod[i] = 0; do { dp = Strstr(cp, lhsub); if (dp) { size_t len = Strlen(cp) + 1 - lhlen + rhlen; np = xreallocarray(NULL, len, sizeof(Char)); *dp = 0; (void) Strlcpy(np, cp, len); (void) Strlcat(np, rhsub, len); (void) Strlcat(np, dp + lhlen, len); xfree(cp); dp = cp = np; didmod = 1; } else { /* should this do a seterror? */ break; } } while (dolwcnt == 10000); /* * restore dolmod for additional words */ dolmod[i] = rhsub[-1] = delim; if (didmod) dolmcnt--; else break; } else { int didmod = 0; do { if ((dp = domod(cp, dolmod[i]))) { didmod = 1; if (Strcmp(cp, dp) == 0) { xfree(cp); cp = dp; break; } else { xfree(cp); cp = dp; } } else break; } while (dolwcnt == 10000); dp = cp; if (didmod) dolmcnt--; else break; } } if (dp) { addla(dp); xfree(dp); } else addla(cp); dolp = STRNULL; if (seterr) stderror(ERR_OLD); }
/* Returns 0 on success; 1 on error. */ int wipspool(const char *file) { char *lpr, *ptr; char fmt[BUFSIZ]; char outbuf[BUFSIZ]; int okayState; #ifdef WIPVMS okayState = 1; #else okayState = 0; #endif /* WIPVMS */ if ((ptr = wipgetstring("print")) == (char *)NULL) { wipoutput(stderr, "HARDCOPY: Error finding printing command.\n"); return(1); } if (wiplenc(ptr) < 1) /* If string is empty, no printing desired. */ return(0); if (Strncmp(ptr, "ignore", 6) == 0) /* Still, no printing desired. */ return(0); lpr = Strcpy(outbuf, ptr); if ((ptr = Strchr(lpr, '&')) != (char *)NULL) { while(*ptr) { /* Remove all '&' characters. */ if (*ptr == '&') *ptr = ' '; ptr++; } } #ifdef WIPVMS if (Strstr(lpr, "%s") == (char *)NULL) { SPrintf(fmt, "%s %%s", lpr); } else { SPrintf(fmt, "%s", lpr); } #else if (Strstr(lpr, "%s") == (char *)NULL) { SPrintf(fmt, "%s %%s &\n", lpr); } else { SPrintf(fmt, "%s &\n", lpr); } #endif /* WIPVMS */ /* * "fmt" now contains the printer command along with a "%s" for * the file name. */ if ((ptr = wipleading(file)) == (char *)NULL) { wipoutput(stderr, "HARDCOPY: Can't get the name of the file to spool.\n"); return(1); } SPrintf(outbuf, fmt, ptr); wipoutput(stdout, "HARDCOPY: Spooling command:\n %s", outbuf); if (System(outbuf) != okayState) { wipoutput(stderr, "HARDCOPY: Error spooling WIP printer file.\n"); return(1); } return(0); }
void Swig_warning(int wnum, const String_or_char *filename, int line, const char *fmt, ...) { String *out; char *msg; int wrn = 1; va_list ap; if (silence) return; va_start(ap,fmt); out = NewString(""); vPrintf(out,fmt,ap); { char temp[64], *t; t = temp; msg = Char(out); while (isdigit((int) *msg)) { *(t++) = *(msg++); } if (t != temp) { msg++; *t = 0; wnum = atoi(temp); } } /* Check in the warning filter */ if (filter) { char temp[32]; char *c; sprintf(temp,"%d",wnum); c = Strstr(filter,temp); if (c) { if (*(c-1) == '-') wrn = 0; /* Warning disabled */ if (*(c-1) == '+') wrn = 1; /* Warning enabled */ } } if (warnall || wrn) { if (wnum) { switch (msg_format) { case EMF_MICROSOFT: Printf(stderr,"%s(%d): Warning(%d): ", filename, line, wnum); break; case EMF_STANDARD: default: Printf(stderr,"%s:%d: Warning(%d): ", filename, line, wnum); break; } } else { switch (msg_format) { case EMF_MICROSOFT: Printf(stderr,"%s(%d): Warning: ", filename, line); break; case EMF_STANDARD: default: Printf(stderr,"%s:%d: Warning: ", filename, line); break; } } Printf(stderr,"%s",msg); nwarning++; } Delete(out); va_end(ap); }