ソースを参照

[cpp] Move some enum logic to cpp/EnumBase.h

hughsando 9 年 前
コミット
574cb29269
4 ファイル変更109 行追加48 行削除
  1. 71 34
      gencpp.ml
  2. 25 0
      std/cpp/EnumBase.hx
  3. 6 4
      std/cpp/_std/Type.hx
  4. 7 10
      std/haxe/Serializer.hx

+ 71 - 34
gencpp.ml

@@ -229,7 +229,7 @@ let new_context common_ctx writer debug file_info =
    ctx_cppast = Common.defined_value_safe common_ctx Define.CppAst <>"";
    ctx_cppast = Common.defined_value_safe common_ctx Define.CppAst <>"";
    ctx_calling = false;
    ctx_calling = false;
    ctx_assigning = false;
    ctx_assigning = false;
-   ctx_debug_level = debug;
+   ctx_debug_level = 2;
    ctx_dump_src_pos = (fun() -> ());
    ctx_dump_src_pos = (fun() -> ());
    ctx_return_from_block = false;
    ctx_return_from_block = false;
    ctx_tcall_expand_args = false;
    ctx_tcall_expand_args = false;
@@ -1656,6 +1656,7 @@ and tcppvarloc =
    | VarInstance of tcppexpr * tclass_field * string
    | VarInstance of tcppexpr * tclass_field * string
    | VarInterface of tcppexpr * tclass_field
    | VarInterface of tcppexpr * tclass_field
    | VarStatic of tclass * tclass_field
    | VarStatic of tclass * tclass_field
+   | VarInternal of tcppexpr * string * string
 
 
 and tcppfuncloc =
 and tcppfuncloc =
    | FuncThis of tclass_field
    | FuncThis of tclass_field
@@ -1682,6 +1683,7 @@ and tcpplvalue =
    | CppVarRef of tcppvarloc
    | CppVarRef of tcppvarloc
    | CppArrayRef of tcpparrayloc
    | CppArrayRef of tcpparrayloc
    | CppDynamicRef of tcppexpr * string
    | CppDynamicRef of tcppexpr * string
+   | CppGlobalRef of string
 
 
 
 
 and tcpp_expr_expr =
 and tcpp_expr_expr =
@@ -1695,6 +1697,7 @@ and tcpp_expr_expr =
    | CppCode of string * tcppexpr list
    | CppCode of string * tcppexpr list
    | CppClosure of tcpp_closure
    | CppClosure of tcpp_closure
    | CppVar of tcppvarloc
    | CppVar of tcppvarloc
+   | CppGlobal of string
    | CppDynamicField of tcppexpr * string
    | CppDynamicField of tcppexpr * string
    | CppFunction of tcppfuncloc * tcpp
    | CppFunction of tcppfuncloc * tcpp
    | CppEnumIndex of tcppexpr
    | CppEnumIndex of tcppexpr
@@ -1724,8 +1727,8 @@ and tcpp_expr_expr =
    | CppReturn of tcppexpr option
    | CppReturn of tcppexpr option
    | CppThrow of tcppexpr
    | CppThrow of tcppexpr
    | CppEnumParameter of tcppexpr * tenum_field * int
    | CppEnumParameter of tcppexpr * tenum_field * int
-   | CppCastDynamic of tcppexpr * tcpp
-   | CppCastInstance of tcppexpr * tclass
+   | CppTCast of tcppexpr * tcpp
+   | CppCast of tcppexpr * tcpp
    | CppCastScalar of tcppexpr * string
    | CppCastScalar of tcppexpr * string
    | CppCastVariant of tcppexpr
    | CppCastVariant of tcppexpr
    | CppCastObjC of tcppexpr * tclass
    | CppCastObjC of tcppexpr * tclass
@@ -1747,7 +1750,9 @@ let s_tcpp = function
    | CppVar VarInstance(expr,field,clazz) -> "CppVarInstance(" ^ clazz ^ "::" ^field.cf_name ^ ")"
    | CppVar VarInstance(expr,field,clazz) -> "CppVarInstance(" ^ clazz ^ "::" ^field.cf_name ^ ")"
    | CppVar VarInterface(_) -> "CppVarInterface"
    | CppVar VarInterface(_) -> "CppVarInterface"
    | CppVar VarStatic(_) -> "CppVarStatic"
    | CppVar VarStatic(_) -> "CppVarStatic"
+   | CppVar VarInternal(_) -> "CppVarInternal"
    | CppDynamicField _ -> "CppDynamicField"
    | CppDynamicField _ -> "CppDynamicField"
+   | CppGlobal _ -> "CppGlobal"
    | CppFunction _ -> "CppFunction"
    | CppFunction _ -> "CppFunction"
    | CppEnumIndex _ -> "CppEnumIndex"
    | CppEnumIndex _ -> "CppEnumIndex"
    | CppEnumField  _ -> "CppEnumField"
    | CppEnumField  _ -> "CppEnumField"
@@ -1789,8 +1794,8 @@ let s_tcpp = function
    | CppReturn _ -> "CppReturn"
    | CppReturn _ -> "CppReturn"
    | CppThrow _ -> "CppThrow"
    | CppThrow _ -> "CppThrow"
    | CppEnumParameter _ -> "CppEnumParameter"
    | CppEnumParameter _ -> "CppEnumParameter"
-   | CppCastDynamic _ -> "CppCastDynamic"
-   | CppCastInstance _ -> "CppCastInstance"
+   | CppTCast _ -> "CppTCast"
+   | CppCast _ -> "CppCast"
    | CppCastScalar _ -> "CppCastScalar"
    | CppCastScalar _ -> "CppCastScalar"
    | CppCastVariant _ -> "CppCastVariant"
    | CppCastVariant _ -> "CppCastVariant"
    | CppCastObjC _ -> "CppCastObjC"
    | CppCastObjC _ -> "CppCastObjC"
@@ -2105,10 +2110,13 @@ let rec cpp_object_name = function
 *)
 *)
 
 
 let cpp_class_name klass =
 let cpp_class_name klass =
+   (*
    let rename = get_meta_string klass.cl_meta Meta.Native in
    let rename = get_meta_string klass.cl_meta Meta.Native in
    if rename <> "" then
    if rename <> "" then
       rename ^ "_obj"
       rename ^ "_obj"
-   else begin
+   else
+   *)
+   begin
       let path = "::" ^ (join_class_path_remap klass.cl_path "::") in
       let path = "::" ^ (join_class_path_remap klass.cl_path "::") in
       if path="::String" then path else path ^ "_obj"
       if path="::String" then path else path ^ "_obj"
    end
    end
@@ -2214,10 +2222,11 @@ let retype_expression ctx request_type function_args expression_tree =
       | CppVar varloc -> CppVarRef(varloc)
       | CppVar varloc -> CppVarRef(varloc)
       | CppArray arrayloc -> CppArrayRef(arrayloc)
       | CppArray arrayloc -> CppArrayRef(arrayloc)
       | CppDynamicField(expr, name) -> CppDynamicRef(expr,name)
       | CppDynamicField(expr, name) -> CppDynamicRef(expr,name)
-      | CppCastDynamic(cppExpr,_)
-      | CppCastInstance(cppExpr,_)
+      | CppTCast(cppExpr,_)
+      | CppCast(cppExpr,_)
       | CppCastScalar(cppExpr,_) -> to_lvalue cppExpr
       | CppCastScalar(cppExpr,_) -> to_lvalue cppExpr
       | CppCastVariant(cppExpr) -> to_lvalue cppExpr
       | CppCastVariant(cppExpr) -> to_lvalue cppExpr
+      | CppGlobal(name) -> CppGlobalRef(name)
       | _ -> error ("Could not convert expression to l-value (" ^ s_tcpp value.cppexpr ^ ")") value.cpppos
       | _ -> error ("Could not convert expression to l-value (" ^ s_tcpp value.cppexpr ^ ")") value.cpppos
    in
    in
 
 
@@ -2337,8 +2346,8 @@ let retype_expression ctx request_type function_args expression_tree =
             | FClosure (None,field)
             | FClosure (None,field)
             | FAnon field ->
             | FAnon field ->
                let obj = retype TCppDynamic obj in
                let obj = retype TCppDynamic obj in
-               if (obj.cpptype=TCppGlobal) then
-                  CppDynamicField(obj, field.cf_name), TCppPrivate
+               if obj.cpptype=TCppGlobal then
+                  CppGlobal(field.cf_name), cpp_type_of expr.etype
                else
                else
                   CppDynamicField(obj, field.cf_name), TCppVariant
                   CppDynamicField(obj, field.cf_name), TCppVariant
 
 
@@ -2346,15 +2355,20 @@ let retype_expression ctx request_type function_args expression_tree =
                let obj = retype TCppDynamic obj in
                let obj = retype TCppDynamic obj in
                if fieldName="cca" && obj.cpptype=TCppString then
                if fieldName="cca" && obj.cpptype=TCppString then
                   CppFunction( FuncInternal(obj,"cca","."), TCppScalar("Int")), TCppDynamic
                   CppFunction( FuncInternal(obj,"cca","."), TCppScalar("Int")), TCppDynamic
+               else if fieldName="__s" && obj.cpptype=TCppString then
+                  CppVar( VarInternal(obj,".","__s")), TCppPointer("ConstPointer", TCppScalar("char"))
                else if fieldName="__Index" then
                else if fieldName="__Index" then
                   CppEnumIndex(obj), TCppScalar("Int")
                   CppEnumIndex(obj), TCppScalar("Int")
                (*else if fieldName="__Tag" then
                (*else if fieldName="__Tag" then
                   CppFunction( FuncInternal(obj,"getTag","->"), TCppString), TCppString*)
                   CppFunction( FuncInternal(obj,"getTag","->"), TCppString), TCppString*)
                else if is_internal_member fieldName then begin
                else if is_internal_member fieldName then begin
                   let cppType = cpp_type_of expr.etype in
                   let cppType = cpp_type_of expr.etype in
-                  CppFunction( FuncInternal(obj,fieldName,"->"), cppType), cppType
+                  if obj.cpptype=TCppString then
+                     CppFunction( FuncInternal(obj,fieldName,"."), cppType), cppType
+                  else
+                     CppFunction( FuncInternal(obj,fieldName,"->"), cppType), cppType
                end else if (obj.cpptype=TCppGlobal) then
                end else if (obj.cpptype=TCppGlobal) then
-                  CppDynamicField(obj, fieldName), TCppVariant
+                  CppGlobal(fieldName), cpp_type_of expr.etype
                else
                else
                   CppDynamicField(obj, fieldName), TCppVariant
                   CppDynamicField(obj, fieldName), TCppVariant
 
 
@@ -2415,6 +2429,8 @@ let retype_expression ctx request_type function_args expression_tree =
                   | _ -> (* not special *)
                   | _ -> (* not special *)
                      CppCall( FuncDynamic(retypedFunc), retypedArgs), TCppDynamic
                      CppCall( FuncDynamic(retypedFunc), retypedArgs), TCppDynamic
                   )
                   )
+            |  CppGlobal(_) ->
+                  CppCall( FuncDynamic(retypedFunc) ,retypedArgs), cppType
             | _ ->
             | _ ->
                CppCall( FuncDynamic(retypedFunc), retypedArgs), TCppDynamic
                CppCall( FuncDynamic(retypedFunc), retypedArgs), TCppDynamic
             )
             )
@@ -2612,16 +2628,18 @@ let retype_expression ctx request_type function_args expression_tree =
             CppReturn(match eo with None -> None | Some e -> Some (retype (cpp_type_of e.etype) e)), TCppVoid
             CppReturn(match eo with None -> None | Some e -> Some (retype (cpp_type_of e.etype) e)), TCppVoid
          | TCast (base,None) -> (* Use auto-cast rules *)
          | TCast (base,None) -> (* Use auto-cast rules *)
             let baseCpp = retype (return_type) base in
             let baseCpp = retype (return_type) base in
-            (match baseCpp.cpptype, return_type with
-            | _, TCppInst(k) -> CppCastInstance(baseCpp,k), return_type
-            | _,_ -> baseCpp.cppexpr, baseCpp.cpptype (* use autocasting rules *)
+            (match return_type with
+            | TCppInst(k) -> CppCast(baseCpp,return_type), return_type
+            | TCppNativePointer(klass) -> CppCastNative(baseCpp), return_type
+            | _ -> baseCpp.cppexpr, baseCpp.cpptype (* use autocasting rules *)
             )
             )
 
 
          | TCast (base,Some t) ->
          | TCast (base,Some t) ->
             let baseCpp = retype (cpp_type_of base.etype) base in
             let baseCpp = retype (cpp_type_of base.etype) base in
-            (match baseCpp.cpptype, return_type with
-            | _, TCppNativePointer(klass) -> CppCastNative(baseCpp), return_type
-            | _,_ -> baseCpp.cppexpr, baseCpp.cpptype (* use autocasting rules *)
+            (match return_type with
+            | TCppNativePointer(klass) -> CppCastNative(baseCpp), return_type
+            | TCppVoid -> baseCpp.cppexpr, TCppVoid
+            | _ -> CppTCast(baseCpp, return_type), return_type
             )
             )
       in
       in
       let mk_cppexpr newExpr newType = { cppexpr = newExpr; cpptype = newType; cpppos = expr.epos } in
       let mk_cppexpr newExpr newType = { cppexpr = newExpr; cpptype = newType; cpppos = expr.epos } in
@@ -2647,10 +2665,8 @@ let retype_expression ctx request_type function_args expression_tree =
          | TCppObjC _
          | TCppObjC _
          | TCppNativePointer _
          | TCppNativePointer _
          | TCppDynamicArray
          | TCppDynamicArray
-             -> mk_cppexpr (CppCastDynamic(cppExpr,return_type)) return_type
-
-         | TCppInst klass
-             -> mk_cppexpr (CppCastInstance(cppExpr,klass)) return_type
+         | TCppInst _
+             -> mk_cppexpr (CppCast(cppExpr,return_type)) return_type
 
 
          | TCppScalar(scalar)
          | TCppScalar(scalar)
              -> mk_cppexpr (CppCastScalar(cppExpr,scalar)) return_type
              -> mk_cppexpr (CppCastScalar(cppExpr,scalar)) return_type
@@ -2806,7 +2822,7 @@ let gen_cpp_ast_expression_tree ctx class_name func_name function_args injection
          (match init with Some init -> out " = "; gen init | _ -> () )
          (match init with Some init -> out " = "; gen init | _ -> () )
       | CppEnumIndex(obj) ->
       | CppEnumIndex(obj) ->
          gen obj;
          gen obj;
-         if cpp_is_dynamic_type obj.cpptype then
+         (*if cpp_is_dynamic_type obj.cpptype then*)
             out ".StaticCast< ::hx::EnumBase >()";
             out ".StaticCast< ::hx::EnumBase >()";
          out "->getIndex()"
          out "->getIndex()"
 
 
@@ -2890,6 +2906,9 @@ let gen_cpp_ast_expression_tree ctx class_name func_name function_args injection
          out ("&::" ^(join_class_path_remap klass.cl_path "::")^ "_obj::" ^ name );
          out ("&::" ^(join_class_path_remap klass.cl_path "::")^ "_obj::" ^ name );
          out " )"
          out " )"
 
 
+      | CppGlobal(name) ->
+         out ("::" ^ name)
+
       | CppDynamicField(obj,name) ->
       | CppDynamicField(obj,name) ->
          gen obj;
          gen obj;
          out ("->__Field(" ^ (strq name)  ^ ",hx::paccDynamic)");
          out ("->__Field(" ^ (strq name)  ^ ",hx::paccDynamic)");
@@ -2934,6 +2953,7 @@ let gen_cpp_ast_expression_tree ctx class_name func_name function_args injection
             )
             )
          | CppDynamicRef(expr,name) ->
          | CppDynamicRef(expr,name) ->
             gen expr; out ("->__SetField(" ^ (strq name) ^ ","); gen rvalue; out ",hx::paccDynamic)"
             gen expr; out ("->__SetField(" ^ (strq name) ^ ","); gen rvalue; out ",hx::paccDynamic)"
+         | CppGlobalRef(name) -> out ("::" ^ name ^ " = ");
          )
          )
 
 
       | CppCrement(incFlag,preFlag, lvalue) ->
       | CppCrement(incFlag,preFlag, lvalue) ->
@@ -3162,11 +3182,11 @@ let gen_cpp_ast_expression_tree ctx class_name func_name function_args injection
 
 
       | CppCode(value, exprs) ->
       | CppCode(value, exprs) ->
          Codegen.interpolate_code ctx.ctx_common (format_code value) exprs out (fun e -> gen e) expr.cpppos
          Codegen.interpolate_code ctx.ctx_common (format_code value) exprs out (fun e -> gen e) expr.cpppos
-      | CppCastDynamic(expr,cppType) ->
+      | CppTCast(expr,cppType) ->
          out ("hx::TCast< " ^ tcpp_to_string cppType ^ " >::cast("); gen expr; out ")"
          out ("hx::TCast< " ^ tcpp_to_string cppType ^ " >::cast("); gen expr; out ")"
 
 
-      | CppCastInstance(expr,klass) ->
-         out ("( ("^ cpp_class_path_of klass ^")("); gen expr; out (") )");
+      | CppCast(expr,toType) ->
+         out ("( ("^ tcpp_to_string toType ^")("); gen expr; out (") )");
 
 
       | CppCastScalar(expr,scalar) ->
       | CppCastScalar(expr,scalar) ->
          out ("( ("^scalar^")("); gen expr; out (") )");
          out ("( ("^scalar^")("); gen expr; out (") )");
@@ -3200,6 +3220,7 @@ let gen_cpp_ast_expression_tree ctx class_name func_name function_args injection
          | ArrayImplements(_,arrayObj,index) ->
          | ArrayImplements(_,arrayObj,index) ->
             out "hx::__ArrayImplRef("; gen arrayObj; out ","; gen index; out ")";
             out "hx::__ArrayImplRef("; gen arrayObj; out ","; gen index; out ")";
          )
          )
+      | CppGlobalRef(name) -> out ("::" ^ name)
       | CppDynamicRef(expr,name) ->
       | CppDynamicRef(expr,name) ->
          let objPtr = match expr.cpptype with
          let objPtr = match expr.cpptype with
          |  TCppVariant -> "getObject()"
          |  TCppVariant -> "getObject()"
@@ -3216,6 +3237,8 @@ let gen_cpp_ast_expression_tree ctx class_name func_name function_args injection
       | VarInstance(obj,member,_) ->
       | VarInstance(obj,member,_) ->
          let operator = if obj.cpptype = TCppString then "." else "->" in
          let operator = if obj.cpptype = TCppString then "." else "->" in
          gen obj; out (operator ^ (cpp_member_name_of member))
          gen obj; out (operator ^ (cpp_member_name_of member))
+      | VarInternal(obj,operator,member) ->
+         gen obj; out (operator ^ member)
       | VarInterface(obj,member) ->
       | VarInterface(obj,member) ->
          gen obj; out ("->" ^ (cpp_member_name_of member) ^ "_get()" )
          gen obj; out ("->" ^ (cpp_member_name_of member) ^ "_get()" )
 
 
@@ -4381,7 +4404,7 @@ let gen_cpp_init ctx dot_name func_name var_name expr =
          hx_stack_push ctx output_i dot_name func_name expr.epos;
          hx_stack_push ctx output_i dot_name func_name expr.epos;
       end
       end
    in
    in
-   let injection = mk_injection prologue (var_name ^ " = ") "" in
+   let injection = mk_injection prologue var_name "" in
    gen_cpp_ast_expression_tree ctx dot_name func_name [] injection (mk_block expr);
    gen_cpp_ast_expression_tree ctx dot_name func_name [] injection (mk_block expr);
 ;;
 ;;
 
 
@@ -4600,7 +4623,7 @@ let gen_field_init ctx class_def field =
                   | _ -> remap_name ) in
                   | _ -> remap_name ) in
 
 
       if ctx.ctx_cppast then
       if ctx.ctx_cppast then
-         gen_cpp_init ctx dot_name "boot" var_name expr
+         gen_cpp_init ctx dot_name "boot" (var_name ^ " = ") expr
       else begin
       else begin
          let var_name = "\t" ^ var_name ^ "= " in
          let var_name = "\t" ^ var_name ^ "= " in
          ctx.ctx_dump_src_pos <- (fun () ->
          ctx.ctx_dump_src_pos <- (fun () ->
@@ -4908,7 +4931,14 @@ let generate_main common_ctx member_types super_deps class_def file_info =
       if is_main then output_main "\n#include <hx/HxcppMain.h>\n\n";
       if is_main then output_main "\n#include <hx/HxcppMain.h>\n\n";
 
 
       generate_main_footer1 output_main;
       generate_main_footer1 output_main;
-      gen_expression_tree (new_context common_ctx cpp_file 1 file_info) false [] main_expression "" ";\n";
+
+      let ctx = new_context common_ctx cpp_file 1 file_info in
+      if ctx.ctx_cppast then
+         gen_cpp_init ctx "hxcpp" "__hxcpp_main" "" main_expression
+      else
+         gen_expression_tree ctx false [] main_expression "" ";\n";
+      
+
       generate_main_footer2 output_main;
       generate_main_footer2 output_main;
       cpp_file#close;
       cpp_file#close;
    in
    in
@@ -5175,7 +5205,7 @@ let generate_enum_files common_ctx enum_def super_deps meta file_info =
       | Some expr ->
       | Some expr ->
          let ctx = new_context common_ctx cpp_file 1 file_info in
          let ctx = new_context common_ctx cpp_file 1 file_info in
          if ctx.ctx_cppast then
          if ctx.ctx_cppast then
-            gen_cpp_init ctx class_name "boot" "__mClass->__meta__" expr
+            gen_cpp_init ctx class_name "boot" "__mClass->__meta__ = " expr
          else
          else
             gen_expression_tree ctx true [] expr  "__mClass->__meta__ = " ";\n";
             gen_expression_tree ctx true [] expr  "__mClass->__meta__ = " ";\n";
       | _ -> () );
       | _ -> () );
@@ -5537,10 +5567,17 @@ let generate_class_files common_ctx member_types super_deps constructor_deps cla
 
 
    (match class_def.cl_init with
    (match class_def.cl_init with
    | Some expression ->
    | Some expression ->
-      output_cpp ("void " ^ class_name^ "::__init__() {\n");
-      hx_stack_push ctx output_cpp dot_name "__init__" expression.epos;
-      gen_expression_tree (new_context common_ctx cpp_file debug file_info) false [] (mk_block expression) "" "";
-      output_cpp "}\n\n";
+      let ctx = new_context common_ctx cpp_file debug file_info in
+      output_cpp ("void " ^ class_name^ "::__init__()");
+      if ctx.ctx_cppast then
+         gen_cpp_init ctx (cpp_class_name class_def) "__init__" "" (mk_block expression)
+      else begin
+         output_cpp " {\n";
+         hx_stack_push ctx output_cpp dot_name "__init__" expression.epos;
+         gen_expression_tree (new_context common_ctx cpp_file debug file_info) false [] (mk_block expression) "" "";
+         output_cpp "}";
+      end;
+      output_cpp "\n\n";
    | _ -> ());
    | _ -> ());
 
 
    let statics_except_meta = statics_except_meta class_def in
    let statics_except_meta = statics_except_meta class_def in

+ 25 - 0
std/cpp/EnumBase.hx

@@ -0,0 +1,25 @@
+package cpp;
+
+@:native("::hx::EnumBase")
+extern class EnumBase
+{
+   #if (hxcpp_api_level >= 330)
+   public function getIndex():Int;
+   public function getTag():String;
+   public function getParamCount():Int;
+   public function getParamI(inIndex:Int):Dynamic;
+   public function getParameters():Array<Dynamic>;
+   #else
+   public function __EnumParams():Array<Dynamic>;
+   public function __Tag():String;
+   public function __Index():Int;
+
+   inline public function getIndex():Int  return untyped __Index();
+   inline public function getTag():String  return untyped __Tag();
+   inline public function getParamCount():Int return untyped __EnumParams()==null ? 0 : __EnumParams().length;
+   inline public function getParamI(inIndex:Int):Dynamic return untyped __EnumParams()[inIndex];
+   inline public function getParameters():Array<Dynamic> return __EnumParams()==null ? [] : __EnumParams();
+
+   #end
+}
+

+ 6 - 4
std/cpp/_std/Type.hx

@@ -130,16 +130,18 @@ enum ValueType {
 	}
 	}
 
 
 	public static function enumConstructor( e : EnumValue ) : String {
 	public static function enumConstructor( e : EnumValue ) : String {
-			return untyped e.__Tag();
+			var value:cpp.EnumBase = cast e;
+			return value.getTag();
 	}
 	}
 
 
 	public static function enumParameters( e : EnumValue ) : Array<Dynamic> {
 	public static function enumParameters( e : EnumValue ) : Array<Dynamic> {
-			var result : Array<Dynamic> =  untyped e.__EnumParams();
-			return result==null ? [] : result;
+			var value:cpp.EnumBase = cast e;
+			return value.getParameters();
 	}
 	}
 
 
 	public inline static function enumIndex( e : EnumValue ) : Int {
 	public inline static function enumIndex( e : EnumValue ) : Int {
-			return untyped e.__Index();
+			var value:cpp.EnumBase = cast e;
+			return value.getIndex();
 	}
 	}
 
 
 	public static function allEnums<T>( e : Enum<T> ) : Array<T> {
 	public static function allEnums<T>( e : Enum<T> ) : Array<T> {

+ 7 - 10
std/haxe/Serializer.hx

@@ -453,20 +453,17 @@ class Serializer {
 					serialize(p);
 					serialize(p);
 			}
 			}
 			#elseif cpp
 			#elseif cpp
+			var enumBase:cpp.EnumBase = v;
 			if( useEnumIndex ) {
 			if( useEnumIndex ) {
 				buf.add(":");
 				buf.add(":");
-				buf.add(v.__Index());
+				buf.add(enumBase.getIndex());
 			} else
 			} else
-				serializeString(v.__Tag());
+				serializeString(enumBase.getTag());
 			buf.add(":");
 			buf.add(":");
-			var pl : Array<Dynamic> = v.__EnumParams();
-			if( pl == null )
-				buf.add(0);
-			else {
-				buf.add(pl.length);
-				for( p in pl )
-					serialize(p);
-			}
+			var len = enumBase.getParamCount();
+			buf.add(len);
+			for( p in 0...len )
+				serialize( enumBase.getParamI(p));
 			#elseif php
 			#elseif php
 			if( useEnumIndex ) {
 			if( useEnumIndex ) {
 				buf.add(":");
 				buf.add(":");