Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

virgin commit

  • Loading branch information...
commit e3172b218eeada72fc67de503474ff4d999d67ff 1 parent 4a70010
unknown authored
View
21 README.md
@@ -14,7 +14,7 @@ To exercise current functionality, start with the following Slice file:
};
};
-Start the node server with `node driver.js`. This will run an Ice server with no objects, but which will accept and validate Ice connections. To test this, run the following with ZeroC's own _blessed_ ice client library in Python.
+Start the node server with `node driver.js`. This will run an Ice server with one Ice object that will respond to the printString method. To test this, run the following with ZeroC's own _blessed_ ice client library in Python.
$ python2.6
Python 2.6.7 (r267:88850, Mar 13 2012, 00:08:50)
@@ -24,26 +24,25 @@ Start the node server with `node driver.js`. This will run an Ice server with no
>>> Ice.loadSlice('printer.ice')
>>> import Demo
>>> proxy = ic.stringToProxy('X:tcp -h localhost -p 4001')
- >>> printer = Demo.PrinterPrx.checkedCast(proxy)
+ >>> printer = Demo.PrinterPrx.uncheckedCast(proxy)
+ >>> printer.printString("A pack of lies!");
The Node server using _hail_ will process the request header and print out the request body. You will see something like this:
$ node driver.js
Started listening!
- Request
- H: {"message_type":"request","compression_mode":0,"body_length":54}
- B: Xice_isA::Demo::Printer
- Produced event request
+ X.printString("A pack of lies!");
-These lines show (poorly) the `H:` header and the `B:` body of the request. The `checkedCast` line we ran in the Python session is the equivalent of running `X.isA("::Demo::Printer")`, all of which we see printed here. The hex output reveals the complete Ice::Request structure.
+The Python client will also finish the request (the response is void). This demonstrates the end-to-end request-response flow currently implemented in Ice.
next steps
----------
-As you see, `hail` has not gotten especially far. The next step would be hosting an Ice object and completing an `isA` call against it from Python. After that, correct parsing of arguments will allow us to run arbitrary methods on an object.
+`Hail` is not a complete implmentation of Ice. The next step would be hosting an Ice object and completing an `isA` call against it from Python (the result of checkedCast), together with the associated exception replies. Dictionary argument types are still unhandled, and until now we only support `void` and `int` return types on remote invocations.
-The model for method dispatch will be event emitters. The following might be the shape of server code using _hail_ to server the `Demo::Printer` object.
+The model for method dispatch, however, is done, with the shape below. This pattern, with the use of EventEmitters and response callbacks, is to be preserved.
- server.on('printString', function(s) {
- console.log("Printing a string!")
+ servant.on('printString', function(resp, s) {
+ console.log("Printing a string!");
+ resp.send();
});
View
40 adapter.js
@@ -1,40 +0,0 @@
-var EventEmitter = require('events').EventEmitter;
-var MessageReceiver = require('./messages').Receiver;
-var OperationParser = require('./operations').Parser;
-var inherits = require('util').inherits;
-
-var Adapter = function(port, host)
-{
- if (this instanceof Adapter) {
- EventEmitter.call(this);
- this.port = port;
- this.host = host;
- this.objects = {};
- } else {
- return new Adapter;
- }
-};
-inherits(Adapter, EventEmitter);
-exports.Adapter = Adapter;
-
-
-/*!
- * IceAdapter::activate
- */
-Adapter.prototype.activate = function(on_start) {
- var self = this;
- message_receiver = MessageReceiver();
- message_receiver.listen(this.port, this.host, function(error) {
- if (!error) {
- self.operations_parser = OperationParser(message_receiver);
- self.operations_parser.on('operation', function(object_id, facet, operation_name, arguments) {
- if (object_id in self.objects)
- console.log('Trying to dispatch ' + object_id.name + '.' + operation_name + '(...)');
- else
- console.log('No such object "' + object_id.name + '"! Throw ObjectNotExistException!');
- });
- }
-
- on_start(error);
- });
-};
View
21 driver.js
@@ -1,6 +1,23 @@
-var ice_adapter = require('./adapter').Adapter;
+var ice = require('./index');
+
+var adapter = new ice.adapter(4001, 'localhost');
+
+ice.create_object_factory('printer.ice', function(error, defs) {
+ var printer_x = defs.Demo.Printer();
+ adapter.publish_object({name: 'X', category: null}, printer_x);
+ printer_x.on('printString', function(response, s) {
+ console.log("X.printString(\"" + s + "\")");
+ response.send();
+ })
+ printer_x.on('ice_isA', function(response, s) {
+ if(s=='::Demo::Printer') {
+ response.send(1);
+ } else {
+ response.send(0);
+ }
+ })
+});
-var adapter = new ice_adapter(4001, 'localhost');
adapter.activate(function() {
console.log('Started listening!');
});
View
37 index.js
@@ -0,0 +1,37 @@
+var fs = require('fs');
+var generate_parser = require('jison').Parser
+var ice_types = require('./lib/slice/types');
+var Servant = require('./lib/servant').Servant;
+var adapter = require('./lib/adapter').Adapter;
+var _ = require('underscore');
+
+var create_object_factory = function create_object_factory(ice_filename, callback) {
+ fs.readFile('lib/slice/grammar.jison', 'utf-8', function(error, raw_grammar) {
+ var parse_slice = generate_parser(raw_grammar);
+ parse_slice.yy = ice_types;
+ fs.readFile(ice_filename, 'utf-8', function(error, slice_file) {
+ if (! error) {
+ // TODO: Parse errors?!
+ var parsed_definitions = parse_slice.parse(slice_file);
+ var define_with_constructors = function(definition) {
+ if (_.has(definition, 'operations')) {
+ return function() { return new Servant(definition); };
+ } else {
+ return _.foldl(definition, function(module, value, this_key) {
+ var complete_definition = {};
+ complete_definition[this_key] = define_with_constructors(value);
+ return _.extend(module, complete_definition);
+ }, {});
+ }
+ };
+ var type_hierarchy = define_with_constructors(parsed_definitions);
+ callback(error, type_hierarchy);
+ } else {
+ callback(error, undefined);
+ }
+ });
+ });
+};
+exports.create_object_factory = create_object_factory;
+
+exports.adapter = adapter;
View
73 lib/adapter.js
@@ -0,0 +1,73 @@
+var EventEmitter = require('events').EventEmitter;
+var MessageReceiver = require('./messages').Receiver;
+var OperationParser = require('./operations').Parser;
+var inherits = require('util').inherits;
+var _ = require('underscore');
+
+var Adapter = function(port, host)
+{
+ if (this instanceof Adapter) {
+ EventEmitter.call(this);
+ this.port = port;
+ this.host = host;
+ this.servants = {};
+ } else {
+ return new Adapter(port, host);
+ }
+};
+inherits(Adapter, EventEmitter);
+exports.Adapter = Adapter;
+
+
+/*!
+ * Makes the object identified by object_id (which may either be a string, meaning {name: <string>,
+ * category: null} or an object filling at least the name property) available to connecting
+ * clients. If the adapter is active, the user must take care to define event handlers for all
+ * of the salient events for this object.
+ */
+Adapter.prototype.publish_object = function(object_id, servant) {
+ if (object_id instanceof String)
+ object_id = {name: object_id};
+
+ if (!! _.has(object_id, 'name')) {
+ _.defaults(object_id, {category: null});
+ servant.facets = [];
+ this.servants[object_id] = servant;
+ return servant;
+ } else {
+ throw new Error('Published object with identity ' + object_id + ' is not the right type.');
+ }
+};
+
+
+/*!
+ * IceAdapter::activate
+ */
+Adapter.prototype.activate = function(on_start) {
+ var self = this;
+ message_receiver = MessageReceiver();
+ message_receiver.listen(this.port, this.host, function(error) {
+ if (!error) {
+ self.operations_parser = OperationParser(message_receiver);
+ // object_id, facet, operation_name, arguments
+ self.operations_parser.on('operation', function(request, stream) {
+ if (request.object_id in self.servants) {
+ var servant = self.servants[request.object_id];
+ if (request.facet !== null) {
+ if (request.facet in servant.facets) {
+ console.log('Unprepared for facets...', request.object_id, request.facet);
+ } else {
+ console.log('No facet "' + request.facet + '" for object ' + JSON.stringify(request.object_id));
+ }
+ } else {
+ servant.apply(request.operation, request.params, stream, request.request_id);
+ }
+ } else {
+ console.log('No such object "' + request.object_id.name + '"! Throw ObjectNotExistException!');
+ }
+ });
+ }
+
+ on_start(error);
+ });
+};
View
43 lib/ice_binary/encode.js
@@ -0,0 +1,43 @@
+var buffer = require('buffer').Buffer;
+var buffers = require('buffers');
+
+/*!
+ * Compute length of UTF-8 serialization of string s.
+ * (from http://stackoverflow.com/questions/8588449)
+ */
+function utf8_length(s)
+{
+ var l = 0;
+ for (var i = 0; i < s.length; i++) {
+ var c = s.charCodeAt(i);
+ if (c <= 0x007f) l += 1;
+ else if (c <= 0x07ff) l += 2;
+ else if (c >= 0xd800 && c <= 0xdfff) l += 2; // surrogates
+ else l += 3;
+ }
+ return l;
+}
+
+/*!
+ * Produces a buffer containing the encoding for an Ice string.
+ */
+exports.ice_string = function encode_ice_string(s) {
+ var encoded_bytes = new buffer(utf8_length(s) + 5); // Make space for all size encodings.
+ if (utf8_length(s) < 255) {
+ encoded_string.writeUInt8(utf8_length(s), 0);
+ encoded_string.write(s, 1);
+ return encoded_string.slice(1 + utf8_length(s));
+ } else {
+ encoded_string.writeUInt8(255, 0);
+ encoded_string.writeUInt32LE(utf8_length(s), 1);
+ encoded_string.write(s, 5);
+ return encoded_string;
+ }
+};
+
+
+exports.ice_bool = function encode_ice_bool(n) {
+ var encoded_bytes = new buffer(1);
+ encoded_bytes.writeInt8(n,0);
+ return encoded_bytes;
+}
View
33 ice_binary.js → lib/ice_binary/parser.js
@@ -1,29 +1,31 @@
-var binary = require('binary');
-var inherits = require('util').inherits;
-var _ = require("underscore");
+var binary = require('binary');
+var inherits = require('util').inherits;
+var _ = require("underscore");
-var ice_binary = function(buffer) {
- if (this instanceof ice_binary) {
- this.buffer_ = buffer;
+var Parser = function(buffer) {
+ if (this instanceof Parser) {
this.parser = binary.parse(buffer);
_.extend(this.parser, this); // Really? What a pain in the ass...
return this.parser;
} else {
- return new ice_binary(buffer);
+ return new Parser(buffer);
}
};
-exports = module.exports = ice_binary;
+exports = module.exports = Parser;
-ice_binary.prototype.ice_string = function(name) {
+Parser.prototype.ice_string = function(name) {
string_size_name = name + '.size';
this.ice_size(string_size_name)
- .buffer(name, string_size_name);
+ .buffer(name, string_size_name)
+ .tap(function(stuff) {
+ stuff[name] = stuff[name].toString();
+ });
return this;
};
-ice_binary.prototype.ice_size = function(name) {
+Parser.prototype.ice_size = function(name) {
this.word8(name)
.tap(function(result) {
if (result[name] != null && result[name] > 255)
@@ -34,15 +36,14 @@ ice_binary.prototype.ice_size = function(name) {
}
-
-ice_binary.prototype.ice_struct = function(name, block) {
+Parser.prototype.ice_struct = function(name, block) {
// Structs are incredibly simple: we just give all the variables a namespace as the name
// of that struct.
return this.into(name, block);
};
-ice_binary.prototype.ice_sequence = function(name, content) {
+Parser.prototype.ice_sequence = function(name, content) {
var result_sequence = Array();
this.vars[name] = result_sequence;
@@ -72,7 +73,7 @@ ice_binary.prototype.ice_sequence = function(name, content) {
};
-ice_binary.prototype.ice_dictionary = function(name, parse_key_format, parse_value_format) {
+Parser.prototype.ice_dictionary = function(name, parse_key_format, parse_value_format) {
var kv_pair_count = name + '.expected_pair_count'; // Delete this associative key later.
this.ice_size(kv_pair_count)
.tap(function(vars) {
@@ -92,7 +93,7 @@ ice_binary.prototype.ice_dictionary = function(name, parse_key_format, parse_val
};
-ice_binary.prototype.ice_encapsulation = function(name) {
+Parser.prototype.ice_encapsulation = function(name) {
this.into(name, function(top) {
this.word32le('size')
.word8('major')
View
2  messages.js → lib/messages.js
@@ -62,7 +62,7 @@ var Parser = function(emitter, stream) {
message.header.message_type = stringified_message_type(message.header.message_type_code);
this.buffer('body', message.length - ice_message_header_length)
.tap(function(message) {
- emitter.emit(message.header.message_type, message.header, message.body);
+ emitter.emit(message.header.message_type, stream, message.header, message.body);
this.flush();
parse_new_message(this);
});
View
13 operations.js → lib/operations.js
@@ -1,5 +1,5 @@
var EventEmitter = require('events').EventEmitter;
-var ice_binary = require('./ice_binary');
+var ice_binary_parser = require('./ice_binary/parser');
var inherits = require('util').inherits;
/*!
@@ -12,9 +12,8 @@ var Parser = function(message_receiver) {
this.message_receiver = message_receiver;
var self = this;
- this.message_receiver.on('request', function(header, body) {
- log_request('Request', header, body);
- var operation_parser = ice_binary(body)
+ this.message_receiver.on('request', function(stream, header, body) {
+ var operation_parser = ice_binary_parser(body)
.word32le ('request_id')
.ice_struct('object_id', function() {
this.ice_string('name');
@@ -27,9 +26,9 @@ var Parser = function(message_receiver) {
.word8('mode')
.ice_dictionary('context', function() { }, function() { }) // Unimplemented!
.ice_encapsulation('params')
- .tap(function(r) {
- var facet = r.facet.length > 0? r.facet[0].name.toString() : null;
- self.emit('operation', r.object_id, facet, r.operation.toString(), r.params);
+ .tap(function(request) {
+ request.facet = request.facet.length > 0? request.facet[0].name : null;
+ self.emit('operation', request, stream);
});
});
View
82 lib/response.js
@@ -0,0 +1,82 @@
+var buffer = require('buffer').Buffer;
+var buffers = require('buffers');
+var encode = require('./ice_binary/encode');
+
+/*!
+ * A builder object that will send a properly-formatted response to an implicit request if all
+ * fields are properly filled.
+ */
+var Response = function(socket, request_id, return_type_definition) {
+ if (this instanceof Response) {
+ this.return_type_definition = return_type_definition;
+ this.request_id = request_id;
+ this.socket = socket;
+ } else {
+ return new Response(socket, request_id, return_type_definition);
+ }
+};
+exports = module.exports = Response;
+
+
+function response_message_for(request_id, encapsulated_return_value) {
+ const ice_message_header_length = 14;
+ const reply_header_length = 5;
+
+ var total_message_length =
+ ice_message_header_length
+ + reply_header_length
+ + encapsulated_return_value.length;
+
+ var message_header = new buffer(14);
+ message_header.write('IceP'); // magic
+ message_header.writeUInt8(1, 4); // Protocol Major version
+ message_header.writeUInt8(0, 5); // Protocol Minor version
+ message_header.writeUInt8(1, 6); // Encoding Major version
+ message_header.writeUInt8(0, 7); // Encoding Minor version
+ message_header.writeUInt8(2, 8); // "Reply" Type (2)
+ message_header.writeUInt8(0, 9); // Compression type (always zero for validation)
+ message_header.writeUInt32LE(total_message_length, 10);
+
+ var reply_header = new buffer(5);
+ reply_header.writeInt32LE(request_id, 0);
+ reply_header.writeUInt8(0, 4); // 0 - "Success"
+
+ var response = new buffers();
+ response.push(message_header);
+ response.push(reply_header);
+ response.push(encapsulated_return_value);
+ return response.toBuffer();
+}
+
+
+function encapsulation_for(b) {
+ const encapsulation_header_length = 6;
+
+ var header = new buffer(encapsulation_header_length);
+ header.writeInt32LE(b.length + encapsulation_header_length, 0);
+ header.writeUInt8(1, 4); // Encoding Major version
+ header.writeUInt8(0, 5); // Encoding Minor version
+
+ var encapsulation = new buffers();
+ encapsulation.push(header);
+ encapsulation.push(b);
+ return encapsulation.toBuffer();
+};
+
+
+Response.prototype.send = function(object) {
+ var self = this;
+ function encapsulated_return_value(o) {
+ if (self.return_type_definition == 'void') {
+ return encapsulation_for(buffer(0));
+ } else if (self.return_type_definition == 'bool') {
+ var encoded_boolean = encode.ice_bool(object);
+ return encapsulation_for(encoded_boolean);
+ } else {
+ throw new Error("Haven't implemented crazy types yet. Return integers, you fiend.");
+ }
+ };
+
+ var body = encapsulated_return_value(object);
+ self.socket.write(response_message_for(self.request_id, body));
+};
View
47 lib/servant.js
@@ -0,0 +1,47 @@
+var EventEmitter = require('events').EventEmitter;
+var ice_binary_parser = require('./ice_binary/parser');
+var inherits = require('util').inherits;
+var response = require('./response');
+var _ = require('underscore');
+
+var Servant = function(definition) {
+ if (this instanceof Servant) {
+ this.operations = definition.operations;
+ } else {
+ return new Servant(definition);
+ }
+};
+inherits(Servant, EventEmitter)
+exports.Servant = Servant;
+
+
+Servant.prototype.apply = function(operation_name, argument_encapsulation, stream, request_id) {
+ if (operation_name in this.operations) {
+ var argument_definitions = this.operations[operation_name].arguments;
+ var parser = ice_binary_parser(argument_encapsulation.body);
+ for (argument_id in argument_definitions) {
+ var this_argument_definition = argument_definitions[argument_id];
+ switch (this_argument_definition.type) {
+ case 'string':
+ parser.ice_string(this_argument_definition.name);
+
+ // TODO: there are other types, ya jerk.
+ };
+ }
+
+ var emitter = this;
+
+ // TODO: We need to handle output parameters as well.
+ var return_type = this.operations[operation_name].returns.result_type;
+ var resp = response(stream, request_id, return_type);
+
+ parser.tap(function(arguments) {
+ var push_back = function(list, value, name) { list.push(value); return list; };
+ var emit_params = _.foldl(arguments, push_back, [operation_name, resp]);
+ emitter.emit.apply(emitter, emit_params);
+ });
+ } else {
+ // Throw not implemented exception? I don't know.
+ console.log(operation_name, this.operations);
+ }
+};
View
187 lib/slice/grammar.jison
@@ -0,0 +1,187 @@
+%lex
+identifier [a-zA-Z]([a-zA-Z0-9]|"_"[a-zA-Z0-9])*
+
+%%
+\s+ /* skip whitespace */
+"{" return 'LEFT_BRACE';
+"}" return 'RIGHT_BRACE';
+"[" return 'LEFT_BRACKET';
+"]" return 'RIGHT_BRACKET';
+"(" return 'LEFT_PARENTHESIS';
+")" return 'RIGHT_PARENTHESIS';
+"<" return 'LEFT_ALLIGATOR';
+">" return 'RIGHT_ALLIGATOR';
+";" return 'SEMICOLON';
+"\"" return 'QUOTE'
+"," return 'COMMA';
+"out" return 'OUT_PARAMETER_KEYWORD';
+"bool" return 'TYPE_BOOL';
+"string" return 'TYPE_STRING';
+"int" return 'TYPE_INT';
+"void" return 'TYPE_VOID';
+"idempotent" return 'IDEMPOTENT_KEYWORD';
+"interface" return 'INTERFACE_KEYWORD';
+"module" return 'MODULE_KEYWORD';
+"sequence" return 'SEQUENCE_TEMPLATE';
+"dictionary" return 'DICTIONARY_TEMPLATE';
+{identifier} return 'IDENTIFIER';
+<<EOF>> return 'END_OF_FILE';
+
+/lex
+
+%%
+
+file
+ : module_children END_OF_FILE
+ { $$ = {};
+ for (var child_id in $module_children) {
+ var child = $module_children[child_id];
+ $$[child.name] = child.body;
+ }
+ return $$;
+ }
+ ;
+
+module_children
+ : module module_children
+ { $module_children.unshift($1);
+ $$ = $module_children;
+ }
+ | qualified_interface module_children
+ { $module_children.unshift($1);
+ $$ = $module_children;
+ }
+ | type_definition module_children
+ -> $module_children;
+ | /* end of sequence */
+ -> [];
+ ;
+
+module
+ : MODULE_KEYWORD IDENTIFIER LEFT_BRACE module_children RIGHT_BRACE SEMICOLON
+ { $$ = {name: $IDENTIFIER, body: {}};
+ for (var child_id in $module_children) {
+ var child = $module_children[child_id];
+ $$.body[child.name] = child.body;
+ };
+ }
+ ;
+
+qualified_interface
+ /* We currently don't care about metadata. Ignored. */
+ : interface
+ | metadata_block interface
+ -> $interface;
+ ;
+
+interface
+ : INTERFACE_KEYWORD IDENTIFIER LEFT_BRACE operations RIGHT_BRACE SEMICOLON
+ { $$ = {name: $IDENTIFIER, body: {operations: {}}};
+ for (var operation_index in $operations) {
+ var operation = $operations[operation_index];
+
+ // TODO: Duplicate detection in $$.operations.
+ $$.body.operations[operation.name] = {arguments: $operation.arguments, returns: $operation.returns};
+ }
+ }
+ ;
+
+operations
+ : qualified_operation operations
+ { $operations.unshift($qualified_operation);
+ $$ = $operations;
+ }
+ | /* end of sequence */
+ -> [];
+ ;
+
+qualified_operation
+ /* We thus far don't care about idempotence. Ignored. */
+ : operation
+ | IDEMPOTENT_KEYWORD operation
+ -> $operation;
+
+ /* We thus far don't care about metadata. Ignored. */
+ | metadata_block operation
+ -> $operation;
+ | metadata_block IDEMPOTENT_KEYWORD operation
+ -> $operation;
+ ;
+
+operation
+ : typename IDENTIFIER LEFT_PARENTHESIS argument_declarations RIGHT_PARENTHESIS SEMICOLON
+ -> {name: $IDENTIFIER, arguments: $argument_declarations, returns: {result_type: $typename, output_parameters: []}};
+ ;
+
+type_definition
+ : SEQUENCE_TEMPLATE LEFT_ALLIGATOR typename RIGHT_ALLIGATOR IDENTIFIER SEMICOLON
+ { if ($IDENTIFIER in yy.type_definitions) {
+ $$ = 'wtf sequence';
+ // Error?
+ } else {
+ yy.type_definitions[$IDENTIFIER] = yy.SequenceType($typename);
+ $$ = yy.type_definitions[$IDENTIFIER]; // Unnecessary?
+ }
+ }
+ | DICTIONARY_TEMPLATE LEFT_ALLIGATOR typename COMMA typename RIGHT_ALLIGATOR IDENTIFIER SEMICOLON
+ { if ($IDENTIFIER in yy.type_definitions) {
+ $$ = 'wtf dictionary';
+ // Error?
+ } else {
+ yy.type_definitions[$IDENTIFIER] = yy.DictionaryType($typename1, $typename2);
+ $$ = yy.type_definitions[$IDENTIFIER]; // Unnecessary?
+ }
+ }
+ ;
+
+metadata_block
+ : LEFT_BRACKET metadata RIGHT_BRACKET
+ -> $metadata;
+ ;
+
+metadata
+ : metadatum COMMA metadata
+ -> $metadatum;
+ | metadatum
+ ;
+
+metadatum
+ : QUOTE IDENTIFIER QUOTE
+ -> $IDENTIFIER;
+ ;
+
+argument_declarations
+ : argument_declaration argument_declarations
+ { $argument_declarations.unshift($argument_declaration);
+ $$ = $argument_declarations;
+ }
+ | /* end of sequence */
+ -> [];
+ ;
+
+argument_declaration
+ : typename IDENTIFIER
+ -> {type: $typename, name: $IDENTIFIER}
+ | metadata_block typename IDENTIFIER
+ -> {type: $typename, name: $IDENTIFIER}
+ ;
+
+typename
+ : TYPE_BOOL
+ | TYPE_STRING
+ | TYPE_INT
+ | TYPE_VOID
+ | user_defined_typename
+ -> $1;
+ ;
+
+user_defined_typename
+ : IDENTIFIER
+ { if ($IDENTIFIER in yy.type_definitions) {
+ $$ = yy.type_definitions[$IDENTIFIER];
+ } else {
+ // ERROR?!?!?
+ $$ = 'wtf type is ' + $IDENTIFIER;
+ }
+ }
+ ;
View
8 lib/slice/object.ice
@@ -0,0 +1,8 @@
+sequence<string> StrSeq;
+
+interface Object {
+ idempotent void ice_ping ();
+ idempotent bool ice_isA (string typeID);
+ idempotent string ice_id ();
+ idempotent StrSeq ice_ids ();
+};
View
32 lib/slice/types.js
@@ -0,0 +1,32 @@
+var SequenceType = function(element_type) {
+ if (this instanceof SequenceType) {
+ this.element_type = element_type;
+ } else {
+ return new SequenceType(element_type);
+ }
+};
+exports.SequenceType = SequenceType;
+
+
+var DictionaryType = function(key_type, value_type) {
+ if (this instanceof DictionaryType) {
+ this.key_type = key_type;
+ this.value_type = value_type;
+ } else {
+ return new DictionaryType(key_type, value_type);
+ }
+};
+exports.DictionaryType = DictionaryType;
+
+
+var Interface = function(name, operations) {
+ if (this instanceof Interface) {
+
+ } else {
+ return new Interface(name, operations);
+ }
+};
+exports.Interface = Interface;
+
+
+exports.type_definitions = {};
View
24 manual_tests/example_server.py
@@ -0,0 +1,24 @@
+import sys, traceback, Ice
+
+status = 0
+ic = None
+try:
+ ic = Ice.initialize(sys.argv)
+ adapter = ic.createObjectAdapterWithEndpoints("xxx", "default -p 4001")
+ # object = PrinterI()
+ # adapter.add(object, ic.stringToIdentity("SimplePrinter"))
+ adapter.activate()
+ ic.waitForShutdown()
+except:
+ traceback.print_exc()
+ status = 1
+
+if ic:
+ # Clean up
+ try:
+ ic.destroy()
+ except:
+ traceback.print_exc()
+ status = 1
+
+sys.exit(status)
View
1  manual_tests/printer.ice
@@ -1,6 +1,5 @@
module Demo {
interface Printer {
- ["ami"]
void printString(string s);
};
};
View
18 manual_tests/two_requests.py
@@ -9,15 +9,17 @@
ic = Ice.initialize();
proxy = ic.stringToProxy('X:tcp -h localhost -p 4001');
-class callbacky:
- def ice_response(self):
- print "Got answer!"
- def ice_exception(self, e):
- print "Got " + str(e)
+# class callbacky:
+# def ice_response(self):
+# print "Got answer!"
+# def ice_exception(self, e):
+# print "Got " + str(e)
-printer = Demo.PrinterPrx.uncheckedCast(proxy, "abc")
-printer.printString_async(callbacky(), "Blah!")
+printer = Demo.PrinterPrx.checkedCast(proxy)
+printer.printString("Blah!")
+print "Finished operation 1!"
import time
time.sleep(0.1)
-printer.printString_async(callbacky(), "Blah a second time!")
+printer.printString("Blah a second time!")
+print "Finished operation 2!"
View
5 package.json
@@ -5,7 +5,10 @@
"author" : "Andres Jaan Tack <andres.jaan.tack@eesti.ee>",
"dependencies" : {
"binary" : "0.3.0",
- "jison" : "0.3.x"
+ "buffers" : "0.1.x",
+ "jison" : "0.3.x",
+ "underscore" : "1.3.x"
},
+ "main": "./index.js",
"license" : "MIT"
}
View
2  printer.ice
@@ -1,6 +1,6 @@
module Demo {
interface Printer {
- ["ami"]
void printString(string s);
+ bool ice_isA(string typeID);
};
};
Please sign in to comment.
Something went wrong with that request. Please try again.