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

Packing Andrei's Upcoming rcstring #43

Closed
nordlow opened this issue Sep 22, 2014 · 4 comments
Closed

Packing Andrei's Upcoming rcstring #43

nordlow opened this issue Sep 22, 2014 · 4 comments

Comments

@nordlow
Copy link
Contributor

nordlow commented Sep 22, 2014

I'm having problem packing Andreis' prel implementation of rcstring at https://github.com/nordlow/justd/blob/master/rcstring.d with pack.

What's the preferred way of doing this if I can't modify the original implementation, which I won't be able to do when this become standardized?

I've tried

import std.stdio;
import std.conv: to;
import rcstring;
import msgpack;

void rcstringPackHandler(ref Packer p, ref RCString rcstring)
{
    writeln("Packing ", p);
    p.pack(rcstring.toString);
}

unittest
{
    registerPackHandler!(RCString, rcstringPackHandler);
    writeln(RCString("").pack);
}

which gives

[149, 149, 192, 192, 0, 183, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 183, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 147, 0, 0, 0]

which isn't what I want. For some reason my rcstringPackHandler is ignored.

I want this to equal string packing, namely

[192]
@nordlow nordlow changed the title Packing rcstring Packing Andrei's Upcoming rcstring Sep 22, 2014
@repeatedly
Copy link
Member

Ah... the problem is type mismatch.

if (auto handler = typeid(T) in packHandlers) {

Maybe, we should use typeid(Unqual!T) instead of typeid(T).
Could you check typeid(Unqual!T) version with your case to check work or not?

@nordlow
Copy link
Contributor Author

nordlow commented Sep 24, 2014

Works! Do you change?

@repeatedly
Copy link
Member

I pushed changes to master and added v0.9.3 tag.

@nordlow
Copy link
Contributor Author

nordlow commented Sep 24, 2014

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants