[msgpack][JIRA] Created: (MSGPACK-80) Cannot serialize 'Object' field

36 views
Skip to first unread message

Andrej Mitrovic (JIRA)

unread,
Nov 10, 2012, 7:21:11 AM11/10/12
to msgpa...@googlegroups.com
Cannot serialize 'Object' field
-------------------------------

Key: MSGPACK-80
URL: http://jira.msgpack.org/browse/MSGPACK-80
Project: MessagePack
Issue Type: Bug
Components: D
Environment: DMD 2.060
Reporter: Andrej Mitrovic
Assignee: FURUHASHI Sadayuki


{code}
import msgpack;

class Foo { int x; }

class Main
{
Object _obj;
}

void main()
{
auto main = new Main;
main._obj = new Foo;
ubyte[] data = msgpack.pack(main);
}
{code}

Errors:
D:\DMD\dmd2\windows\bin\..\..\src\phobos\std\traits.d(2480): Error: tuple index 0 exceeds 0
D:\DMD\dmd2\windows\bin\..\..\src\phobos\std\traits.d(2481): Error: tuple index 0 exceeds 0
msgpack.d(4497): Error: template instance std.traits.BaseClassesTuple!(Object) error instantiating
msgpack.d(779): instantiated from here: SerializingClasses!(Object)
msgpack.d(792): instantiated from here: pack!(Object)
msgpack.d(4055): instantiated from here: pack!(Main)
test.d(18): instantiated from here: pack!(false,Main)
msgpack.d(779): Error: template instance msgpack.SerializingClasses!(Object) error instantiating
msgpack.d(792): instantiated from here: pack!(Object)
msgpack.d(4055): instantiated from here: pack!(Main)
test.d(18): instantiated from here: pack!(false,Main)
msgpack.d(783): Error: function msgpack.Packer!(Appender!(ubyte[])).Packer.beginMap (const(uint) length) is not callable using argument types (immutable(_error_))
msgpack.d(783): Error: function msgpack.Packer!(Appender!(ubyte[])).Packer.beginMap (const(uint) length) is not callable using argument types (immutable(_error_))
msgpack.d(785): Error: function msgpack.Packer!(Appender!(ubyte[])).Packer.beginArray (const(uint) length) is not callable using argument types (immutable(_error_))
msgpack.d(785): Error: function msgpack.Packer!(Appender!(ubyte[])).Packer.beginArray (const(uint) length) is not callable using argument types (immutable(_error_))
msgpack.d(788): Error: Class is used as a type
msgpack.d(788): Error: Class is used as a type
msgpack.d(792): Error: template instance msgpack.Packer!(Appender!(ubyte[])).Packer.pack!(Object) error instantiating
msgpack.d(4055): instantiated from here: pack!(Main)
test.d(18): instantiated from here: pack!(false,Main)
msgpack.d(4055): Error: template instance msgpack.Packer!(Appender!(ubyte[])).Packer.pack!(Main) error instantiating
test.d(18): instantiated from here: pack!(false,Main)
test.d(18): Error: template instance msgpack.pack!(false,Main) error instantiating

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira


Masahiro Nakagawa (JIRA)

unread,
Nov 13, 2012, 12:53:13 PM11/13/12
to msgpa...@googlegroups.com

[ http://jira.msgpack.org/browse/MSGPACK-80?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=10505#comment-10505 ]

Masahiro Nakagawa commented on MSGPACK-80:
------------------------------------------

msgpack-d does not now support polymorphic type serialization(subclass through super class reference).
David had already mentioned this problem, but I cannot implement yet.
Because API design is important, so I need some time.
Handler with RTTI is one approach, which I commented in msgpack.d.

And this issue is probably SerializingClasses's bug. will fix.

> Cannot serialize 'Object' field
> -------------------------------
>
> Key: MSGPACK-80
> URL: http://jira.msgpack.org/browse/MSGPACK-80
> Project: MessagePack
> Issue Type: Bug
> Components: D
> Environment: DMD 2.060
> Reporter: Andrej Mitrovic
> Assignee: Masahiro Nakagawa

Andrej Mitrovic (JIRA)

unread,
Nov 13, 2012, 1:11:11 PM11/13/12
to msgpa...@googlegroups.com

[ http://jira.msgpack.org/browse/MSGPACK-80?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=10506#comment-10506 ]

Andrej Mitrovic commented on MSGPACK-80:
----------------------------------------

Ok, no problem. As a workaround I can use this:

{code}
class Foo { int x; }

class Main
{
Object _obj;

void toMsgpack(P)(ref P p) const
{
Foo foo = cast(Foo)_obj;
p.pack(foo);
}
}

void main()
{
auto main = new Main;
main._obj = new Foo;
ubyte[] data = msgpack.pack(main);
}
{code}

Btw your codebase is very readable, great design! So take as much time as you need. :)

> Cannot serialize 'Object' field
> -------------------------------
>
> Key: MSGPACK-80
> URL: http://jira.msgpack.org/browse/MSGPACK-80
> Project: MessagePack
> Issue Type: Bug
> Components: D
> Environment: DMD 2.060
> Reporter: Andrej Mitrovic
> Assignee: Masahiro Nakagawa

Masahiro Nakagawa (JIRA)

unread,
Nov 24, 2012, 2:48:13 PM11/24/12
to msgpa...@googlegroups.com

[ http://jira.msgpack.org/browse/MSGPACK-80?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=10507#comment-10507 ]

Masahiro Nakagawa commented on MSGPACK-80:
------------------------------------------

I added static assert for Object type.

https://github.com/msgpack/msgpack-d/commit/5e0d19c679fe2fbb9f4874a161d7a4eeb674f6d5

This limitation will be removed when msgpack-d supports derived class through reference to base class serialization.

> Btw your codebase is very readable, great design! So take as much time as you need.

Thanks!

BTW, msgpack-d's issue moved to github.
Please use github instead of this jira.

> Cannot serialize 'Object' field
> -------------------------------
>
> Key: MSGPACK-80
> URL: http://jira.msgpack.org/browse/MSGPACK-80
> Project: MessagePack
> Issue Type: Bug
> Components: D
> Environment: DMD 2.060
> Reporter: Andrej Mitrovic
> Assignee: Masahiro Nakagawa
Reply all
Reply to author
Forward
0 new messages