Browse Source

[cpp] Allow classes called 'String' in sub-packages

hughsando 10 years ago
parent
commit
3f4d4df0f3
2 changed files with 16 additions and 3 deletions
  1. 3 3
      gencpp.ml
  2. 13 0
      tests/unit/src/unit/hxcpp_issues/String.hx

+ 3 - 3
gencpp.ml

@@ -3910,7 +3910,7 @@ let generate_class_files common_ctx member_types super_deps constructor_deps cla
    let sMemberFields = if List.length reflective_members>0 then begin
       output_cpp "static ::String sMemberFields[] = {\n";
       List.iter dump_field_name  reflective_members;
-      output_cpp "\tString(null()) };\n\n";
+      output_cpp "\t::String(null()) };\n\n";
       "sMemberFields"
    end else
       "0 /* sMemberFields */";
@@ -4083,7 +4083,7 @@ let generate_class_files common_ctx member_types super_deps constructor_deps cla
       let sStaticFields = if List.length reflective_statics > 0 then begin
          output_cpp "static ::String sStaticFields[] = {\n";
          List.iter dump_field_name  reflective_statics;
-         output_cpp "\tString(null()) };\n\n";
+         output_cpp "\t::String(null()) };\n\n";
          "sStaticFields";
       end else
         "0 /* sStaticFields */"
@@ -4346,7 +4346,7 @@ let write_resources common_ctx =
       incr idx;
    ) common_ctx.resources;
 
-   resource_file#write_i "{String(null()),0,0}";
+   resource_file#write_i "{::String(null()),0,0}";
    resource_file#end_block_line;
    resource_file#write ";\n\n";
    resource_file#write "namespace hx { Resource *GetResources() { return __Resources; } } \n\n";

+ 13 - 0
tests/unit/src/unit/hxcpp_issues/String.hx

@@ -0,0 +1,13 @@
+package unit.hxcpp_issues;
+
+class String extends Test {
+   @:keep public static var x = 1;
+   @:keep public var y:Float;
+   @:keep public function z() return 1;
+	function test() {
+      y = 1.0;
+		t( Reflect.hasField(String, "x") );
+		eq( Reflect.field(this, "y"),1.0);
+		eq( Reflect.field(this, "z")(),1);
+	}
+}