[Pharo-project] Help "migrating" from classic streams to XStreams
Hi guys. We are developing Fuel with Martin Dias. Fuel is a binary serializer similar to Parcels. More info in http://rmod.lille.inria.fr/web/pier/software/Fuel For the moment, we are using the "classic" streams we want to give it a try to XStreams. My knowledge on streams is very little, so if someone can give me a hint I would really appreciate it. What I want to do right now is an adaptor of XStreams to classic stream. I mean, I want to create custom subclasses of XTFileWriteStream and XTFileReadStream that implements the same API from classic streams that we use in Fuel. And the implementations of such methods will do just a "self something" where something is the way of doing that in XStreams. So, the following is the protocol we use in Fuel for streams, and what I would love to know is the associated way to do it it XStreams. The left is classic streams, and after the "->" it is XStreams: *Reading:* nextNumber: -> ?? nextPutAll: -> write: nextStringPut: -> ?? nextPut: -> put: nextNumber:put: -> ?? nextWordPut: -> ?? *Writing: * nextNumber: -> ?? next: -> read: nextString -> ?? next -> get nextWord -> ?? Thanks a lot in advance, -- Mariano http://marianopeck.wordpress.com
Don't do it exclusively for file, but do it for every XTream One way to do it would be with a wrapper. I mean create a new subclass of XTReadStream, say XTCompatibilityReadStream implement the compatibility methods you want. Same for WriteStream. You'll have to define a few XTream messages too that delegates to the source/destination blah ^source blah foo ^destination foo Then define something like XTReadStream>>classicalStreamAPI ^XTCompatibilityReadStream on: self My 2c. Nicolas 2011/5/13 Mariano Martinez Peck <marianopeck@gmail.com>:
Hi guys. We are developing Fuel with Martin Dias. Fuel is a binary serializer similar to Parcels. More info in http://rmod.lille.inria.fr/web/pier/software/Fuel
For the moment, we are using the "classic" streams we want to give it a try to XStreams. My knowledge on streams is very little, so if someone can give me a hint I would really appreciate it. What I want to do right now is an adaptor of XStreams to classic stream. I mean, I want to create custom subclasses of XTFileWriteStream and XTFileReadStream that implements the same API from classic streams that we use in Fuel. And the implementations of such methods will do just a "self something" where something is the way of doing that in XStreams.
So, the following is the protocol we use in Fuel for streams, and what I would love to know is the associated way to do it it XStreams. The left is classic streams, and after the "->" it is XStreams:
Reading:
nextNumber: -> ?? nextPutAll: -> write: nextStringPut: -> ?? nextPut:Â -> put: nextNumber:put: -> ?? nextWordPut: -> ??
Writing:
nextNumber: -> ?? next: -> read: nextString -> ?? next -> get nextWord -> ??
Thanks a lot in advance,
-- Mariano http://marianopeck.wordpress.com
Of course, another way is simply to define a *XTream-classic-API-compatibility in upper level XTReadStream, but that's less fun :) Nicolas 2011/5/13 Nicolas Cellier <nicolas.cellier.aka.nice@gmail.com>:
Don't do it exclusively for file, but do it for every XTream One way to do it would be with a wrapper. I mean create a new subclass of XTReadStream, say XTCompatibilityReadStream  implement the compatibility methods you want. Same for WriteStream. You'll have to define a few XTream messages too that delegates to the source/destination
blah   ^source blah
foo   ^destination foo
Then define something like
XTReadStream>>classicalStreamAPI Â Â ^XTCompatibilityReadStream on: self
My 2c.
Nicolas
2011/5/13 Mariano Martinez Peck <marianopeck@gmail.com>:
Hi guys. We are developing Fuel with Martin Dias. Fuel is a binary serializer similar to Parcels. More info in http://rmod.lille.inria.fr/web/pier/software/Fuel
For the moment, we are using the "classic" streams we want to give it a try to XStreams. My knowledge on streams is very little, so if someone can give me a hint I would really appreciate it. What I want to do right now is an adaptor of XStreams to classic stream. I mean, I want to create custom subclasses of XTFileWriteStream and XTFileReadStream that implements the same API from classic streams that we use in Fuel. And the implementations of such methods will do just a "self something" where something is the way of doing that in XStreams.
So, the following is the protocol we use in Fuel for streams, and what I would love to know is the associated way to do it it XStreams. The left is classic streams, and after the "->" it is XStreams:
Reading:
nextNumber: -> ?? nextPutAll: -> write: nextStringPut: -> ?? nextPut:Â -> put: nextNumber:put: -> ?? nextWordPut: -> ??
Writing:
nextNumber: -> ?? next: -> read: nextString -> ?? next -> get nextWord -> ??
Thanks a lot in advance,
-- Mariano http://marianopeck.wordpress.com
And concerning nextNumber nextString etc... this supposes a certain format, we can't guess. If you have a DSL for your data with known grammar, you could try a PEG parser. Otherwise, if your data are in a classical Smalltalk format in ASCII, you could use Number readFrom: yourXTCompatibilityReadStream. Otherwise if you have a specific binary encoded data, it's up to you... Nicolas 2011/5/13 Nicolas Cellier <nicolas.cellier.aka.nice@gmail.com>:
Of course, another way is simply to define a *XTream-classic-API-compatibility in upper level XTReadStream, but that's less fun :)
Nicolas
2011/5/13 Nicolas Cellier <nicolas.cellier.aka.nice@gmail.com>:
Don't do it exclusively for file, but do it for every XTream One way to do it would be with a wrapper. I mean create a new subclass of XTReadStream, say XTCompatibilityReadStream  implement the compatibility methods you want. Same for WriteStream. You'll have to define a few XTream messages too that delegates to the source/destination
blah   ^source blah
foo   ^destination foo
Then define something like
XTReadStream>>classicalStreamAPI Â Â ^XTCompatibilityReadStream on: self
My 2c.
Nicolas
2011/5/13 Mariano Martinez Peck <marianopeck@gmail.com>:
Hi guys. We are developing Fuel with Martin Dias. Fuel is a binary serializer similar to Parcels. More info in http://rmod.lille.inria.fr/web/pier/software/Fuel
For the moment, we are using the "classic" streams we want to give it a try to XStreams. My knowledge on streams is very little, so if someone can give me a hint I would really appreciate it. What I want to do right now is an adaptor of XStreams to classic stream. I mean, I want to create custom subclasses of XTFileWriteStream and XTFileReadStream that implements the same API from classic streams that we use in Fuel. And the implementations of such methods will do just a "self something" where something is the way of doing that in XStreams.
So, the following is the protocol we use in Fuel for streams, and what I would love to know is the associated way to do it it XStreams. The left is classic streams, and after the "->" it is XStreams:
Reading:
nextNumber: -> ?? nextPutAll: -> write: nextStringPut: -> ?? nextPut:Â -> put: nextNumber:put: -> ?? nextWordPut: -> ??
Writing:
nextNumber: -> ?? next: -> read: nextString -> ?? next -> get nextWord -> ??
Thanks a lot in advance,
-- Mariano http://marianopeck.wordpress.com
Mariano Martinez Peck wrote
For the moment, we are using the "classic" streams we want to give it a try to XStreams.
Mariano, was there any progress on this? Sean -- View this message in context: http://forum.world.st/Help-migrating-from-classic-streams-to-XStreams-tp3520... Sent from the Pharo Smalltalk mailing list archive at Nabble.com.
On Fri, Jun 22, 2012 at 8:05 PM, Sean P. DeNigris <sean@clipperadams.com>wrote:
Mariano Martinez Peck wrote
For the moment, we are using the "classic" streams we want to give it a try to XStreams.
Mariano, was there any progress on this?
Not really. The problem was that at that moment, the Fuel's design regarding Streams was not very beatiful and we were depending on a lot of messages on Streams. Now in Fuel 1.8 we have reified FLEncoder and FLDecoder and hence we depend only on a few methods for streams: Write stream: nextPut: aSmallInteger nextBytesPutAll: aBytesObject nextWordsPut: aWordObject Read stream: next next:numberOfBytes into: aBytesObject nextInto: aCollection fuelNextWordsInto: aWordsObject So if someone help me to figure it out how to do it in XStreams let me know and I try. Moreover, we have also improved the tests and now you can run all of them with the steam you want. Basically, you have to subclass FLStreamStrategy and implement #writeStreamDo: and #readStreamDo:. So far we have FLByteArrayStreamStrategy, FLFileStreamStrategy, FLMultiByteStreamStrategy and FLFileSystemFileStreamStrategy (for FS). So...the procedure is to create FLXSteamsStrategy accordly and start trying to create (as extensions) the needed methods ;) cheers, -- Mariano http://marianopeck.wordpress.com
Mariano Martinez Peck wrote
So if someone help me to figure it out how to do it in XStreams let me know and I try
That sounds like a cool project, also as a test possibly to get them in Pharo :) I may have time soon. I'll be in touch... Sean -- View this message in context: http://forum.world.st/Help-migrating-from-classic-streams-to-XStreams-tp3520... Sent from the Pharo Smalltalk mailing list archive at Nabble.com.
participants (3)
-
Mariano Martinez Peck -
Nicolas Cellier -
Sean P. DeNigris