Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cpp.Lib.stringReference (always?) returns 0-length string #8457

Open
jcward opened this issue Jun 20, 2019 · 0 comments

Comments

Projects
None yet
2 participants
@jcward
Copy link
Contributor

commented Jun 20, 2019

I was testing sys.ssl.Key.loadFile, which uses cpp.Lib.stringReference to determine the file format, when I discovered that the string returned is always 0-length.

I made a simple test to confirmed this:

Haxe 4.0.0-rc3
hxcpp 4.0.19 (latest haxelib)
Linux 64

Test.hx

class Test
{
  public static function main()
  {
    var content = 'Hello world, testing, 1, 2, 3...';
    var bytes = haxe.io.Bytes.ofString(content);

    // Test stringReference...
    var s_ref = cpp.Lib.stringReference(bytes);

    trace('content.length = ${ content.length }');
    trace('bytes.toString().length = ${ bytes.toString().length }');
    trace('s_ref.length = ${ s_ref.length }');

    trace('content.indexOf(testing) = ${ content.indexOf("testing") }');
    trace('bytes.toString().indexOf(testing) = ${ bytes.toString().indexOf("testing") }');
    trace('s_ref.indexOf(testing) = ${ s_ref.indexOf("testing") }');

    var pass = s_ref.length == content.length;
    trace(pass ? 'SUCCESS' : 'FAIL' );
  }
}

output

> haxe -main Test -cpp out && ./out/Test
Test.hx:11: content.length = 32
Test.hx:12: bytes.toString().length = 32
Test.hx:13: s_ref.length = 0
Test.hx:15: content.indexOf(testing) = 13
Test.hx:16: bytes.toString().indexOf(testing) = 13
Test.hx:17: s_ref.indexOf(testing) = -1
Test.hx:20: FAIL

In another test, I loaded bytes from a file, with the same result -- stringReference(bytesFromFile) gives a 0-length string.

@RealyUniqueName RealyUniqueName added this to the Bugs milestone Jun 20, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.