Browse Source

Lua: Generate enum __construct___ with std arrays

Justin Donaldson 9 years ago
parent
commit
ecdc4843fa
1 changed files with 8 additions and 1 deletions
  1. 8 1
      genlua.ml

+ 8 - 1
genlua.ml

@@ -1506,7 +1506,14 @@ let generate_enum ctx e =
 	    if has_feature ctx "lua.Boot.isEnum" then  begin
 		print ctx " __ename__ = %s," (if has_feature ctx "Type.getEnumName" then "{" ^ String.concat "," ename ^ "}" else "true");
 	    end;
-	    print ctx " __constructs__ = {%s} }" (String.concat "," (List.map (fun s -> Printf.sprintf "\"%s\"" s) e.e_names));
+	    (* TODO :  Come up with a helper function for __tabArray declarations *)
+	    spr ctx " __constructs__ = __tabArray({";
+	    if ((List.length e.e_names) > 0) then
+		begin
+		    spr ctx "[0]=";
+		    spr ctx (String.concat "," (List.map (fun s -> Printf.sprintf "\"%s\"" s) e.e_names));
+	    end;
+	    print ctx "},%i)}" (List.length e.e_names);
 	    ctx.separator <- true;
 	    newline ctx;
 	end;