2005-01-22 00:25:36 +03:00
|
|
|
#include "cmXCodeObject.h"
|
|
|
|
const char* cmXCodeObject::PBXTypeNames[] = {
|
|
|
|
"PBXGroup", "PBXBuildStyle", "PBXProject", "PBXHeadersBuildPhase",
|
|
|
|
"PBXSourcesBuildPhase", "PBXFrameworksBuildPhase", "PBXNativeTarget",
|
|
|
|
"PBXFileReference", "PBXBuildFile", "PBXContainerItemProxy", "PBXTargetDependency",
|
|
|
|
"PBXShellScriptBuildPhase", "PBXResourcesBuildPhase", "PBXApplicationReference",
|
|
|
|
"PBXExecutableFileReference", "PBXLibraryReference", "PBXToolTarget", "PBXLibraryTarget",
|
|
|
|
"None"
|
|
|
|
};
|
|
|
|
|
2005-01-25 01:35:54 +03:00
|
|
|
//----------------------------------------------------------------------------
|
2005-01-22 00:25:36 +03:00
|
|
|
cmXCodeObject::cmXCodeObject(PBXType ptype, Type type)
|
|
|
|
{
|
|
|
|
m_IsA = ptype;
|
|
|
|
cmOStringStream str;
|
|
|
|
str << (void*)this;
|
|
|
|
m_Id = str.str();
|
|
|
|
m_Type = type;
|
2005-01-25 01:35:54 +03:00
|
|
|
if(m_Type == OBJECT)
|
|
|
|
{
|
2005-01-25 23:26:57 +03:00
|
|
|
this->AddAttribute("isa", 0);
|
2005-01-25 01:35:54 +03:00
|
|
|
}
|
2005-01-22 00:25:36 +03:00
|
|
|
}
|
|
|
|
|
2005-01-25 01:35:54 +03:00
|
|
|
//----------------------------------------------------------------------------
|
2005-01-22 00:25:36 +03:00
|
|
|
void cmXCodeObject::Indent(int level, std::ostream& out)
|
|
|
|
{
|
|
|
|
while(level)
|
|
|
|
{
|
|
|
|
out << " ";
|
|
|
|
level--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-01-25 01:35:54 +03:00
|
|
|
//----------------------------------------------------------------------------
|
2005-01-22 00:25:36 +03:00
|
|
|
void cmXCodeObject::Print(std::ostream& out)
|
|
|
|
{
|
2005-01-25 01:35:54 +03:00
|
|
|
cmXCodeObject::Indent(2, out);
|
2005-01-22 00:25:36 +03:00
|
|
|
out << m_Id << " = {\n";
|
|
|
|
std::map<cmStdString, cmXCodeObject*>::iterator i;
|
|
|
|
for(i = m_ObjectAttributes.begin(); i != m_ObjectAttributes.end(); ++i)
|
|
|
|
{
|
2005-01-25 23:26:57 +03:00
|
|
|
|
2005-01-22 00:25:36 +03:00
|
|
|
cmXCodeObject* object = i->second;
|
2005-01-25 23:26:57 +03:00
|
|
|
cmXCodeObject::Indent(3, out);
|
|
|
|
if(i->first == "isa")
|
|
|
|
{
|
|
|
|
out << i->first << " = " << PBXTypeNames[m_IsA] << ";\n";
|
|
|
|
}
|
|
|
|
else if(object->m_Type == OBJECT_LIST)
|
2005-01-22 00:25:36 +03:00
|
|
|
{
|
|
|
|
out << i->first << " = {\n";
|
|
|
|
for(unsigned int k = 0; k < i->second->m_List.size(); k++)
|
|
|
|
{
|
2005-01-25 01:35:54 +03:00
|
|
|
cmXCodeObject::Indent(4, out);
|
2005-01-22 00:25:36 +03:00
|
|
|
out << i->second->m_List[k]->m_Id << ",\n";
|
|
|
|
}
|
2005-01-25 01:35:54 +03:00
|
|
|
cmXCodeObject::Indent(3, out);
|
2005-01-22 00:25:36 +03:00
|
|
|
out << "};\n";
|
|
|
|
}
|
|
|
|
else if(object->m_Type == ATTRIBUTE_GROUP)
|
|
|
|
{
|
2005-01-25 23:26:57 +03:00
|
|
|
std::map<cmStdString, cmXCodeObject*>::iterator j;
|
2005-01-22 00:25:36 +03:00
|
|
|
out << i->first << " = {\n";
|
2005-01-25 23:26:57 +03:00
|
|
|
for(j = object->m_ObjectAttributes.begin(); j != object->m_ObjectAttributes.end(); ++j)
|
2005-01-22 00:25:36 +03:00
|
|
|
{
|
2005-01-25 01:35:54 +03:00
|
|
|
cmXCodeObject::Indent(4, out);
|
2005-01-25 23:26:57 +03:00
|
|
|
out << j->first << " = " << j->second->m_String << ";\n";
|
2005-01-22 00:25:36 +03:00
|
|
|
}
|
2005-01-25 01:35:54 +03:00
|
|
|
cmXCodeObject::Indent(3, out);
|
|
|
|
out << "}\n";
|
2005-01-22 00:25:36 +03:00
|
|
|
}
|
|
|
|
else if(object->m_Type == OBJECT_REF)
|
|
|
|
{
|
|
|
|
out << i->first << " = " << object->m_Object->m_Id << ";\n";
|
|
|
|
}
|
2005-01-25 23:26:57 +03:00
|
|
|
else if(object->m_Type == STRING)
|
|
|
|
{
|
|
|
|
out << i->first << " = " << object->m_String << ";\n";
|
|
|
|
}
|
2005-01-22 00:25:36 +03:00
|
|
|
|
|
|
|
}
|
2005-01-25 01:35:54 +03:00
|
|
|
cmXCodeObject::Indent(2, out);
|
2005-01-22 00:25:36 +03:00
|
|
|
out << "};\n";
|
|
|
|
}
|
|
|
|
|
2005-01-25 01:35:54 +03:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmXCodeObject::PrintList(std::vector<cmXCodeObject*> const& objs,
|
|
|
|
std::ostream& out)
|
|
|
|
{
|
|
|
|
cmXCodeObject::Indent(1, out);
|
2005-01-22 00:25:36 +03:00
|
|
|
out << "objects = {\n";
|
2005-01-25 01:35:54 +03:00
|
|
|
for(unsigned int i = 0; i < objs.size(); ++i)
|
2005-01-22 00:25:36 +03:00
|
|
|
{
|
2005-01-25 01:35:54 +03:00
|
|
|
if(objs[i]->m_Type == OBJECT)
|
2005-01-22 00:25:36 +03:00
|
|
|
{
|
2005-01-25 01:35:54 +03:00
|
|
|
objs[i]->Print(out);
|
2005-01-22 00:25:36 +03:00
|
|
|
}
|
|
|
|
}
|
2005-01-25 01:35:54 +03:00
|
|
|
cmXCodeObject::Indent(1, out);
|
2005-01-22 00:25:36 +03:00
|
|
|
out << "};\n";
|
|
|
|
}
|