DNU in BalloonEnginePlugin

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

DNU in BalloonEnginePlugin

fniephaus
 
Hi all,

In BalloonEnginePlugin>>#primitiveSetBitBltPlugin, #stringOf: is sent to the interpreterProxy which does not understand the message.
Could someone please have a look at this?

Thanks,
Fabio
Reply | Threaded
Open this post in threaded view
|

Re: DNU in BalloonEnginePlugin

Eliot Miranda-2
 
Hi Fabio,

On Wed, May 16, 2018 at 3:51 AM, Fabio Niephaus <[hidden email]> wrote:
 
Hi all,

In BalloonEnginePlugin>>#primitiveSetBitBltPlugin, #stringOf: is sent to the interpreterProxy which does not understand the message.
Could someone please have a look at this?

To be accurate, BalloonEngineSimulation sends stringOf: to interpreterProxy.   BalloonEngineBase>>#primitiveSetBitBltPlugin (inherited by BalloonEnginePlugin) inlines the code:

length := interpreterProxy byteSizeOf: pluginName.
length >= 256 
ifTrue:[^interpreterProxy primitiveFail].
ptr := interpreterProxy firstIndexableField: pluginName.
needReload := false.
0 to: length-1 do:[:i|
"Compare and store the plugin to be used"
(bbPluginName at: i) = (ptr at: i) ifFalse:[
bbPluginName at: i put: (ptr at: i).
needReload := true]].
(bbPluginName at: length) = 0 ifFalse:[
bbPluginName at: length put: 0.
needReload := true].

So it looks like stringOf: has never been implemented by InterpreterProxy because in the simulation work that Dan would have done to develop the plugin interpreterProxy would have been bound to an interpreter.

Something like this should work:

primitiveSetBitBltPlugin
"Primitive. Set the BitBlt plugin to use."
| pluginName |
pluginName := interpreterProxy stackValue: 0.
"Must be string to work"
(interpreterProxy isBytes: pluginName) 
ifFalse:[^interpreterProxy primitiveFail].
(interpreterProxy cStringOrNilFor: pluginName) = bbPluginName
ifTrue: [interpreterProxy pop: 1. "Return receiver"]
ifFalse: [^interpreterProxy primitiveFail]

Please test it both in your VM and in the simulator on a simulated image.

But this primitive is funny/strange/dubious.  It doesn't actually allow one to change the name.  It fails if the name isn't what it was already, and it gets initialized to "BitBltPlugin" in BalloonEngineBase class>>#declareCVarsIn: and by BalloonEngineSimulation>>initialize.  So what it really does is force initialiseModule to be called.  It might be better if it was replaced by e.g. primitiveReinitialiseModule.

_,,,^..^,,,_
best, Eliot
Reply | Threaded
Open this post in threaded view
|

Re: DNU in BalloonEnginePlugin

fniephaus
 
Hi Eliot,

On Wed, May 16, 2018 at 6:21 PM Eliot Miranda <[hidden email]> wrote:
 
Hi Fabio,

On Wed, May 16, 2018 at 3:51 AM, Fabio Niephaus <[hidden email]> wrote:
 
Hi all,

In BalloonEnginePlugin>>#primitiveSetBitBltPlugin, #stringOf: is sent to the interpreterProxy which does not understand the message.
Could someone please have a look at this?

To be accurate, BalloonEngineSimulation sends stringOf: to interpreterProxy.   BalloonEngineBase>>#primitiveSetBitBltPlugin (inherited by BalloonEnginePlugin) inlines the code:

length := interpreterProxy byteSizeOf: pluginName.
length >= 256 
ifTrue:[^interpreterProxy primitiveFail].
ptr := interpreterProxy firstIndexableField: pluginName.
needReload := false.
0 to: length-1 do:[:i|
"Compare and store the plugin to be used"
(bbPluginName at: i) = (ptr at: i) ifFalse:[
bbPluginName at: i put: (ptr at: i).
needReload := true]].
(bbPluginName at: length) = 0 ifFalse:[
bbPluginName at: length put: 0.
needReload := true].

So it looks like stringOf: has never been implemented by InterpreterProxy because in the simulation work that Dan would have done to develop the plugin interpreterProxy would have been bound to an interpreter.

Something like this should work:

primitiveSetBitBltPlugin
"Primitive. Set the BitBlt plugin to use."
| pluginName |
pluginName := interpreterProxy stackValue: 0.
"Must be string to work"
(interpreterProxy isBytes: pluginName) 
ifFalse:[^interpreterProxy primitiveFail].
(interpreterProxy cStringOrNilFor: pluginName) = bbPluginName
ifTrue: [interpreterProxy pop: 1. "Return receiver"]
ifFalse: [^interpreterProxy primitiveFail]

Please test it both in your VM and in the simulator on a simulated image.

Thanks for the info! Unfortunately, #cStringOrNilFor: is not implemented in my image. Looking at other methods using an interpreterProxy, it seems I need to use #byteSizeOf: as well as #firstIndexableField: and then collect all bytes to get the string value? Is there a convenience method for this? At least I couldn't find one...
 

But this primitive is funny/strange/dubious.  It doesn't actually allow one to change the name.  It fails if the name isn't what it was already, and it gets initialized to "BitBltPlugin" in BalloonEngineBase class>>#declareCVarsIn: and by BalloonEngineSimulation>>initialize.  So what it really does is force initialiseModule to be called.  It might be better if it was replaced by e.g. primitiveReinitialiseModule.

I agree, but I'm not sure how things are being deprecated in the VMMaker package and what this change would break in the first place.

Cheers,
Fabio
 

_,,,^..^,,,_
best, Eliot
Reply | Threaded
Open this post in threaded view
|

Re: DNU in BalloonEnginePlugin

Eliot Miranda-2
In reply to this post by Eliot Miranda-2
 
Hi Fabio,

On Wed, May 16, 2018 at 9:21 AM, Eliot Miranda <[hidden email]> wrote:
Hi Fabio,

On Wed, May 16, 2018 at 3:51 AM, Fabio Niephaus <[hidden email]> wrote:
 
Hi all,

In BalloonEnginePlugin>>#primitiveSetBitBltPlugin, #stringOf: is sent to the interpreterProxy which does not understand the message.
Could someone please have a look at this?

To be accurate, BalloonEngineSimulation sends stringOf: to interpreterProxy.   BalloonEngineBase>>#primitiveSetBitBltPlugin (inherited by BalloonEnginePlugin) inlines the code:

length := interpreterProxy byteSizeOf: pluginName.
length >= 256 
ifTrue:[^interpreterProxy primitiveFail].
ptr := interpreterProxy firstIndexableField: pluginName.
needReload := false.
0 to: length-1 do:[:i|
"Compare and store the plugin to be used"
(bbPluginName at: i) = (ptr at: i) ifFalse:[
bbPluginName at: i put: (ptr at: i).
needReload := true]].
(bbPluginName at: length) = 0 ifFalse:[
bbPluginName at: length put: 0.
needReload := true].

So it looks like stringOf: has never been implemented by InterpreterProxy because in the simulation work that Dan would have done to develop the plugin interpreterProxy would have been bound to an interpreter.

Something like this should work:

primitiveSetBitBltPlugin
"Primitive. Set the BitBlt plugin to use."
| pluginName |
pluginName := interpreterProxy stackValue: 0.
"Must be string to work"
(interpreterProxy isBytes: pluginName) 
ifFalse:[^interpreterProxy primitiveFail].
(interpreterProxy cStringOrNilFor: pluginName) = bbPluginName
ifTrue: [interpreterProxy pop: 1. "Return receiver"]
ifFalse: [^interpreterProxy primitiveFail]

Please test it both in your VM and in the simulator on a simulated image.

But this primitive is funny/strange/dubious.  It doesn't actually allow one to change the name.  It fails if the name isn't what it was already, and it gets initialized to "BitBltPlugin" in BalloonEngineBase class>>#declareCVarsIn: and by BalloonEngineSimulation>>initialize.  So what it really does is force initialiseModule to be called.  It might be better if it was replaced by e.g. primitiveReinitialiseModule.

No, I read that wrong.  The  BalloonEngineBase primitive does allow one to change the name; it is the BalloonEngineSimulation that doesn't.  I *hate* these crappy overrides :-)


_,,,^..^,,,_
best, Eliot
Reply | Threaded
Open this post in threaded view
|

Re: DNU in BalloonEnginePlugin

Eliot Miranda-2
In reply to this post by fniephaus
 
Hi Fabio,

On Wed, May 16, 2018 at 9:36 AM, Fabio Niephaus <[hidden email]> wrote:
 
Hi Eliot,

On Wed, May 16, 2018 at 6:21 PM Eliot Miranda <[hidden email]> wrote:
 
Hi Fabio,

On Wed, May 16, 2018 at 3:51 AM, Fabio Niephaus <[hidden email]> wrote:
 
Hi all,

In BalloonEnginePlugin>>#primitiveSetBitBltPlugin, #stringOf: is sent to the interpreterProxy which does not understand the message.
Could someone please have a look at this?

To be accurate, BalloonEngineSimulation sends stringOf: to interpreterProxy.   BalloonEngineBase>>#primitiveSetBitBltPlugin (inherited by BalloonEnginePlugin) inlines the code:

length := interpreterProxy byteSizeOf: pluginName.
length >= 256 
ifTrue:[^interpreterProxy primitiveFail].
ptr := interpreterProxy firstIndexableField: pluginName.
needReload := false.
0 to: length-1 do:[:i|
"Compare and store the plugin to be used"
(bbPluginName at: i) = (ptr at: i) ifFalse:[
bbPluginName at: i put: (ptr at: i).
needReload := true]].
(bbPluginName at: length) = 0 ifFalse:[
bbPluginName at: length put: 0.
needReload := true].

So it looks like stringOf: has never been implemented by InterpreterProxy because in the simulation work that Dan would have done to develop the plugin interpreterProxy would have been bound to an interpreter.

Something like this should work:

primitiveSetBitBltPlugin
"Primitive. Set the BitBlt plugin to use."
| pluginName |
pluginName := interpreterProxy stackValue: 0.
"Must be string to work"
(interpreterProxy isBytes: pluginName) 
ifFalse:[^interpreterProxy primitiveFail].
(interpreterProxy cStringOrNilFor: pluginName) = bbPluginName
ifTrue: [interpreterProxy pop: 1. "Return receiver"]
ifFalse: [^interpreterProxy primitiveFail]

Please test it both in your VM and in the simulator on a simulated image.

Thanks for the info! Unfortunately, #cStringOrNilFor: is not implemented in my image. Looking at other methods using an interpreterProxy, it seems I need to use #byteSizeOf: as well as #firstIndexableField: and then collect all bytes to get the string value? Is there a convenience method for this? At least I couldn't find one...

Build a VMMaker image from the image/buildspurtrunkvmmaker64image.sh script and you'll be able to browse for InterpreterPrimitives>>#cStringOrNilFor: and InterpreterProxy>>#cStringOrNilFor::

InterpreterProxy methods for simulation
cStringOrNullFor: oop
"Answer either a malloced string with the null-terminated contents of oop if oop is a string,
or the null pointer if oop is nil, or fail.  It is the client's responsibility to free the string later."
<returnTypeC: #'char *'>
oop isString ifTrue: [^oop] ifFalse: [self primitiveFail. ^0]

 

But this primitive is funny/strange/dubious.  It doesn't actually allow one to change the name.  It fails if the name isn't what it was already, and it gets initialized to "BitBltPlugin" in BalloonEngineBase class>>#declareCVarsIn: and by BalloonEngineSimulation>>initialize.  So what it really does is force initialiseModule to be called.  It might be better if it was replaced by e.g. primitiveReinitialiseModule.

I agree, but I'm not sure how things are being deprecated in the VMMaker package and what this change would break in the first place.

Ignore this suggestion.  I misread the code.  We need BalloonEngineSimulation>>primitiveSetBitBltPlugin to follow BalloonEngineBase>>#primitiveSetBitBltPlugin more closely.
 

Cheers,
Fabio
 

_,,,^..^,,,_
best, Eliot




--
_,,,^..^,,,_
best, Eliot