summaryrefslogtreecommitdiff
path: root/cpp/src/slice2js
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src/slice2js')
-rwxr-xr-xcpp/src/slice2js/.depend.mak58
-rw-r--r--cpp/src/slice2js/.gitignore5
-rw-r--r--cpp/src/slice2js/Gen.cpp1361
-rw-r--r--cpp/src/slice2js/Gen.h19
-rw-r--r--cpp/src/slice2js/JsUtil.cpp200
-rw-r--r--cpp/src/slice2js/JsUtil.h11
-rw-r--r--cpp/src/slice2js/Main.cpp62
-rw-r--r--cpp/src/slice2js/Makefile32
-rw-r--r--cpp/src/slice2js/Makefile.mak50
-rw-r--r--cpp/src/slice2js/Slice2Js.rc37
-rw-r--r--cpp/src/slice2js/msbuild/packages.config6
-rw-r--r--cpp/src/slice2js/msbuild/slice2js.vcxproj143
-rw-r--r--cpp/src/slice2js/msbuild/slice2js.vcxproj.filters44
13 files changed, 932 insertions, 1096 deletions
diff --git a/cpp/src/slice2js/.depend.mak b/cpp/src/slice2js/.depend.mak
deleted file mode 100755
index 888153164ec..00000000000
--- a/cpp/src/slice2js/.depend.mak
+++ /dev/null
@@ -1,58 +0,0 @@
-
-Gen.obj: \
- Gen.cpp \
- "$(includedir)\IceUtil\DisableWarnings.h" \
- "$(includedir)\IceUtil\Functional.h" \
- "$(includedir)\IceUtil\Handle.h" \
- "$(includedir)\IceUtil\Exception.h" \
- "$(includedir)\IceUtil\Config.h" \
- "$(includedir)\IceUtil\StringUtil.h" \
- "$(includedir)\IceUtil\InputUtil.h" \
- "Gen.h" \
- "JsUtil.h" \
- "$(includedir)\Slice\Parser.h" \
- "$(includedir)\IceUtil\Shared.h" \
- "$(includedir)\IceUtil\Atomic.h" \
- "$(includedir)\IceUtil\OutputUtil.h" \
- "$(includedir)\IceUtil\Iterator.h" \
- "$(includedir)\IceUtil\UUID.h" \
- "$(includedir)\Slice\Checksum.h" \
- "$(includedir)\Slice\FileTracker.h" \
- "$(includedir)\Slice\Util.h" \
-
-JsUtil.obj: \
- JsUtil.cpp \
- "JsUtil.h" \
- "$(includedir)\Slice\Parser.h" \
- "$(includedir)\IceUtil\Shared.h" \
- "$(includedir)\IceUtil\Config.h" \
- "$(includedir)\IceUtil\Atomic.h" \
- "$(includedir)\IceUtil\Handle.h" \
- "$(includedir)\IceUtil\Exception.h" \
- "$(includedir)\IceUtil\OutputUtil.h" \
- "$(includedir)\Slice\Util.h" \
- "$(includedir)\IceUtil\Functional.h" \
-
-Main.obj: \
- Main.cpp \
- "$(includedir)\IceUtil\Options.h" \
- "$(includedir)\IceUtil\Config.h" \
- "$(includedir)\IceUtil\RecMutex.h" \
- "$(includedir)\IceUtil\Lock.h" \
- "$(includedir)\IceUtil\ThreadException.h" \
- "$(includedir)\IceUtil\Exception.h" \
- "$(includedir)\IceUtil\Time.h" \
- "$(includedir)\IceUtil\MutexProtocol.h" \
- "$(includedir)\IceUtil\Shared.h" \
- "$(includedir)\IceUtil\Atomic.h" \
- "$(includedir)\IceUtil\Handle.h" \
- "$(includedir)\IceUtil\CtrlCHandler.h" \
- "$(includedir)\IceUtil\Mutex.h" \
- "$(includedir)\IceUtil\MutexPtrLock.h" \
- "$(includedir)\Slice\Preprocessor.h" \
- "$(includedir)\Slice\FileTracker.h" \
- "$(includedir)\Slice\Parser.h" \
- "$(includedir)\Slice\Util.h" \
- "$(includedir)\IceUtil\OutputUtil.h" \
- "Gen.h" \
- "JsUtil.h" \
diff --git a/cpp/src/slice2js/.gitignore b/cpp/src/slice2js/.gitignore
deleted file mode 100644
index 720f44c7047..00000000000
--- a/cpp/src/slice2js/.gitignore
+++ /dev/null
@@ -1,5 +0,0 @@
-// Generated by makegitignore.py
-
-// IMPORTANT: Do not edit this file -- any edits made here will be lost!
-.depend
-.depend
diff --git a/cpp/src/slice2js/Gen.cpp b/cpp/src/slice2js/Gen.cpp
index 59574fe6ad8..611f505c440 100644
--- a/cpp/src/slice2js/Gen.cpp
+++ b/cpp/src/slice2js/Gen.cpp
@@ -20,7 +20,6 @@
#include <direct.h>
#endif
#include <IceUtil/Iterator.h>
-#include <IceUtil/Unicode.h>
#include <IceUtil/UUID.h>
#include <Slice/Checksum.h>
#include <Slice/FileTracker.h>
@@ -36,44 +35,6 @@ namespace
{
string
-u16CodePoint(unsigned short value)
-{
- ostringstream s;
- s << "\\u";
- s << hex;
- s.width(4);
- s.fill('0');
- s << value;
- return s.str();
-}
-
-void
-writeU8Buffer(const vector<unsigned char>& u8buffer, ::IceUtilInternal::Output& out)
-{
- vector<unsigned short> u16buffer;
- IceUtilInternal::ConversionResult result = convertUTF8ToUTF16(u8buffer, u16buffer, IceUtil::lenientConversion);
- switch(result)
- {
- case conversionOK:
- break;
- case sourceExhausted:
- throw IceUtil::IllegalConversionException(__FILE__, __LINE__, "string source exhausted");
- case sourceIllegal:
- throw IceUtil::IllegalConversionException(__FILE__, __LINE__, "string source illegal");
- default:
- {
- assert(0);
- throw IceUtil::IllegalConversionException(__FILE__, __LINE__);
- }
- }
-
- for(vector<unsigned short>::const_iterator c = u16buffer.begin(); c != u16buffer.end(); ++c)
- {
- out << u16CodePoint(*c);
- }
-}
-
-string
sliceModeToIceMode(Operation::Mode opMode)
{
switch(opMode)
@@ -137,78 +98,6 @@ Slice::JsVisitor::~JsVisitor()
}
void
-Slice::JsVisitor::writeMarshalUnmarshalParams(const ParamDeclList& params, const OperationPtr& op, bool marshal)
-{
- ParamDeclList optionals;
-
- for(ParamDeclList::const_iterator pli = params.begin(); pli != params.end(); ++pli)
- {
- string param = fixId((*pli)->name());
- TypePtr type = (*pli)->type();
-
- if((*pli)->optional())
- {
- optionals.push_back(*pli);
- }
- else
- {
- writeMarshalUnmarshalCode(_out, type, param, marshal);
- }
- }
-
- TypePtr ret;
-
- if(op && op->returnType())
- {
- ret = op->returnType();
-
- string param = "__ret";
-
- if(!op->returnIsOptional())
- {
- writeMarshalUnmarshalCode(_out, ret, param, marshal);
- }
- }
-
- //
- // Sort optional parameters by tag.
- //
- class SortFn
- {
- public:
- static bool compare(const ParamDeclPtr& lhs, const ParamDeclPtr& rhs)
- {
- return lhs->tag() < rhs->tag();
- }
- };
- optionals.sort(SortFn::compare);
-
- //
- // Handle optional parameters.
- //
- bool checkReturnType = op && op->returnIsOptional();
-
- for(ParamDeclList::const_iterator pli = optionals.begin(); pli != optionals.end(); ++pli)
- {
- if(checkReturnType && op->returnTag() < (*pli)->tag())
- {
- writeOptionalMarshalUnmarshalCode(_out, ret, "__ret", op->returnTag(), marshal);
- checkReturnType = false;
- }
-
- string param = fixId((*pli)->name());
- TypePtr type = (*pli)->type();
-
- writeOptionalMarshalUnmarshalCode(_out, type, param, (*pli)->tag(), marshal);
- }
-
- if(checkReturnType)
- {
- writeOptionalMarshalUnmarshalCode(_out, ret, "__ret", op->returnTag(), marshal);
- }
-}
-
-void
Slice::JsVisitor::writeMarshalDataMembers(const DataMemberList& dataMembers, const DataMemberList& optionalMembers)
{
for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q)
@@ -230,15 +119,6 @@ Slice::JsVisitor::writeUnmarshalDataMembers(const DataMemberList& dataMembers, c
{
for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q)
{
- if(isClassType((*q)->type()))
- {
- _out << nl << "var self = this;";
- break;
- }
- }
-
- for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q)
- {
if(!(*q)->optional())
{
writeMarshalUnmarshalCode(_out, (*q)->type(), "this." + fixId((*q)->name()), false);
@@ -257,182 +137,8 @@ Slice::JsVisitor::writeInitDataMembers(const DataMemberList& dataMembers, const
for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q)
{
const string m = fixId((*q)->name());
- if((*q)->optional())
- {
- if((*q)->defaultValueType())
- {
- _out << nl << "this." << m << " = " << m << " !== undefined ? " << m << " : ";
- writeConstantValue(scope, (*q)->type(), (*q)->defaultValueType(), (*q)->defaultValue());
- _out << ';';
- }
- else
- {
- _out << nl << "this." << m << " = " << m << ';';
- }
- }
- else
- {
- _out << nl << "this." << m << " = " << m << " !== undefined ? " << m << " : ";
- if((*q)->defaultValueType())
- {
- writeConstantValue(scope, (*q)->type(), (*q)->defaultValueType(), (*q)->defaultValue());
- }
- else
- {
- _out << getValue(scope, (*q)->type());
- }
- _out << ';';
- }
- }
-}
-
-vector<string>
-Slice::JsVisitor::getParams(const OperationPtr& op)
-{
- vector<string> params;
- ParamDeclList paramList = op->parameters();
- for(ParamDeclList::const_iterator q = paramList.begin(); q != paramList.end(); ++q)
- {
- if(!(*q)->isOutParam())
- {
- params.push_back(fixId((*q)->name()));
- }
- }
- return params;
-}
-
-vector<string>
-Slice::JsVisitor::getParamsAsync(const OperationPtr& op, bool amd, bool newAMI)
-{
- vector<string> params;
-
- string name = fixId(op->name());
- ContainerPtr container = op->container();
- ClassDefPtr cl = ClassDefPtr::dynamicCast(container); // Get the class containing the op.
- string scope = fixId(cl->scope());
- if(!newAMI)
- {
- params.push_back(scope + (amd ? "AMD_" : "AMI_") + cl->name() + '_' + op->name() + " cb__");
- }
-
- ParamDeclList paramList = op->parameters();
- for(ParamDeclList::const_iterator q = paramList.begin(); q != paramList.end(); ++q)
- {
- if(!(*q)->isOutParam())
- {
- params.push_back(typeToString((*q)->type(), (*q)->optional()) + " " + fixId((*q)->name()));
- }
- }
- return params;
-}
-
-vector<string>
-Slice::JsVisitor::getParamsAsyncCB(const OperationPtr& op, bool newAMI, bool outKeyword)
-{
- vector<string> params;
-
- if(!newAMI)
- {
- TypePtr ret = op->returnType();
- if(ret)
- {
- params.push_back(typeToString(ret, op->returnIsOptional()) + " ret__");
- }
- }
-
- ParamDeclList paramList = op->parameters();
- for(ParamDeclList::const_iterator q = paramList.begin(); q != paramList.end(); ++q)
- {
- if((*q)->isOutParam())
- {
- if(!newAMI)
- {
- params.push_back(typeToString((*q)->type(), (*q)->optional()) + ' ' + fixId((*q)->name()));
- }
- else
- {
- string s;
- if(outKeyword)
- {
- s += "out ";
- }
- s += typeToString((*q)->type(), (*q)->optional()) + ' ' + fixId((*q)->name());
- params.push_back(s);
- }
- }
- }
-
- return params;
-}
-
-vector<string>
-Slice::JsVisitor::getArgs(const OperationPtr& op)
-{
- vector<string> args;
- ParamDeclList paramList = op->parameters();
- for(ParamDeclList::const_iterator q = paramList.begin(); q != paramList.end(); ++q)
- {
- string arg = fixId((*q)->name());
- if((*q)->isOutParam())
- {
- arg = "out " + arg;
- }
- args.push_back(arg);
- }
- return args;
-}
-
-vector<string>
-Slice::JsVisitor::getArgsAsync(const OperationPtr& op, bool newAMI)
-{
- vector<string> args;
-
- if(!newAMI)
- {
- args.push_back("cb__");
- }
-
- ParamDeclList paramList = op->parameters();
- for(ParamDeclList::const_iterator q = paramList.begin(); q != paramList.end(); ++q)
- {
- if(!(*q)->isOutParam())
- {
- args.push_back(fixId((*q)->name()));
- }
- }
- return args;
-}
-
-vector<string>
-Slice::JsVisitor::getArgsAsyncCB(const OperationPtr& op, bool newAMI, bool outKeyword)
-{
- vector<string> args;
-
- if(!newAMI)
- {
- TypePtr ret = op->returnType();
- if(ret)
- {
- args.push_back("ret__");
- }
- }
-
- ParamDeclList paramList = op->parameters();
- for(ParamDeclList::const_iterator q = paramList.begin(); q != paramList.end(); ++q)
- {
- if((*q)->isOutParam())
- {
- string s;
- if(outKeyword)
- {
- s = "out ";
- }
- s += fixId((*q)->name());
- args.push_back(s);
- }
+ _out << nl << "this." << m << " = " << m << ';';
}
-
- return args;
}
string
@@ -479,7 +185,7 @@ Slice::JsVisitor::getValue(const string& scope, const TypePtr& type)
EnumPtr en = EnumPtr::dynamicCast(type);
if(en)
{
- return getReference(scope, en->scoped()) + '.' + fixId((*en->getEnumerators().begin())->name());
+ return getReference(scope, en->scoped()) + '.' + fixId((*en->enumerators().begin())->name());
}
StructPtr st = StructPtr::dynamicCast(type);
@@ -491,14 +197,15 @@ Slice::JsVisitor::getValue(const string& scope, const TypePtr& type)
return "null";
}
-void
+string
Slice::JsVisitor::writeConstantValue(const string& scope, const TypePtr& type, const SyntaxTreeBasePtr& valueType,
const string& value)
{
+ ostringstream os;
ConstPtr constant = ConstPtr::dynamicCast(valueType);
if(constant)
{
- _out << getReference(scope, constant->scoped());
+ os << getReference(scope, constant->scoped());
}
else
{
@@ -507,124 +214,9 @@ Slice::JsVisitor::writeConstantValue(const string& scope, const TypePtr& type, c
if(bp && bp->kind() == Builtin::KindString)
{
//
- // Expand strings into the basic source character set. We can't use isalpha() and the like
- // here because they are sensitive to the current locale.
- //
- static const string basicSourceChars = "abcdefghijklmnopqrstuvwxyz"
- "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- "0123456789"
- "_{}[]#()<>%:;.?*+-/^&|~!=,\\\"' ";
- static const set<char> charSet(basicSourceChars.begin(), basicSourceChars.end());
-
- _out << "\""; // Opening "
-
- vector<unsigned char> u8buffer; // Buffer to convert multibyte characters
-
- for(size_t i = 0; i < value.size();)
- {
- if(charSet.find(value[i]) == charSet.end())
- {
- if(static_cast<unsigned char>(value[i]) < 128) // Single byte character
- {
- //
- // Print as unicode if not in basic source character set
- //
- _out << u16CodePoint(static_cast<unsigned int>(value[i]));
- }
- else
- {
- u8buffer.push_back(value[i]);
- }
- }
- else
- {
- //
- // Write any pedding characters in the utf8 buffer
- //
- if(!u8buffer.empty())
- {
- writeU8Buffer(u8buffer, _out);
- u8buffer.clear();
- }
- switch(value[i])
- {
- case '\\':
- {
- string s = "\\";
- size_t j = i + 1;
- for(; j < value.size(); ++j)
- {
- if(value[j] != '\\')
- {
- break;
- }
- s += "\\";
- }
-
- //
- // An even number of slash \ will escape the backslash and
- // the codepoint will be interpreted as its charaters
- //
- // \\U00000041 - ['\\', 'U', '0', '0', '0', '0', '0', '0', '4', '1']
- // \\\U00000041 - ['\\', 'A'] (41 is the codepoint for 'A')
- //
- if(s.size() % 2 != 0 && value[j] == 'U')
- {
- _out << s.substr(0, s.size() - 1);
- i = j + 1;
-
- string codepoint = value.substr(j + 1, 8);
- assert(codepoint.size() == 8);
-
- IceUtil::Int64 v = IceUtilInternal::strToInt64(codepoint.c_str(), 0, 16);
-
-
- //
- // Unicode character in the range U+10000 to U+10FFFF is not permitted in a character literal
- // and is represented using a Unicode surrogate pair.
- //
- if(v > 0xFFFF)
- {
- unsigned int high = ((static_cast<unsigned int>(v) - 0x10000) / 0x400) + 0xD800;
- unsigned int low = ((static_cast<unsigned int>(v) - 0x10000) % 0x400) + 0xDC00;
- _out << u16CodePoint(high);
- _out << u16CodePoint(low);
- }
- else
- {
- _out << u16CodePoint(static_cast<unsigned int>(v));
- }
-
- i = j + 1 + 8;
- }
- else
- {
- _out << s;
- i = j;
- }
- continue;
- }
- case '"':
- {
- _out << "\\";
- break;
- }
- }
- _out << value[i]; // Print normally if in basic source character set
- }
- i++;
- }
-
- //
- // Write any pedding characters in the utf8 buffer
+ // For now, we generate strings in ECMAScript 5 format, with two \unnnn for astral characters
//
- if(!u8buffer.empty())
- {
- writeU8Buffer(u8buffer, _out);
- u8buffer.clear();
- }
-
- _out << "\""; // Closing "
+ os << "\"" << toStringLiteral(value, "\b\f\n\r\t\v", "", ShortUCN, 0) << "\"";
}
else if(bp && bp->kind() == Builtin::KindLong)
{
@@ -639,30 +231,23 @@ Slice::JsVisitor::writeConstantValue(const string& scope, const TypePtr& type, c
// output file.
//
#ifdef ICE_BIG_ENDIAN
- _out << "new Ice.Long(" << (l & 0xFFFFFFFF) << ", " << ((l >> 32) & 0xFFFFFFFF) << ")";
+ os << "new Ice.Long(" << (l & 0xFFFFFFFF) << ", " << ((l >> 32) & 0xFFFFFFFF) << ")";
#else
- _out << "new Ice.Long(" << ((l >> 32) & 0xFFFFFFFF) << ", " << (l & 0xFFFFFFFF) << ")";
+ os << "new Ice.Long(" << ((l >> 32) & 0xFFFFFFFF) << ", " << (l & 0xFFFFFFFF) << ")";
#endif
}
else if((ep = EnumPtr::dynamicCast(type)))
{
- string::size_type colon = value.rfind(':');
- string enumerator;
- if(colon != string::npos)
- {
- enumerator = fixId(value.substr(colon + 1));
- }
- else
- {
- enumerator = fixId(value);
- }
- _out << getReference(scope, ep->scoped()) << '.' << enumerator;
+ EnumeratorPtr lte = EnumeratorPtr::dynamicCast(valueType);
+ assert(lte);
+ os << getReference(scope, ep->scoped()) << '.' << fixId(lte->name());
}
else
{
- _out << value;
+ os << value;
}
}
+ return os.str();
}
StringList
@@ -796,29 +381,33 @@ void
Slice::Gen::generate(const UnitPtr& p)
{
//
- // Check for global "js:ice-build" metadata.
- // If this is set then we are building Ice.
+ // Check for global "js:ice-build" and "js:es6-module"
+ // metadata. If this is set then we are building Ice.
//
DefinitionContextPtr dc = p->findDefinitionContext(p->topLevelFile());
assert(dc);
StringList globalMetaData = dc->getMetaData();
bool icejs = find(globalMetaData.begin(), globalMetaData.end(), "js:ice-build") != globalMetaData.end();
+ bool es6module = find(globalMetaData.begin(), globalMetaData.end(), "js:es6-module") != globalMetaData.end();
- if(icejs)
+ if(!es6module)
{
- _out.zeroIndent();
- _out << nl << "/* slice2js browser-bundle-skip */";
- _out.restoreIndent();
- }
- _out << nl << "(function(module, require, exports)";
- _out << sb;
- if(icejs)
- {
- _out.zeroIndent();
- _out << nl << "/* slice2js browser-bundle-skip-end */";
- _out.restoreIndent();
+ if(icejs)
+ {
+ _out.zeroIndent();
+ _out << nl << "/* slice2js browser-bundle-skip */";
+ _out.restoreIndent();
+ }
+ _out << nl << "(function(module, require, exports)";
+ _out << sb;
+ if(icejs)
+ {
+ _out.zeroIndent();
+ _out << nl << "/* slice2js browser-bundle-skip-end */";
+ _out.restoreIndent();
+ }
}
- RequireVisitor requireVisitor(_out, _includePaths, icejs);
+ RequireVisitor requireVisitor(_out, _includePaths, icejs, es6module);
p->visit(&requireVisitor, false);
vector<string> seenModules = requireVisitor.writeRequires(p);
@@ -828,26 +417,29 @@ Slice::Gen::generate(const UnitPtr& p)
//
// Export the top-level modules.
//
- ExportVisitor exportVisitor(_out, icejs);
+ ExportVisitor exportVisitor(_out, icejs, es6module);
p->visit(&exportVisitor, false);
- if(icejs)
+ if(!es6module)
{
- _out.zeroIndent();
- _out << nl << "/* slice2js browser-bundle-skip */";
- _out.restoreIndent();
- }
- _out << eb;
+ if(icejs)
+ {
+ _out.zeroIndent();
+ _out << nl << "/* slice2js browser-bundle-skip */";
+ _out.restoreIndent();
+ }
- _out << nl << "(typeof(global) !== \"undefined\" && typeof(global.process) !== \"undefined\" ? module : undefined,"
- << nl << " typeof(global) !== \"undefined\" && typeof(global.process) !== \"undefined\" ? require : this.Ice.__require,"
- << nl << " typeof(global) !== \"undefined\" && typeof(global.process) !== \"undefined\" ? exports : this));";
+ _out << eb;
+ _out << nl << "(typeof(global) !== \"undefined\" && typeof(global.process) !== \"undefined\" ? module : undefined,"
+ << nl << " typeof(global) !== \"undefined\" && typeof(global.process) !== \"undefined\" ? require : this.Ice._require,"
+ << nl << " typeof(global) !== \"undefined\" && typeof(global.process) !== \"undefined\" ? exports : this));";
- if(icejs)
- {
- _out.zeroIndent();
- _out << nl << "/* slice2js browser-bundle-skip-end */";
- _out.restoreIndent();
+ if(icejs)
+ {
+ _out.zeroIndent();
+ _out << nl << "/* slice2js browser-bundle-skip-end */";
+ _out.restoreIndent();
+ }
}
}
@@ -878,9 +470,10 @@ Slice::Gen::printHeader()
}
Slice::Gen::RequireVisitor::RequireVisitor(IceUtilInternal::Output& out, vector<string> includePaths,
- bool icejs) :
+ bool icejs, bool es6modules) :
JsVisitor(out),
_icejs(icejs),
+ _es6modules(es6modules),
_seenClass(false),
_seenCompactId(false),
_seenOperation(false),
@@ -971,6 +564,59 @@ bool iceBuiltinModule(const string& name)
return name == "Glacier2" || name == "Ice" || name == "IceGrid" || name == "IceMX" || name == "IceStorm";
}
+string
+relativePath(string p1, string p2)
+{
+ vector<string> tokens1;
+ vector<string> tokens2;
+
+ splitString(p1, "/\\", tokens1);
+ splitString(p2, "/\\", tokens2);
+
+ string f1 = tokens1.back();
+ string f2 = tokens2.back();
+
+ tokens1.pop_back();
+ tokens2.pop_back();
+
+ vector<string>::const_iterator i1 = tokens1.begin();
+ vector<string>::const_iterator i2 = tokens2.begin();
+
+ while(i1 != tokens1.end() && i2 != tokens2.end() && *i1 == *i2)
+ {
+ i1++;
+ i2++;
+ }
+
+ //
+ // Different volumes, relative path not possible.
+ //
+ if(i1 == tokens1.begin() && i2 == tokens2.begin())
+ {
+ return p1;
+ }
+
+ string newPath;
+ if(i2 == tokens2.end())
+ {
+ newPath += "./";
+ for(; i1 != tokens1.end(); ++i1)
+ {
+ newPath += *i1 + "/";
+ }
+ }
+ else
+ {
+ for(;i2 != tokens2.end();++i2)
+ {
+ newPath += "../";
+ }
+ }
+ newPath += f1;
+
+ return newPath;
+}
+
}
vector<string>
@@ -978,10 +624,10 @@ Slice::Gen::RequireVisitor::writeRequires(const UnitPtr& p)
{
vector<string> seenModules;
- map<string, vector<string> > requires;
+ map<string, list<string> > requires;
if(_icejs)
{
- requires["Ice"] = vector<string>();
+ requires["Ice"] = list<string>();
//
// Generate require() statements for all of the run-time code needed by the generated code.
@@ -989,6 +635,7 @@ Slice::Gen::RequireVisitor::writeRequires(const UnitPtr& p)
if(_seenClass || _seenObjectSeq || _seenObjectDict)
{
requires["Ice"].push_back("Ice/Object");
+ requires["Ice"].push_back("Ice/Value");
}
if(_seenClass)
{
@@ -1026,100 +673,161 @@ Slice::Gen::RequireVisitor::writeRequires(const UnitPtr& p)
}
else
{
- requires["Ice"] = vector<string>();
+ requires["Ice"] = list<string>();
requires["Ice"].push_back("ice");
}
StringList includes = p->includeFiles();
- for(StringList::const_iterator i = includes.begin(); i != includes.end(); ++i)
+ if(_es6modules)
{
- set<string> modules = p->getTopLevelModules(*i);
- for(set<string>::const_iterator j = modules.begin(); j != modules.end(); ++j)
+ _out << nl << "import { Ice } from \"ice\";";
+ _out << nl << "const _ModuleRegistry = Ice._ModuleRegistry;";
+
+ seenModules.push_back("Ice");
+
+
+ for(StringList::const_iterator i = includes.begin(); i != includes.end(); ++i)
{
- if(!_icejs && iceBuiltinModule(*j))
+ set<string> modules = p->getTopLevelModules(*i);
+ vector<string> newModules;
+ bool externals = false; // is there any external modules?
+ for(set<string>::const_iterator j = modules.begin(); j != modules.end(); ++j)
{
- if(requires.find(*j) == requires.end())
+ if(find(seenModules.begin(), seenModules.end(), *j) == seenModules.end())
{
- requires[*j] = vector<string>();
- requires[*j].push_back("ice");
+ seenModules.push_back(*j);
+ if(!_icejs && iceBuiltinModule(*j))
+ {
+ _out << nl << "import { " << *j << " } from \"ice\";";
+ }
+ else
+ {
+ newModules.push_back(*j);
+ externals = true;
+ }
}
}
- else
+
+ if(externals)
{
- if(requires.find(*j) == requires.end())
+ _out << nl << "import ";
+ if(!newModules.empty())
+ {
+ _out << "{ ";
+ for(vector<string>::const_iterator j = newModules.begin(); j != newModules.end();)
+ {
+ _out << *j;
+ ++j;
+ if(j != newModules.end())
+ {
+ _out << ", ";
+ }
+ }
+ _out << " } from ";
+ }
+
+ string result = relativePath(*i, p->topLevelFile());
+ string::size_type pos;
+ if((pos = result.rfind('.')) != string::npos)
{
- requires[*j] = vector<string>();
+ result.erase(pos);
}
- requires[*j].push_back(changeInclude(*i, _includePaths));
+ _out << "\"" << result << "\";";
}
}
- }
-
- if(_icejs)
- {
- _out.zeroIndent();
- _out << nl << "/* slice2js browser-bundle-skip */";
- _out.restoreIndent();
- }
-
- if(!_icejs)
- {
- _out << nl << "var Ice = require(\"ice\").Ice;";
- _out << nl << "var __M = Ice.__M;";
+ _out << nl << "const Slice = Ice.Slice;";
}
else
{
- _out << nl << "var __M = require(\"../Ice/ModuleRegistry\").Ice.__M;";
- }
-
- for(map<string, vector<string> >::const_iterator i = requires.begin(); i != requires.end(); ++i)
- {
- if(!_icejs && i->first == "Ice")
+ for(StringList::const_iterator i = includes.begin(); i != includes.end(); ++i)
+ {
+ set<string> modules = p->getTopLevelModules(*i);
+ for(set<string>::const_iterator j = modules.begin(); j != modules.end(); ++j)
+ {
+ if(!_icejs && iceBuiltinModule(*j))
+ {
+ if(requires.find(*j) == requires.end())
+ {
+ requires[*j] = list<string>();
+ requires[*j].push_back("ice");
+ }
+ }
+ else
+ {
+ if(requires.find(*j) == requires.end())
+ {
+ requires[*j] = list<string>();
+ }
+ requires[*j].push_back(changeInclude(*i, _includePaths));
+ }
+ }
+ }
+ if(_icejs)
{
- continue;
+ _out.zeroIndent();
+ _out << nl << "/* slice2js browser-bundle-skip */";
+ _out.restoreIndent();
}
- if(i->second.size() == 1)
+ if(!_icejs)
{
- _out << nl << "var " << i->first << " = require(\"";
- if(_icejs && iceBuiltinModule(i->first))
- {
- _out << "../";
- }
- _out << i->second[0] << "\")." << i->first << ";";
+ _out << nl << "const Ice = require(\"ice\").Ice;";
+ _out << nl << "const _ModuleRegistry = Ice._ModuleRegistry;";
}
else
{
- _out << nl << "var " << i->first << " = __M.require(module, ";
- _out << nl << "[";
- _out.inc();
- for(vector<string>::const_iterator j = i->second.begin(); j != i->second.end();)
+ _out << nl << "const _ModuleRegistry = require(\"../Ice/ModuleRegistry\").Ice._ModuleRegistry;";
+ }
+
+ for(map<string, list<string> >::const_iterator i = requires.begin(); i != requires.end(); ++i)
+ {
+ if(!_icejs && i->first == "Ice")
+ {
+ continue;
+ }
+
+ if(i->second.size() == 1)
{
- _out << nl << '"';
+ _out << nl << "const " << i->first << " = require(\"";
if(_icejs && iceBuiltinModule(i->first))
{
_out << "../";
}
- _out << *j << '"';
- if(++j != i->second.end())
+ _out << i->second.front() << "\")." << i->first << ";";
+ }
+ else
+ {
+ _out << nl << "const " << i->first << " = _ModuleRegistry.require(module, ";
+ _out << nl << "[";
+ _out.inc();
+ for(list<string>::const_iterator j = i->second.begin(); j != i->second.end();)
{
- _out << ",";
+ _out << nl << '"';
+ if(_icejs && iceBuiltinModule(i->first))
+ {
+ _out << "../";
+ }
+ _out << *j << '"';
+ if(++j != i->second.end())
+ {
+ _out << ",";
+ }
}
+ _out.dec();
+ _out << nl << "])." << i->first << ";";
+ _out << nl;
}
- _out.dec();
- _out << nl << "])." << i->first << ";";
- _out << nl;
+ seenModules.push_back(i->first);
}
- seenModules.push_back(i->first);
- }
- _out << nl << "var Slice = Ice.Slice;";
+ _out << nl << "const Slice = Ice.Slice;";
- if(_icejs)
- {
- _out.zeroIndent();
- _out << nl << "/* slice2js browser-bundle-skip-end */";
- _out.restoreIndent();
+ if(_icejs)
+ {
+ _out.zeroIndent();
+ _out << nl << "/* slice2js browser-bundle-skip-end */";
+ _out.restoreIndent();
+ }
}
return seenModules;
}
@@ -1137,11 +845,11 @@ Slice::Gen::TypesVisitor::visitModuleStart(const ModulePtr& p)
//
// For a top-level module we write the following:
//
- // var Foo = __M.module("Foo");
+ // let Foo = _ModuleRegistry.module("Foo");
//
// For a nested module we write
//
- // Foo.Bar = __M.module("Foo.Bar");
+ // Foo.Bar = _ModuleRegistry.module("Foo.Bar");
//
const string scoped = getLocalScope(p->scoped());
vector<string>::const_iterator i = find(_seenModules.begin(), _seenModules.end(), scoped);
@@ -1160,9 +868,9 @@ Slice::Gen::TypesVisitor::visitModuleStart(const ModulePtr& p)
_out << nl;
if(topLevel)
{
- _out << "var ";
+ _out << "let ";
}
- _out << scoped << " = __M.module(\"" << scoped << "\");";
+ _out << scoped << " = _ModuleRegistry.module(\"" << scoped << "\");";
if(_icejs)
{
@@ -1182,31 +890,32 @@ Slice::Gen::TypesVisitor::visitModuleEnd(const ModulePtr& p)
bool
Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p)
{
+ //
+ // Don't need to generate any code for local interfaces.
+ //
+ if(p->isInterface() && p->isLocal())
+ {
+ return false;
+ }
const string scope = p->scope();
const string scoped = p->scoped();
const string localScope = getLocalScope(scope);
const string name = fixId(p->name());
const string prxName = p->name() + "Prx";
- const string objectRef = "Ice.Object";
- const string prxRef = "Ice.ObjectPrx";
- const string defineObject = p->isLocal() ? "Slice.defineLocalObject" : "Slice.defineObject";
ClassList bases = p->bases();
ClassDefPtr base;
string baseRef;
- string basePrxRef;
const bool hasBaseClass = !bases.empty() && !bases.front()->isInterface();
if(hasBaseClass)
{
base = bases.front();
bases.erase(bases.begin());
baseRef = getReference(scope, base->scoped());
- basePrxRef = getReference(scope, base->scoped() + "Prx");
}
else
{
- baseRef = objectRef;
- basePrxRef = prxRef;
+ baseRef = "Ice.Value";
}
const DataMemberList allDataMembers = p->allDataMembers();
@@ -1231,135 +940,171 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p)
}
}
- _out << sp;
- writeDocComment(p, getDeprecateReason(p, 0, "type"));
- _out << nl << localScope << '.' << name << " = " << defineObject << "(";
- _out.inc();
+ ClassList allBases = p->allBases();
+ StringList ids;
+ transform(allBases.begin(), allBases.end(), back_inserter(ids), ::IceUtil::constMemFun(&Contained::scoped));
+ StringList other;
+ other.push_back(scoped);
+ other.push_back("::Ice::Object");
+ other.sort();
+ ids.merge(other);
+ ids.unique();
- if(!allParamNames.empty())
+ StringList::const_iterator firstIter = ids.begin();
+ StringList::const_iterator scopedIter = find(ids.begin(), ids.end(), scoped);
+ assert(scopedIter != ids.end());
+ StringList::difference_type scopedPos = IceUtilInternal::distance(firstIter, scopedIter);
+
+ if(!p->isLocal())
{
- _out << nl << "function" << spar << allParamNames << epar;
- _out << sb;
- if(!p->isLocal() || hasBaseClass)
+ _out << sp;
+ _out << nl << "const iceC_" << getLocalScope(scoped, "_") << "_ids = [";
+ _out.inc();
+
+ for(StringList::const_iterator q = ids.begin(); q != ids.end(); ++q)
{
- _out << nl << baseRef << ".call" << spar << "this" << baseParamNames << epar << ';';
+ if(q != ids.begin())
+ {
+ _out << ',';
+ }
+ _out << nl << '"' << *q << '"';
}
- writeInitDataMembers(dataMembers, scope);
- _out << eb;
+
+ _out.dec();
+ _out << nl << "];";
}
- else
+
+ if(!p->isInterface() || p->isLocal())
{
- if(hasBaseClass || !p->isLocal())
+ _out << sp;
+ writeDocComment(p, getDeprecateReason(p, 0, "type"));
+ _out << nl << localScope << '.' << name << " = class";
+ if(!p->isLocal() || hasBaseClass)
{
- _out << nl << "undefined";
+ _out << " extends " << baseRef;
}
- }
- if(!p->isLocal() || hasBaseClass)
- {
- _out << ",";
- _out << nl << baseRef;
- }
- if(!p->isLocal())
- {
- ClassList allBases = p->allBases();
- StringList ids;
-
- if(!bases.empty())
+ _out << sb;
+ if(!allParamNames.empty())
{
- _out << ",";
- _out << nl << "[";
- _out.inc();
- for(ClassList::const_iterator q = bases.begin(); q != bases.end();)
+ _out << nl << "constructor" << spar;
+ for(DataMemberList::const_iterator q = baseDataMembers.begin(); q != baseDataMembers.end(); ++q)
{
- ClassDefPtr base = *q;
- if(base->isInterface())
+ _out << fixId((*q)->name());
+ }
+
+ for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q)
+ {
+ string value;
+ if((*q)->optional())
{
- _out << nl << getLocalScope(base->scope()) << "." << base->name();
- if(++q != bases.end())
+ if((*q)->defaultValueType())
{
- _out << ", ";
+ value = writeConstantValue(scope, (*q)->type(), (*q)->defaultValueType(), (*q)->defaultValue());
+ }
+ else
+ {
+ value = "undefined";
}
}
else
{
- q++;
+ if((*q)->defaultValueType())
+ {
+ value = writeConstantValue(scope, (*q)->type(), (*q)->defaultValueType(), (*q)->defaultValue());
+ }
+ else
+ {
+ value = getValue(scope, (*q)->type());
+ }
+ }
+ _out << (fixId((*q)->name()) + (value.empty() ? value : (" = " + value)));
+ }
+
+ _out << epar << sb;
+ if(!p->isLocal() || hasBaseClass)
+ {
+ _out << nl << "super" << spar << baseParamNames << epar << ';';
+ }
+ writeInitDataMembers(dataMembers, scope);
+ _out << eb;
+
+ if(!p->isLocal())
+ {
+ if(p->compactId() != -1)
+ {
+ _out << sp;
+ _out << nl << "static get _iceCompactId()";
+ _out << sb;
+ _out << nl << "return " << p->compactId() << ";";
+ _out << eb;
+ }
+
+ if(!dataMembers.empty())
+ {
+ _out << sp;
+ _out << nl << "_iceWriteMemberImpl(ostr)";
+ _out << sb;
+ writeMarshalDataMembers(dataMembers, optionalMembers);
+ _out << eb;
+
+ _out << sp;
+ _out << nl << "_iceReadMemberImpl(istr)";
+ _out << sb;
+ writeUnmarshalDataMembers(dataMembers, optionalMembers);
+ _out << eb;
}
}
- _out.dec();
- _out << nl << "]";
- }
- else
- {
- _out << ", undefined";
}
+ _out << eb << ";";
- transform(allBases.begin(), allBases.end(), back_inserter(ids), ::IceUtil::constMemFun(&Contained::scoped));
- StringList other;
- other.push_back(scoped);
- other.push_back("::Ice::Object");
- other.sort();
- ids.merge(other);
- ids.unique();
-
- StringList::const_iterator firstIter = ids.begin();
- StringList::const_iterator scopedIter = find(ids.begin(), ids.end(), scoped);
- assert(scopedIter != ids.end());
- StringList::difference_type scopedPos = IceUtilInternal::distance(firstIter, scopedIter);
-
- _out << ", " << scopedPos << ",";
- _out << nl << "[";
- _out.inc();
- for(StringList::const_iterator q = ids.begin(); q != ids.end(); ++q)
+ _out << sp;
+ if(!p->isLocal())
{
- if(q != ids.begin())
+ bool preserved = p->hasMetaData("preserve-slice") && !p->inheritsMetaData("preserve-slice");
+
+ _out << nl << "Slice.defineValue(" << localScope << "." << name << ", "
+ << "iceC_" << getLocalScope(scoped, "_") << "_ids[" << scopedPos << "], "
+ << (preserved ? "true" : "false") ;
+ if(p->compactId() >= 0)
{
- _out << ',';
+ _out << ", " << p->compactId();
}
- _out << nl << '"' << *q << '"';
+ _out << ");";
}
- _out.dec();
- _out << nl << "],";
- _out << nl << p->compactId() << ",";
- if(dataMembers.empty())
+ }
+
+ //
+ // Define servant an proxy types for non local classes
+ //
+ if(!p->isLocal())
+ {
+ _out << sp;
+ writeDocComment(p, getDeprecateReason(p, 0, "type"));
+ _out << nl << localScope << "._" << p->name() << "Disp" << " = class extends ";
+ if(hasBaseClass)
{
- _out << " undefined, undefined, ";
+ _out << getLocalScope(base->scope()) << "._" << base->name() << "Disp";
}
else
{
- _out << nl << "function(__os)";
- _out << sb;
- writeMarshalDataMembers(dataMembers, optionalMembers);
- _out << eb << ",";
- _out << nl << "function(__is)";
- _out << sb;
- writeUnmarshalDataMembers(dataMembers, optionalMembers);
- _out << eb << ",";
- _out << nl;
+ _out << "Ice.Object";
}
- _out << (p->hasMetaData("preserve-slice") && !p->inheritsMetaData("preserve-slice") ? "true" : "false");
- }
- _out.dec();
- _out << ");";
-
- if(!p->isLocal())
- {
- const string staticId = localScope + "." + name + ".ice_staticId";
- const string baseProxy =
- !p->isInterface() && base ? (getLocalScope(base->scope()) + "." + base->name() + "Prx") : "Ice.ObjectPrx";
+ _out << sb;
- _out << sp;
- _out << nl << localScope << '.' << prxName << " = " << "Slice.defineProxy(" << baseProxy << ", " << staticId;
if(!bases.empty())
{
- _out << ", [";
+ _out << sp;
+ _out << nl << "static get _iceImplements()";
+ _out << sb;
+ _out << nl << "return [";
_out.inc();
for(ClassList::const_iterator q = bases.begin(); q != bases.end();)
{
ClassDefPtr base = *q;
if(base->isInterface())
{
- _out << nl << getLocalScope(base->scope()) << "." << base->name() << "Prx";
+ _out << nl << getLocalScope(base->scope()) << "._" << base->name()<< "Disp" ;
if(++q != bases.end())
{
_out << ", ";
@@ -1371,28 +1116,67 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p)
}
}
_out.dec();
- _out << "]";
- }
- else
- {
- _out << ", undefined";
+ _out << nl << "];";
+ _out << eb;
}
- _out << ");";
-
+ _out << eb << ";";
+
//
- // Register the compact id
+ // Generate a proxy class for interfaces or classes with operations.
//
- if(p->compactId() >= 0)
+ string proxyType = "undefined";
+ if(p->isInterface() || p->allOperations().size() > 0)
{
- //
- // Also register the type using the stringified compact ID.
- //
- _out << nl << "Ice.CompactIdRegistry.set(" << p->compactId() << ", " << localScope << "."
- << name << ".ice_staticId());";
+ proxyType = localScope + '.' + prxName;
+ string baseProxy = "Ice.ObjectPrx";
+ if(!p->isInterface() && base && base->allOperations().size() > 0)
+ {
+ baseProxy = (getLocalScope(base->scope()) + "." + base->name() + "Prx");
+ }
+
+ _out << sp;
+ _out << nl << proxyType << " = class extends " << baseProxy;
+ _out << sb;
+
+
+ if(!bases.empty())
+ {
+ _out << sp;
+ _out << nl << "static get _implements()";
+ _out << sb;
+ _out << nl << "return [";
+
+ _out.inc();
+ for(ClassList::const_iterator q = bases.begin(); q != bases.end();)
+ {
+ ClassDefPtr base = *q;
+ if(base->isInterface())
+ {
+ _out << nl << getLocalScope(base->scope()) << "." << base->name() << "Prx";
+ if(++q != bases.end())
+ {
+ _out << ", ";
+ }
+ }
+ else
+ {
+ q++;
+ }
+ }
+ _out.dec();
+ _out << "];";
+ _out << eb;
+ }
+
+ _out << eb << ";";
}
- _out << sp << nl << "Slice.defineOperations(" << localScope << '.' << name << ", " << localScope << '.'
- << prxName;
+ _out << sp << nl << "Slice.defineOperations("
+ << localScope << "._" << p->name() << "Disp, "
+ << proxyType << ", "
+ << "iceC_" << getLocalScope(scoped, "_") << "_ids, "
+ << scopedPos;
+
const OperationList ops = p->operations();
if(!ops.empty())
{
@@ -1459,12 +1243,6 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p)
}
_out << ", ";
- if(p->hasMetaData("amd") || op->hasMetaData("amd"))
- {
- _out << "1"; // AMD.
- }
- _out << ", ";
-
if(op->format() != DefaultFormat)
{
_out << opFormatTypeToString(op); // Format.
@@ -1605,7 +1383,6 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p)
}
_out << ");";
}
-
return false;
}
@@ -1623,6 +1400,7 @@ Slice::Gen::TypesVisitor::visitSequence(const SequencePtr& p)
const string propertyName = name + "Helper";
const bool fixed = !type->isVariableLength();
+ _out << sp;
_out << nl << "Slice.defineSequence(" << scope << ", \"" << propertyName << "\", "
<< "\"" << getHelper(type) << "\"" << ", " << (fixed ? "true" : "false");
if(isClassType(type))
@@ -1640,7 +1418,6 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p)
const string name = fixId(p->name());
const ExceptionPtr base = p->base();
string baseRef;
- string defineException = p->isLocal() ? "Slice.defineLocalException" : "Slice.defineUserException";
if(base)
{
baseRef = getReference(scope, base->scoped());
@@ -1674,55 +1451,114 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p)
_out << sp;
writeDocComment(p, getDeprecateReason(p, 0, "type"));
- _out << nl << localScope << '.' << name << " = " << defineException << "(";
- _out.inc();
+ _out << nl << localScope << '.' << name << " = class extends " << baseRef;
+ _out << sb;
+
+ _out << nl << "constructor" << spar;
+
+ for(DataMemberList::const_iterator q = baseDataMembers.begin(); q != baseDataMembers.end(); ++q)
+ {
+ _out << fixId((*q)->name());
+ }
+
+ for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q)
+ {
+ string value;
+ if((*q)->optional())
+ {
+ if((*q)->defaultValueType())
+ {
+ value = writeConstantValue(scope, (*q)->type(), (*q)->defaultValueType(), (*q)->defaultValue());
+ }
+ else
+ {
+ value = "undefined";
+ }
+ }
+ else
+ {
+ if((*q)->defaultValueType())
+ {
+ value = writeConstantValue(scope, (*q)->type(), (*q)->defaultValueType(), (*q)->defaultValue());
+ }
+ else
+ {
+ value = getValue(scope, (*q)->type());
+ }
+ }
+ _out << (fixId((*q)->name()) + (value.empty() ? value : (" = " + value)));
+ }
- _out << nl << "function" << spar << allParamNames << "_cause" << epar;
+ _out << "_cause = \"\"" << epar;
_out << sb;
- _out << nl << baseRef << ".call" << spar << "this" << baseParamNames << "_cause" << epar << ';';
+ _out << nl << "super" << spar << baseParamNames << "_cause" << epar << ';';
writeInitDataMembers(dataMembers, scope);
- _out << eb << ",";
- _out << nl << baseRef << ",";
- _out << nl << "\"" << p->scoped().substr(2) << "\"";
+ _out << eb;
+
+ _out << sp;
+ _out << nl << "static get _parent()";
+ _out << sb;
+ _out << nl << "return " << baseRef << ";";
+ _out << eb;
+
+ _out << sp;
+ _out << nl << "static get _id()";
+ _out << sb;
+ _out << nl << "return \"" << p->scoped() << "\";";
+ _out << eb;
+
+ _out << sp;
+ _out << nl << "ice_name()";
+ _out << sb;
+ _out << nl << "return \"" << p->scoped().substr(2) << "\";";
+ _out << eb;
// TODO: equals?
if(!p->isLocal())
{
- _out << ",";
+ _out << sp;
+ _out << nl << "_mostDerivedType()";
+ _out << sb;
+ _out << nl << "return " << localScope << '.' << name << ";";
+ _out << eb;
+
if(!dataMembers.empty())
{
- _out << nl << "function(__os)";
+ _out << sp;
+ _out << nl << "_writeMemberImpl(ostr)";
_out << sb;
writeMarshalDataMembers(dataMembers, optionalMembers);
- _out << eb << ",";
- _out << nl << "function(__is)";
+ _out << eb;
+
+ _out << sp;
+ _out << nl << "_readMemberImpl(istr)";
_out << sb;
writeUnmarshalDataMembers(dataMembers, optionalMembers);
_out << eb;
}
- else
- {
- _out << nl << "undefined, undefined";
- }
- bool basePreserved = p->inheritsMetaData("preserve-slice");
- bool preserved = p->hasMetaData("preserve-slice");
- _out << ",";
- if(preserved && !basePreserved)
- {
- _out << nl << "true";
- }
- else
+ if(p->usesClasses(false) && (!base || (base && !base->usesClasses(false))))
{
- _out << nl << "false";
+ _out << sp;
+ _out << nl << "_usesClasses()";
+ _out << sb;
+ _out << nl << "return true;";
+ _out << eb;
}
+ }
+
+ _out << eb << ";";
+
+ bool basePreserved = p->inheritsMetaData("preserve-slice");
+ bool preserved = p->hasMetaData("preserve-slice");
- const bool usesClasses = p->usesClasses(false) && (!base || (base && !base->usesClasses(false)));
- _out << "," << nl << (usesClasses ? "true" : "false");
+ if(!p->isLocal() && preserved && !basePreserved)
+ {
+ _out << sp;
+ _out << nl << "Slice.PreservedUserException(" << localScope << '.' << name << ");";
}
- _out << ");";
- _out.dec();
+
return false;
}
@@ -1741,42 +1577,79 @@ Slice::Gen::TypesVisitor::visitStructStart(const StructPtr& p)
paramNames.push_back(fixId((*q)->name()));
}
- //
- // Only generate hashCode if this structure type is a legal dictionary key type.
- //
- bool containsSequence = false;
- bool legalKeyType = Dictionary::legalKeyType(p, containsSequence);
-
_out << sp;
writeDocComment(p, getDeprecateReason(p, 0, "type"));
- _out << nl << localScope << '.' << name << " = Slice.defineStruct(";
- _out.inc();
- _out << nl << "function" << spar << paramNames << epar;
+ _out << nl << localScope << '.' << name << " = class";
_out << sb;
- writeInitDataMembers(dataMembers, scope);
- _out << eb << ",";
- _out << nl << (legalKeyType ? "true" : "false");
+ _out << nl << "constructor" << spar;
+
+ for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q)
+ {
+ string value;
+ if((*q)->optional())
+ {
+ if((*q)->defaultValueType())
+ {
+ value = writeConstantValue(scope, (*q)->type(), (*q)->defaultValueType(), (*q)->defaultValue());
+ }
+ else
+ {
+ value = "undefined";
+ }
+ }
+ else
+ {
+ if((*q)->defaultValueType())
+ {
+ value = writeConstantValue(scope, (*q)->type(), (*q)->defaultValueType(), (*q)->defaultValue());
+ }
+ else
+ {
+ value = getValue(scope, (*q)->type());
+ }
+ }
+ _out << (fixId((*q)->name()) + (value.empty() ? value : (" = " + value)));
+ }
+
+ _out << epar;
+ _out << sb;
+ writeInitDataMembers(dataMembers, scope);
+ _out << eb;
if(!p->isLocal())
{
- _out << ",";
- _out << nl << "function(__os)";
+ _out << sp;
+ _out << nl << "_write(ostr)";
_out << sb;
writeMarshalDataMembers(dataMembers, DataMemberList());
- _out << eb << ",";
- _out << nl << "function(__is)";
+ _out << eb;
+
+ _out << sp;
+ _out << nl << "_read(istr)";
_out << sb;
writeUnmarshalDataMembers(dataMembers, DataMemberList());
- _out << eb << "," << nl << p->minWireSize() << ", " << nl << (p->isVariableLength() ? "false" : "true");
- _out.dec();
- _out << ");";
- }
- else
- {
- _out.dec();
- _out << ");";
+ _out << eb;
+
+ _out << sp;
+ _out << nl << "static get minWireSize()";
+ _out << sb;
+ _out << nl << "return " << p->minWireSize() << ";";
+ _out << eb;
}
+
+ _out << eb << ";";
+
+ //
+ // Only generate hashCode if this structure type is a legal dictionary key type.
+ //
+ bool containsSequence = false;
+ bool legalKeyType = Dictionary::legalKeyType(p, containsSequence);
+
+ _out << sp;
+ _out << nl << "Slice.defineStruct(" << localScope << '.' << name << ", "
+ << (legalKeyType ? "true" : "false") << ", "
+ << (p->isVariableLength() ? "true" : "false") << ");";
return false;
}
@@ -1797,9 +1670,6 @@ Slice::Gen::TypesVisitor::visitDictionary(const DictionaryPtr& p)
keyUseEquals = true;
}
- b = BuiltinPtr::dynamicCast(valueType);
- bool valueUseEquals = !b || (b->kind() == Builtin::KindLong);
-
//
// Stream helpers for dictionaries of objects are lazy initialized
// as the required object type might not be available until later.
@@ -1809,6 +1679,7 @@ Slice::Gen::TypesVisitor::visitDictionary(const DictionaryPtr& p)
const string propertyName = name + "Helper";
bool fixed = !keyType->isVariableLength() && !valueType->isVariableLength();
+ _out << sp;
_out << nl << "Slice.defineDictionary(" << scope << ", \"" << name << "\", \"" << propertyName << "\", "
<< "\"" << getHelper(keyType) << "\", "
<< "\"" << getHelper(valueType) << "\", "
@@ -1828,10 +1699,6 @@ Slice::Gen::TypesVisitor::visitDictionary(const DictionaryPtr& p)
{
_out << ", Ice.ArrayUtil.equals";
}
- else if(valueUseEquals)
- {
- _out << ", Ice.HashMap.compareEquals";
- }
_out << ");";
}
@@ -1848,7 +1715,7 @@ Slice::Gen::TypesVisitor::visitEnum(const EnumPtr& p)
_out.inc();
_out << nl;
- const EnumeratorList enumerators = p->getEnumerators();
+ const EnumeratorList enumerators = p->enumerators();
int i = 0;
for(EnumeratorList::const_iterator en = enumerators.begin(); en != enumerators.end(); ++en)
{
@@ -1884,7 +1751,7 @@ Slice::Gen::TypesVisitor::visitConst(const ConstPtr& p)
_out << nl << "Object.defineProperty(" << localScope << ", '" << name << "', {";
_out.inc();
_out << nl << "value: ";
- writeConstantValue(scope, p->type(), p->valueType(), p->value());
+ _out << writeConstantValue(scope, p->type(), p->valueType(), p->value());
_out.dec();
_out << nl << "});";
}
@@ -1896,17 +1763,18 @@ Slice::Gen::TypesVisitor::encodeTypeForOperation(const TypePtr& type)
static const char* builtinTable[] =
{
- "0", // byte
- "1", // bool
- "2", // short
- "3", // int
- "4", // long
- "5", // float
- "6", // double
- "7", // string
- "8", // Ice.Object
- "9", // Ice.ObjectPrx
- "??" // LocalObject
+ "0", // byte
+ "1", // bool
+ "2", // short
+ "3", // int
+ "4", // long
+ "5", // float
+ "6", // double
+ "7", // string
+ "8", // Ice.Object
+ "9", // Ice.ObjectPrx
+ "??", // LocalObject
+ "10", // Ice.Value
};
BuiltinPtr builtin = BuiltinPtr::dynamicCast(type);
@@ -1918,7 +1786,15 @@ Slice::Gen::TypesVisitor::encodeTypeForOperation(const TypePtr& type)
ProxyPtr proxy = ProxyPtr::dynamicCast(type);
if(proxy)
{
- return "\"" + fixId(proxy->_class()->scoped() + "Prx") + "\"";
+ ClassDefPtr def = proxy->_class()->definition();
+ if(def->isInterface() || def->allOperations().size() > 0)
+ {
+ return "\"" + fixId(proxy->_class()->scoped() + "Prx") + "\"";
+ }
+ else
+ {
+ return "Ice.ObjectPrx";
+ }
}
SequencePtr seq = SequencePtr::dynamicCast(type);
@@ -1936,7 +1812,7 @@ Slice::Gen::TypesVisitor::encodeTypeForOperation(const TypePtr& type)
EnumPtr e = EnumPtr::dynamicCast(type);
if(e)
{
- return fixId(e->scoped()) + ".__helper";
+ return fixId(e->scoped()) + "._helper";
}
StructPtr st = StructPtr::dynamicCast(type);
@@ -1948,15 +1824,23 @@ Slice::Gen::TypesVisitor::encodeTypeForOperation(const TypePtr& type)
ClassDeclPtr cl = ClassDeclPtr::dynamicCast(type);
if(cl)
{
- return "\"" + fixId(cl->scoped()) + "\"";
+ if(cl->isInterface())
+ {
+ return "\"Ice.Value\"";
+ }
+ else
+ {
+ return "\"" + fixId(cl->scoped()) + "\"";
+ }
}
return "???";
}
-Slice::Gen::ExportVisitor::ExportVisitor(IceUtilInternal::Output& out, bool icejs) :
+Slice::Gen::ExportVisitor::ExportVisitor(IceUtilInternal::Output& out, bool icejs, bool es6modules) :
JsVisitor(out),
- _icejs(icejs)
+ _icejs(icejs),
+ _es6modules(es6modules)
{
}
@@ -1968,18 +1852,29 @@ Slice::Gen::ExportVisitor::visitModuleStart(const ModulePtr& p)
{
const string localScope = getLocalScope(p->scope());
const string name = localScope.empty() ? fixId(p->name()) : localScope + "." + p->name();
- if(_icejs)
+ if(find(_exported.begin(), _exported.end(), name) == _exported.end())
{
- _out.zeroIndent();
- _out << nl << "/* slice2js browser-bundle-skip */";
- _out.restoreIndent();
- }
- _out << nl << "exports." << name << " = " << name << ";";
- if(_icejs)
- {
- _out.zeroIndent();
- _out << nl << "/* slice2js browser-bundle-skip-end */";
- _out.restoreIndent();
+ _exported.push_back(name);
+ if(_es6modules)
+ {
+ _out << nl << "export { " << name << " };";
+ }
+ else
+ {
+ if(_icejs)
+ {
+ _out.zeroIndent();
+ _out << nl << "/* slice2js browser-bundle-skip */";
+ _out.restoreIndent();
+ }
+ _out << nl << "exports." << name << " = " << name << ";";
+ if(_icejs)
+ {
+ _out.zeroIndent();
+ _out << nl << "/* slice2js browser-bundle-skip-end */";
+ _out.restoreIndent();
+ }
+ }
}
}
return false;
diff --git a/cpp/src/slice2js/Gen.h b/cpp/src/slice2js/Gen.h
index 224003cb03d..842bc2d24e6 100644
--- a/cpp/src/slice2js/Gen.h
+++ b/cpp/src/slice2js/Gen.h
@@ -24,22 +24,13 @@ public:
protected:
- void writeMarshalUnmarshalParams(const ParamDeclList&, const OperationPtr&, bool);
- void writePostUnmarshalParams(const ParamDeclList&, const OperationPtr&);
void writeMarshalDataMembers(const DataMemberList&, const DataMemberList&);
void writeUnmarshalDataMembers(const DataMemberList&, const DataMemberList&);
void writeInitDataMembers(const DataMemberList&, const std::string&);
- virtual std::vector<std::string> getParams(const OperationPtr&);
- virtual std::vector<std::string> getParamsAsync(const OperationPtr&, bool, bool = false);
- virtual std::vector<std::string> getParamsAsyncCB(const OperationPtr&, bool = false, bool = true);
- virtual std::vector<std::string> getArgs(const OperationPtr&);
- virtual std::vector<std::string> getArgsAsync(const OperationPtr&, bool = false);
- virtual std::vector<std::string> getArgsAsyncCB(const OperationPtr&, bool = false, bool = false);
-
std::string getValue(const std::string&, const TypePtr&);
- void writeConstantValue(const std::string&, const TypePtr&, const SyntaxTreeBasePtr&, const std::string&);
+ std::string writeConstantValue(const std::string&, const TypePtr&, const SyntaxTreeBasePtr&, const std::string&);
static StringList splitComment(const ContainedPtr&);
void writeDocComment(const ContainedPtr&, const std::string&, const std::string& = "");
@@ -59,6 +50,7 @@ public:
const std::vector<std::string>&,
const std::string&,
std::ostream&);
+
~Gen();
void generate(const UnitPtr&);
@@ -79,7 +71,7 @@ private:
{
public:
- RequireVisitor(::IceUtilInternal::Output&, std::vector<std::string>, bool);
+ RequireVisitor(::IceUtilInternal::Output&, std::vector<std::string>, bool, bool);
virtual bool visitClassDefStart(const ClassDefPtr&);
virtual bool visitStructStart(const StructPtr&);
@@ -94,6 +86,7 @@ private:
private:
bool _icejs;
+ bool _es6modules;
bool _seenClass;
bool _seenCompactId;
bool _seenOperation;
@@ -134,12 +127,14 @@ private:
{
public:
- ExportVisitor(::IceUtilInternal::Output&, bool);
+ ExportVisitor(::IceUtilInternal::Output&, bool, bool);
virtual bool visitModuleStart(const ModulePtr&);
private:
bool _icejs;
+ bool _es6modules;
+ std::vector<std::string> _exported;
};
};
diff --git a/cpp/src/slice2js/JsUtil.cpp b/cpp/src/slice2js/JsUtil.cpp
index 7194ba5bd4e..c96900cf4bf 100644
--- a/cpp/src/slice2js/JsUtil.cpp
+++ b/cpp/src/slice2js/JsUtil.cpp
@@ -28,16 +28,16 @@ using namespace IceUtil;
using namespace IceUtilInternal;
static string
-lookupKwd(const string& name, bool mangleCasts = false)
+lookupKwd(const string& name)
{
//
// Keyword list. *Must* be kept in alphabetical order.
//
static const string keywordList[] =
{
- "break", "case", "catch", "class", "const", "continue", "debugger", "default", "delete", "do", "else",
- "enum", "export", "extends", "false", "finally", "for", "function", "if", "implements", "import", "in",
- "instanceof", "interface", "let", "new", "null", "package", "private", "protected", "public", "return",
+ "await", "break", "case", "catch", "class", "const", "continue", "debugger", "default", "delete", "do",
+ "else", "enum", "export", "extends", "false", "finally", "for", "function", "if", "implements", "import",
+ "in", "instanceof", "interface", "let", "new", "null", "package", "private", "protected", "public", "return",
"static", "super", "switch", "this", "throw", "true", "try", "typeof", "var", "void", "while", "with",
"yield"
};
@@ -49,10 +49,7 @@ lookupKwd(const string& name, bool mangleCasts = false)
{
return "_" + name;
}
- if(mangleCasts && (name == "checkedCast" || name == "uncheckedCast"))
- {
- return "_" + name;
- }
+
return name;
}
@@ -102,18 +99,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)
{
@@ -128,7 +113,7 @@ Slice::JsGenerator::isClassType(const TypePtr& type)
// not scoped, but a JS keyword, return the "_"-prefixed name.
//
string
-Slice::JsGenerator::fixId(const string& name, bool mangleCasts)
+Slice::JsGenerator::fixId(const string& name)
{
if(name.empty())
{
@@ -136,7 +121,7 @@ Slice::JsGenerator::fixId(const string& name, bool mangleCasts)
}
if(name[0] != ':')
{
- return lookupKwd(name, mangleCasts);
+ return lookupKwd(name);
}
const StringList ids = splitScopedName(name);
@@ -155,118 +140,13 @@ Slice::JsGenerator::fixId(const string& name, bool mangleCasts)
}
string
-Slice::JsGenerator::fixId(const ContainedPtr& cont, bool mangleCasts)
+Slice::JsGenerator::fixId(const ContainedPtr& cont)
{
- return fixId(cont->name(), mangleCasts);
+ return fixId(cont->name());
}
string
-Slice::JsGenerator::getOptionalFormat(const TypePtr& type)
-{
- BuiltinPtr bp = BuiltinPtr::dynamicCast(type);
- if(bp)
- {
- switch(bp->kind())
- {
- case Builtin::KindByte:
- case Builtin::KindBool:
- {
- return "Ice.OptionalFormat.F1";
- }
- case Builtin::KindShort:
- {
- return "Ice.OptionalFormat.F2";
- }
- case Builtin::KindInt:
- case Builtin::KindFloat:
- {
- return "Ice.OptionalFormat.F4";
- }
- case Builtin::KindLong:
- case Builtin::KindDouble:
- {
- return "Ice.OptionalFormat.F8";
- }
- case Builtin::KindString:
- {
- return "Ice.OptionalFormat.VSize";
- }
- case Builtin::KindObject:
- {
- return "Ice.OptionalFormat.Class";
- }
- case Builtin::KindObjectProxy:
- {
- return "Ice.OptionalFormat.FSize";
- }
- case Builtin::KindLocalObject:
- {
- assert(false);
- break;
- }
- }
- }
-
- if(EnumPtr::dynamicCast(type))
- {
- return "Ice.OptionalFormat.Size";
- }
-
- SequencePtr seq = SequencePtr::dynamicCast(type);
- if(seq)
- {
- return seq->type()->isVariableLength() ? "Ice.OptionalFormat.FSize" : "Ice.OptionalFormat.VSize";
- }
-
- DictionaryPtr d = DictionaryPtr::dynamicCast(type);
- if(d)
- {
- return (d->keyType()->isVariableLength() || d->valueType()->isVariableLength()) ?
- "Ice.OptionalFormat.FSize" : "Ice.OptionalFormat.VSize";
- }
-
- StructPtr st = StructPtr::dynamicCast(type);
- if(st)
- {
- return st->isVariableLength() ? "Ice.OptionalFormat.FSize" : "Ice.OptionalFormat.VSize";
- }
-
- if(ProxyPtr::dynamicCast(type))
- {
- return "Ice.OptionalFormat.FSize";
- }
-
- ClassDeclPtr cl = ClassDeclPtr::dynamicCast(type);
- assert(cl);
- return "Ice.OptionalFormat.Class";
-}
-
-string
-Slice::JsGenerator::getStaticId(const TypePtr& type)
-{
- BuiltinPtr b = BuiltinPtr::dynamicCast(type);
- ClassDeclPtr cl = ClassDeclPtr::dynamicCast(type);
-
- assert((b && b->kind() == Builtin::KindObject) || cl);
-
- if(b)
- {
- return "Ice.ObjectImpl.ice_staticId()";
- }
- else if(cl->isInterface())
- {
- ContainedPtr cont = ContainedPtr::dynamicCast(cl->container());
- assert(cont);
- return fixId(cont->scoped()) + "." + cl->name() + "Disp_.ice_staticId()";
- }
- else
- {
- return fixId(cl->scoped()) + ".ice_staticId()";
- }
-}
-
-string
-Slice::JsGenerator::typeToString(const TypePtr& type, bool optional)
+Slice::JsGenerator::typeToString(const TypePtr& type)
{
if(!type)
{
@@ -283,9 +163,10 @@ Slice::JsGenerator::typeToString(const TypePtr& type, bool optional)
"Number", // float
"Number", // double
"String",
- "Ice.Object",
+ "Ice.Value",
"Ice.ObjectPrx",
- "Object"
+ "Object",
+ "Ice.Value"
};
BuiltinPtr builtin = BuiltinPtr::dynamicCast(type);
@@ -309,7 +190,9 @@ Slice::JsGenerator::typeToString(const TypePtr& type, bool optional)
DictionaryPtr d = DictionaryPtr::dynamicCast(type);
if(d)
{
- return "Ice.HashMap";
+ const TypePtr keyType = d->keyType();
+ BuiltinPtr b = BuiltinPtr::dynamicCast(keyType);
+ return ((b && b->kind() == Builtin::KindLong) || StructPtr::dynamicCast(keyType)) ? "Ice.HashMap" : "Map";
}
ContainedPtr contained = ContainedPtr::dynamicCast(type);
@@ -322,7 +205,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 +236,7 @@ Slice::JsGenerator::getLocalScope(const string& scope)
{
if(i != ids.begin())
{
- result << '.';
+ result << separator;
}
result << *i;
}
@@ -399,7 +282,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 +386,7 @@ Slice::JsGenerator::writeMarshalUnmarshalCode(Output &out,
return;
}
case Builtin::KindObject:
+ case Builtin::KindValue:
{
// Handle by isClassType below.
break;
@@ -531,11 +415,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 +441,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 +473,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 +493,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 +553,7 @@ Slice::JsGenerator::getHelper(const TypePtr& type)
return "Ice.StringHelper";
}
case Builtin::KindObject:
+ case Builtin::KindValue:
{
return "Ice.ObjectHelper";
}
@@ -687,13 +571,27 @@ 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))
+ if(StructPtr::dynamicCast(type))
{
return typeToString(type);
}
+
+ ProxyPtr prx = ProxyPtr::dynamicCast(type);
+ if(prx)
+ {
+ ClassDefPtr def = prx->_class()->definition();
+ if(def->isInterface() || def->allOperations().size() > 0)
+ {
+ return typeToString(type);
+ }
+ else
+ {
+ return "Ice.ObjectPrx";
+ }
+ }
if(SequencePtr::dynamicCast(type) || DictionaryPtr::dynamicCast(type))
{
diff --git a/cpp/src/slice2js/JsUtil.h b/cpp/src/slice2js/JsUtil.h
index b02c8952d41..2ffa4f8ebd6 100644
--- a/cpp/src/slice2js/JsUtil.h
+++ b/cpp/src/slice2js/JsUtil.h
@@ -25,13 +25,10 @@ public:
protected:
static bool isClassType(const TypePtr&);
- static std::string localProxyHelper(const TypePtr&);
- static std::string fixId(const std::string&, bool = false);
- static std::string fixId(const ContainedPtr&, bool = false);
- static std::string getOptionalFormat(const TypePtr&);
- static std::string getStaticId(const TypePtr&);
- static std::string typeToString(const TypePtr&, bool = false);
- static std::string getLocalScope(const std::string&);
+ static std::string fixId(const std::string&);
+ static std::string fixId(const ContainedPtr&);
+ static std::string typeToString(const TypePtr&);
+ static std::string getLocalScope(const std::string&, const std::string& separator = ".");
static std::string getReference(const std::string&, const std::string&);
static std::string getHelper(const TypePtr&);
diff --git a/cpp/src/slice2js/Main.cpp b/cpp/src/slice2js/Main.cpp
index fe5986e2f45..d135fbaec2c 100644
--- a/cpp/src/slice2js/Main.cpp
+++ b/cpp/src/slice2js/Main.cpp
@@ -11,6 +11,7 @@
#include <IceUtil/CtrlCHandler.h>
#include <IceUtil/Mutex.h>
#include <IceUtil/MutexPtrLock.h>
+#include <IceUtil/ConsoleUtil.h>
#include <Slice/Preprocessor.h>
#include <Slice/FileTracker.h>
#include <Slice/Util.h>
@@ -18,6 +19,7 @@
using namespace std;
using namespace Slice;
+using namespace IceUtilInternal;
namespace
{
@@ -56,8 +58,8 @@ interruptedCallback(int /*signal*/)
void
usage(const string& n)
{
- getErrorStream() << "Usage: " << n << " [options] slice-files...\n";
- getErrorStream() <<
+ consoleErr << "Usage: " << n << " [options] slice-files...\n";
+ consoleErr <<
"Options:\n"
"-h, --help Show this message.\n"
"-v, --version Display the Ice version.\n"
@@ -74,8 +76,10 @@ usage(const string& n)
"--depend-xml Generate dependencies in XML format.\n"
"--depend-file FILE Write dependencies to FILE instead of standard output.\n"
"-d, --debug Print debug messages.\n"
- "--ice Allow reserved Ice prefix in Slice identifiers.\n"
- "--underscore Allow underscores in Slice identifiers.\n"
+ "--ice Allow reserved Ice prefix in Slice identifiers\n"
+ " deprecated: use instead [[\"ice-prefix\"]] metadata.\n"
+ "--underscore Allow underscores in Slice identifiers\n"
+ " deprecated: use instead [[\"underscore\"]] metadata.\n"
;
}
@@ -109,7 +113,7 @@ compile(const vector<string>& argv)
}
catch(const IceUtilInternal::BadOptException& e)
{
- getErrorStream() << argv[0] << ": error: " << e.reason << endl;
+ consoleErr << argv[0] << ": error: " << e.reason << endl;
if(!validate)
{
usage(argv[0]);
@@ -125,7 +129,7 @@ compile(const vector<string>& argv)
if(opts.isSet("version"))
{
- getErrorStream() << ICE_STRING_VERSION << endl;
+ consoleErr << ICE_STRING_VERSION << endl;
return EXIT_SUCCESS;
}
@@ -170,7 +174,7 @@ compile(const vector<string>& argv)
if(args.empty())
{
- getErrorStream() << argv[0] << ": error: no input file" << endl;
+ consoleErr << argv[0] << ": error: no input file" << endl;
if(!validate)
{
usage(argv[0]);
@@ -180,7 +184,7 @@ compile(const vector<string>& argv)
if(depend && dependJSON)
{
- getErrorStream() << argv[0] << ": error: cannot specify both --depend and --depend-json" << endl;
+ consoleErr << argv[0] << ": error: cannot specify both --depend and --depend-json" << endl;
if(!validate)
{
usage(argv[0]);
@@ -190,7 +194,7 @@ compile(const vector<string>& argv)
if(depend && dependxml)
{
- getErrorStream() << argv[0] << ": error: cannot specify both --depend and --depend-xml" << endl;
+ consoleErr << argv[0] << ": error: cannot specify both --depend and --depend-xml" << endl;
if(!validate)
{
usage(argv[0]);
@@ -200,7 +204,7 @@ compile(const vector<string>& argv)
if(dependxml && dependJSON)
{
- getErrorStream() << argv[0] << ": error: cannot specify both --depend-xml and --depend-json" << endl;
+ consoleErr << argv[0] << ": error: cannot specify both --depend-xml and --depend-json" << endl;
if(!validate)
{
usage(argv[0]);
@@ -218,14 +222,14 @@ compile(const vector<string>& argv)
IceUtil::CtrlCHandler ctrlCHandler;
ctrlCHandler.setCallback(interruptedCallback);
- DependOutputUtil out(dependFile);
+ ostringstream os;
if(dependJSON)
{
- out.os() << "{" << endl;
+ os << "{" << endl;
}
else if(dependxml)
{
- out.os() << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<dependencies>" << endl;
+ os << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<dependencies>" << endl;
}
//
@@ -250,7 +254,6 @@ compile(const vector<string>& argv)
if(cppHandle == 0)
{
- out.cleanup();
return EXIT_FAILURE;
}
@@ -260,24 +263,21 @@ compile(const vector<string>& argv)
if(parseStatus == EXIT_FAILURE)
{
- out.cleanup();
return EXIT_FAILURE;
}
bool last = (++i == sources.end());
- if(!icecpp->printMakefileDependencies(out.os(),
+ if(!icecpp->printMakefileDependencies(os,
depend ? Preprocessor::JavaScript : (dependJSON ? Preprocessor::JavaScriptJSON : Preprocessor::SliceXML),
includePaths,
"-D__SLICE2JS__"))
{
- out.cleanup();
return EXIT_FAILURE;
}
if(!icecpp->close())
{
- out.cleanup();
return EXIT_FAILURE;
}
@@ -285,9 +285,9 @@ compile(const vector<string>& argv)
{
if(!last)
{
- out.os() << ",";
+ os << ",";
}
- out.os() << "\n";
+ os << "\n";
}
}
else
@@ -302,7 +302,7 @@ compile(const vector<string>& argv)
if(preprocess)
{
char buf[4096];
- while(fgets(buf, static_cast<int>(sizeof(buf)), cppHandle) != NULL)
+ while(fgets(buf, static_cast<int>(sizeof(buf)), cppHandle) != ICE_NULLPTR)
{
if(fputs(buf, stdout) == EOF)
{
@@ -351,7 +351,7 @@ compile(const vector<string>& argv)
//
FileTracker::instance()->cleanup();
p->destroy();
- getErrorStream() << argv[0] << ": error: " << ex.reason() << endl;
+ consoleErr << argv[0] << ": error: " << ex.reason() << endl;
return EXIT_FAILURE;
}
}
@@ -366,7 +366,6 @@ compile(const vector<string>& argv)
if(interrupted)
{
- out.cleanup();
FileTracker::instance()->cleanup();
return EXIT_FAILURE;
}
@@ -375,11 +374,16 @@ compile(const vector<string>& argv)
if(dependJSON)
{
- out.os() << "}" << endl;
+ os << "}\n";
}
else if(dependxml)
{
- out.os() << "</dependencies>\n";
+ os << "</dependencies>\n";
+ }
+
+ if(depend || dependJSON || dependxml)
+ {
+ writeDependencies(os.str(), dependFile);
}
return status;
@@ -398,22 +402,22 @@ int main(int argc, char* argv[])
}
catch(const std::exception& ex)
{
- getErrorStream() << args[0] << ": error:" << ex.what() << endl;
+ consoleErr << args[0] << ": error:" << ex.what() << endl;
return EXIT_FAILURE;
}
catch(const std::string& msg)
{
- getErrorStream() << args[0] << ": error:" << msg << endl;
+ consoleErr << args[0] << ": error:" << msg << endl;
return EXIT_FAILURE;
}
catch(const char* msg)
{
- getErrorStream() << args[0] << ": error:" << msg << endl;
+ consoleErr << args[0] << ": error:" << msg << endl;
return EXIT_FAILURE;
}
catch(...)
{
- getErrorStream() << args[0] << ": error:" << "unknown exception" << endl;
+ consoleErr << args[0] << ": error:" << "unknown exception" << endl;
return EXIT_FAILURE;
}
}
diff --git a/cpp/src/slice2js/Makefile b/cpp/src/slice2js/Makefile
deleted file mode 100644
index f6fdc22dc56..00000000000
--- a/cpp/src/slice2js/Makefile
+++ /dev/null
@@ -1,32 +0,0 @@
-# **********************************************************************
-#
-# Copyright (c) 2003-2017 ZeroC, Inc. All rights reserved.
-#
-# This copy of Ice is licensed to you under the terms described in the
-# ICE_LICENSE file included in this distribution.
-#
-# **********************************************************************
-
-top_srcdir = ../..
-
-NAME = $(bindir)/slice2js
-
-TARGETS = $(NAME)
-
-OBJS = Gen.o \
- JsUtil.o \
- Main.o
-
-RPATH_DIR = $(LOADER_PATH)/../$(libsubdir)
-
-include $(top_srcdir)/config/Make.rules
-
-CPPFLAGS := -I. -I.. $(CPPFLAGS)
-
-$(NAME): $(OBJS)
- rm -f $@
- $(CXX) $(LDFLAGS) $(LDEXEFLAGS) -o $@ $(OBJS) $(SLICE_LIBS) $(MCPP_RPATH_LINK)
-
-install:: all
- $(call installprogram,$(NAME),$(DESTDIR)$(install_bindir))
- $(call installdata,$(top_srcdir)/../man/man1/slice2js.1,$(DESTDIR)$(install_mandir))
diff --git a/cpp/src/slice2js/Makefile.mak b/cpp/src/slice2js/Makefile.mak
deleted file mode 100644
index 520753a07d2..00000000000
--- a/cpp/src/slice2js/Makefile.mak
+++ /dev/null
@@ -1,50 +0,0 @@
-# **********************************************************************
-#
-# Copyright (c) 2003-2017 ZeroC, Inc. All rights reserved.
-#
-# This copy of Ice is licensed to you under the terms described in the
-# ICE_LICENSE file included in this distribution.
-#
-# **********************************************************************
-
-top_srcdir = ..\..
-
-NAME = $(top_srcdir)\bin\slice2js.exe
-
-TARGETS = $(NAME)
-
-OBJS = .\Gen.obj \
- .\JsUtil.obj \
- .\Main.obj
-
-!include $(top_srcdir)/config/Make.rules.mak
-
-CPPFLAGS = -I. -I.. $(CPPFLAGS) -DWIN32_LEAN_AND_MEAN
-
-!if "$(GENERATE_PDB)" == "yes"
-PDBFLAGS = /pdb:$(NAME:.exe=.pdb)
-!endif
-
-RES_FILE = Slice2Js.res
-
-$(NAME): $(OBJS) Slice2Js.res
- $(LINK) $(LD_EXEFLAGS) $(PDBFLAGS) $(OBJS) $(SETARGV) $(PREOUT)$@ $(SLICE_LIBS) \
- $(BASELIBS) $(RES_FILE)
- @if exist $@.manifest echo ^ ^ ^ Embedding manifest using $(MT) && \
- $(MT) -nologo -manifest $@.manifest -outputresource:$@;#1 && del /q $@.manifest
- @if defined SIGN_CERTIFICATE echo ^ ^ ^ Signing $@ && \
- signtool sign /f "$(SIGN_CERTIFICATE)" /p $(SIGN_PASSWORD) /t $(SIGN_TIMESTAMPSERVER) $@
-
-clean::
- del /q $(NAME:.exe=.*)
- del /q Slice2Js.res
-
-install:: all
- copy $(NAME) "$(install_bindir)"
-
-!if "$(GENERATE_PDB)" == "yes"
-
-install:: all
- copy $(NAME:.exe=.pdb) "$(install_bindir)"
-
-!endif
diff --git a/cpp/src/slice2js/Slice2Js.rc b/cpp/src/slice2js/Slice2Js.rc
index dc1c9b05377..82a88bfd8dc 100644
--- a/cpp/src/slice2js/Slice2Js.rc
+++ b/cpp/src/slice2js/Slice2Js.rc
@@ -1,30 +1,29 @@
-#include "winver.h"
+#include<IceUtil/ResourceConfig.h>
+
+#define ICE_INTERNALNAME "slice2js\0"
+#define ICE_ORIGINALFILENAME "slice2js.exe\0"
VS_VERSION_INFO VERSIONINFO
- FILEVERSION 3,6,3,0
- PRODUCTVERSION 3,6,3,0
- FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
-#ifdef _DEBUG
- FILEFLAGS VS_FF_DEBUG
-#else
- FILEFLAGS 0x0L
-#endif
- FILEOS 0x4L
- FILETYPE VFT_APP
- FILESUBTYPE 0x0L
+FILEVERSION ICE_VERSION
+PRODUCTVERSION ICE_VERSION
+FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
+FILEOS VOS_NT_WINDOWS32
+FILETYPE VFT_APP
+FILESUBTYPE VFT2_UNKNOWN
+FILEFLAGS VER_DEBUG
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904e4"
BEGIN
- VALUE "CompanyName", "ZeroC, Inc.\0"
+ VALUE "CompanyName", ICE_COMPANY_NAME
VALUE "FileDescription", "Slice to JavaScript Translator\0"
- VALUE "FileVersion", "3.6.3\0"
- VALUE "InternalName", "slice2js\0"
- VALUE "LegalCopyright", "\251 2003-2016 ZeroC, Inc.\0"
- VALUE "OriginalFilename", "slice2js.exe\0"
- VALUE "ProductName", "Ice\0"
- VALUE "ProductVersion", "3.6.3\0"
+ VALUE "FileVersion", ICE_STRING_VERSION
+ VALUE "InternalName", ICE_INTERNALNAME
+ VALUE "LegalCopyright", ICE_COPYRIGHT
+ VALUE "OriginalFilename", ICE_ORIGINALFILENAME
+ VALUE "ProductName", ICE_PRODUCT_NAME
+ VALUE "ProductVersion", ICE_STRING_VERSION
END
END
BLOCK "VarFileInfo"
diff --git a/cpp/src/slice2js/msbuild/packages.config b/cpp/src/slice2js/msbuild/packages.config
new file mode 100644
index 00000000000..3843006e3cd
--- /dev/null
+++ b/cpp/src/slice2js/msbuild/packages.config
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+ <package id="mcpp.v120" version="2.7.2.12" targetFramework="native" />
+ <package id="mcpp.v140" version="2.7.2.12" targetFramework="native" />
+ <package id="mcpp.v141" version="2.7.2.12" targetFramework="native" />
+</packages> \ No newline at end of file
diff --git a/cpp/src/slice2js/msbuild/slice2js.vcxproj b/cpp/src/slice2js/msbuild/slice2js.vcxproj
new file mode 100644
index 00000000000..1cff710b759
--- /dev/null
+++ b/cpp/src/slice2js/msbuild/slice2js.vcxproj
@@ -0,0 +1,143 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{8DF85304-2A53-4C36-804F-5C6FA2F75ACF}</ProjectGuid>
+ <WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>$(DefaultPlatformToolset)</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <PlatformToolset>$(DefaultPlatformToolset)</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>$(DefaultPlatformToolset)</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <PlatformToolset>$(DefaultPlatformToolset)</PlatformToolset>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <Import Project="$(MSBuildThisFileDirectory)\..\..\..\msbuild\ice.cpp98.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="Shared">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <AdditionalIncludeDirectories>..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>ICE_STATIC_LIBS;ICE_BUILDING_SLICE_COMPILERS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>rpcrt4.lib;advapi32.lib;DbgHelp.lib;Shlwapi.lib</AdditionalDependencies>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <AdditionalIncludeDirectories>..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>ICE_STATIC_LIBS;ICE_BUILDING_SLICE_COMPILERS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>rpcrt4.lib;advapi32.lib;DbgHelp.lib;Shlwapi.lib</AdditionalDependencies>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <ClCompile>
+ <AdditionalIncludeDirectories>..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>ICE_STATIC_LIBS;ICE_BUILDING_SLICE_COMPILERS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>rpcrt4.lib;advapi32.lib;DbgHelp.lib;Shlwapi.lib</AdditionalDependencies>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <ClCompile>
+ <AdditionalIncludeDirectories>..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>ICE_STATIC_LIBS;ICE_BUILDING_SLICE_COMPILERS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>rpcrt4.lib;advapi32.lib;DbgHelp.lib;Shlwapi.lib</AdditionalDependencies>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="..\Gen.cpp" />
+ <ClCompile Include="..\JsUtil.cpp" />
+ <ClCompile Include="..\Main.cpp" />
+ </ItemGroup>
+ <ItemGroup>
+ <ResourceCompile Include="..\Slice2Js.rc" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="..\Gen.h" />
+ <ClInclude Include="..\JsUtil.h" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="packages.config" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\..\IceUtil\msbuild\iceutil\iceutil.vcxproj">
+ <Project>{4d1a5110-3176-44ba-8bbb-57bf56519b9f}</Project>
+ </ProjectReference>
+ <ProjectReference Include="..\..\Slice\msbuild\slice.vcxproj">
+ <Project>{57cd6ac2-0c9d-4648-9e9d-5df60c90f18a}</Project>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ <Import Project="..\..\..\msbuild\packages\mcpp.v120.2.7.2.12\build\native\mcpp.v120.targets" Condition="Exists('..\..\..\msbuild\packages\mcpp.v120.2.7.2.12\build\native\mcpp.v120.targets')" />
+ <Import Project="..\..\..\msbuild\packages\mcpp.v140.2.7.2.12\build\native\mcpp.v140.targets" Condition="Exists('..\..\..\msbuild\packages\mcpp.v140.2.7.2.12\build\native\mcpp.v140.targets')" />
+ <Import Project="..\..\..\msbuild\packages\mcpp.v141.2.7.2.12\build\native\mcpp.v141.targets" Condition="Exists('..\..\..\msbuild\packages\mcpp.v141.2.7.2.12\build\native\mcpp.v141.targets')" />
+ </ImportGroup>
+ <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
+ <PropertyGroup>
+ <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
+ </PropertyGroup>
+ <Error Condition="!Exists('..\..\..\msbuild\packages\mcpp.v120.2.7.2.12\build\native\mcpp.v120.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\msbuild\packages\mcpp.v120.2.7.2.12\build\native\mcpp.v120.targets'))" />
+ <Error Condition="!Exists('..\..\..\msbuild\packages\mcpp.v140.2.7.2.12\build\native\mcpp.v140.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\msbuild\packages\mcpp.v140.2.7.2.12\build\native\mcpp.v140.targets'))" />
+ <Error Condition="!Exists('..\..\..\msbuild\packages\mcpp.v141.2.7.2.12\build\native\mcpp.v141.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\msbuild\packages\mcpp.v141.2.7.2.12\build\native\mcpp.v141.targets'))" />
+ </Target>
+ <Import Project="$(MSBuildThisFileDirectory)..\..\..\..\config\ice.sign.targets" />
+</Project> \ No newline at end of file
diff --git a/cpp/src/slice2js/msbuild/slice2js.vcxproj.filters b/cpp/src/slice2js/msbuild/slice2js.vcxproj.filters
new file mode 100644
index 00000000000..20badfb10f7
--- /dev/null
+++ b/cpp/src/slice2js/msbuild/slice2js.vcxproj.filters
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{0C9C0450-4DFC-441E-A440-DD94642EE0AC}</UniqueIdentifier>
+ <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
+ </Filter>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{4ABE07FF-1ACC-4CD2-9DF6-873BD17C212E}</UniqueIdentifier>
+ <Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
+ </Filter>
+ <Filter Include="Resource Files">
+ <UniqueIdentifier>{380D5A23-E390-4B11-817F-8F4115971A2A}</UniqueIdentifier>
+ <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="..\Gen.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\Main.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\JsUtil.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <ResourceCompile Include="..\Slice2Js.rc">
+ <Filter>Resource Files</Filter>
+ </ResourceCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="..\Gen.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\JsUtil.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="packages.config" />
+ </ItemGroup>
+</Project> \ No newline at end of file