Commits

Christian Krebs committed 344b587

Fixed an issue with primitive types in the class creation.

Comments (0)

Files changed (1)

hob/templates/js/js-message-classes.mako

   % if message.comment:
 ${INDENT}// ${message.comment}
   % endif
-cls.${service.name}["${version}"].${message.name} = function(arr, parent)
+cls.${service.name}["${version}"].${message.name} = function(arr)
 {
-  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;
+      % if field.type.name in ["message"]:
 ${INDENT}this.${field.name} = (arr[${str(field.number - 1)}] || []).map(function(item)
 ${INDENT}{
-${INDENT * 2}return new cls.${service.name}["${version}"].${field.typename()}(item, self);
+${INDENT * 2}return new cls.${service.name}["${version}"].${field.typename()}(item);
 ${INDENT}});
+      % else:
+${INDENT}this.${field.name} = arr[${str(field.number - 1)}] || [];
+      % endif
     % 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)}], this) : null;
     % else:
 ${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: