本文整理汇总了C++中Setattr函数的典型用法代码示例。如果您正苦于以下问题:C++ Setattr函数的具体用法?C++ Setattr怎么用?C++ Setattr使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Setattr函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Swig_feature_set
void
Swig_feature_set(Hash *features, String *name, SwigType *decl, String *featurename, DOH *value) {
Hash *n;
Hash *fhash;
/* Printf(stdout,"feature: %s %s %s %s\n", name, decl, featurename, value);*/
n = Getattr(features,name);
if (!n) {
n = NewHash();
Setattr(features,name,n);
}
if (!decl) {
fhash = Getattr(n,"*");
if (!fhash) {
fhash = NewHash();
Setattr(n,"*",fhash);
}
} else {
fhash = Getattr(n,decl);
if (!fhash) {
fhash = NewHash();
Setattr(n,Copy(decl),fhash);
}
}
if (value) {
Setattr(fhash,featurename,value);
} else {
Delattr(fhash,featurename);
}
}
示例2: Swig_name_nameobj_add
void Swig_name_nameobj_add(Hash *name_hash, List *name_list, String *prefix, String *name, SwigType *decl, Hash *nameobj) {
String *nname = 0;
if (name && Len(name)) {
String *target_fmt = Getattr(nameobj, "targetfmt");
nname = prefix ? NewStringf("%s::%s", prefix, name) : NewString(name);
if (target_fmt) {
String *tmp = NewStringf(target_fmt, nname);
Delete(nname);
nname = tmp;
}
}
if (!nname || !Len(nname) || Getattr(nameobj, "fullname") || /* any of these options trigger a 'list' nameobj */
Getattr(nameobj, "sourcefmt") || Getattr(nameobj, "matchlist") || Getattr(nameobj, "regextarget")) {
if (decl)
Setattr(nameobj, "decl", decl);
if (nname && Len(nname))
Setattr(nameobj, "targetname", nname);
/* put the new nameobj at the beginnig of the list, such that the
last inserted rule take precedence */
Insert(name_list, 0, nameobj);
} else {
/* here we add an old 'hash' nameobj, simple and fast */
Swig_name_object_set(name_hash, nname, decl, nameobj);
}
Delete(nname);
}
示例3: Swig_VargetToFunction
int Swig_VargetToFunction(Node *n, int flags) {
String *cres, *call;
String *name;
SwigType *type;
SwigType *ty = 0;
int varcref = flags & CWRAP_NATURAL_VAR;
name = Getattr(n, "name");
type = Getattr(n, "type");
ty = Swig_wrapped_var_type(type, varcref);
if (flags & CWRAP_EXTEND) {
String *sname = Swig_name_get(name);
String *mangled = Swig_name_mangle(sname);
call = Swig_cfunction_call(mangled, 0);
cres = Swig_cresult(ty, "result", call);
Setattr(n, "wrap:action", cres);
Delete(mangled);
Delete(sname);
} else {
String *nname = SwigType_namestr(name);
call = Swig_wrapped_var_assign(type, nname, varcref);
cres = Swig_cresult(ty, "result", call);
Setattr(n, "wrap:action", cres);
Delete(nname);
}
Setattr(n, "type", ty);
Delattr(n, "parms");
Delete(cres);
Delete(call);
Delete(ty);
return SWIG_OK;
}
示例4: NewHash
Parm *NewParm(SwigType *type, String_or_char *n) {
Parm *p = NewHash();
if (type) {
Setattr(p,"type", Copy(type));
}
Setattr(p,"name",n);
return p;
}
示例5: Swig_require
int
Swig_require(const char *ns, Node *n, ...) {
va_list ap;
char *name;
DOH *obj;
char temp[512];
va_start(ap, n);
name = va_arg(ap, char *);
while (name) {
int newref = 0;
int opt = 0;
if (*name == '*') {
newref = 1;
name++;
} else if (*name == '?') {
newref = 1;
opt = 1;
name++;
}
obj = Getattr(n,name);
if (!opt && !obj) {
Printf(stderr,"%s:%d. Fatal error (Swig_require). Missing attribute '%s' in node '%s'.\n",
Getfile(n), Getline(n), name, nodeType(n));
assert(obj);
}
if (!obj) obj = DohNone;
if (newref) {
/* Save a copy of the attribute */
strcpy(temp,ns);
strcat(temp,":");
strcat(temp,name);
Setattr(n,temp,obj);
}
name = va_arg(ap, char *);
}
va_end(ap);
/* Save the view */
{
String *view = Getattr(n,"view");
if (view) {
if (Strcmp(view,ns) != 0) {
strcpy(temp,ns);
strcat(temp,":view");
Setattr(n,temp,view);
Setattr(n,"view",ns);
}
} else {
Setattr(n,"view",ns);
}
}
return 1;
}
示例6: Swig_extend_merge
void Swig_extend_merge(Node *cls, Node *am) {
Node *n;
Node *csym;
n = firstChild(am);
while (n) {
String *symname;
if (Strcmp(nodeType(n),"constructor") == 0) {
symname = Getattr(n,"sym:name");
if (symname) {
if (Strcmp(symname,Getattr(n,"name")) == 0) {
/* If the name and the sym:name of a constructor are the same,
then it hasn't been renamed. However---the name of the class
itself might have been renamed so we need to do a consistency
check here */
if (Getattr(cls,"sym:name")) {
Setattr(n,"sym:name", Getattr(cls,"sym:name"));
}
}
}
}
symname = Getattr(n,"sym:name");
DohIncref(symname);
if ((symname) && (!Getattr(n,"error"))) {
/* Remove node from its symbol table */
Swig_symbol_remove(n);
csym = Swig_symbol_add(symname,n);
if (csym != n) {
/* Conflict with previous definition. Nuke previous definition */
String *e = NewStringEmpty();
String *en = NewStringEmpty();
String *ec = NewStringEmpty();
Printf(ec,"Identifier '%s' redefined by %%extend (ignored),",symname);
Printf(en,"%%extend definition of '%s'.",symname);
SWIG_WARN_NODE_BEGIN(n);
Swig_warning(WARN_PARSE_REDEFINED,Getfile(csym),Getline(csym),"%s\n",ec);
Swig_warning(WARN_PARSE_REDEFINED,Getfile(n),Getline(n),"%s\n",en);
SWIG_WARN_NODE_END(n);
Printf(e,"%s:%d:%s\n%s:%d:%s\n",Getfile(csym),Getline(csym),ec,
Getfile(n),Getline(n),en);
Setattr(csym,"error",e);
Delete(e);
Delete(en);
Delete(ec);
Swig_symbol_remove(csym); /* Remove class definition */
Swig_symbol_add(symname,n); /* Insert extend definition */
}
}
n = nextSibling(n);
}
}
示例7: Swig_MembergetToFunction
int
Swig_MembergetToFunction(Node *n, String *classname, int flags) {
String *name;
ParmList *parms;
SwigType *t;
SwigType *ty;
SwigType *type;
String *membername;
String *mangled;
String *self = 0;
if (flags & CWRAP_SMART_POINTER) {
self = NewString("(*this)->");
}
name = Getattr(n,"name");
type = Getattr(n,"type");
membername = Swig_name_member(classname, Swig_name_get(name));
mangled = Swig_name_mangle(membername);
t = NewString(classname);
SwigType_add_pointer(t);
parms = NewParm(t,"self");
Delete(t);
ty = Swig_wrapped_var_type(type);
if (flags & CWRAP_EXTEND) {
String *code = Getattr(n,"code");
if (code) {
String *tmp = NewStringf("%s(%s)", mangled, ParmList_str(parms));
String *s = SwigType_str(ty,tmp);
Delete(tmp);
Printv(s,code,"\n",NIL);
Setattr(n,"wrap:code",s);
Delete(s);
}
Setattr(n,"wrap:action", Swig_cresult(ty,"result",Swig_cfunction_call(mangled,parms)));
} else {
Setattr(n,"wrap:action", Swig_cresult(ty,"result",Swig_cmemberget_call(name,type,self)));
}
Setattr(n,"type",ty);
Setattr(n,"parms", parms);
Delete(parms);
Delete(ty);
Delete(membername);
Delete(mangled);
return SWIG_OK;
}
示例8: Swig_fragment_register
void
Swig_fragment_register(Node* fragment) {
if (Getattr(fragment,k_emitonly)) {
Swig_fragment_emit(fragment);
return;
} else {
String *name = Copy(Getattr(fragment,k_value));
String *type = Getattr(fragment,k_type);
if (type) {
SwigType *rtype = SwigType_typedef_resolve_all(type);
String *mangle = Swig_string_mangle(type);
Append(name,mangle);
Delete(mangle);
Delete(rtype);
if (debug) Printf(stdout,"register fragment %s %s\n",name,type);
}
if (!fragments) {
fragments = NewHash();
}
if (!Getattr(fragments,name)) {
String *section = Copy(Getattr(fragment,k_section));
String *ccode = Copy(Getattr(fragment,k_code));
Hash *kwargs = Getattr(fragment,k_kwargs);
Setmeta(ccode,k_section,section);
if (kwargs) {
Setmeta(ccode,k_kwargs,kwargs);
}
Setattr(fragments,name,ccode);
if (debug) Printf(stdout,"registering fragment %s %s\n",name,section);
Delete(section);
Delete(ccode);
}
Delete(name);
}
}
示例9: Swig_restore
void
Swig_restore(Node *n) {
char temp[512];
int len;
List *l;
String *ns;
Iterator ki;
ns = Getattr(n,"view");
assert(ns);
l = NewList();
strcpy(temp,Char(ns));
strcat(temp,":");
len = strlen(temp);
for (ki = First(n); ki.key; ki = Next(ki)) {
if (Strncmp(temp,ki.key,len) == 0) {
Append(l,ki.key);
}
}
for (ki = First(l); ki.item; ki = Next(ki)) {
DOH *obj = Getattr(n,ki.item);
Setattr(n,Char(ki.item)+len,obj);
Delattr(n,ki.item);
}
Delete(l);
}
示例10: DohSetInt
void
DohSetInt(DOH *obj, const DOH *name, int value) {
DOH *temp;
temp = NewStringEmpty();
Printf(temp,"%d",value);
Setattr(obj,(DOH *) name,temp);
}
示例11: NewHash
SwigType *SwigType_strip_qualifiers(SwigType *t) {
static Hash *memoize_stripped = 0;
SwigType *r;
List *l;
Iterator ei;
if (!memoize_stripped)
memoize_stripped = NewHash();
r = Getattr(memoize_stripped, t);
if (r)
return Copy(r);
l = SwigType_split(t);
r = NewStringEmpty();
for (ei = First(l); ei.item; ei = Next(ei)) {
if (SwigType_isqualifier(ei.item))
continue;
Append(r, ei.item);
}
Delete(l);
{
String *key, *value;
key = Copy(t);
value = Copy(r);
Setattr(memoize_stripped, key, value);
Delete(key);
Delete(value);
}
return r;
}
示例12: Swig_restore
void Swig_restore(Node *n) {
String *temp;
int len;
List *l;
String *ns;
Iterator ki;
ns = Getattr(n, "view");
assert(ns);
l = NewList();
temp = NewStringf("%s:", ns);
len = Len(temp);
for (ki = First(n); ki.key; ki = Next(ki)) {
if (Strncmp(temp, ki.key, len) == 0) {
Append(l, ki.key);
}
}
for (ki = First(l); ki.item; ki = Next(ki)) {
DOH *obj = Getattr(n, ki.item);
Setattr(n, Char(ki.item) + len, obj);
Delattr(n, ki.item);
}
Delete(l);
Delete(temp);
}
示例13: DohSetDouble
void
DohSetDouble(DOH *obj, const DOH *name, double value) {
DOH *temp;
temp = NewStringEmpty();
Printf(temp,"%0.17f",value);
Setattr(obj,(DOH *) name,temp);
}
示例14: Swig_VarsetToFunction
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;
}
示例15: Swig_name_object_set
void
Swig_name_object_set(Hash *namehash, String *name, SwigType *decl, DOH *object) {
DOH *n;
/* Printf(stdout,"name: '%s', '%s'\n", name, decl);*/
n = Getattr(namehash,name);
if (!n) {
n = NewHash();
Setattr(namehash,name,n);
}
/* Add an object based on the declarator value */
if (!decl) {
Setattr(n,NewString("*"),object);
} else {
Setattr(n,Copy(decl),object);
}
}