summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
authorMichi Henning <michi@zeroc.com>2006-02-13 07:54:33 +0000
committerMichi Henning <michi@zeroc.com>2006-02-13 07:54:33 +0000
commita85739f90496efa8449085df0f3b3aa2697fab31 (patch)
treeaf462aa19db7068a585b20f51d7c5c5185e7aa79 /cpp/src
parentAdded test to operations test to check double marshalling (diff)
downloadice-a85739f90496efa8449085df0f3b3aa2697fab31.tar.bz2
ice-a85739f90496efa8449085df0f3b3aa2697fab31.tar.xz
ice-a85739f90496efa8449085df0f3b3aa2697fab31.zip
Bug 859
Diffstat (limited to 'cpp/src')
-rwxr-xr-xcpp/src/Slice/CsUtil.cpp22
-rwxr-xr-xcpp/src/Slice/VbUtil.cpp22
-rwxr-xr-xcpp/src/slice2cs/Gen.cpp41
-rwxr-xr-xcpp/src/slice2vb/Gen.cpp45
4 files changed, 118 insertions, 12 deletions
diff --git a/cpp/src/Slice/CsUtil.cpp b/cpp/src/Slice/CsUtil.cpp
index 37f1c116301..b1bc74d704a 100755
--- a/cpp/src/Slice/CsUtil.cpp
+++ b/cpp/src/Slice/CsUtil.cpp
@@ -1017,8 +1017,8 @@ Slice::CsGenerator::MetaDataVisitor::visitModuleStart(const ModulePtr& p)
}
}
_globalMetaDataDone = true;
- validate(p);
}
+ validate(p);
return true;
}
@@ -1061,6 +1061,15 @@ bool
Slice::CsGenerator::MetaDataVisitor::visitStructStart(const StructPtr& p)
{
validate(p);
+ if(p->hasMetaData("clr:property"))
+ {
+ if(!p->hasMetaData("clr:class"))
+ {
+ string file = p->definitionContext()->filename();
+ cout << file << ":" << p->line() << ": warning: the property mapping applies to Slice "
+ << "structures only in conjunction with the `clr:class' metadata directive" << endl;
+ }
+ }
return true;
}
@@ -1174,6 +1183,17 @@ Slice::CsGenerator::MetaDataVisitor::validate(const ContainedPtr& cont)
{
continue;
}
+ if(s.substr(prefix.size()) == "property")
+ {
+ continue;
+ }
+ }
+ if(ClassDefPtr::dynamicCast(cont))
+ {
+ if(s.substr(prefix.size()) == "property")
+ {
+ continue;
+ }
}
cout << file << ":" << cont->line() << ": warning: ignoring invalid metadata `" << s << "'" << endl;
}
diff --git a/cpp/src/Slice/VbUtil.cpp b/cpp/src/Slice/VbUtil.cpp
index 545aa6f4ef0..4894958b78b 100755
--- a/cpp/src/Slice/VbUtil.cpp
+++ b/cpp/src/Slice/VbUtil.cpp
@@ -1065,8 +1065,8 @@ Slice::VbGenerator::MetaDataVisitor::visitModuleStart(const ModulePtr& p)
}
}
_globalMetaDataDone = true;
- validate(p);
}
+ validate(p);
return true;
}
@@ -1109,6 +1109,15 @@ bool
Slice::VbGenerator::MetaDataVisitor::visitStructStart(const StructPtr& p)
{
validate(p);
+ if(p->hasMetaData("clr:property"))
+ {
+ if(!p->hasMetaData("clr:class"))
+ {
+ string file = p->definitionContext()->filename();
+ cout << file << ":" << p->line() << ": warning: the property mapping applies to Slice "
+ << "structures only in conjunction with the `clr:class' metadata directive" << endl;
+ }
+ }
return true;
}
@@ -1222,6 +1231,17 @@ Slice::VbGenerator::MetaDataVisitor::validate(const ContainedPtr& cont)
{
continue;
}
+ if(s.substr(prefix.size()) == "property")
+ {
+ continue;
+ }
+ }
+ if(ClassDefPtr::dynamicCast(cont))
+ {
+ if(s.substr(prefix.size()) == "property")
+ {
+ continue;
+ }
}
cout << file << ":" << cont->line() << ": warning: ignoring invalid metadata `" << s << "'" << endl;
}
diff --git a/cpp/src/slice2cs/Gen.cpp b/cpp/src/slice2cs/Gen.cpp
index 38a009798fd..e87a4691bce 100755
--- a/cpp/src/slice2cs/Gen.cpp
+++ b/cpp/src/slice2cs/Gen.cpp
@@ -1318,7 +1318,6 @@ Slice::Gen::TypesVisitor::visitClassDefEnd(const ClassDefPtr& p)
_out << nl << "os__.startWriteSlice();";
for(d = members.begin(); d != members.end(); ++d)
{
- StringList metaData = (*d)->getMetaData();
writeMarshalUnmarshalCode(_out, (*d)->type(),
fixId((*d)->name(), DotNet::ICloneable, true),
true, false, false);
@@ -1400,7 +1399,6 @@ Slice::Gen::TypesVisitor::visitClassDefEnd(const ClassDefPtr& p)
int classMemberCount = static_cast<int>(allClassMembers.size() - classMembers.size());
for(d = members.begin(); d != members.end(); ++d)
{
- StringList metaData = (*d)->getMetaData();
ostringstream patchParams;
patchParams << "this";
BuiltinPtr builtin = BuiltinPtr::dynamicCast((*d)->type());
@@ -1430,7 +1428,6 @@ Slice::Gen::TypesVisitor::visitClassDefEnd(const ClassDefPtr& p)
_out << nl << "outS__.startSlice();";
for(d = members.begin(); d != members.end(); ++d)
{
- StringList metaData = (*d)->getMetaData();
writeMarshalUnmarshalCode(_out, (*d)->type(),
fixId((*d)->name(), DotNet::ICloneable, true),
true, true, false);
@@ -1448,7 +1445,6 @@ Slice::Gen::TypesVisitor::visitClassDefEnd(const ClassDefPtr& p)
_out << nl << "inS__.startSlice();";
for(d = members.begin(); d != members.end(); ++d)
{
- StringList metaData = (*d)->getMetaData();
ostringstream patchParams;
patchParams << "this";
BuiltinPtr builtin = BuiltinPtr::dynamicCast((*d)->type());
@@ -2985,11 +2981,16 @@ Slice::Gen::TypesVisitor::visitDataMember(const DataMemberPtr& p)
{
int baseTypes = 0;
bool isClass = false;
+ bool propertyMapping = false;
ContainedPtr cont = ContainedPtr::dynamicCast(p->container());
assert(cont);
if(StructPtr::dynamicCast(cont) && cont->hasMetaData("clr:class"))
{
baseTypes = DotNet::ICloneable;
+ if(cont->hasMetaData("clr:property"))
+ {
+ propertyMapping = true;
+ }
}
else if(ExceptionPtr::dynamicCast(cont))
{
@@ -2999,10 +3000,40 @@ Slice::Gen::TypesVisitor::visitDataMember(const DataMemberPtr& p)
{
baseTypes = DotNet::ICloneable;
isClass = true;
+ if(cont->hasMetaData("clr:property"))
+ {
+ propertyMapping = true;
+ }
}
_out << sp << nl;
+
emitAttributes(p);
- _out << "public " << typeToString(p->type()) << " " << fixId(p->name(), baseTypes, isClass) << ";";
+
+ string type = typeToString(p->type());
+ string propertyName = fixId(p->name(), baseTypes, isClass);
+ string dataMemberName = propertyName;
+ if(propertyMapping)
+ {
+ dataMemberName += "_prop";
+ }
+ _out << (propertyMapping ? "private" : "public") << ' ' << type << ' ' << dataMemberName << ';';
+
+ if(!propertyMapping)
+ {
+ return;
+ }
+
+ _out << nl << "public virtual " << type << ' ' << propertyName;
+ _out << sb;
+ _out << nl << "get";
+ _out << sb;
+ _out << nl << "return " << dataMemberName << ';';
+ _out << eb;
+ _out << nl << "set";
+ _out << sb;
+ _out << nl << dataMemberName << " = value;";
+ _out << eb;
+ _out << eb;
}
Slice::Gen::ProxyVisitor::ProxyVisitor(IceUtil::Output& out)
diff --git a/cpp/src/slice2vb/Gen.cpp b/cpp/src/slice2vb/Gen.cpp
index 7ff9b51533c..2568b0283f2 100755
--- a/cpp/src/slice2vb/Gen.cpp
+++ b/cpp/src/slice2vb/Gen.cpp
@@ -1323,7 +1323,6 @@ Slice::Gen::TypesVisitor::visitClassDefEnd(const ClassDefPtr& p)
_out << nl << "os__.startWriteSlice()";
for(d = members.begin(); d != members.end(); ++d)
{
- StringList metaData = (*d)->getMetaData();
writeMarshalUnmarshalCode(_out, (*d)->type(), fixId((*d)->name(), DotNet::ICloneable, true), true, false,
false);
}
@@ -1407,7 +1406,6 @@ Slice::Gen::TypesVisitor::visitClassDefEnd(const ClassDefPtr& p)
int classMemberCount = static_cast<int>(allClassMembers.size() - classMembers.size());
for(d = members.begin(); d != members.end(); ++d)
{
- StringList metaData = (*d)->getMetaData();
ostringstream patchParams;
patchParams << "Me";
BuiltinPtr builtin = BuiltinPtr::dynamicCast((*d)->type());
@@ -1438,7 +1436,6 @@ Slice::Gen::TypesVisitor::visitClassDefEnd(const ClassDefPtr& p)
_out << nl << "outS__.startSlice()";
for(d = members.begin(); d != members.end(); ++d)
{
- StringList metaData = (*d)->getMetaData();
writeMarshalUnmarshalCode(_out, (*d)->type(),
fixId((*d)->name(), DotNet::ICloneable, true),
true, true, false);
@@ -1459,7 +1456,6 @@ Slice::Gen::TypesVisitor::visitClassDefEnd(const ClassDefPtr& p)
_out << nl << "inS__.startSlice()";
for(d = members.begin(); d != members.end(); ++d)
{
- StringList metaData = (*d)->getMetaData();
ostringstream patchParams;
patchParams << "Me";
BuiltinPtr builtin = BuiltinPtr::dynamicCast((*d)->type());
@@ -3258,11 +3254,16 @@ Slice::Gen::TypesVisitor::visitDataMember(const DataMemberPtr& p)
{
int baseTypes = 0;
bool isClass = false;
+ bool propertyMapping = false;
ContainedPtr cont = ContainedPtr::dynamicCast(p->container());
assert(cont);
if(StructPtr::dynamicCast(cont) && cont->hasMetaData("clr:class"))
{
baseTypes = DotNet::ICloneable;
+ if(cont->hasMetaData("clr:property"))
+ {
+ propertyMapping = true;
+ }
}
else if(ExceptionPtr::dynamicCast(cont))
{
@@ -3272,10 +3273,44 @@ Slice::Gen::TypesVisitor::visitDataMember(const DataMemberPtr& p)
{
baseTypes = DotNet::ICloneable;
isClass = true;
+ if(cont->hasMetaData("clr:property"))
+ {
+ propertyMapping = true;
+ }
}
_out << sp << nl;
+
emitAttributes(p);
- _out << "Public " << fixId(p->name(), baseTypes, isClass) << " As " << typeToString(p->type());
+
+ string type = typeToString(p->type());
+ string propertyName = fixId(p->name(), baseTypes, isClass);
+ string dataMemberName = propertyName;
+ if(propertyMapping)
+ {
+ dataMemberName += "_prop";
+ }
+
+ _out << (propertyMapping ? "Private" : "Public") << ' ' << dataMemberName << " As " << type;
+
+ if(!propertyMapping)
+ {
+ return;
+ }
+
+ _out << nl << "Public Overridable Property " << propertyName << " As " << type;
+ _out.inc();
+ _out << nl << "Get";
+ _out.inc();
+ _out << nl << "Return " << dataMemberName;
+ _out.dec();
+ _out << nl << "End Get";
+ _out << nl << "Set";
+ _out.inc();
+ _out << nl << dataMemberName << " = Value";
+ _out.dec();
+ _out << nl << "End Set";
+ _out.dec();
+ _out << nl << "End Property";
}
void