浏览代码

[cpp] fixed Lib.stringReference (closes #8457)

Aleksandr Kuzmenko 5 年之前
父节点
当前提交
280b13bd3f
共有 3 个文件被更改,包括 14 次插入1 次删除
  1. 1 0
      extra/CHANGES.txt
  2. 1 1
      std/cpp/Lib.hx
  3. 12 0
      tests/unit/src/unit/issues/Issue8457.hx

+ 1 - 0
extra/CHANGES.txt

@@ -17,6 +17,7 @@
 	jvm : fixed multiplication of `Null<Float>` and `Int` (#9870)
 	flash : fixed loading swc libraries containing `Vector` without a type parameter (#9805)
 	hl : fixed messages being send to wrong threads with `sendMessage`/`readMessage` in `sys.thread.Thread` (#9875)
+	cpp : fixed `cpp.Lib.stringReference()` (#8457)
 
 2020-07-22 4.1.3
 

+ 1 - 1
std/cpp/Lib.hx

@@ -88,7 +88,7 @@ class Lib {
 
 	public static function stringReference(inBytes:haxe.io.Bytes):String {
 		var result:String = "";
-		untyped __global__.__hxcpp_string_of_bytes(inBytes.b, result, 0, 0, true);
+		untyped __global__.__hxcpp_string_of_bytes(inBytes.b, result, 0, inBytes.length, true);
 		return result;
 	}
 

+ 12 - 0
tests/unit/src/unit/issues/Issue8457.hx

@@ -0,0 +1,12 @@
+package unit.issues;
+
+class Issue8457 extends unit.Test {
+#if cpp
+	function test() {
+		var content = 'Hello world, testing, 1, 2, 3...';
+		var bytes = haxe.io.Bytes.ofString(content);
+		var s = cpp.Lib.stringReference(bytes);
+		eq(content, s);
+	}
+#end
+}