00001 #include "xi-Parameter.h"
00002 #include "xi-Template.h"
00003 #include "xi-Type.h"
00004
00005 namespace xi {
00006
00007 void FuncType::print(XStr& str) {
00008 rtype->print(str);
00009 str << "(*" << name << ")(";
00010 if (params) params->print(str);
00011 str << ")";
00012 }
00013
00014 void Type::genProxyName(XStr& str, forWhom forElement) {
00015 (void)str;
00016 (void)forElement;
00017 die("type::genProxyName called (INTERNAL ERROR)");
00018 }
00019 void Type::genIndexName(XStr& str) {
00020 (void)str;
00021 die("type::genIndexName called (INTERNAL ERROR)");
00022 }
00023 void Type::genMsgProxyName(XStr& str) {
00024 (void)str;
00025 die("type::genMsgProxyName called (INTERNAL ERROR)");
00026 }
00027
00028 void NamedType::genProxyName(XStr& str, forWhom forElement) {
00029 const char* prefix = forWhomStr(forElement);
00030 if (prefix == NULL)
00031 die("Unrecognized forElement type passed to NamedType::genProxyName");
00032 if (scope) str << scope;
00033 str << prefix;
00034 str << name;
00035 if (tparams) str << "<" << tparams << ">";
00036 }
00037
00038 void NamedType::print(XStr& str) {
00039 if (useTypename) str << "typename ";
00040 if (scope) str << scope;
00041 str << name;
00042 if (tparams) str << "<" << tparams << ">";
00043 }
00044
00045 void NamedType::genIndexName(XStr& str) {
00046 if (scope) str << scope;
00047 str << Prefix::Index;
00048 str << name;
00049 if (tparams) str << "<" << tparams << ">";
00050 }
00051
00052 void NamedType::genMsgProxyName(XStr& str) {
00053 if (scope) str << scope;
00054 str << Prefix::Message;
00055 str << name;
00056 if (tparams) str << "<" << tparams << ">";
00057 }
00058
00059 void NamedEllipsisType::print(XStr& str) {
00060 if (scope) str << scope;
00061 str << nameWithEllipsis;
00062 if (tparams) str << "<" << tparams << ">";
00063 }
00064
00065 void NamedEllipsisType::printWithoutEllipsis(XStr& str) {
00066 if (scope) str << scope;
00067 str << name;
00068 if (tparams) str << "<" << tparams << ">";
00069 }
00070
00071 void PtrType::print(XStr& str) {
00072 type->print(str);
00073 for (int i = 0; i < numstars; i++) str << "*";
00074 }
00075
00076 void TypeList::print(XStr& str) {
00077 type->print(str);
00078 if (next) {
00079 str << ", ";
00080 next->print(str);
00081 }
00082 }
00083
00084 int TypeList::length(void) const {
00085 if (next)
00086 return next->length() + 1;
00087 else
00088 return 1;
00089 }
00090
00091 void TypeList::genProxyNames(XStr& str, const char* prefix, const char* middle,
00092 const char* suffix, const char* sep, forWhom forElement) {
00093 if (type) {
00094 str << prefix;
00095 type->genProxyName(str, forElement);
00096 if (middle != NULL) {
00097 str << middle;
00098 type->genProxyName(str, forElement);
00099 }
00100 str << suffix;
00101 }
00102 if (next) {
00103 str << sep;
00104 next->genProxyNames(str, prefix, middle, suffix, sep, forElement);
00105 }
00106 }
00107
00108 }