Browse Source

[cpp] Support type parameters on extern classes (#10415)

* Initial support of templated extern classes

* Removed some redundant code and debug output

* Ignore generic parameters when getting the class path string of a non extern class

* Restore native meta check on default match case when getting the class string

* Visit extern class parameters for references

* Use the type of the argument expressions instead of the function definition on struct classes in case of extern class type parameter
Aidan Lee 3 years ago
parent
commit
f2e23f6d27
1 changed files with 72 additions and 49 deletions
  1. 72 49
      src/generators/gencpp.ml

+ 72 - 49
src/generators/gencpp.ml

@@ -768,7 +768,10 @@ let rec class_string klass suffix params remap =
             (join_class_path_remap klass.cl_path "::") ^ " *"
             (join_class_path_remap klass.cl_path "::") ^ " *"
    (* Normal class *)
    (* Normal class *)
    | _ when is_native_class klass ->
    | _ when is_native_class klass ->
-      join_class_path_remap klass.cl_path "::"
+      let class_params = match params with
+      | [] -> ""
+      | _ -> "<" ^ (String.concat "," (List.map type_string params)) ^ ">" in
+      (join_class_path_remap klass.cl_path "::") ^ class_params
    | _ ->
    | _ ->
       let globalNamespace = if (get_meta_string klass.cl_meta Meta.Native)<>"" then "" else "::" in
       let globalNamespace = if (get_meta_string klass.cl_meta Meta.Native)<>"" then "" else "::" in
       globalNamespace ^ (join_class_path_remap klass.cl_path "::") ^ suffix
       globalNamespace ^ (join_class_path_remap klass.cl_path "::") ^ suffix
@@ -1381,7 +1384,7 @@ type tcpp =
    | TCppNativePointer of tclass
    | TCppNativePointer of tclass
    | TCppVariant
    | TCppVariant
    | TCppCode of tcpp
    | TCppCode of tcpp
-   | TCppInst of tclass
+   | TCppInst of tclass * tcpp list
    | TCppInterface of tclass
    | TCppInterface of tclass
    | TCppProtocol of tclass
    | TCppProtocol of tclass
    | TCppClass
    | TCppClass
@@ -1649,10 +1652,10 @@ and tcpp_to_string_suffix suffix tcpp = match tcpp with
           name
           name
        else
        else
           "::hx::Native< " ^ name ^ "* >";
           "::hx::Native< " ^ name ^ "* >";
-   | TCppInst klass ->
-      (cpp_class_path_of klass) ^ (if is_native_class klass then "" else suffix)
+   | TCppInst (klass, p) ->
+      (cpp_class_path_of klass p) ^ (if is_native_class klass then "" else suffix)
    | TCppInterface klass when suffix="_obj" ->
    | TCppInterface klass when suffix="_obj" ->
-        (cpp_class_path_of klass) ^ suffix
+        (cpp_class_path_of klass []) ^ suffix
    | TCppInterface _ -> "::Dynamic"
    | TCppInterface _ -> "::Dynamic"
    | TCppClass -> "::hx::Class" ^ suffix;
    | TCppClass -> "::hx::Class" ^ suffix;
    | TCppGlobal -> "::Dynamic";
    | TCppGlobal -> "::Dynamic";
@@ -1678,9 +1681,14 @@ and tcpp_objc_block_struct argTypes retType =
 and tcpp_to_string tcpp =
 and tcpp_to_string tcpp =
     tcpp_to_string_suffix "" tcpp
     tcpp_to_string_suffix "" tcpp
 
 
-and cpp_class_path_of klass =
-      let globalNamespace = if (get_meta_string klass.cl_meta Meta.Native)<>"" then " " else " ::" in
-      globalNamespace ^ (join_class_path_remap klass.cl_path "::")
+and cpp_class_path_of klass params =
+   match (get_meta_string klass.cl_meta Meta.Native)<>"" with
+   | true -> 
+      let typeParams = match params with
+      | [] -> ""
+      | _ -> "<" ^ String.concat "," (List.map tcpp_to_string params) ^ ">" in
+      (join_class_path_remap klass.cl_path "::") ^ typeParams
+   | false -> "::" ^ (join_class_path_remap klass.cl_path "::")
 ;;
 ;;
 
 
 
 
@@ -1703,7 +1711,7 @@ let is_cpp_scalar cpp_type =
 
 
 let is_cpp_array_implementer cppType =
 let is_cpp_array_implementer cppType =
    match cppType with
    match cppType with
-   | TCppInst (klass)
+   | TCppInst (klass, _)
    | TCppInterface (klass) ->
    | TCppInterface (klass) ->
       (match klass.cl_array_access with
       (match klass.cl_array_access with
       | Some _ -> true
       | Some _ -> true
@@ -1741,7 +1749,7 @@ let rec cpp_is_struct_access t =
    match t with
    match t with
    | TCppFunction _ -> true
    | TCppFunction _ -> true
    | TCppStruct _-> false
    | TCppStruct _-> false
-   | TCppInst (class_def) -> (has_meta_key class_def.cl_meta Meta.StructAccess)
+   | TCppInst (class_def, _) -> (has_meta_key class_def.cl_meta Meta.StructAccess)
    | TCppReference (r) -> cpp_is_struct_access r
    | TCppReference (r) -> cpp_is_struct_access r
    | _ -> false
    | _ -> false
 ;;
 ;;
@@ -1945,9 +1953,11 @@ let rec cpp_type_of stack ctx haxe_type =
          else if (has_class_flag klass CInterface) then
          else if (has_class_flag klass CInterface) then
             TCppInterface(klass)
             TCppInterface(klass)
          else if (has_class_flag klass CExtern) && (not (is_internal_class klass.cl_path) ) then
          else if (has_class_flag klass CExtern) && (not (is_internal_class klass.cl_path) ) then
-            TCppInst(klass)
+            let tcpp_params = List.map (cpp_type_of stack ctx) params in
+            TCppInst(klass, tcpp_params)
          else
          else
-            TCppInst(klass)
+            let tcpp_params = List.map (cpp_type_of stack ctx) params in
+            TCppInst(klass, tcpp_params)
        )
        )
 
 
 let cpp_type_of ctx = cpp_type_of [] ctx
 let cpp_type_of ctx = cpp_type_of [] ctx
@@ -2221,8 +2231,8 @@ let cpp_no_debug_synbol ctx var =
    (ctx.ctx_debug_level<=1) || (match var.v_kind with VUser _ -> false | _ -> true) ||
    (ctx.ctx_debug_level<=1) || (match var.v_kind with VUser _ -> false | _ -> true) ||
       match cpp_type_of ctx var.v_type with
       match cpp_type_of ctx var.v_type with
       | TCppStar _ | TCppReference _ -> true
       | TCppStar _ | TCppReference _ -> true
-      | TCppInst (class_def) when (has_meta_key class_def.cl_meta Meta.StructAccess) -> true
-      | TCppInst (class_def) when (has_meta_key class_def.cl_meta Meta.Unreflective) -> true
+      | TCppInst (class_def, _) when (has_meta_key class_def.cl_meta Meta.StructAccess) -> true
+      | TCppInst (class_def, _) when (has_meta_key class_def.cl_meta Meta.Unreflective) -> true
       | _->
       | _->
          let name = cpp_var_debug_name_of var in
          let name = cpp_var_debug_name_of var in
          (String.length name) >4 && (String.sub name 0 4) = "_hx_"
          (String.length name) >4 && (String.sub name 0 4) = "_hx_"
@@ -2240,7 +2250,7 @@ let cpp_debug_var_visible ctx var =
 let only_stack_access ctx haxe_type =
 let only_stack_access ctx haxe_type =
    let tcpp = cpp_type_of ctx haxe_type in
    let tcpp = cpp_type_of ctx haxe_type in
    match tcpp with
    match tcpp with
-   | TCppInst(klass) -> has_meta_key klass.cl_meta Meta.StackOnly
+   | TCppInst(klass, _) -> has_meta_key klass.cl_meta Meta.StackOnly
    | _ -> false;
    | _ -> false;
 ;;
 ;;
 
 
@@ -2262,9 +2272,9 @@ let is_array_splice_call obj member =
 let is_map_get_call obj member =
 let is_map_get_call obj member =
    member.cf_name="get" &&
    member.cf_name="get" &&
    (match obj.cpptype  with
    (match obj.cpptype  with
-   | TCppInst({cl_path=(["haxe";"ds"],"IntMap")}) -> true
-   | TCppInst({cl_path=(["haxe";"ds"],"StringMap")}) -> true
-   | TCppInst({cl_path=(["haxe";"ds"],"ObjectMap")}) -> true
+   | TCppInst({cl_path=(["haxe";"ds"],"IntMap")}, _) -> true
+   | TCppInst({cl_path=(["haxe";"ds"],"StringMap")}, _) -> true
+   | TCppInst({cl_path=(["haxe";"ds"],"ObjectMap")}, _) -> true
    | _ -> false
    | _ -> false
    )
    )
 ;;
 ;;
@@ -2272,9 +2282,9 @@ let is_map_get_call obj member =
 let is_map_set_call obj member =
 let is_map_set_call obj member =
    member.cf_name="set" &&
    member.cf_name="set" &&
    (match obj.cpptype  with
    (match obj.cpptype  with
-   | TCppInst({cl_path=(["haxe";"ds"],"IntMap")}) -> true
-   | TCppInst({cl_path=(["haxe";"ds"],"StringMap")}) -> true
-   | TCppInst({cl_path=(["haxe";"ds"],"ObjectMap")}) -> true
+   | TCppInst({cl_path=(["haxe";"ds"],"IntMap")}, _) -> true
+   | TCppInst({cl_path=(["haxe";"ds"],"StringMap")}, _) -> true
+   | TCppInst({cl_path=(["haxe";"ds"],"ObjectMap")}, _) -> true
    | _ -> false
    | _ -> false
    )
    )
 ;;
 ;;
@@ -2349,7 +2359,7 @@ let cpp_enum_name_of field =
 
 
 let is_object_element ctx member_type =
 let is_object_element ctx member_type =
   match member_type with
   match member_type with
-   | TCppInst x
+   | TCppInst (x, _)
    | TCppInterface x
    | TCppInterface x
        -> not (is_extern_class x)
        -> not (is_extern_class x)
    | TCppDynamic
    | TCppDynamic
@@ -2795,6 +2805,17 @@ let retype_expression ctx request_type function_args function_type expression_tr
                   *)
                   *)
 
 
                (* Other functions ... *)
                (* Other functions ... *)
+               | CppFunction( FuncInstance(_, InstStruct, {cf_type=TFun(arg_types,_)}) as func, return_type) ->
+                  (* For struct access classes use the types of the arguments instead of the function argument types *)
+                  (* In the case of generic extern classes a TFun arg type could be `MyClass.T` instead of the real type *)
+                  let map_args func_arg passed_arg =
+                     let (name, opt, _) = func_arg in
+                     name, opt, passed_arg.etype in
+                  let real_types = List.map2 map_args arg_types args in
+                  let arg_types = List.map (fun (_,opt,t) -> cpp_tfun_arg_type_of ctx opt t) real_types in
+                  let retypedArgs = retype_function_args args arg_types in
+                  CppCall(func,retypedArgs), return_type
+
                | CppFunction( FuncInstance(_,_,{cf_type=TFun(arg_types,_)} ) as func, returnType )
                | CppFunction( FuncInstance(_,_,{cf_type=TFun(arg_types,_)} ) as func, returnType )
                | CppFunction( FuncStatic(_,_,{cf_type=TFun(arg_types,_)} ) as func, returnType )
                | CppFunction( FuncStatic(_,_,{cf_type=TFun(arg_types,_)} ) as func, returnType )
                | CppFunction( FuncThis({cf_type=TFun(arg_types,_)},_ ) as func, returnType ) ->
                | CppFunction( FuncThis({cf_type=TFun(arg_types,_)},_ ) as func, returnType ) ->
@@ -2856,7 +2877,7 @@ let retype_expression ctx request_type function_args function_type expression_tr
             let arg_types, _ = cpp_function_type_of_args_ret ctx constructor_type in
             let arg_types, _ = cpp_function_type_of_args_ret ctx constructor_type in
             let retypedArgs = retype_function_args args arg_types in
             let retypedArgs = retype_function_args args arg_types in
             let created_type = cpp_type_of expr.etype in
             let created_type = cpp_type_of expr.etype in
-            gc_stack := !gc_stack || (match created_type with | TCppInst(t) -> not (is_native_class t) | _ -> false );
+            gc_stack := !gc_stack || (match created_type with | TCppInst(t, _) -> not (is_native_class t) | _ -> false );
             CppCall( FuncNew(created_type), retypedArgs), created_type
             CppCall( FuncNew(created_type), retypedArgs), created_type
 
 
          | TFunction func ->
          | TFunction func ->
@@ -2911,7 +2932,7 @@ let retype_expression ctx request_type function_args function_type expression_tr
                  CppArray( ArrayObject(retypedObj,retypedIdx,TCppDynamic) ), TCppDynamic
                  CppArray( ArrayObject(retypedObj,retypedIdx,TCppDynamic) ), TCppDynamic
               | TCppObjectArray elem ->
               | TCppObjectArray elem ->
                  CppArray( ArrayObject(retypedObj,retypedIdx,elem) ), elem
                  CppArray( ArrayObject(retypedObj,retypedIdx,elem) ), elem
-              | TCppInst({cl_array_access = Some _ } as klass) ->
+              | TCppInst({cl_array_access = Some _ } as klass, _) ->
                  CppArray( ArrayImplements(klass, retypedObj,retypedIdx) ), cpp_type_of expr.etype
                  CppArray( ArrayImplements(klass, retypedObj,retypedIdx) ), cpp_type_of expr.etype
               | TCppDynamicArray ->
               | TCppDynamicArray ->
                  CppArray( ArrayVirtual(retypedObj, retypedIdx) ), TCppDynamic
                  CppArray( ArrayVirtual(retypedObj, retypedIdx) ), TCppDynamic
@@ -3190,10 +3211,10 @@ let retype_expression ctx request_type function_args function_type expression_tr
       end else if (cppExpr.cpptype=TCppVariant || cppExpr.cpptype=TCppDynamic || cppExpr.cpptype==TCppObject) then begin
       end else if (cppExpr.cpptype=TCppVariant || cppExpr.cpptype=TCppDynamic || cppExpr.cpptype==TCppObject) then begin
          match return_type with
          match return_type with
          | TCppUnchanged -> cppExpr
          | TCppUnchanged -> cppExpr
-         | TCppInst(t) when (has_meta_key t.cl_meta Meta.StructAccess) ->
-             let structType = TCppStruct( TCppInst(t) ) in
+         | TCppInst(t, _) when (has_meta_key t.cl_meta Meta.StructAccess) ->
+             let structType = TCppStruct( TCppInst(t, []) ) in
              let structCast =  mk_cppexpr (CppCast(cppExpr,structType)) structType in
              let structCast =  mk_cppexpr (CppCast(cppExpr,structType)) structType in
-             mk_cppexpr (CppCast(structCast,(TCppInst t))) (TCppInst t)
+             mk_cppexpr (CppCast(structCast,(TCppInst (t, [])))) (TCppInst (t, []))
 
 
          | TCppObjectArray _
          | TCppObjectArray _
          | TCppScalarArray _
          | TCppScalarArray _
@@ -3281,7 +3302,7 @@ let retype_expression ctx request_type function_args function_type expression_tr
          | TCppStar(t,const), TCppStruct _ ->
          | TCppStar(t,const), TCppStruct _ ->
              mk_cppexpr (CppDereference(cppExpr)) return_type
              mk_cppexpr (CppDereference(cppExpr)) return_type
 
 
-         | TCppInst(t), TCppStar _ when (is_native_class t) && (match cppExpr.cppexpr with
+         | TCppInst(t, _), TCppStar _ when (is_native_class t) && (match cppExpr.cppexpr with
             | CppCall(FuncNew(_), _) -> true
             | CppCall(FuncNew(_), _) -> true
             | _ -> false) ->
             | _ -> false) ->
             mk_cppexpr (CppNewNative(cppExpr)) return_type
             mk_cppexpr (CppNewNative(cppExpr)) return_type
@@ -3298,8 +3319,8 @@ let retype_expression ctx request_type function_args function_type expression_tr
          | t, TCppProtocol protocol ->
          | t, TCppProtocol protocol ->
               mk_cppexpr (CppCastProtocol(cppExpr,protocol)) return_type
               mk_cppexpr (CppCastProtocol(cppExpr,protocol)) return_type
 
 
-         | TCppInst(t), TCppDynamic when (has_meta_key t.cl_meta Meta.StructAccess) ->
-             let structType = TCppStruct( TCppInst(t) ) in
+         | TCppInst(t, _), TCppDynamic when (has_meta_key t.cl_meta Meta.StructAccess) ->
+             let structType = TCppStruct( TCppInst(t, []) ) in
              let structCast =  mk_cppexpr (CppCast(cppExpr,structType)) structType in
              let structCast =  mk_cppexpr (CppCast(cppExpr,structType)) structType in
              mk_cppexpr (CppCast(structCast,TCppDynamic)) TCppDynamic
              mk_cppexpr (CppCast(structCast,TCppDynamic)) TCppDynamic
 
 
@@ -3595,8 +3616,8 @@ let gen_cpp_ast_expression_tree ctx class_name func_name function_args function_
            expr.cpppos);
            expr.cpppos);
          out " ]"
          out " ]"
 
 
-      | CppCall(FuncNew( TCppInst klass), args) when can_quick_alloc klass ->
-         out ((cpp_class_path_of klass) ^ "_obj::__alloc( HX_CTX ");
+      | CppCall(FuncNew( TCppInst (klass, p)), args) when can_quick_alloc klass ->
+         out ((cpp_class_path_of klass p) ^ "_obj::__alloc( HX_CTX ");
          List.iter (fun arg -> out ","; gen arg ) args;
          List.iter (fun arg -> out ","; gen arg ) args;
          out (")")
          out (")")
 
 
@@ -3650,14 +3671,14 @@ let gen_cpp_ast_expression_tree ctx class_name func_name function_args function_
          | FuncEnumConstruct(enum,field) ->
          | FuncEnumConstruct(enum,field) ->
             out ((string_of_path enum.e_path) ^ "::" ^ (cpp_enum_name_of field));
             out ((string_of_path enum.e_path) ^ "::" ^ (cpp_enum_name_of field));
 
 
-         | FuncSuperConstruct(TCppInst klass) when is_native_class klass ->
+         | FuncSuperConstruct(TCppInst (klass, _)) when is_native_class klass ->
             doCall := false;
             doCall := false;
 
 
          | FuncSuperConstruct _ ->
          | FuncSuperConstruct _ ->
             out ((if not ctx.ctx_real_this_ptr then "__this->" else "") ^  "super::__construct")
             out ((if not ctx.ctx_real_this_ptr then "__this->" else "") ^  "super::__construct")
 
 
-         | FuncSuper(_,TCppInst(klass),field) when is_native_class klass ->
-            out ((cpp_class_path_of klass) ^ "::" ^ (cpp_member_name_of field));
+         | FuncSuper(_,TCppInst(klass, p),field) when is_native_class klass ->
+            out ((cpp_class_path_of klass p) ^ "::" ^ (cpp_member_name_of field));
 
 
          | FuncSuper(this,_,field) ->
          | FuncSuper(this,_,field) ->
             out ( (if this==ThisReal then "this->" else "__->") ^ "super::" ^ (cpp_member_name_of field) )
             out ( (if this==ThisReal then "this->" else "__->") ^ "super::" ^ (cpp_member_name_of field) )
@@ -3668,10 +3689,10 @@ let gen_cpp_ast_expression_tree ctx class_name func_name function_args function_
             | TCppDynamicArray -> "::cpp::VirtualArray_obj::__new"
             | TCppDynamicArray -> "::cpp::VirtualArray_obj::__new"
             | TCppObjectArray _ -> "::Array_obj< ::Dynamic>::__new"
             | TCppObjectArray _ -> "::Array_obj< ::Dynamic>::__new"
             | TCppScalarArray(value) -> "::Array_obj< " ^ (tcpp_to_string value) ^ " >::__new"
             | TCppScalarArray(value) -> "::Array_obj< " ^ (tcpp_to_string value) ^ " >::__new"
-            | TCppObjC klass ->  (cpp_class_path_of klass) ^ "_obj::__new"
-            | TCppNativePointer klass -> "new " ^ (cpp_class_path_of klass);
-            | TCppInst klass when is_native_class klass -> cpp_class_path_of klass
-            | TCppInst klass -> (cpp_class_path_of klass) ^ "_obj::__new"
+            | TCppObjC klass ->  (cpp_class_path_of klass []) ^ "_obj::__new"
+            | TCppNativePointer klass -> "new " ^ (cpp_class_path_of klass []);
+            | TCppInst (klass, p) when is_native_class klass -> cpp_class_path_of klass p
+            | TCppInst (klass, p) -> (cpp_class_path_of klass p) ^ "_obj::__new"
             | TCppClass -> "::hx::Class_obj::__new";
             | TCppClass -> "::hx::Class_obj::__new";
             | TCppFunction _ -> tcpp_to_string newType
             | TCppFunction _ -> tcpp_to_string newType
             | _ -> abort ("Unknown 'new' target " ^ (tcpp_to_string newType)) expr.cpppos
             | _ -> abort ("Unknown 'new' target " ^ (tcpp_to_string newType)) expr.cpppos
@@ -4473,7 +4494,7 @@ let gen_field ctx class_def class_name ptr_name dot_name is_static is_interface
 
 
       let needsWrapper t = match t with
       let needsWrapper t = match t with
          | TCppStar _ -> true
          | TCppStar _ -> true
-         | TCppInst(t) -> has_meta_key t.cl_meta Meta.StructAccess
+         | TCppInst(t, _) -> has_meta_key t.cl_meta Meta.StructAccess
          | _ -> false
          | _ -> false
       in
       in
       let orig_debug = ctx.ctx_debug_level in
       let orig_debug = ctx.ctx_debug_level in
@@ -4519,7 +4540,7 @@ let gen_field ctx class_def class_name ptr_name dot_name is_static is_interface
                   match return_type with
                   match return_type with
                     | TCppStar _ ->
                     | TCppStar _ ->
                        output "return (cpp::Pointer<const void *>) "
                        output "return (cpp::Pointer<const void *>) "
-                    | TCppInst(t) when has_meta_key t.cl_meta Meta.StructAccess ->
+                    | TCppInst(t, _) when has_meta_key t.cl_meta Meta.StructAccess ->
                        output ("return (cpp::Struct< " ^ (tcpp_to_string return_type) ^ " >) ");
                        output ("return (cpp::Struct< " ^ (tcpp_to_string return_type) ^ " >) ");
                     | _ -> output "return ";
                     | _ -> output "return ";
                end;
                end;
@@ -4535,7 +4556,7 @@ let gen_field ctx class_def class_name ptr_name dot_name is_static is_interface
                      (match arg with
                      (match arg with
                        | TCppStar (t,const) ->
                        | TCppStar (t,const) ->
                           output ("(cpp::" ^ (if const then "Const" else "") ^"Pointer<" ^ (tcpp_to_string t)^" >) ")
                           output ("(cpp::" ^ (if const then "Const" else "") ^"Pointer<" ^ (tcpp_to_string t)^" >) ")
-                       | TCppInst(t) when has_meta_key t.cl_meta Meta.StructAccess ->
+                       | TCppInst(t, _) when has_meta_key t.cl_meta Meta.StructAccess ->
                           output ("(cpp::Struct< " ^ (tcpp_to_string arg) ^ " >) ");
                           output ("(cpp::Struct< " ^ (tcpp_to_string arg) ^ " >) ");
                        | _ -> () );
                        | _ -> () );
                      output ("a" ^ (string_of_int i));
                      output ("a" ^ (string_of_int i));
@@ -4839,7 +4860,9 @@ let find_referenced_types_flags ctx obj field_name super_deps constructor_deps h
             | (["cpp"],"Pointer") | (["cpp"],"ConstPointer") | (["cpp"],"Function")
             | (["cpp"],"Pointer") | (["cpp"],"ConstPointer") | (["cpp"],"Function")
             | (["cpp"],"RawPointer") | (["cpp"],"RawConstPointer") -> List.iter visit_type params
             | (["cpp"],"RawPointer") | (["cpp"],"RawConstPointer") -> List.iter visit_type params
             | _ when is_native_gen_class klass -> add_native_gen_class klass
             | _ when is_native_gen_class klass -> add_native_gen_class klass
-            | _ when is_extern_class klass -> add_extern_class klass
+            | _ when is_extern_class klass ->
+               add_extern_class klass;
+               List.iter visit_type params;
             | _ -> (match klass.cl_kind with KTypeParameter _ -> () | _ -> add_type klass.cl_path);
             | _ -> (match klass.cl_kind with KTypeParameter _ -> () | _ -> add_type klass.cl_path);
             )
             )
          | TAbstract (a,params) when is_scalar_abstract a ->
          | TAbstract (a,params) when is_scalar_abstract a ->
@@ -5846,7 +5869,7 @@ let generate_class_files baseCtx super_deps constructor_deps class_def inScripta
                   in
                   in
                   (match find_super_args [function_def.tf_expr.eexpr] with
                   (match find_super_args [function_def.tf_expr.eexpr] with
                   | Some args ->
                   | Some args ->
-                     out ("\n:" ^ (cpp_class_path_of klass) ^ "(");
+                     out ("\n:" ^ (cpp_class_path_of klass []) ^ "(");
                      let sep = ref "" in
                      let sep = ref "" in
                      List.iter (fun arg ->
                      List.iter (fun arg ->
                         out !sep; sep := ",";
                         out !sep; sep := ",";
@@ -6154,7 +6177,7 @@ let generate_class_files baseCtx super_deps constructor_deps class_def inScripta
 
 
       let toCommon t f value =
       let toCommon t f value =
          t ^ "( " ^ ( match cpp_type_of ctx f.cf_type with
          t ^ "( " ^ ( match cpp_type_of ctx f.cf_type with
-           | TCppInst(t) as inst when (has_meta_key t.cl_meta Meta.StructAccess)
+           | TCppInst(t, _) as inst when (has_meta_key t.cl_meta Meta.StructAccess)
               -> "cpp::Struct< " ^ (tcpp_to_string inst) ^ " >( " ^ value ^ " )"
               -> "cpp::Struct< " ^ (tcpp_to_string inst) ^ " >( " ^ value ^ " )"
            | TCppStar(t,_) -> "cpp::Pointer<void *>( " ^ value ^ " )"
            | TCppStar(t,_) -> "cpp::Pointer<void *>( " ^ value ^ " )"
            | _ -> value
            | _ -> value
@@ -6202,7 +6225,7 @@ let generate_class_files baseCtx super_deps constructor_deps class_def inScripta
 
 
       let castable f =
       let castable f =
          match cpp_type_of ctx f.cf_type with
          match cpp_type_of ctx f.cf_type with
-           | TCppInst(t) as inst when (has_meta_key t.cl_meta Meta.StructAccess)
+           | TCppInst(t, _) as inst when (has_meta_key t.cl_meta Meta.StructAccess)
               -> "cpp::Struct< " ^ (tcpp_to_string inst) ^ " > "
               -> "cpp::Struct< " ^ (tcpp_to_string inst) ^ " > "
            | TCppStar(t,_) -> "cpp::Pointer< " ^ ( tcpp_to_string t ) ^ " >"
            | TCppStar(t,_) -> "cpp::Pointer< " ^ ( tcpp_to_string t ) ^ " >"
            | _ -> ctx_type_string ctx f.cf_type
            | _ -> ctx_type_string ctx f.cf_type
@@ -7114,7 +7137,7 @@ let rec script_cpptype_string cppType = match cppType with
    | TCppProtocol _ -> "cpp.ObjC.Protocol"
    | TCppProtocol _ -> "cpp.ObjC.Protocol"
    | TCppNativePointer klass -> "cpp.Pointer." ^ (join_class_path klass.cl_path ".")
    | TCppNativePointer klass -> "cpp.Pointer." ^ (join_class_path klass.cl_path ".")
    | TCppInterface klass -> (join_class_path klass.cl_path ".")
    | TCppInterface klass -> (join_class_path klass.cl_path ".")
-   | TCppInst klass -> (join_class_path klass.cl_path ".")
+   | TCppInst (klass, _) -> (join_class_path klass.cl_path ".")
    | TCppClass -> "Class"
    | TCppClass -> "Class"
    | TCppGlobal -> "?global";
    | TCppGlobal -> "?global";
    | TCppNull -> "null";
    | TCppNull -> "null";
@@ -8012,11 +8035,11 @@ class script_writer ctx filename asciiOut =
             | FuncEnumConstruct(enum,field) ->
             | FuncEnumConstruct(enum,field) ->
                this#write ((this#op IaCreateEnum) ^ (this#enumText enum) ^ " " ^ (this#stringText field.ef_name) ^ argN ^
                this#write ((this#op IaCreateEnum) ^ (this#enumText enum) ^ " " ^ (this#stringText field.ef_name) ^ argN ^
                    (this#commentOf field.ef_name) ^ "\n");
                    (this#commentOf field.ef_name) ^ "\n");
-            | FuncSuperConstruct(TCppInst klass) when (is_native_gen_class klass) && (is_native_class klass) ->
+            | FuncSuperConstruct(TCppInst (klass, _)) when (is_native_gen_class klass) && (is_native_class klass) ->
                abort "Unsupported super for native class constructor" expression.cpppos;
                abort "Unsupported super for native class constructor" expression.cpppos;
             | FuncSuperConstruct childType ->
             | FuncSuperConstruct childType ->
                this#write ((this#op IaCallSuperNew) ^ (this#astType childType) ^ " " ^ argN ^ "\n");
                this#write ((this#op IaCallSuperNew) ^ (this#astType childType) ^ " " ^ argN ^ "\n");
-            | FuncSuper(_,TCppInst(klass),_) when (is_native_gen_class klass) && (is_native_class klass) ->
+            | FuncSuper(_,TCppInst(klass, _),_) when (is_native_gen_class klass) && (is_native_class klass) ->
                abort "Unsupported super for native class method" expression.cpppos;
                abort "Unsupported super for native class method" expression.cpppos;
             | FuncSuper(_,objType,field) ->
             | FuncSuper(_,objType,field) ->
                this#write ( (this#op IaCallSuper) ^ (this#astType objType) ^ " " ^ (this#stringText field.cf_name) ^
                this#write ( (this#op IaCallSuper) ^ (this#astType objType) ^ " " ^ (this#stringText field.cf_name) ^