Serializing SmallIntegers

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Serializing SmallIntegers

Jerome Chan
I get a SmallInteger should not implement basicNew when I try to
unserialize on a Win98 box a SmallInteger serialized from a NT box. The
code works with other data structures. Anyone encountering this problem?


Reply | Threaded
Open this post in threaded view
|

Re: Serializing SmallIntegers

Bill Schwab
Jerome,

> I get a SmallInteger should not implement basicNew when I try to
> unserialize on a Win98 box a SmallInteger serialized from a NT box. The
> code works with other data structures. Anyone encountering this problem?

No, and I _think_ that I would have if it were just plain broke, but, I'm
curious.  Can you post some more details of how it's serialized?  Is it as
simple as 3 binaryStoreBytes, or are you doing something more elaborate?  If
the blob from the NT box is small enough, you might be able to post it here
as a literal byte array.  Which version of Dolphin are you using?  Is this
in deployed apps or a development image?

Have a good one,

Bill

--
Wilhelm K. Schwab, Ph.D.
[hidden email]


Reply | Threaded
Open this post in threaded view
|

Re: Serializing SmallIntegers

Andy Bower
In reply to this post by Jerome Chan
Jerome,

> I get a SmallInteger should not implement basicNew when I try to
> unserialize on a Win98 box a SmallInteger serialized from a NT box. The
> code works with other data structures. Anyone encountering this problem?

Can you supply a snippet of code that demonstrates the problem? We may have
problems reproducing it even then since I don't think we have an NT box
available any more. Let's hope the problem can be reproduced using Win98 and
Win2K.

Best Regards,

Andy Bower
Dolphin Support
http://www.object-arts.com

---
Visit the Dolphin Smalltalk WikiWeb
http://www.object-arts.com/wiki/html/Dolphin/FrontPage.htm
---


Reply | Threaded
Open this post in threaded view
|

Re: Serializing SmallIntegers

Jerome Chan
w := 1.
x := ByteArray new.
y := STBOutFiler on: (WriteStream on: x).
y nextPut: w.
b := x copy.
z := STBInFiler on: (ReadStream on: b).
a := z next.

This works. I get a as 1.

w := 1.
x := ByteArray new.
y := STBOutFiler on: (WriteStream on: x).
y saveObject: w.
b := x copy.
z := STBInFiler on: (ReadStream on: b).
a := z next.

This does not. It gives me a SmallInteger class should not implement
#basicNew.

w := 12.23.
x := ByteArray new.
y := STBOutFiler on: (WriteStream on: x).
y saveObject: w.
b := x copy.
z := STBInFiler on: (ReadStream on: b).
a := z next.

This also works. I get a as 12.23

What am I doing wrong? Running on a Win2k box. Sorry for the delay and
the crappy variable names.


Reply | Threaded
Open this post in threaded view
|

Re: Serializing SmallIntegers

Bill Schwab-2
Jerome,

AFAIK, #saveObject: is a lower-level method that is useful for customizing
storage.  That it works for your Float example and not for the SmallInteger
probably hinges on whether #basicNextPut: happens to use #saveObject:.
SmallIntegers are encoded entirely in their STB prefix, so #saveObject:
isn't appropriate for them.

One might argue that #saveObject: should be private, but, that wouldn't be
"fair" to classes that need to customize their binary filing.  Fortunately,
the Education Centre documentation on the binary filer is quite clear, so
you can either consult it or some "old" code that you know works before
doing anything new with the binary filer.

Have a good one,

Bill

--
Wilhelm K. Schwab, Ph.D.
[hidden email]


Reply | Threaded
Open this post in threaded view
|

Re: Serializing SmallIntegers

Blair McGlashan
In reply to this post by Jerome Chan
Jerome

You wrote in message
news:[hidden email]...

>...
> y nextPut: w.
> ...
>
> This works. I get a as 1.
> ...
> y saveObject: w.
> ...
> This does not. It gives me a SmallInteger class should not implement
> #basicNew.
> ....
> What am I doing wrong? Running on a Win2k box. Sorry for the delay and
> the crappy variable names.

Although (as Bill explains) this is not a bug, I have added a defect report
(206) to have the method comment for #saveObject: make it absolutely clear
that it only works for non-immediate Objects.

Regards

Blair


Reply | Threaded
Open this post in threaded view
|

Re: Serializing SmallIntegers

Bill Schwab-2
Blair,

> Although (as Bill explains) this is not a bug, I have added a defect
report
> (206) to have the method comment for #saveObject: make it absolutely clear
> that it only works for non-immediate Objects.

It might also help to have some additional categories for "customized
serialization" or similar.

Have a good one,

Bill

--
Wilhelm K. Schwab, Ph.D.
[hidden email]