summaryrefslogtreecommitdiff
path: root/cpp/src/slice2js/JsUtil.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src/slice2js/JsUtil.cpp')
-rw-r--r--cpp/src/slice2js/JsUtil.cpp48
1 files changed, 19 insertions, 29 deletions
diff --git a/cpp/src/slice2js/JsUtil.cpp b/cpp/src/slice2js/JsUtil.cpp
index ac4cba9ea2f..641cc7c5632 100644
--- a/cpp/src/slice2js/JsUtil.cpp
+++ b/cpp/src/slice2js/JsUtil.cpp
@@ -102,18 +102,6 @@ fixIds(const StringList& ids)
return newIds;
}
-static string
-fixSuffix(const string& param)
-{
- const string thisSuffix = "this.";
- string p = param;
- if(p.find(thisSuffix) == 0)
- {
- p = "self." + p.substr(thisSuffix.size());
- }
- return p;
-}
-
bool
Slice::JsGenerator::isClassType(const TypePtr& type)
{
@@ -192,6 +180,7 @@ Slice::JsGenerator::getOptionalFormat(const TypePtr& type)
return "Ice.OptionalFormat.VSize";
}
case Builtin::KindObject:
+ case Builtin::KindValue:
{
return "Ice.OptionalFormat.Class";
}
@@ -322,7 +311,7 @@ Slice::JsGenerator::typeToString(const TypePtr& type, bool optional)
}
string
-Slice::JsGenerator::getLocalScope(const string& scope)
+Slice::JsGenerator::getLocalScope(const string& scope, const string& separator)
{
assert(!scope.empty());
@@ -353,7 +342,7 @@ Slice::JsGenerator::getLocalScope(const string& scope)
{
if(i != ids.begin())
{
- result << '.';
+ result << separator;
}
result << *i;
}
@@ -399,7 +388,7 @@ Slice::JsGenerator::writeMarshalUnmarshalCode(Output &out,
const string& param,
bool marshal)
{
- string stream = marshal ? "__os" : "__is";
+ string stream = marshal ? "ostr" : "istr";
BuiltinPtr builtin = BuiltinPtr::dynamicCast(type);
if(builtin)
@@ -503,6 +492,7 @@ Slice::JsGenerator::writeMarshalUnmarshalCode(Output &out,
return;
}
case Builtin::KindObject:
+ case Builtin::KindValue:
{
// Handle by isClassType below.
break;
@@ -531,11 +521,11 @@ Slice::JsGenerator::writeMarshalUnmarshalCode(Output &out,
{
if(marshal)
{
- out << nl << typeToString(type) << ".__write(" << stream << ", " << param << ");";
+ out << nl << typeToString(type) << "._write(" << stream << ", " << param << ");";
}
else
{
- out << nl << param << " = " << typeToString(type) << ".__read(" << stream << ");";
+ out << nl << param << " = " << typeToString(type) << "._read(" << stream << ");";
}
return;
}
@@ -557,12 +547,11 @@ Slice::JsGenerator::writeMarshalUnmarshalCode(Output &out,
{
if(marshal)
{
- out << nl << stream << ".writeObject(" << param << ");";
+ out << nl << stream << ".writeValue(" << param << ");";
}
else
{
- out << nl << stream << ".readObject(function(__o){ " << fixSuffix(param) << " = __o; }, "
- << typeToString(type) << ");";
+ out << nl << stream << ".readValue(obj => " << param << " = obj, " << typeToString(type) << ");";
}
return;
}
@@ -590,18 +579,18 @@ Slice::JsGenerator::writeOptionalMarshalUnmarshalCode(Output &out,
int tag,
bool marshal)
{
- string stream = marshal ? "__os" : "__is";
+ string stream = marshal ? "ostr" : "istr";
if(isClassType(type))
{
if(marshal)
{
- out << nl << stream << ".writeOptObject(" << tag << ", " << param << ");";
+ out << nl << stream << ".writeOptionalValue(" << tag << ", " << param << ");";
}
else
{
- out << nl << stream << ".readOptObject(" << tag << ", function(__o){ " << fixSuffix(param)
- << " = __o; }, " << typeToString(type) << ");";
+ out << nl << stream << ".readOptionalValue(" << tag << ", obj => " << param << " = obj, "
+ << typeToString(type) << ");";
}
return;
}
@@ -610,22 +599,22 @@ Slice::JsGenerator::writeOptionalMarshalUnmarshalCode(Output &out,
{
if(marshal)
{
- out << nl << typeToString(type) <<".__writeOpt(" << stream << ", " << tag << ", " << param << ");";
+ out << nl << typeToString(type) <<"._writeOpt(" << stream << ", " << tag << ", " << param << ");";
}
else
{
- out << nl << param << " = " << typeToString(type) << ".__readOpt(" << stream << ", " << tag << ");";
+ out << nl << param << " = " << typeToString(type) << "._readOpt(" << stream << ", " << tag << ");";
}
return;
}
if(marshal)
{
- out << nl << getHelper(type) <<".writeOpt(" << stream << ", " << tag << ", " << param << ");";
+ out << nl << getHelper(type) <<".writeOptional(" << stream << ", " << tag << ", " << param << ");";
}
else
{
- out << nl << param << " = " << getHelper(type) << ".readOpt(" << stream << ", " << tag << ");";
+ out << nl << param << " = " << getHelper(type) << ".readOptional(" << stream << ", " << tag << ");";
}
}
@@ -670,6 +659,7 @@ Slice::JsGenerator::getHelper(const TypePtr& type)
return "Ice.StringHelper";
}
case Builtin::KindObject:
+ case Builtin::KindValue:
{
return "Ice.ObjectHelper";
}
@@ -687,7 +677,7 @@ Slice::JsGenerator::getHelper(const TypePtr& type)
if(EnumPtr::dynamicCast(type))
{
- return typeToString(type) + ".__helper";
+ return typeToString(type) + "._helper";
}
if(ProxyPtr::dynamicCast(type) || StructPtr::dynamicCast(type))