Browse Source

[cpp] Do not StaticCast to VirtualArray - you never know what you are going to get. Closes #5050

Hugh 9 years ago
parent
commit
053b8fcbc3
1 changed files with 8 additions and 3 deletions
  1. 8 3
      src/generators/gencpp.ml

+ 8 - 3
src/generators/gencpp.ml

@@ -2840,9 +2840,14 @@ let gen_cpp_ast_expression_tree ctx class_name func_name function_args injection
             gen arrayObj; out "->__get("; gen index; out ")"
             gen arrayObj; out "->__get("; gen index; out ")"
 
 
          | ArrayObject(arrayObj,index,elem) ->
          | ArrayObject(arrayObj,index,elem) ->
-            gen arrayObj; out "->__get("; gen index; out ")";
-            if not (cpp_is_dynamic_type elem) then
-               out (".StaticCast< " ^ tcpp_to_string elem ^ " >()")
+            let close = if cpp_is_dynamic_type elem then
+                  ""
+               else if elem=TCppDynamicArray then begin
+                  out (tcpp_to_string elem ^ "( "); ")"
+               end else
+                  ".StaticCast< " ^ tcpp_to_string elem ^ " >()"
+            in
+            gen arrayObj; out "->__get("; gen index; out (")" ^ close);
 
 
          | ArrayVirtual(arrayObj,index) ->
          | ArrayVirtual(arrayObj,index) ->
             gen arrayObj; out "->__get("; gen index; out ")";
             gen arrayObj; out "->__get("; gen index; out ")";