Commits

Jan Borsodi committed 0f408ab Merge

Merged in changes from runeh.

Comments (0)

Files changed (2)

            'templates/js/js-runtimes.mako',
            'templates/js/js-service-base.mako',
            'templates/js/js-service-implementation.mako',
+           'templates/js/js-message-classes.mako',
            'templates/js/js-stp-0-wrapper.mako',
            'templates/js/js-windows.mako',
            'templates/js/json.js',

templates/js/js-message-classes.mako

   % if message.comment:
 ${INDENT}// ${message.comment}
   % endif
-cls.${service.name}["${version}"].${message.name} = function(arr)
+cls.${service.name}["${version}"].${message.name} = function(arr, parent)
 {
+  this.parent = parent || null;
   % for field in message.fields:
     % if field.doc:
 ${print_doc(field.doc, 1, INDENT)}
 ${INDENT}// ${field.comment}
     % endif
     % if field.q.name == "repeated":
+${INDENT}var self = this;
 ${INDENT}this.${field.name} = (arr[${str(field.number - 1)}] || []).map(function(item)
 ${INDENT}{
-${INDENT * 2}return new cls.${service.name}["${version}"].${field.typename()}(item);
+${INDENT * 2}return new cls.${service.name}["${version}"].${field.typename()}(item, self);
 ${INDENT}});
     % elif field.message and isinstance(field.message, proto.Message):
-${INDENT}this.${field.name} = arr[${str(field.number - 1)}] ? new cls.${service.name}["${version}"].${field.typename()}(arr[${str(field.number - 1)}]) : null;
+${INDENT}this.${field.name} = arr[${str(field.number - 1)}] ? new cls.${service.name}["${version}"].${field.typename()}(arr[${str(field.number - 1)}], this) : null;
     % else:
       % if field.message and isinstance(field.message, proto.Enum):
 ${INDENT}// cls.${service.name}["${version}"].${message.name}.${field.message.name}
 ${INDENT}this.${field.name} = arr[${str(field.number - 1)}];
     % endif
   % endfor
+  this.toString = function() { return "[message ${message.name}]"; }
 };
 % if message.enums:
   % for enum in message.enums: