|
@@ -60,6 +60,7 @@ let is_internal_class = function
|
|
| (["cpp"],"Pointer") | (["cpp"],"ConstPointer")
|
|
| (["cpp"],"Pointer") | (["cpp"],"ConstPointer")
|
|
| (["cpp"],"RawPointer") | (["cpp"],"RawConstPointer")
|
|
| (["cpp"],"RawPointer") | (["cpp"],"RawConstPointer")
|
|
| (["cpp"],"Function") -> true
|
|
| (["cpp"],"Function") -> true
|
|
|
|
+ | (["cpp"],"VirtualArray") -> true
|
|
| ([],"Math") | (["haxe";"io"], "Unsigned_char__") -> true
|
|
| ([],"Math") | (["haxe";"io"], "Unsigned_char__") -> true
|
|
| (["cpp"],"Int8") | (["cpp"],"UInt8") | (["cpp"],"Char")
|
|
| (["cpp"],"Int8") | (["cpp"],"UInt8") | (["cpp"],"Char")
|
|
| (["cpp"],"Int16") | (["cpp"],"UInt16")
|
|
| (["cpp"],"Int16") | (["cpp"],"UInt16")
|
|
@@ -626,7 +627,8 @@ let rec class_string klass suffix params remap =
|
|
(match klass.cl_path with
|
|
(match klass.cl_path with
|
|
(* Array class *)
|
|
(* Array class *)
|
|
| ([],"Array") when is_dynamic_array_param (List.hd params) ->
|
|
| ([],"Array") when is_dynamic_array_param (List.hd params) ->
|
|
- "cpp::ArrayBase" ^ suffix (* "Dynamic" *)
|
|
|
|
|
|
+ "cpp::ArrayBase" ^ suffix
|
|
|
|
+ (* "cpp::VirtualArray" ^ suffix *)
|
|
| ([],"Array") -> (snd klass.cl_path) ^ suffix ^ "< " ^ (String.concat ","
|
|
| ([],"Array") -> (snd klass.cl_path) ^ suffix ^ "< " ^ (String.concat ","
|
|
(List.map array_element_type params) ) ^ " >"
|
|
(List.map array_element_type params) ) ^ " >"
|
|
(* FastIterator class *)
|
|
(* FastIterator class *)
|
|
@@ -1317,6 +1319,7 @@ let find_undeclared_variables_ctx ctx undeclared declarations this_suffix allow_
|
|
find_undeclared_variables undeclared declarations this_suffix allow_this expression
|
|
find_undeclared_variables undeclared declarations this_suffix allow_this expression
|
|
;;
|
|
;;
|
|
|
|
|
|
|
|
+let is_virtual_array expr = (type_string expr.etype="cpp::VirtualArray") ;;
|
|
|
|
|
|
let rec is_dynamic_in_cpp ctx expr =
|
|
let rec is_dynamic_in_cpp ctx expr =
|
|
let expr_type = type_string ( match follow expr.etype with TFun (args,ret) -> ret | _ -> expr.etype) in
|
|
let expr_type = type_string ( match follow expr.etype with TFun (args,ret) -> ret | _ -> expr.etype) in
|
|
@@ -1348,7 +1351,7 @@ let rec is_dynamic_in_cpp ctx expr =
|
|
)
|
|
)
|
|
| TConst TThis when ((not ctx.ctx_real_this_ptr) && ctx.ctx_dynamic_this_ptr) ->
|
|
| TConst TThis when ((not ctx.ctx_real_this_ptr) && ctx.ctx_dynamic_this_ptr) ->
|
|
ctx.ctx_dbgout ("/* dthis */"); true
|
|
ctx.ctx_dbgout ("/* dthis */"); true
|
|
- | TArray (obj,index) -> let dyn = is_dynamic_in_cpp ctx obj in
|
|
|
|
|
|
+ | TArray (obj,index) -> let dyn = (is_dynamic_in_cpp ctx obj || is_virtual_array obj) in
|
|
ctx.ctx_dbgout ("/* aidr:" ^ (if dyn then "Dyn" else "Not") ^ " */");
|
|
ctx.ctx_dbgout ("/* aidr:" ^ (if dyn then "Dyn" else "Not") ^ " */");
|
|
dyn;
|
|
dyn;
|
|
| TTypeExpr _ -> false
|
|
| TTypeExpr _ -> false
|
|
@@ -1399,18 +1402,20 @@ and is_dynamic_member_return_in_cpp ctx field_object field =
|
|
| TTypeExpr t ->
|
|
| TTypeExpr t ->
|
|
let full_name = "::" ^ (join_class_path (t_path t) "::" ) ^ "." ^ member in
|
|
let full_name = "::" ^ (join_class_path (t_path t) "::" ) ^ "." ^ member in
|
|
ctx.ctx_dbgout ("/*static:"^ full_name^"*/");
|
|
ctx.ctx_dbgout ("/*static:"^ full_name^"*/");
|
|
- ( try ( let mem_type = (Hashtbl.find ctx.ctx_class_member_types full_name) in mem_type="Dynamic"||mem_type="cpp::ArrayBase" )
|
|
|
|
|
|
+ ( try ( let mem_type = (Hashtbl.find ctx.ctx_class_member_types full_name) in
|
|
|
|
+ mem_type="Dynamic" || mem_type="cpp::ArrayBase" || mem_type="cpp::VirtualArray" )
|
|
with Not_found -> true )
|
|
with Not_found -> true )
|
|
| _ ->
|
|
| _ ->
|
|
let tstr = type_string field_object.etype in
|
|
let tstr = type_string field_object.etype in
|
|
(match tstr with
|
|
(match tstr with
|
|
(* Internal classes have no dynamic members *)
|
|
(* Internal classes have no dynamic members *)
|
|
| "::String" | "Null" | "::hx::Class" | "::Enum" | "::Math" | "::ArrayAccess" -> false
|
|
| "::String" | "Null" | "::hx::Class" | "::Enum" | "::Math" | "::ArrayAccess" -> false
|
|
- | "Dynamic" | "cpp::ArrayBase" -> ctx.ctx_dbgout "/*D*/"; true
|
|
|
|
|
|
+ | "Dynamic" | "cpp::ArrayBase" | "cpp::VirtualArray" -> ctx.ctx_dbgout "/*D*/"; true
|
|
| name ->
|
|
| name ->
|
|
let full_name = name ^ "." ^ member in
|
|
let full_name = name ^ "." ^ member in
|
|
ctx.ctx_dbgout ("/*R:"^full_name^"*/");
|
|
ctx.ctx_dbgout ("/*R:"^full_name^"*/");
|
|
- try ( let mem_type = (Hashtbl.find ctx.ctx_class_member_types full_name) in mem_type="Dynamic"||mem_type="cpp::ArrayBase" )
|
|
|
|
|
|
+ try ( let mem_type = (Hashtbl.find ctx.ctx_class_member_types full_name) in
|
|
|
|
+ mem_type="Dynamic" || mem_type="cpp::ArrayBase" || mem_type="cpp::VirtualArray" )
|
|
with Not_found -> true )
|
|
with Not_found -> true )
|
|
;;
|
|
;;
|
|
|
|
|
|
@@ -1950,10 +1955,14 @@ let gen_expression_tree ctx retval expression_tree set_var tail_code =
|
|
output ( "." ^ remap_name )
|
|
output ( "." ^ remap_name )
|
|
else begin
|
|
else begin
|
|
cast_if_required ctx field_object (type_string field_object.etype);
|
|
cast_if_required ctx field_object (type_string field_object.etype);
|
|
- let remap_name = if (type_string field_object.etype)="cpp::ArrayBase" then
|
|
|
|
- match remap_name with
|
|
|
|
- | "length" -> remap_name
|
|
|
|
- | _ -> "__" ^ remap_name
|
|
|
|
|
|
+ let field_type = type_string field_object.etype in
|
|
|
|
+ let remap_name = if remap_name="length" then begin
|
|
|
|
+ if field_type="cpp::VirtualArray" then
|
|
|
|
+ "__length()"
|
|
|
|
+ else
|
|
|
|
+ remap_name
|
|
|
|
+ end else if field_type="cpp::ArrayBase" then
|
|
|
|
+ "__" ^ remap_name
|
|
else
|
|
else
|
|
remap_name
|
|
remap_name
|
|
in
|
|
in
|
|
@@ -2072,7 +2081,7 @@ let gen_expression_tree ctx retval expression_tree set_var tail_code =
|
|
let cpp_type = member_type ctx obj field.cf_name in
|
|
let cpp_type = member_type ctx obj field.cf_name in
|
|
(not (is_scalar cpp_type)) && (
|
|
(not (is_scalar cpp_type)) && (
|
|
let fixed = (cpp_type<>"?") && (expr_type<>"Dynamic") && (cpp_type<>"Dynamic") &&
|
|
let fixed = (cpp_type<>"?") && (expr_type<>"Dynamic") && (cpp_type<>"Dynamic") &&
|
|
- (cpp_type<>expr_type) && (expr_type<>"Void") && (cpp_type<>"cpp::ArrayBase") in
|
|
|
|
|
|
+ (cpp_type<>expr_type) && (expr_type<>"Void") && (cpp_type<>"cpp::ArrayBase") && (cpp_type<>"cpp::VirtualArray") in
|
|
if (fixed && (ctx.ctx_debug_level>1) ) then begin
|
|
if (fixed && (ctx.ctx_debug_level>1) ) then begin
|
|
output ("/* " ^ (cpp_type) ^ " != " ^ expr_type ^ " -> cast */");
|
|
output ("/* " ^ (cpp_type) ^ " != " ^ expr_type ^ " -> cast */");
|
|
end;
|
|
end;
|
|
@@ -2117,7 +2126,7 @@ let gen_expression_tree ctx retval expression_tree set_var tail_code =
|
|
|
|
|
|
if (cast_result) then output (")");
|
|
if (cast_result) then output (")");
|
|
if ( (is_variable func) && (not (is_cpp_function_member func) ) &&
|
|
if ( (is_variable func) && (not (is_cpp_function_member func) ) &&
|
|
- (expr_type<>"Dynamic" && expr_type<>"cpp::ArrayBase" ) && (not is_super) ) then
|
|
|
|
|
|
+ (expr_type<>"Dynamic" && expr_type<>"cpp::ArrayBase" && expr_type<>"cpp::VirtualArray" ) && (not is_super) ) then
|
|
ctx.ctx_output (".Cast< " ^ expr_type ^ " >()" );
|
|
ctx.ctx_output (".Cast< " ^ expr_type ^ " >()" );
|
|
|
|
|
|
let rec cast_array_output func =
|
|
let rec cast_array_output func =
|
|
@@ -2201,7 +2210,9 @@ let gen_expression_tree ctx retval expression_tree set_var tail_code =
|
|
| TLocal v -> output (keyword_remap v.v_name);
|
|
| TLocal v -> output (keyword_remap v.v_name);
|
|
| TArray (array_expr,_) when (is_null array_expr) -> output "Dynamic()"
|
|
| TArray (array_expr,_) when (is_null array_expr) -> output "Dynamic()"
|
|
| TArray (array_expr,index) ->
|
|
| TArray (array_expr,index) ->
|
|
- let dynamic = is_dynamic_in_cpp ctx array_expr || (type_string array_expr.etype) = "cpp::ArrayBase" in
|
|
|
|
|
|
+ let dynamic = (is_dynamic_in_cpp ctx array_expr) ||
|
|
|
|
+ (type_string array_expr.etype) = "cpp::ArrayBase" ||
|
|
|
|
+ (is_virtual_array array_expr) in
|
|
if ( assigning && (not dynamic) ) then begin
|
|
if ( assigning && (not dynamic) ) then begin
|
|
if (is_array_implementer array_expr.etype) then begin
|
|
if (is_array_implementer array_expr.etype) then begin
|
|
output "hx::__ArrayImplRef(";
|
|
output "hx::__ArrayImplRef(";
|
|
@@ -2331,8 +2342,16 @@ let gen_expression_tree ctx retval expression_tree set_var tail_code =
|
|
| None -> ()
|
|
| None -> ()
|
|
| Some expression -> output " = "; gen_expression true expression);
|
|
| Some expression -> output " = "; gen_expression true expression);
|
|
count := !count -1;
|
|
count := !count -1;
|
|
|
|
+ let get_var_name v =
|
|
|
|
+ let rec loop meta = match meta with
|
|
|
|
+ | (Meta.RealPath,[EConst (String s),_],_) :: _ -> s
|
|
|
|
+ | _ :: meta -> loop meta
|
|
|
|
+ | [] -> v.v_name
|
|
|
|
+ in
|
|
|
|
+ loop v.v_meta
|
|
|
|
+ in
|
|
if (ctx.ctx_debug_level>0) then
|
|
if (ctx.ctx_debug_level>0) then
|
|
- output (";\t\tHX_STACK_VAR(" ^name ^",\""^ tvar.v_name ^"\")");
|
|
|
|
|
|
+ output (";\t\tHX_STACK_VAR(" ^name ^",\""^ (get_var_name tvar) ^"\")");
|
|
if (!count > 0) then begin output ";\n"; output_i "" end
|
|
if (!count > 0) then begin output ";\n"; output_i "" end
|
|
end
|
|
end
|
|
| TFor (tvar, init, loop) ->
|
|
| TFor (tvar, init, loop) ->
|
|
@@ -2790,10 +2809,10 @@ let gen_member_def ctx class_def is_static is_interface field =
|
|
end
|
|
end
|
|
end else begin
|
|
end else begin
|
|
let return_type = (type_string function_def.tf_type) in
|
|
let return_type = (type_string function_def.tf_type) in
|
|
-
|
|
|
|
|
|
+
|
|
if ( not is_static && not nonVirtual ) then output "virtual ";
|
|
if ( not is_static && not nonVirtual ) then output "virtual ";
|
|
output (if return_type="Void" && (has_meta_key field.cf_meta Meta.Void) then "void" else return_type );
|
|
output (if return_type="Void" && (has_meta_key field.cf_meta Meta.Void) then "void" else return_type );
|
|
-
|
|
|
|
|
|
+
|
|
output (" " ^ remap_name ^ "(" );
|
|
output (" " ^ remap_name ^ "(" );
|
|
output (gen_arg_list function_def.tf_args "" );
|
|
output (gen_arg_list function_def.tf_args "" );
|
|
output ");\n";
|
|
output ");\n";
|
|
@@ -2810,7 +2829,7 @@ let gen_member_def ctx class_def is_static is_interface field =
|
|
(* Variable access *)
|
|
(* Variable access *)
|
|
gen_type ctx field.cf_type;
|
|
gen_type ctx field.cf_type;
|
|
output (" " ^ remap_name ^ ";\n" );
|
|
output (" " ^ remap_name ^ ";\n" );
|
|
-
|
|
|
|
|
|
+
|
|
(* Add a "dyn" function for variable to unify variable/function access *)
|
|
(* Add a "dyn" function for variable to unify variable/function access *)
|
|
(match follow field.cf_type with
|
|
(match follow field.cf_type with
|
|
| _ when nativeGen -> ()
|
|
| _ when nativeGen -> ()
|
|
@@ -5097,7 +5116,7 @@ class script_writer common_ctx ctx filename asciiOut =
|
|
| "::String" -> ArrayData "String"
|
|
| "::String" -> ArrayData "String"
|
|
| "int" | "Float" | "bool" | "String" | "unsigned char" ->
|
|
| "int" | "Float" | "bool" | "String" | "unsigned char" ->
|
|
ArrayData typeName
|
|
ArrayData typeName
|
|
- | "cpp::ArrayBase" | "Dynamic" -> ArrayAny
|
|
|
|
|
|
+ | "cpp::ArrayBase" | "cpp::VirtualArray" | "Dynamic" -> ArrayAny
|
|
| _ when is_interface_type param -> ArrayInterface (this#typeId (script_type_string param))
|
|
| _ when is_interface_type param -> ArrayInterface (this#typeId (script_type_string param))
|
|
| _ -> ArrayObject
|
|
| _ -> ArrayObject
|
|
)
|
|
)
|