summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJose <jose@zeroc.com>2017-01-23 21:37:19 +0100
committerJose <jose@zeroc.com>2017-01-23 21:37:19 +0100
commitdc857ec709508da224559437eef19f396b9733e6 (patch)
tree3e0e42b216cc291fc9868062487bb2b13532ad8e
parentBuild shared executables with -fPIE/-pie on Linux (diff)
downloadice-dc857ec709508da224559437eef19f396b9733e6.tar.bz2
ice-dc857ec709508da224559437eef19f396b9733e6.tar.xz
ice-dc857ec709508da224559437eef19f396b9733e6.zip
Ice for Ruby Ice::Value implementation
-rw-r--r--cpp/src/Slice/RubyUtil.cpp485
-rw-r--r--cpp/src/slice2php/Main.cpp4
-rw-r--r--ruby/ruby/Ice.rb101
-rw-r--r--ruby/src/IceRuby/Proxy.cpp63
-rw-r--r--ruby/src/IceRuby/Types.cpp191
-rw-r--r--ruby/src/IceRuby/Types.h22
-rw-r--r--ruby/src/IceRuby/ValueFactoryManager.cpp2
-rw-r--r--ruby/test/Ice/objects/AllTests.rb26
-rw-r--r--ruby/test/Ice/operations/Twoways.rb2
-rw-r--r--ruby/test/Ice/optional/AllTests.rb24
-rw-r--r--ruby/test/Ice/slicing/exceptions/AllTests.rb2
-rw-r--r--ruby/test/Ice/slicing/objects/AllTests.rb2
-rw-r--r--slice/Ice/Connection.ice10
-rw-r--r--slice/Ice/Endpoint.ice12
14 files changed, 468 insertions, 478 deletions
diff --git a/cpp/src/Slice/RubyUtil.cpp b/cpp/src/Slice/RubyUtil.cpp
index afe0ce289d2..4d77524594b 100644
--- a/cpp/src/Slice/RubyUtil.cpp
+++ b/cpp/src/Slice/RubyUtil.cpp
@@ -68,12 +68,12 @@ public:
private:
//
- // Return a Python symbol for the given parser element.
+ // Return a Ruby symbol for the given parser element.
//
string getSymbol(const ContainedPtr&);
//
- // Emit Python code to assign the given symbol in the current module.
+ // Emit Ruby code to assign the given symbol in the current module.
//
void registerName(const string&);
@@ -234,225 +234,58 @@ Slice::Ruby::CodeVisitor::visitClassDecl(const ClassDeclPtr& p)
bool
Slice::Ruby::CodeVisitor::visitClassDefStart(const ClassDefPtr& p)
{
- string scoped = p->scoped();
- string name = fixIdent(p->name(), IdentToUpper);
- ClassList bases = p->bases();
- ClassDefPtr base;
- OperationList ops = p->operations();
-
//
- // Define a mix-in module for the class.
+ // Do not generate any code for ruby:internal types, those are provided by
+ // IceRuby C++ extension.
//
- _out << sp << nl << "if not defined?(" << getAbsolute(p, IdentToUpper) << "_mixin)";
- _out.inc();
- _out << nl << "module " << name << "_mixin";
- _out.inc();
-
- if(!p->isLocal())
+ StringList metadata = p->getMetaData();
+ if(find(metadata.begin(), metadata.end(), "ruby:internal") != metadata.end())
{
- if(!bases.empty() && !bases.front()->isInterface())
- {
- base = bases.front();
- _out << nl << "include " << getAbsolute(bases.front(), IdentToUpper) << "_mixin";
- }
- else
- {
- _out << nl << "include ::Ice::Object_mixin";
- }
-
- //
- // ice_ids
- //
- 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();
- _out << sp << nl << "def ice_ids(current=nil)";
- _out.inc();
- _out << nl << "[";
- for(StringList::iterator q = ids.begin(); q != ids.end(); ++q)
- {
- if(q != ids.begin())
- {
- _out << ", ";
- }
- _out << "'" << *q << "'";
- }
- _out << ']';
- _out.dec();
- _out << nl << "end";
-
- //
- // ice_id
- //
- _out << sp << nl << "def ice_id(current=nil)";
- _out.inc();
- _out << nl << "'" << scoped << "'";
- _out.dec();
- _out << nl << "end";
+ return false;
}
- if(!ops.empty())
- {
- //
- // Emit a comment for each operation.
- //
- _out << sp
- << nl << "#"
- << nl << "# Operation signatures."
- << nl << "#";
- for(OperationList::iterator oli = ops.begin(); oli != ops.end(); ++oli)
- {
- string fixedOpName = fixIdent((*oli)->name(), IdentNormal);
-/* If AMI/AMD is ever implemented...
- if(!p->isLocal() && (p->hasMetaData("amd") || (*oli)->hasMetaData("amd")))
- {
- _out << nl << "# def " << fixedOpName << "_async(_cb";
-
- ParamDeclList params = (*oli)->parameters();
-
- for(ParamDeclList::iterator pli = params.begin(); pli != params.end(); ++pli)
- {
- if(!(*pli)->isOutParam())
- {
- _out << ", " << fixIdent((*pli)->name(), IdentToLower);
- }
- }
- if(!p->isLocal())
- {
- _out << ", current=nil";
- }
- _out << ")";
- }
- else
-*/
- {
- _out << nl << "# def " << fixedOpName << "(";
+ bool isInterface = p->isInterface();
+ bool isLocal = p->isLocal();
+ bool isAbstract = isInterface || p->allOperations().size() > 0; // Don't use isAbstract() - see bug 3739
- ParamDeclList params = (*oli)->parameters();
-
- bool first = true;
- for(ParamDeclList::iterator pli = params.begin(); pli != params.end(); ++pli)
- {
- if(!(*pli)->isOutParam())
- {
- if(first)
- {
- first = false;
- }
- else
- {
- _out << ", ";
- }
- _out << fixIdent((*pli)->name(), IdentToLower);
- }
- }
- if(!p->isLocal())
- {
- if(!first)
- {
- _out << ", ";
- }
- _out << "current=nil";
- }
- _out << ")";
- }
- }
- }
//
- // inspect
+ // Do not generate any code for local interfaces.
//
- _out << sp << nl << "def inspect";
+ if(isLocal && isInterface)
+ {
+ return false;
+ }
+
+ _out << sp << nl << "if not defined?(" << getAbsolute(p, IdentToUpper) << (isInterface ? "Prx)" : ")");
_out.inc();
- _out << nl << "::Ice::__stringify(self, T_" << name << ")";
- _out.dec();
- _out << nl << "end";
+
+ string scoped = p->scoped();
+ string name = fixIdent(p->name(), IdentToUpper);
+ ClassList bases = p->bases();
+ ClassDefPtr base;
+ OperationList ops = p->operations();
- //
- // read/write accessors for data members.
- //
+ //bool isAbstract = isInterface || p->allOperations().size() > 0; // Don't use isAbstract() - see bug 3739
DataMemberList members = p->dataMembers();
- if(!members.empty())
- {
- bool prot = p->hasMetaData("protected");
- DataMemberList protectedMembers;
- _out << sp << nl << "attr_accessor ";
- for(DataMemberList::iterator q = members.begin(); q != members.end(); ++q)
- {
- if(q != members.begin())
- {
- _out << ", ";
- }
- _out << ":" << fixIdent((*q)->name(), IdentNormal);
- if(prot || (*q)->hasMetaData("protected"))
- {
- protectedMembers.push_back(*q);
- }
- }
-
- if(!protectedMembers.empty())
+ if(isLocal || !isInterface)
+ {
+ if(!bases.empty() && !bases.front()->isInterface())
{
- _out << nl << "protected ";
- for(DataMemberList::iterator q = protectedMembers.begin(); q != protectedMembers.end(); ++q)
- {
- if(q != protectedMembers.begin())
- {
- _out << ", ";
- }
- //
- // We need to list the symbols of the reader and the writer (e.g., ":member" and ":member=").
- //
- _out << ":" << fixIdent((*q)->name(), IdentNormal) << ", :"
- << fixIdent((*q)->name(), IdentNormal) << '=';
- }
+ base = bases.front();
}
- }
-
- _out.dec();
- _out << nl << "end"; // End of mix-in module for class.
- if(p->isInterface())
- {
- //
- // Class.
- //
- _out << nl << "class " << name;
- _out.inc();
- _out << nl << "include " << name << "_mixin";
- _out << nl;
- _out << nl << "def " << name << ".ice_staticId()";
- _out.inc();
- _out << nl << "'" << scoped << "'";
- _out.dec();
- _out << nl << "end";
- _out.dec();
- _out << nl << "end";
- }
- else
- {
- //
- // Class.
- //
_out << nl << "class " << name;
if(base)
{
_out << " < " << getAbsolute(base, IdentToUpper);
}
+ else if(!isLocal)
+ {
+ _out << " < ::Ice::Value";
+ }
_out.inc();
- _out << nl << "include " << name << "_mixin";
- _out << nl;
- _out << nl << "def " << name << ".ice_staticId()";
- _out.inc();
- _out << nl << "'" << scoped << "'";
- _out.dec();
- _out << nl << "end";
//
// initialize
@@ -500,6 +333,47 @@ Slice::Ruby::CodeVisitor::visitClassDefStart(const ClassDefPtr& p)
_out.dec();
_out << nl << "end";
}
+
+ //
+ // read/write accessors for data members.
+ //
+ DataMemberList members = p->dataMembers();
+ if(!members.empty())
+ {
+ bool prot = p->hasMetaData("protected");
+ DataMemberList protectedMembers;
+
+ _out << sp << nl << "attr_accessor ";
+ for(DataMemberList::iterator q = members.begin(); q != members.end(); ++q)
+ {
+ if(q != members.begin())
+ {
+ _out << ", ";
+ }
+ _out << ":" << fixIdent((*q)->name(), IdentNormal);
+ if(prot || (*q)->hasMetaData("protected"))
+ {
+ protectedMembers.push_back(*q);
+ }
+ }
+
+ if(!protectedMembers.empty())
+ {
+ _out << nl << "protected ";
+ for(DataMemberList::iterator q = protectedMembers.begin(); q != protectedMembers.end(); ++q)
+ {
+ if(q != protectedMembers.begin())
+ {
+ _out << ", ";
+ }
+ //
+ // We need to list the symbols of the reader and the writer (e.g., ":member" and ":member=").
+ //
+ _out << ":" << fixIdent((*q)->name(), IdentNormal) << ", :"
+ << fixIdent((*q)->name(), IdentNormal) << '=';
+ }
+ }
+ }
_out.dec();
_out << nl << "end"; // End of class.
@@ -509,13 +383,17 @@ Slice::Ruby::CodeVisitor::visitClassDefStart(const ClassDefPtr& p)
// Generate proxy support. This includes a mix-in module for the proxy's
// operations and a class for the proxy itself.
//
- if(!p->isLocal())
+ if(!p->isLocal() && isAbstract)
{
_out << nl << "module " << name << "Prx_mixin";
_out.inc();
for(ClassList::iterator cli = bases.begin(); cli != bases.end(); ++cli)
{
- _out << nl << "include " << getAbsolute(*cli, IdentToUpper) << "Prx_mixin";
+ ClassDefPtr def = *cli;
+ if(def->isInterface() || def->allOperations().size() > 0)
+ {
+ _out << nl << "include " << getAbsolute(*cli, IdentToUpper) << "Prx_mixin";
+ }
}
for(OperationList::iterator oli = ops.begin(); oli != ops.end(); ++oli)
{
@@ -548,7 +426,7 @@ Slice::Ruby::CodeVisitor::visitClassDefStart(const ClassDefPtr& p)
const string contextParamName = getEscapedParamName(*oli, "context");
_out << contextParamName << "=nil)";
_out.inc();
- _out << nl << name << "_mixin::OP_" << (*oli)->name() << ".invoke(self, [" << inParams;
+ _out << nl << name << "Prx_mixin::OP_" << (*oli)->name() << ".invoke(self, [" << inParams;
_out << "], " << contextParamName << ")";
_out.dec();
_out << nl << "end";
@@ -556,28 +434,10 @@ Slice::Ruby::CodeVisitor::visitClassDefStart(const ClassDefPtr& p)
_out.dec();
_out << nl << "end"; // End of mix-in module for proxy.
- _out << nl << "class " << name << "Prx < ::Ice::ObjectPrx";
+ _out << sp << nl << "class " << name << "Prx < ::Ice::ObjectPrx";
_out.inc();
+ _out << nl << "include ::Ice::Proxy_mixin";
_out << nl << "include " << name << "Prx_mixin";
-
- _out << sp << nl << "def " << name << "Prx.checkedCast(proxy, facetOrContext=nil, context=nil)";
- _out.inc();
- _out << nl << "ice_checkedCast(proxy, '" << scoped << "', facetOrContext, context)";
- _out.dec();
- _out << nl << "end";
-
- _out << sp << nl << "def " << name << "Prx.uncheckedCast(proxy, facet=nil)";
- _out.inc();
- _out << nl << "ice_uncheckedCast(proxy, facet)";
- _out.dec();
- _out << nl << "end";
-
- _out << nl << "def " << name << "Prx.ice_staticId()";
- _out.inc();
- _out << nl << "'" << scoped << "'";
- _out.dec();
- _out << nl << "end";
-
_out.dec();
_out << nl << "end"; // End of proxy class.
}
@@ -585,7 +445,12 @@ Slice::Ruby::CodeVisitor::visitClassDefStart(const ClassDefPtr& p)
//
// Emit type descriptions.
//
- _out << sp << nl << "if not defined?(" << getAbsolute(p, IdentToUpper, "T_") << ')';
+ _out << sp << nl << "if not defined?(" << getAbsolute(p, IdentToUpper, "T_");
+ if(isInterface)
+ {
+ _out << "Prx";
+ }
+ _out << ')';
_out.inc();
if(p->isLocal())
{
@@ -594,16 +459,23 @@ Slice::Ruby::CodeVisitor::visitClassDefStart(const ClassDefPtr& p)
else
{
_out << nl << "T_" << name << " = ::Ice::__declareClass('" << scoped << "')";
- _out << nl << "T_" << name << "Prx = ::Ice::__declareProxy('" << scoped << "')";
+ if(isAbstract)
+ {
+ _out << nl << "T_" << name << "Prx = ::Ice::__declareProxy('" << scoped << "')";
+ }
}
_out.dec();
_out << nl << "end";
_classHistory.insert(scoped); // Avoid redundant declarations.
- bool isAbstract = p->isInterface() || p->allOperations().size() > 0; // Don't use isAbstract() here - see bug 3739
const bool preserved = p->hasMetaData("preserve-slice") || p->inheritsMetaData("preserve-slice");
- _out << sp << nl << "T_" << name << ".defineClass(" << name << ", " << p->compactId() << ", "
- << (isAbstract ? "true" : "false") << ", " << (preserved ? "true" : "false") << ", ";
+
+
+ _out << sp << nl << "T_" << name << ".defineClass("
+ << (isInterface ? "::Ice::Value" : name) << ", "
+ << p->compactId() << ", "
+ << (preserved ? "true" : "false") << ", "
+ << (isInterface ? "true" : "false") << ", ";
if(!base)
{
_out << "nil";
@@ -612,25 +484,7 @@ Slice::Ruby::CodeVisitor::visitClassDefStart(const ClassDefPtr& p)
{
_out << getAbsolute(base, IdentToUpper, "T_");
}
- _out << ", [";
- //
- // Interfaces
- //
- {
- int interfaceCount = 0;
- for(ClassList::const_iterator q = bases.begin(); q != bases.end(); ++q)
- {
- if((*q)->isInterface())
- {
- if(interfaceCount > 0)
- {
- _out << ", ";
- }
- _out << getAbsolute(*q, IdentToUpper, "T_");
- ++interfaceCount;
- }
- }
- }
+ _out << ", ";
//
// Members
//
@@ -640,7 +494,7 @@ Slice::Ruby::CodeVisitor::visitClassDefStart(const ClassDefPtr& p)
//
// where MemberType is either a primitive type constant (T_INT, etc.) or the id of a constructed type.
//
- _out << "], [";
+ _out << "[";
if(members.size() > 1)
{
_out.inc();
@@ -665,7 +519,7 @@ Slice::Ruby::CodeVisitor::visitClassDefStart(const ClassDefPtr& p)
_out << nl;
}
_out << "])";
- _out << nl << name << "_mixin::ICE_TYPE = T_" << name;
+
//
// Define each operation. The arguments to __defineOperation are:
@@ -675,10 +529,39 @@ Slice::Ruby::CodeVisitor::visitClassDefStart(const ClassDefPtr& p)
// where InParams and OutParams are arrays of type descriptions, and Exceptions
// is an array of exception types.
//
- if(!p->isLocal())
+ if(!p->isLocal() && isAbstract)
{
- _out << sp << nl << "T_" << name << "Prx.defineProxy(" << name << "Prx, T_" << name << ')';
- _out << nl << name << "Prx::ICE_TYPE = T_" << name << "Prx";
+ _out << sp << nl << "T_" << name << "Prx.defineProxy(" << name << "Prx, ";
+
+ if(!base || (!base->isInterface() && base->allOperations().size() == 0))
+ {
+ _out << "nil";
+ }
+ else
+ {
+ _out << getAbsolute(base, IdentToUpper, "T_") << "Prx";
+ }
+
+ //
+ // Interfaces
+ //
+ _out << ", [";
+ {
+ int interfaceCount = 0;
+ for(ClassList::const_iterator q = bases.begin(); q != bases.end(); ++q)
+ {
+ if((*q)->isInterface())
+ {
+ if(interfaceCount > 0)
+ {
+ _out << ", ";
+ }
+ _out << getAbsolute(*q, IdentToUpper, "T_") << "Prx";
+ ++interfaceCount;
+ }
+ }
+ }
+ _out << "])";
if(!ops.empty())
{
@@ -703,7 +586,7 @@ Slice::Ruby::CodeVisitor::visitClassDefStart(const ClassDefPtr& p)
break;
}
- _out << nl << name << "_mixin::OP_" << (*s)->name() << " = ::Ice::__defineOperation('"
+ _out << nl << name << "Prx_mixin::OP_" << (*s)->name() << " = ::Ice::__defineOperation('"
<< (*s)->name() << "', ";
switch((*s)->mode())
{
@@ -802,11 +685,11 @@ Slice::Ruby::CodeVisitor::visitClassDefStart(const ClassDefPtr& p)
{
msg = deprecateMetadata.substr(pos + 1);
}
- _out << nl << name << "_mixin::OP_" << (*s)->name() << ".deprecate(\"" << msg << "\")";
+ _out << nl << name << "Prx_mixin::OP_" << (*s)->name() << ".deprecate(\"" << msg << "\")";
}
}
}
-
+
_out.dec();
_out << nl << "end"; // if not defined?()
@@ -816,6 +699,16 @@ Slice::Ruby::CodeVisitor::visitClassDefStart(const ClassDefPtr& p)
bool
Slice::Ruby::CodeVisitor::visitExceptionStart(const ExceptionPtr& p)
{
+ //
+ // Do not generate any code for ruby:internal types, those are provided by
+ // IceRuby C++ extension.
+ //
+ StringList metadata = p->getMetaData();
+ if(find(metadata.begin(), metadata.end(), "ruby:internal") != metadata.end())
+ {
+ return false;
+ }
+
string scoped = p->scoped();
string name = fixIdent(p->name(), IdentToUpper);
@@ -959,7 +852,6 @@ Slice::Ruby::CodeVisitor::visitExceptionStart(const ExceptionPtr& p)
_out << nl;
}
_out << "])";
- _out << nl << name << "::ICE_TYPE = T_" << name;
_out.dec();
_out << nl << "end"; // if not defined?()
@@ -970,6 +862,16 @@ Slice::Ruby::CodeVisitor::visitExceptionStart(const ExceptionPtr& p)
bool
Slice::Ruby::CodeVisitor::visitStructStart(const StructPtr& p)
{
+ //
+ // Do not generate any code for ruby:internal types, those are provided by
+ // IceRuby C++ extension.
+ //
+ StringList metadata = p->getMetaData();
+ if(find(metadata.begin(), metadata.end(), "ruby:internal") != metadata.end())
+ {
+ return false;
+ }
+
string scoped = p->scoped();
string name = fixIdent(p->name(), IdentToUpper);
MemberInfoList memberList;
@@ -990,6 +892,7 @@ Slice::Ruby::CodeVisitor::visitStructStart(const StructPtr& p)
_out.inc();
_out << nl << "class " << name;
_out.inc();
+ _out << nl << "include ::Ice::Inspect_mixin";
if(!memberList.empty())
{
_out << nl << "def initialize(";
@@ -1051,15 +954,6 @@ Slice::Ruby::CodeVisitor::visitStructStart(const StructPtr& p)
_out << nl << "end";
//
- // inspect
- //
- _out << sp << nl << "def inspect";
- _out.inc();
- _out << nl << "::Ice::__stringify(self, T_" << name << ")";
- _out.dec();
- _out << nl << "end";
-
- //
// read/write accessors for data members.
//
if(!memberList.empty())
@@ -1121,6 +1015,16 @@ void
Slice::Ruby::CodeVisitor::visitSequence(const SequencePtr& p)
{
//
+ // Do not generate any code for ruby:internal types, those are provided by
+ // IceRuby C++ extension.
+ //
+ StringList metadata = p->getMetaData();
+ if(find(metadata.begin(), metadata.end(), "ruby:internal") != metadata.end())
+ {
+ return;
+ }
+
+ //
// Emit the type information.
//
string name = fixIdent(p->name(), IdentToUpper);
@@ -1138,6 +1042,16 @@ void
Slice::Ruby::CodeVisitor::visitDictionary(const DictionaryPtr& p)
{
//
+ // Do not generate any code for ruby:internal types, those are provided by
+ // IceRuby C++ extension.
+ //
+ StringList metadata = p->getMetaData();
+ if(find(metadata.begin(), metadata.end(), "ruby:internal") != metadata.end())
+ {
+ return;
+ }
+
+ //
// Emit the type information.
//
string name = fixIdent(p->name(), IdentToUpper);
@@ -1156,6 +1070,16 @@ Slice::Ruby::CodeVisitor::visitDictionary(const DictionaryPtr& p)
void
Slice::Ruby::CodeVisitor::visitEnum(const EnumPtr& p)
{
+ //
+ // Do not generate any code for ruby:internal types, those are provided by
+ // IceRuby C++ extension.
+ //
+ StringList metadata = p->getMetaData();
+ if(find(metadata.begin(), metadata.end(), "ruby:internal") != metadata.end())
+ {
+ return;
+ }
+
string scoped = p->scoped();
string name = fixIdent(p->name(), IdentToUpper);
EnumeratorList enums = p->getEnumerators();
@@ -1223,15 +1147,6 @@ Slice::Ruby::CodeVisitor::visitEnum(const EnumPtr& p)
_out << nl << "end";
//
- // inspect
- //
- _out << sp << nl << "def inspect";
- _out.inc();
- _out << nl << "@name + \"(#{@value})\"";
- _out.dec();
- _out << nl << "end";
-
- //
// each
//
_out << sp << nl << "def " << name << ".each(&block)";
@@ -1288,6 +1203,16 @@ Slice::Ruby::CodeVisitor::visitEnum(const EnumPtr& p)
void
Slice::Ruby::CodeVisitor::visitConst(const ConstPtr& p)
{
+ //
+ // Do not generate any code for ruby:internal types, those are provided by
+ // IceRuby C++ extension.
+ //
+ StringList metadata = p->getMetaData();
+ if(find(metadata.begin(), metadata.end(), "ruby:internal") != metadata.end())
+ {
+ return;
+ }
+
Slice::TypePtr type = p->type();
string name = fixIdent(p->name(), IdentToUpper);
@@ -1346,7 +1271,7 @@ Slice::Ruby::CodeVisitor::writeType(const TypePtr& p)
case Builtin::KindValue:
case Builtin::KindObject:
{
- _out << "::Ice::T_Object";
+ _out << "::Ice::T_Value";
break;
}
case Builtin::KindObjectProxy:
@@ -1362,11 +1287,19 @@ Slice::Ruby::CodeVisitor::writeType(const TypePtr& p)
}
return;
}
-
+
ProxyPtr prx = ProxyPtr::dynamicCast(p);
if(prx)
{
- _out << getAbsolute(prx->_class(), IdentToUpper, "T_") << "Prx";
+ ClassDefPtr def = prx->_class()->definition();
+ if(def->isInterface() || def->allOperations().size() > 0)
+ {
+ _out << getAbsolute(prx->_class(), IdentToUpper, "T_") << "Prx";
+ }
+ else
+ {
+ _out << "::Ice::T_ObjectPrx";
+ }
return;
}
diff --git a/cpp/src/slice2php/Main.cpp b/cpp/src/slice2php/Main.cpp
index 385ba28dfbe..c8c3ea264fc 100644
--- a/cpp/src/slice2php/Main.cpp
+++ b/cpp/src/slice2php/Main.cpp
@@ -264,10 +264,6 @@ CodeVisitor::visitClassDefStart(const ClassDefPtr& p)
else
{
_out << nl;
- if(isAbstract)
- {
- _out << "abstract ";
- }
_out << "class " << name;
if(!bases.empty() && !bases.front()->isInterface())
{
diff --git a/ruby/ruby/Ice.rb b/ruby/ruby/Ice.rb
index 41d14b2ad7d..fcc46264ea9 100644
--- a/ruby/ruby/Ice.rb
+++ b/ruby/ruby/Ice.rb
@@ -63,7 +63,7 @@ module Ice
def ice_name
to_s[2..-1]
end
-
+
def ice_id
to_s
end
@@ -80,53 +80,89 @@ module Ice
end
#
- # Object.
+ # Ice::Object
#
- T_Object = Ice.__declareClass('::Ice::Object')
+ T_Value = Ice.__declareClass('::Ice::Object')
T_ObjectPrx = Ice.__declareProxy('::Ice::Object')
-
- module Object_mixin
- def ice_isA(id, current=nil)
- return ice_ids().include?(id)
+
+ #
+ # Provide some common functionality for structs
+ #
+ module Inspect_mixin
+ def inspect
+ ::Ice::__stringify(self, self.class::ICE_TYPE)
end
+ end
+
+ #
+ # Provide some common functionality for proxy classes
+ #
+ module Proxy_mixin
+ module ClassMethods
+ def inspect
+ ::Ice::__stringify(self, self.class::ICE_TYPE)
+ end
- def ice_ping(current=nil)
+ def ice_staticId()
+ self::ICE_ID
+ end
+
+ def checkedCast(proxy, facetOrContext=nil, context=nil)
+ ice_checkedCast(proxy, self::ICE_ID, facetOrContext, context)
+ end
+
+ def uncheckedCast(proxy, facet=nil)
+ ice_uncheckedCast(proxy, facet)
+ end
end
- attr_accessor :_ice_slicedData # Only used for instances of preserved classes.
+ def self.included(base)
+ base.extend(ClassMethods)
+ end
end
- class Object
- include Object_mixin
+ #
+ # Base class for Value types
+ #
+ class Value
+ def inspect
+ ::Ice::__stringify(self, self.class::ICE_TYPE)
+ end
- def Object.ice_staticId()
- '::Ice::Object'
+ def ice_id()
+ self.class::ICE_ID
end
- end
- T_Object.defineClass(nil, -1, true, false, nil, [], [])
- Object_mixin::ICE_TYPE = T_Object
+ def Value.ice_staticId()
+ self::ICE_ID
+ end
- T_ObjectPrx.defineProxy(ObjectPrx, T_Object)
- ObjectPrx::ICE_TYPE = T_ObjectPrx
+ attr_accessor :_ice_slicedData # Only used for instances of preserved classes.
+ end
- #
- # LocalObject.
- #
- T_LocalObject = Ice.__declareLocalClass('::Ice::LocalObject')
- T_LocalObject.defineClass(nil, -1, true, false, nil, [], [])
+ T_Value.defineClass(Value, -1, false, false, nil, [])
+
+ T_ObjectPrx.defineProxy(ObjectPrx, nil, [])
+
+
+ class InterfaceByValue < Value
+ def initialize(id)
+ @id = id
+ end
+
+ def ice_id
+ @id
+ end
+ end
#
- # UnknownSlicedObject.
+ # UnknownSlicedValue.
#
- class UnknownSlicedObject
- include ::Ice::Object_mixin
-
+ class UnknownSlicedValue < Value
attr_accessor :unknownTypeId
end
- T_UnknownSlicedObject = Ice.__declareClass('::Ice::UnknownSlicedObject')
- T_UnknownSlicedObject.defineClass(UnknownSlicedObject, -1, false, true, nil, [], [])
- UnknownSlicedObject::ICE_TYPE = T_UnknownSlicedObject
+ T_UnknownSlicedValue = Ice.__declareClass('::Ice::UnknownSlicedValue')
+ T_UnknownSlicedValue.defineClass(UnknownSlicedValue, -1, true, false, T_Value, [])
#
# InitializationData.
@@ -659,8 +695,3 @@ module Ice
Encoding_1_0 = EncodingVersion.new(1, 0)
Encoding_1_1 = EncodingVersion.new(1, 1)
end
-
-Ice::Object_mixin::OP_ice_isA = ::Ice::__defineOperation('ice_isA', ::Ice::OperationMode::Idempotent, ::Ice::OperationMode::Nonmutating, false, nil, [[::Ice::T_string, false, 0]], [], [::Ice::T_bool, false, 0], [])
-Ice::Object_mixin::OP_ice_ping = ::Ice::__defineOperation('ice_ping', ::Ice::OperationMode::Idempotent, ::Ice::OperationMode::Nonmutating, false, nil, [], [], nil, [])
-Ice::Object_mixin::OP_ice_ids = ::Ice::__defineOperation('ice_ids', ::Ice::OperationMode::Idempotent, ::Ice::OperationMode::Nonmutating, false, nil, [], [], [::Ice::T_StringSeq, false, 0], [])
-Ice::Object_mixin::OP_ice_id = ::Ice::__defineOperation('ice_id', ::Ice::OperationMode::Idempotent, ::Ice::OperationMode::Nonmutating, false, nil, [], [], [::Ice::T_string, false, 0], [])
diff --git a/ruby/src/IceRuby/Proxy.cpp b/ruby/src/IceRuby/Proxy.cpp
index fee9df5c85d..2f59a6a9ee9 100644
--- a/ruby/src/IceRuby/Proxy.cpp
+++ b/ruby/src/IceRuby/Proxy.cpp
@@ -49,9 +49,9 @@ IceRuby_ObjectPrx_free(Ice::ObjectPrx* p)
}
//
-// Returns true if a context was provided.
+// If a context was provided set it to ::Ice::noExplicitContext.
//
-static bool
+static void
checkArgs(const char* name, int numArgs, int argc, VALUE* argv, Ice::Context& ctx)
{
if(argc < numArgs || argc > numArgs + 1)
@@ -65,9 +65,11 @@ checkArgs(const char* name, int numArgs, int argc, VALUE* argv, Ice::Context& ct
{
throw RubyException(rb_eArgError, "%s: invalid context hash", name);
}
- return true;
}
- return false;
+ else
+ {
+ ctx = ::Ice::noExplicitContext;
+ }
}
extern "C"
@@ -120,20 +122,10 @@ IceRuby_ObjectPrx_ice_isA(int argc, VALUE* argv, VALUE self)
Ice::ObjectPrx p = getProxy(self);
Ice::Context ctx;
- bool haveContext = checkArgs("ice_isA", 1, argc, argv, ctx);
-
+ checkArgs("ice_isA", 1, argc, argv, ctx);
string id = getString(argv[0]);
- bool result;
- if(haveContext)
- {
- result = p->ice_isA(id, ctx);
- }
- else
- {
- result = p->ice_isA(id);
- }
- return result ? Qtrue : Qfalse;
+ return p->ice_isA(id, ctx) ? Qtrue : Qfalse;
}
ICE_RUBY_CATCH
return Qnil;
@@ -148,16 +140,8 @@ IceRuby_ObjectPrx_ice_ping(int argc, VALUE* argv, VALUE self)
Ice::ObjectPrx p = getProxy(self);
Ice::Context ctx;
- bool haveContext = checkArgs("ice_ping", 0, argc, argv, ctx);
-
- if(haveContext)
- {
- p->ice_ping(ctx);
- }
- else
- {
- p->ice_ping();
- }
+ checkArgs("ice_ping", 0, argc, argv, ctx);
+ p->ice_ping(ctx);
}
ICE_RUBY_CATCH
return Qnil;
@@ -172,18 +156,9 @@ IceRuby_ObjectPrx_ice_ids(int argc, VALUE* argv, VALUE self)
Ice::ObjectPrx p = getProxy(self);
Ice::Context ctx;
- bool haveContext = checkArgs("ice_ids", 0, argc, argv, ctx);
-
- vector<string> ids;
- if(haveContext)
- {
- ids = p->ice_ids(ctx);
- }
- else
- {
- ids = p->ice_ids();
- }
+ checkArgs("ice_ids", 0, argc, argv, ctx);
+ vector<string> ids = p->ice_ids(ctx);
volatile VALUE result = createArray(ids.size());
long i = 0;
for(vector<string>::iterator q = ids.begin(); q != ids.end(); ++q, ++i)
@@ -206,18 +181,8 @@ IceRuby_ObjectPrx_ice_id(int argc, VALUE* argv, VALUE self)
Ice::ObjectPrx p = getProxy(self);
Ice::Context ctx;
- bool haveContext = checkArgs("ice_id", 0, argc, argv, ctx);
-
- string id;
- if(haveContext)
- {
- id = p->ice_id(ctx);
- }
- else
- {
- id = p->ice_id();
- }
-
+ checkArgs("ice_id", 0, argc, argv, ctx);
+ string id = p->ice_id(ctx);
return createString(id);
}
ICE_RUBY_CATCH
diff --git a/ruby/src/IceRuby/Types.cpp b/ruby/src/IceRuby/Types.cpp
index 3561d1f3952..43326e728b6 100644
--- a/ruby/src/IceRuby/Types.cpp
+++ b/ruby/src/IceRuby/Types.cpp
@@ -373,7 +373,7 @@ IceRuby::StreamUtil::getSlicedDataMember(VALUE obj, ObjectMap* objectMap)
ObjectMap::iterator i = objectMap->find(o);
if(i == objectMap->end())
{
- writer = new ObjectWriter(o, objectMap);
+ writer = new ObjectWriter(o, objectMap, 0);
objectMap->insert(ObjectMap::value_type(o, writer));
}
else
@@ -1944,7 +1944,7 @@ IceRuby::DictionaryInfo::destroy()
// ClassInfo implementation.
//
IceRuby::ClassInfo::ClassInfo(VALUE ident, bool loc) :
- compactId(-1), isBase(false), isLocal(loc), isAbstract(false), preserve(false), rubyClass(Qnil), typeObj(Qnil),
+ compactId(-1), isBase(false), isLocal(loc), preserve(false), interface(false), rubyClass(Qnil), typeObj(Qnil),
defined(false)
{
const_cast<string&>(id) = getString(ident);
@@ -1960,7 +1960,7 @@ IceRuby::ClassInfo::ClassInfo(VALUE ident, bool loc) :
}
void
-IceRuby::ClassInfo::define(VALUE t, VALUE compact, VALUE abstr, VALUE pres, VALUE b, VALUE i, VALUE m)
+IceRuby::ClassInfo::define(VALUE t, VALUE compact, VALUE pres, VALUE intf, VALUE b, VALUE m)
{
if(!NIL_P(b))
{
@@ -1969,23 +1969,9 @@ IceRuby::ClassInfo::define(VALUE t, VALUE compact, VALUE abstr, VALUE pres, VALU
}
const_cast<Ice::Int&>(compactId) = static_cast<Ice::Int>(getInteger(compact));
- const_cast<bool&>(isAbstract) = RTEST(abstr);
const_cast<bool&>(preserve) = RTEST(pres);
-
- long n;
- volatile VALUE arr;
-
- arr = callRuby(rb_check_array_type, i);
- assert(!NIL_P(arr));
- for(n = 0; n < RARRAY_LEN(arr); ++n)
- {
- ClassInfoPtr iface = ClassInfoPtr::dynamicCast(getType(RARRAY_AREF(arr, n)));
- assert(iface);
- const_cast<ClassInfoList&>(interfaces).push_back(iface);
- }
-
+ const_cast<bool&>(interface) = RTEST(intf);
convertDataMembers(m, const_cast<DataMemberList&>(members), const_cast<DataMemberList&>(optionalMembers), true);
-
const_cast<VALUE&>(rubyClass) = t;
const_cast<bool&>(defined) = true;
}
@@ -2034,7 +2020,7 @@ IceRuby::ClassInfo::validate(VALUE val)
assert(!NIL_P(type));
ClassInfoPtr info = ClassInfoPtr::dynamicCast(getType(type));
assert(info);
- return info->isA(this);
+ return this->interface || info->isA(this);
}
bool
@@ -2087,7 +2073,7 @@ IceRuby::ClassInfo::marshal(VALUE p, Ice::OutputStream* os, ObjectMap* objectMap
ObjectMap::iterator q = objectMap->find(p);
if(q == objectMap->end())
{
- writer = new ObjectWriter(p, objectMap);
+ writer = new ObjectWriter(p, objectMap, this);
objectMap->insert(ObjectMap::value_type(p, writer));
}
else
@@ -2204,7 +2190,6 @@ void
IceRuby::ClassInfo::destroy()
{
const_cast<ClassInfoPtr&>(base) = 0;
- const_cast<ClassInfoList&>(interfaces).clear();
if(!members.empty())
{
DataMemberList ml = members;
@@ -2278,40 +2263,40 @@ IceRuby::ClassInfo::isA(const ClassInfoPtr& info)
{
return true;
}
- else if(base && base->isA(info))
- {
- return true;
- }
- else if(!interfaces.empty())
- {
- for(ClassInfoList::const_iterator p = interfaces.begin(); p != interfaces.end(); ++p)
- {
- if((*p)->isA(info))
- {
- return true;
- }
- }
- }
-
- return false;
+
+ return base && base->isA(info);
}
//
// ProxyInfo implementation.
//
IceRuby::ProxyInfo::ProxyInfo(VALUE ident) :
- rubyClass(Qnil), typeObj(Qnil)
+ isBase(false), rubyClass(Qnil), typeObj(Qnil)
{
const_cast<string&>(id) = getString(ident);
+ const_cast<bool&>(isBase) = id == "::Ice::Object";
const_cast<VALUE&>(typeObj) = createType(this);
}
void
-IceRuby::ProxyInfo::define(VALUE t, VALUE i)
+IceRuby::ProxyInfo::define(VALUE t, VALUE b, VALUE i)
{
+ if(!NIL_P(b))
+ {
+ const_cast<ProxyInfoPtr&>(base) = ProxyInfoPtr::dynamicCast(getType(b));
+ assert(base);
+ }
+
+ volatile VALUE arr = callRuby(rb_check_array_type, i);
+ assert(!NIL_P(arr));
+ for(int n = 0; n < RARRAY_LEN(arr); ++n)
+ {
+ ProxyInfoPtr iface = ProxyInfoPtr::dynamicCast(getType(RARRAY_AREF(arr, n)));
+ assert(iface);
+ const_cast<ProxyInfoList&>(interfaces).push_back(iface);
+ }
+
const_cast<VALUE&>(rubyClass) = t;
- const_cast<ClassInfoPtr&>(classInfo) = ClassInfoPtr::dynamicCast(getType(i));
- assert(classInfo);
}
string
@@ -2334,7 +2319,7 @@ IceRuby::ProxyInfo::validate(VALUE val)
assert(!NIL_P(type));
ProxyInfoPtr info = ProxyInfoPtr::dynamicCast(getType(type));
assert(info);
- return info->classInfo->isA(classInfo);
+ return info->isA(this);
}
return true;
}
@@ -2428,28 +2413,63 @@ IceRuby::ProxyInfo::print(VALUE value, IceUtilInternal::Output& out, PrintObject
}
}
+bool
+IceRuby::ProxyInfo::isA(const ProxyInfoPtr& info)
+{
+ //
+ // Return true if this class has an is-a relationship with info.
+ //
+ if(info->isBase)
+ {
+ return true;
+ }
+ else if(this == info.get())
+ {
+ return true;
+ }
+ else if(base && base->isA(info))
+ {
+ return true;
+ }
+ else if(!interfaces.empty())
+ {
+ for(ProxyInfoList::const_iterator p = interfaces.begin(); p != interfaces.end(); ++p)
+ {
+ if((*p)->isA(info))
+ {
+ return true;
+ }
+ }
+ }
+
+ return false;
+}
+
void
IceRuby::ProxyInfo::destroy()
{
- const_cast<ClassInfoPtr&>(classInfo) = 0;
+ const_cast<ProxyInfoPtr&>(base) = 0;
+ const_cast<ProxyInfoList&>(interfaces).clear();
}
//
// ObjectWriter implementation.
//
-IceRuby::ObjectWriter::ObjectWriter(VALUE object, ObjectMap* objectMap) :
- _object(object), _map(objectMap)
+IceRuby::ObjectWriter::ObjectWriter(VALUE object, ObjectMap* objectMap, const ClassInfoPtr& formal) :
+ _object(object), _map(objectMap), _formal(formal)
{
//
// Mark the object as in use for the lifetime of this wrapper.
//
rb_gc_register_address(&_object);
-
- volatile VALUE cls = CLASS_OF(object);
- volatile VALUE type = callRuby(rb_const_get, cls, rb_intern("ICE_TYPE"));
- assert(!NIL_P(type));
- _info = ClassInfoPtr::dynamicCast(getType(type));
- assert(_info);
+ if(!_formal || !_formal->interface)
+ {
+ volatile VALUE cls = CLASS_OF(object);
+ volatile VALUE type = callRuby(rb_const_get, cls, rb_intern("ICE_TYPE"));
+ assert(!NIL_P(type));
+ _info = ClassInfoPtr::dynamicCast(getType(type));
+ assert(_info);
+ }
}
IceRuby::ObjectWriter::~ObjectWriter()
@@ -2472,7 +2492,7 @@ IceRuby::ObjectWriter::_iceWrite(Ice::OutputStream* os) const
{
Ice::SlicedDataPtr slicedData;
- if(_info->preserve)
+ if(_info && _info->preserve)
{
//
// Retrieve the SlicedData object that we stored as a hidden member of the Ruby object.
@@ -2481,23 +2501,31 @@ IceRuby::ObjectWriter::_iceWrite(Ice::OutputStream* os) const
}
os->startValue(slicedData);
-
- if(_info->id != "::Ice::UnknownSlicedObject")
+ if(_formal && _formal->interface)
{
- ClassInfoPtr info = _info;
- while(info)
+ ID op = rb_intern("ice_id");
+ string id = getString(callRuby(rb_funcall, _object, op, 0));
+ os->startSlice(id, -1, true);
+ os->endSlice();
+ }
+ else
+ {
+ if(_info->id != "::Ice::UnknownSlicedValue")
{
- os->startSlice(info->id, info->compactId, !info->base);
+ ClassInfoPtr info = _info;
+ while(info)
+ {
+ os->startSlice(info->id, info->compactId, !info->base);
- writeMembers(os, info->members);
- writeMembers(os, info->optionalMembers); // The optional members have already been sorted by tag.
+ writeMembers(os, info->members);
+ writeMembers(os, info->optionalMembers); // The optional members have already been sorted by tag.
- os->endSlice();
+ os->endSlice();
- info = info->base;
+ info = info->base;
+ }
}
}
-
os->endValue();
}
@@ -2569,7 +2597,7 @@ IceRuby::ObjectReader::_iceRead(Ice::InputStream* is)
{
is->startValue();
- const bool unknown = _info->id == "::Ice::UnknownSlicedObject";
+ const bool unknown = _info->id == "::Ice::UnknownSlicedValue";
//
// Unmarshal the slices of a user-defined class.
@@ -2620,7 +2648,7 @@ IceRuby::ObjectReader::_iceRead(Ice::InputStream* is)
util->add(this);
//
- // Define the "unknownTypeId" member for an instance of UnknownSlicedObject.
+ // Define the "unknownTypeId" member for an instance of UnknownSlicedValue.
//
if(unknown)
{
@@ -2692,7 +2720,7 @@ IceRuby::ReadObjectCallback::invoke(const Ice::ObjectPtr& p)
// Verify that the unmarshaled object is compatible with the formal type.
//
volatile VALUE obj = reader->getObject();
- if(!_info->validate(obj))
+ if(!_info->interface && !_info->validate(obj))
{
Ice::UnexpectedObjectException ex(__FILE__, __LINE__);
ex.reason = "unmarshaled object is not an instance of " + _info->id;
@@ -3060,14 +3088,16 @@ IceRuby_defineException(VALUE /*self*/, VALUE id, VALUE type, VALUE preserve, VA
extern "C"
VALUE
-IceRuby_TypeInfo_defineProxy(VALUE self, VALUE type, VALUE classInfo)
+IceRuby_TypeInfo_defineProxy(VALUE self, VALUE type, VALUE base, VALUE interfaces)
{
ICE_RUBY_TRY
{
ProxyInfoPtr info = ProxyInfoPtr::dynamicCast(getType(self));
assert(info);
- info->define(type, classInfo);
+ info->define(type, base, interfaces);
+ rb_define_const(type, "ICE_TYPE", self);
+ rb_define_const(type, "ICE_ID", createString(info->id));
}
ICE_RUBY_CATCH
return Qnil;
@@ -3075,22 +3105,31 @@ IceRuby_TypeInfo_defineProxy(VALUE self, VALUE type, VALUE classInfo)
extern "C"
VALUE
-IceRuby_TypeInfo_defineClass(VALUE self, VALUE type, VALUE compactId, VALUE isAbstract, VALUE preserve, VALUE base,
- VALUE interfaces, VALUE members)
+IceRuby_TypeInfo_defineClass(VALUE self, VALUE type, VALUE compactId, VALUE preserve, VALUE interface, VALUE base,
+ VALUE members)
{
ICE_RUBY_TRY
{
ClassInfoPtr info = ClassInfoPtr::dynamicCast(getType(self));
assert(info);
- info->define(type, compactId, isAbstract, preserve, base, interfaces, members);
+ info->define(type, compactId, preserve, interface, base, members);
- CompactIdMap::iterator q = _compactIdMap.find(info->compactId);
- if(q != _compactIdMap.end())
+ if(info->compactId != -1)
+ {
+ CompactIdMap::iterator q = _compactIdMap.find(info->compactId);
+ if(q != _compactIdMap.end())
+ {
+ _compactIdMap.erase(q);
+ }
+ _compactIdMap.insert(CompactIdMap::value_type(info->compactId, info));
+ }
+
+ if(type != Qnil && !info->interface)
{
- _compactIdMap.erase(q);
+ rb_define_const(type, "ICE_TYPE", self);
+ rb_define_const(type, "ICE_ID", createString(info->id));
}
- _compactIdMap.insert(CompactIdMap::value_type(info->compactId, info));
}
ICE_RUBY_CATCH
return Qnil;
@@ -3193,8 +3232,8 @@ IceRuby::initTypes(VALUE iceModule)
rb_define_module_function(iceModule, "__declareLocalClass", CAST_METHOD(IceRuby_declareLocalClass), 1);
rb_define_module_function(iceModule, "__defineException", CAST_METHOD(IceRuby_defineException), 5);
- rb_define_method(_typeInfoClass, "defineClass", CAST_METHOD(IceRuby_TypeInfo_defineClass), 7);
- rb_define_method(_typeInfoClass, "defineProxy", CAST_METHOD(IceRuby_TypeInfo_defineProxy), 2);
+ rb_define_method(_typeInfoClass, "defineClass", CAST_METHOD(IceRuby_TypeInfo_defineClass), 6);
+ rb_define_method(_typeInfoClass, "defineProxy", CAST_METHOD(IceRuby_TypeInfo_defineProxy), 3);
rb_define_module_function(iceModule, "__stringify", CAST_METHOD(IceRuby_stringify), 2);
rb_define_module_function(iceModule, "__stringifyException", CAST_METHOD(IceRuby_stringifyException), 1);
diff --git a/ruby/src/IceRuby/Types.h b/ruby/src/IceRuby/Types.h
index 8e59edc056f..9d2ae37ee95 100644
--- a/ruby/src/IceRuby/Types.h
+++ b/ruby/src/IceRuby/Types.h
@@ -26,7 +26,10 @@ typedef std::vector<ExceptionInfoPtr> ExceptionInfoList;
class ClassInfo;
typedef IceUtil::Handle<ClassInfo> ClassInfoPtr;
-typedef std::vector<ClassInfoPtr> ClassInfoList;
+
+class ProxyInfo;
+typedef IceUtil::Handle<ProxyInfo> ProxyInfoPtr;
+typedef std::vector<ProxyInfoPtr> ProxyInfoList;
//
// This class is raised as an exception when object marshaling needs to be aborted.
@@ -388,7 +391,7 @@ public:
ClassInfo(VALUE, bool);
- void define(VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE);
+ void define(VALUE, VALUE, VALUE, VALUE, VALUE, VALUE);
virtual std::string getId() const;
@@ -415,10 +418,9 @@ public:
const Ice::Int compactId;
const bool isBase; // Is this the ClassInfo for Ice::Object or Ice::LocalObject?
const bool isLocal;
- const bool isAbstract;
const bool preserve;
+ const bool interface;
const ClassInfoPtr base;
- const ClassInfoList interfaces;
const DataMemberList members;
const DataMemberList optionalMembers;
const VALUE rubyClass;
@@ -435,7 +437,7 @@ public:
ProxyInfo(VALUE);
- void define(VALUE, VALUE);
+ void define(VALUE, VALUE, VALUE);
virtual std::string getId() const;
@@ -452,12 +454,15 @@ public:
virtual void destroy();
+ bool isA(const ProxyInfoPtr&);
+
const std::string id;
+ const bool isBase; // Is this the ClassInfo for Ice::ObjectPrx?
+ const ProxyInfoPtr base;
+ const ProxyInfoList interfaces;
const VALUE rubyClass;
- const ClassInfoPtr classInfo;
const VALUE typeObj;
};
-typedef IceUtil::Handle<ProxyInfo> ProxyInfoPtr;
//
// Exception information.
@@ -487,7 +492,7 @@ class ObjectWriter : public Ice::Object
{
public:
- ObjectWriter(VALUE, ObjectMap*);
+ ObjectWriter(VALUE, ObjectMap*, const ClassInfoPtr&);
virtual ~ObjectWriter();
virtual void ice_preMarshal();
@@ -502,6 +507,7 @@ private:
VALUE _object;
ObjectMap* _map;
ClassInfoPtr _info;
+ ClassInfoPtr _formal;
};
//
diff --git a/ruby/src/IceRuby/ValueFactoryManager.cpp b/ruby/src/IceRuby/ValueFactoryManager.cpp
index 562526c0003..e125328afdf 100644
--- a/ruby/src/IceRuby/ValueFactoryManager.cpp
+++ b/ruby/src/IceRuby/ValueFactoryManager.cpp
@@ -31,7 +31,7 @@ getClassInfo(const string& id)
// When the ID is that of Ice::Object, it indicates that the stream has not
// found a factory and is providing us an opportunity to preserve the object.
//
- info = lookupClassInfo("::Ice::UnknownSlicedObject");
+ info = lookupClassInfo("::Ice::UnknownSlicedValue");
}
else
{
diff --git a/ruby/test/Ice/objects/AllTests.rb b/ruby/test/Ice/objects/AllTests.rb
index 57672910a48..873725baabf 100644
--- a/ruby/test/Ice/objects/AllTests.rb
+++ b/ruby/test/Ice/objects/AllTests.rb
@@ -9,6 +9,20 @@
require './TestI.rb'
+
+class II < ::Ice::InterfaceByValue
+ def initialize()
+ super("::Test::I")
+ end
+end
+
+class JI < ::Ice::InterfaceByValue
+ def initialize()
+ super("::Test::J")
+ end
+end
+
+
#
# Ice for Ruby behaves differently than Ice for C++, because
# collocated invocations are still sent "over the wire". Therefore
@@ -28,9 +42,15 @@ class MyValueFactory
#elsif type == '::Test::D'
# return DI.new
elsif type == '::Test::E'
- return EI.new
+ return EI.new
elsif type == '::Test::F'
- return FI.new
+ return FI.new
+ elsif type == '::Test::I'
+ puts "create ::Test::I"
+ return II.new
+ elsif type == '::Test::J'
+ puts "create ::Test::J"
+ return JI.new
end
fail "unknown type"
end
@@ -60,6 +80,8 @@ def allTests(communicator)
#communicator.getValueFactoryManager().add(factory, '::Test::D')
communicator.getValueFactoryManager().add(factory, '::Test::E')
communicator.getValueFactoryManager().add(factory, '::Test::F')
+ communicator.getValueFactoryManager().add(factory, '::Test::I')
+ communicator.getValueFactoryManager().add(factory, '::Test::J')
communicator.addObjectFactory(MyObjectFactory.new, 'TestOF')
diff --git a/ruby/test/Ice/operations/Twoways.rb b/ruby/test/Ice/operations/Twoways.rb
index c6d32ab6106..43bf0d5f840 100644
--- a/ruby/test/Ice/operations/Twoways.rb
+++ b/ruby/test/Ice/operations/Twoways.rb
@@ -119,7 +119,7 @@ def twoways(communicator, p)
#
test(Test::MyClassPrx::ice_staticId() == Test::MyClass::ice_staticId())
test(Test::MyDerivedClassPrx::ice_staticId() == Test::MyDerivedClass::ice_staticId())
- test(Ice::ObjectPrx::ice_staticId() == Ice::Object::ice_staticId())
+ test(Ice::ObjectPrx::ice_staticId() == Ice::Value::ice_staticId())
#
# opVoid
diff --git a/ruby/test/Ice/optional/AllTests.rb b/ruby/test/Ice/optional/AllTests.rb
index ffe0ab5095d..98d9b93fee6 100644
--- a/ruby/test/Ice/optional/AllTests.rb
+++ b/ruby/test/Ice/optional/AllTests.rb
@@ -75,13 +75,13 @@ def allTests(communicator)
fs = Test::FixedStruct.new(78)
vs = Test::VarStruct.new("hello")
mo1 = Test::MultiOptional.new(15, true, 19, 78, 99, 5.5, 1.0, "test", Test::MyEnum::MyEnumMember, \
- Test::MultiOptionalPrx::uncheckedCast(communicator.stringToProxy("test")), \
+ communicator.stringToProxy("test"), \
nil, [5], ["test", "test2"], {4=>3}, {"test"=>10}, fs, vs, [1], \
[Test::MyEnum::MyEnumMember, Test::MyEnum::MyEnumMember], \
[ fs ], [ vs ], [ oo1 ], \
- [ Test::OneOptionalPrx::uncheckedCast(communicator.stringToProxy("test")) ], \
- {4=>Test::MyEnum::MyEnumMember}, {4=>fs}, {5=>vs}, {5=>Test::OneOptional.new(15)}, \
- {5=>Test::OneOptionalPrx::uncheckedCast(communicator.stringToProxy("test"))}, \
+ [ communicator.stringToProxy("test") ], \
+ {4=> Test::MyEnum::MyEnumMember}, {4=>fs}, {5=>vs}, {5=>Test::OneOptional.new(15)}, \
+ {5=> communicator.stringToProxy("test")}, \
[false, true, false])
test(mo1.a == 15)
@@ -93,7 +93,7 @@ def allTests(communicator)
test(mo1.g == 1.0)
test(mo1.h == "test")
test(mo1.i == Test::MyEnum::MyEnumMember)
- test(mo1.j == Test::MultiOptionalPrx::uncheckedCast(communicator.stringToProxy("test")))
+ test(mo1.j == communicator.stringToProxy("test"))
test(mo1.k == nil)
test(mo1.bs == [5])
test(mo1.ss == ["test", "test2"])
@@ -107,13 +107,13 @@ def allTests(communicator)
test(mo1.fss[0] == Test::FixedStruct.new(78))
test(mo1.vss[0] == Test::VarStruct.new("hello"))
test(mo1.oos[0] == oo1)
- test(mo1.oops[0] == Test::OneOptionalPrx::uncheckedCast(communicator.stringToProxy("test")))
+ test(mo1.oops[0] == communicator.stringToProxy("test"))
test(mo1.ied[4] == Test::MyEnum::MyEnumMember)
test(mo1.ifsd[4] == Test::FixedStruct.new(78))
test(mo1.ivsd[5] == Test::VarStruct.new("hello"))
test(mo1.iood[5].a == 15)
- test(mo1.ioopd[5] == Test::OneOptionalPrx::uncheckedCast(communicator.stringToProxy("test")))
+ test(mo1.ioopd[5] == communicator.stringToProxy("test"))
test(mo1.bos == [false, true, false])
@@ -185,13 +185,13 @@ def allTests(communicator)
test(mo5.fss[0] == Test::FixedStruct.new(78))
test(mo5.vss[0] == Test::VarStruct.new("hello"))
test(mo5.oos[0].a == 15)
- test(mo5.oops[0] == Test::OneOptionalPrx::uncheckedCast(communicator.stringToProxy("test")))
+ test(mo5.oops[0] == communicator.stringToProxy("test"))
test(mo5.ied[4] == Test::MyEnum::MyEnumMember)
test(mo5.ifsd[4] == Test::FixedStruct.new(78))
test(mo5.ivsd[5] == Test::VarStruct.new("hello"))
test(mo5.iood[5].a == 15)
- test(mo5.ioopd[5] == Test::OneOptionalPrx::uncheckedCast(communicator.stringToProxy("test")))
+ test(mo5.ioopd[5] == communicator.stringToProxy("test"))
test(mo5.bos == mo1.bos)
@@ -290,13 +290,13 @@ def allTests(communicator)
test(mo9.fss == Ice::Unset)
test(mo9.vss[0] == Test::VarStruct.new("hello"))
test(mo9.oos == Ice::Unset)
- test(mo9.oops[0] == Test::OneOptionalPrx::uncheckedCast(communicator.stringToProxy("test")))
+ test(mo9.oops[0] == communicator.stringToProxy("test"))
test(mo9.ied[4] == Test::MyEnum::MyEnumMember)
test(mo9.ifsd == Ice::Unset)
test(mo9.ivsd[5] == Test::VarStruct.new("hello"))
test(mo9.iood == Ice::Unset)
- test(mo9.ioopd[5] == Test::OneOptionalPrx::uncheckedCast(communicator.stringToProxy("test")))
+ test(mo9.ioopd[5] == communicator.stringToProxy("test"))
test(mo9.bos == Ice::Unset)
@@ -524,7 +524,7 @@ def allTests(communicator)
p2, p3 = initial.opOneOptionalProxy(Ice::Unset)
test(p2 == Ice::Unset && p3 == Ice::Unset)
- p1 = Test::OneOptionalPrx::uncheckedCast(communicator.stringToProxy("test"))
+ p1 = communicator.stringToProxy("test")
p2, p3 = initial.opOneOptionalProxy(p1)
test(p2 == p1 && p3 == p1)
diff --git a/ruby/test/Ice/slicing/exceptions/AllTests.rb b/ruby/test/Ice/slicing/exceptions/AllTests.rb
index 746cd365bf8..7fee4ae7819 100644
--- a/ruby/test/Ice/slicing/exceptions/AllTests.rb
+++ b/ruby/test/Ice/slicing/exceptions/AllTests.rb
@@ -7,8 +7,6 @@
#
# **********************************************************************
-Ice::loadSlice('Test.ice')
-
def test(b)
if !b
raise RuntimeError, 'test assertion failed'
diff --git a/ruby/test/Ice/slicing/objects/AllTests.rb b/ruby/test/Ice/slicing/objects/AllTests.rb
index e6992aa83d1..230eee7acd6 100644
--- a/ruby/test/Ice/slicing/objects/AllTests.rb
+++ b/ruby/test/Ice/slicing/objects/AllTests.rb
@@ -110,7 +110,7 @@ def allTests(communicator)
begin
o = t.SUnknownAsObject()
test(t.ice_getEncodingVersion() != Ice::Encoding_1_0)
- test(o.is_a?(Ice::UnknownSlicedObject))
+ test(o.is_a?(Ice::UnknownSlicedValue))
test(o.unknownTypeId == "::Test::SUnknown")
test(o._ice_slicedData != nil)
t.checkSUnknown(o)
diff --git a/slice/Ice/Connection.ice b/slice/Ice/Connection.ice
index e87f8527958..bbcf78360e4 100644
--- a/slice/Ice/Connection.ice
+++ b/slice/Ice/Connection.ice
@@ -27,7 +27,7 @@ module Ice
*
* Base class providing access to the connection details. *
**/
-["php:internal"]
+["php:internal", "ruby:internal"]
local class ConnectionInfo
{
/**
@@ -324,7 +324,7 @@ local interface Connection
* Provides access to the connection details of an IP connection
*
**/
-["php:internal"]
+["php:internal", "ruby:internal"]
local class IPConnectionInfo extends ConnectionInfo
{
/** The local address. */
@@ -345,7 +345,7 @@ local class IPConnectionInfo extends ConnectionInfo
* Provides access to the connection details of a TCP connection
*
**/
-["php:internal"]
+["php:internal", "ruby:internal"]
local class TCPConnectionInfo extends IPConnectionInfo
{
/**
@@ -368,7 +368,7 @@ local class TCPConnectionInfo extends IPConnectionInfo
* Provides access to the connection details of a UDP connection
*
**/
-["php:internal"]
+["php:internal", "ruby:internal"]
local class UDPConnectionInfo extends IPConnectionInfo
{
/**
@@ -407,7 +407,7 @@ dictionary<string, string> HeaderDict;
* Provides access to the connection details of a WebSocket connection
*
**/
-["php:internal"]
+["php:internal", "ruby:internal"]
local class WSConnectionInfo extends ConnectionInfo
{
/** The headers from the HTTP upgrade request. */
diff --git a/slice/Ice/Endpoint.ice b/slice/Ice/Endpoint.ice
index 09c69ddf9fd..0f819d7b8e1 100644
--- a/slice/Ice/Endpoint.ice
+++ b/slice/Ice/Endpoint.ice
@@ -91,7 +91,7 @@ const short iAPSEndpointType = 9;
* Base class providing access to the endpoint details.
*
**/
-["php:internal"]
+["php:internal", "ruby:internal"]
local class EndpointInfo
{
/**
@@ -180,7 +180,7 @@ local interface Endpoint
* @see Endpoint
*
**/
-["php:internal"]
+["php:internal", "ruby:internal"]
local class IPEndpointInfo extends EndpointInfo
{
/**
@@ -212,7 +212,7 @@ local class IPEndpointInfo extends EndpointInfo
* @see Endpoint
*
**/
-["php:internal"]
+["php:internal", "ruby:internal"]
local class TCPEndpointInfo extends IPEndpointInfo
{
};
@@ -224,7 +224,7 @@ local class TCPEndpointInfo extends IPEndpointInfo
* @see Endpoint
*
**/
-["php:internal"]
+["php:internal", "ruby:internal"]
local class UDPEndpointInfo extends IPEndpointInfo
{
/**
@@ -247,7 +247,7 @@ local class UDPEndpointInfo extends IPEndpointInfo
* Provides access to a WebSocket endpoint information.
*
**/
-["php:internal"]
+["php:internal", "ruby:internal"]
local class WSEndpointInfo extends EndpointInfo
{
/**
@@ -265,7 +265,7 @@ local class WSEndpointInfo extends EndpointInfo
* @see Endpoint
*
**/
-["php:internal"]
+["php:internal", "ruby:internal"]
local class OpaqueEndpointInfo extends EndpointInfo
{
/**