本文整理汇总了C++中Obj::obj方法的典型用法代码示例。如果您正苦于以下问题:C++ Obj::obj方法的具体用法?C++ Obj::obj怎么用?C++ Obj::obj使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Obj
的用法示例。
在下文中一共展示了Obj::obj方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetRecordTypeFromDecl
bool GetRecordTypeFromDecl(RecordDecl * rd, Obj * tt) {
if(rd->isStruct() || rd->isUnion()) {
std::string name = rd->getName();
Obj * thenamespace = &tagged;
if(name == "") {
TypedefNameDecl * decl = rd->getTypedefNameForAnonDecl();
if(decl) {
thenamespace = &general;
name = decl->getName();
}
}
//if name == "" then we have an anonymous struct
if(!thenamespace->obj(name.c_str(),tt)) {
PushTypeField("getorcreatecstruct");
lua_pushstring(L, name.c_str());
lua_pushboolean(L, thenamespace == &tagged);
lua_call(L,2,1);
tt->initFromStack(L,ref_table);
if(!tt->boolean("llvm_definingfunction")) {
std::string definingfunction;
size_t argpos;
RegisterRecordType(Context->getRecordType(rd), &definingfunction, &argpos);
lua_pushstring(L,definingfunction.c_str());
tt->setfield("llvm_definingfunction");
lua_pushinteger(L,argpos);
tt->setfield("llvm_argumentposition");
}
if(name != "") { //do not remember a name for an anonymous struct
tt->push();
thenamespace->setfield(name.c_str()); //register the type
}
}
if(tt->boolean("undefined") && rd->getDefinition() != NULL) {
tt->clearfield("undefined");
RecordDecl * defn = rd->getDefinition();
Obj entries;
tt->newlist(&entries);
if(GetFields(defn, &entries)) {
if(!defn->isUnion()) {
//structtype.entries = {entry1, entry2, ... }
entries.push();
tt->setfield("entries");
} else {
//add as a union:
//structtype.entries = { {entry1,entry2,...} }
Obj allentries;
tt->obj("entries",&allentries);
entries.push();
allentries.addentry();
}
tt->pushfield("complete");
tt->push();
lua_call(L,1,0);
}
}
return true;
} else {
return ImportError("non-struct record types are not supported");
}
}
示例2: GetRecordTypeFromDecl
bool GetRecordTypeFromDecl(RecordDecl * rd, Obj * tt, std::string * fullname) {
if(rd->isStruct() || rd->isUnion()) {
std::string name = rd->getName();
//TODO: why do some types not have names?
Obj * thenamespace = &tagged;
if(name == "") {
TypedefNameDecl * decl = rd->getTypedefNameForAnonDecl();
if(decl) {
thenamespace = &general;
name = decl->getName();
} else {
name = "anon";
}
}
assert(name != "");
if(!thenamespace->obj(name.c_str(),tt)) {
//create new blank struct, fill in with members
std::stringstream ss;
ss << (rd->isStruct() ? "struct." : "union.") << name;
PushTypeFunction("getorcreatecstruct");
lua_pushstring(L, name.c_str());
lua_pushstring(L,ss.str().c_str());
lua_call(L,2,1);
tt->initFromStack(L,ref_table);
tt->push();
thenamespace->setfield(name.c_str()); //register the type (this prevents an infinite loop for recursive types)
}
if(tt->boolean("undefined") && rd->getDefinition() != NULL) {
tt->clearfield("undefined");
RecordDecl * defn = rd->getDefinition();
Obj entries;
tt->newlist(&entries);
if(GetFields(defn, &entries)) {
if(!defn->isUnion()) {
//structtype.entries = {entry1, entry2, ... }
entries.push();
tt->setfield("entries");
} else {
//add as a union:
//structtype.entries = { {entry1,entry2,...} }
Obj allentries;
tt->obj("entries",&allentries);
entries.push();
allentries.addentry();
}
tt->pushfield("complete");
tt->push();
lua_call(L,1,0);
}
}
if(fullname) {
std::stringstream ss;
if(thenamespace == &tagged)
ss << (rd->isStruct() ? "struct " : "union ");
ss << name;
*fullname = ss.str();
}
return true;
} else {
return ImportError("non-struct record types are not supported");
}
}