Christian Krebs avatar Christian Krebs committed 56e0d3a

Fixed missing enums.

Comments (0)

Files changed (1)

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

 ${(indent_level)*indent}${local_comments[2]}\
 </%def>\
   ## ************************************************************** ##
+  ## def print_enum
+  ## ************************************************************** ##
+<%def name="print_enum(enum)">\
+    % if enum.doc:
+${print_doc(enum.doc, 0, INDENT)}
+    % endif
+cls.${service.name}["${version}"].${".".join(enum.path())} =
+{
+    % for value in enum.values:
+      % if value.doc:
+${print_doc(value.doc, 1, INDENT)}
+      % endif
+${INDENT}${value.value}: "${value.name}",
+    % endfor
+};
+  % for value in enum.values:
+    % if value.doc:
+${print_doc(value.doc, 0, INDENT)}
+    % endif
+cls.${service.name}["${version}"].${".".join(enum.path())}.${value.name} = ${value.value};
+  % endfor
+</%def>\
+  ## ************************************************************** ##
   ## def message_class
   ## ************************************************************** ##
 <%def name="message_class(message, submessages=None)">\
 ${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}// cls.${service.name}["${version}"].${".".join(field.message.path())}
       % endif
 ${INDENT}this.${field.name} = arr[${str(field.number - 1)}];
     % endif
   % endfor
 };
 % if message.enums:
-  % for enum in message.enums:
-    % if enum.doc:
-${print_doc(enum.doc, 0, INDENT)}
-    % endif
-cls.${service.name}["${version}"].${message.name}.${enum.name} =
-{
-    % for value in enum.values:
-      % if value.doc:
-${print_doc(value.doc, 1, INDENT)}
-      % endif
-${INDENT}${value.value}: "${value.name}",
-    % endfor
-};
+  % for enum in message.enums: 
+${print_enum(enum)}
   % endfor
 % endif
+% for field in message.fields:
+  % if field.message and isinstance(field.message, proto.Enum) and not field.message in message.enums:
+${print_enum(field.message)}
+  % endif
+% endfor
 </%def>\
   ## ************************************************************** ##
   ## template
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.