本文整理汇总了C++中Getattr函数的典型用法代码示例。如果您正苦于以下问题:C++ Getattr函数的具体用法?C++ Getattr怎么用?C++ Getattr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Getattr函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SwigType_namestr
String *Swig_name_disown(const String_or_char *classname) {
String *r;
String *f;
String *rclassname;
char *cname;
rclassname = SwigType_namestr(classname);
r = NewString("");
if (!naming_hash) naming_hash = NewHash();
f = Getattr(naming_hash,"disown");
if (!f) {
Append(r,"disown_%c");
} else {
Append(r,f);
}
cname = Char(rclassname);
if ((strncmp(cname,"struct ", 7) == 0) ||
((strncmp(cname,"class ", 6) == 0)) ||
((strncmp(cname,"union ", 6) == 0))) {
cname = strchr(cname, ' ')+1;
}
Replace(r,"%c",cname, DOH_REPLACE_ANY);
Delete(rclassname);
return r;
}
示例2: SwigType_strip_qualifiers
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 = NewString("");
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;
}
示例3: DohGetVoid
void *
DohGetVoid(DOH *obj, const DOH *name) {
DOH *val;
val = Getattr(obj,(DOH *) name);
if (!val) return 0;
return (void *) Data(val);
}
示例4: Swig_need_redefined_warn
int Swig_need_redefined_warn(Node *a, Node *b, int InClass) {
String *a_name = Getattr(a, "name");
String *b_name = Getattr(b, "name");
String *a_symname = Getattr(a, "sym:name");
String *b_symname = Getattr(b, "sym:name");
/* always send a warning if a 'rename' is involved */
if ((a_symname && !Equal(a_symname, a_name))
|| (b_symname && !Equal(b_symname, b_name))) {
if (!Equal(a_name, b_name)) {
return 1;
}
}
return !nodes_are_equivalent(a, b, InClass);
}
示例5: SwigType_namestr
String *Swig_name_destroy(const_String_or_char_ptr nspace, const_String_or_char_ptr classname) {
String *r;
String *f;
String *rclassname;
char *cname;
rclassname = SwigType_namestr(classname);
r = NewStringEmpty();
if (!naming_hash)
naming_hash = NewHash();
f = Getattr(naming_hash, "destroy");
if (!f) {
Append(r, "delete_%n%c");
} else {
Append(r, f);
}
cname = Char(rclassname);
if ((strncmp(cname, "struct ", 7) == 0) || ((strncmp(cname, "class ", 6) == 0)) || ((strncmp(cname, "union ", 6) == 0))) {
cname = strchr(cname, ' ') + 1;
}
replace_nspace(r, nspace);
Replace(r, "%c", cname, DOH_REPLACE_ANY);
Delete(rclassname);
return r;
}
示例6: 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;
}
示例7: ParmList_numarg
int ParmList_numarg(ParmList *p) {
int n = 0;
while (p) {
if (!Getattr(p,"ignore")) n++;
p = nextSibling(p);
}
return n;
}
示例8: NewStringEmpty
String *ParmList_errorstr(ParmList *p) {
String *out = NewStringEmpty();
while (p) {
if (Getattr(p,"hidden")) {
p = nextSibling(p);
} else {
String *pstr = SwigType_str(Getattr(p, "type"), 0);
Append(out, pstr);
p = nextSibling(p);
if (p) {
Append(out, ",");
}
Delete(pstr);
}
}
return out;
}
示例9: ParmList_is_compactdefargs
int ParmList_is_compactdefargs(ParmList *p) {
int compactdefargs = 0;
if (p) {
compactdefargs = Getattr(p, "compactdefargs") ? 1 : 0;
/* The "compactdefargs" attribute should only be set on the first parameter in the list.
* However, sometimes an extra parameter is inserted at the beginning of the parameter list,
* so we check the 2nd parameter too. */
if (!compactdefargs) {
Parm *nextparm = nextSibling(p);
compactdefargs = (nextparm && Getattr(nextparm, "compactdefargs")) ? 1 : 0;
}
}
return compactdefargs;
}
示例10: Swig_require
void Swig_require(const char *ns, Node *n, ...) {
va_list ap;
char *name;
DOH *obj;
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) {
Swig_error(Getfile(n), Getline(n), "Fatal error (Swig_require). Missing attribute '%s' in node '%s'.\n", name, nodeType(n));
assert(obj);
}
if (!obj)
obj = DohNone;
if (newref) {
/* Save a copy of the attribute */
Setattr(n, NewStringf("%s:%s", ns, name), obj);
}
name = va_arg(ap, char *);
}
va_end(ap);
/* Save the view */
{
String *view = Getattr(n, "view");
if (view) {
if (Strcmp(view, ns) != 0) {
Setattr(n, NewStringf("%s:view", ns), view);
Setattr(n, "view", NewString(ns));
}
} else {
Setattr(n, "view", NewString(ns));
}
}
}
示例11: checkAttribute
int
checkAttribute(Node *n, const String_or_char *name, const String_or_char *value) {
String *v;
v = Getattr(n,name);
if (!v) return 0;
if (Cmp(v,value) == 0) return 1;
return 0;
}
示例12: Swig_save
int
Swig_save(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) {
if (*name == '*') {
name++;
} else if (*name == '?') {
name++;
}
obj = Getattr(n,name);
if (!obj) {
obj = DohNone;
}
strcpy(temp,ns);
strcat(temp,":");
strcat(temp,name);
if (Setattr(n,temp,obj)) {
Printf(stderr,"Swig_save('%s','%s'): Warning, attribute '%s' was already saved.\n", ns, nodeType(n), name);
}
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;
}
示例13: Getattr
static Parm *nonvoid_parms(Parm *p) {
if (p) {
SwigType *t = Getattr(p, k_type);
if (SwigType_type(t) == T_VOID)
return 0;
}
return p;
}
示例14: Swig_cargs
int Swig_cargs(Wrapper *w, ParmList *p) {
int i;
SwigType *pt;
String *pvalue;
String *pname;
String *local;
String *lname;
SwigType *altty;
String *type;
int tycode;
i = 0;
while (p != 0) {
lname = Swig_cparm_name(p,i);
pt = Getattr(p,"type");
if ((SwigType_type(pt) != T_VOID)) {
pname = Getattr(p,"name");
pvalue = Getattr(p,"value");
altty = Getattr(p,"alttype");
type = Getattr(p,"type");
tycode = SwigType_type(type);
if (tycode == T_REFERENCE) {
if (pvalue) {
String *defname, *defvalue;
defname = NewStringf("%s_defvalue", lname);
defvalue = NewStringf("%s = %s", SwigType_str(type,defname), pvalue);
Wrapper_add_localv(w,defname, defvalue, NIL);
Delete(defname);
Delete(defvalue);
}
} else if (!pvalue && (tycode == T_POINTER)) {
pvalue = (String *) "0";
}
if (!altty) {
local = Swig_clocal(pt,lname,pvalue);
} else {
local = Swig_clocal(altty,lname, pvalue);
}
Wrapper_add_localv(w,lname,local,NIL);
i++;
}
p = nextSibling(p);
}
return(i);
}
示例15: 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);
}
}