[Pharo-dev] FileSystem-Git status update 3

Henrik Johansen henrik.s.johansen at veloxit.no
Thu Apr 10 09:27:37 EDT 2014


On 10 Apr 2014, at 2:29 , Igor Stasenko <siguctua at gmail.com> wrote:

> 
> 
> 
> On 10 April 2014 13:35, Henrik Johansen <henrik.s.johansen at veloxit.no> wrote:
> 
> On 10 Apr 2014, at 1:18 , Igor Stasenko <siguctua at gmail.com> wrote:
> 
>> 
>> 
>> 
>> On 10 April 2014 11:44, Henrik Johansen <henrik.s.johansen at veloxit.no> wrote:
>> 
>> On 09 Apr 2014, at 5:30 , Max Leske <maxleske at gmail.com> wrote:
>> 
>> >
>> > On 09.04.2014, at 17:25, Sean P. DeNigris <sean at clipperadams.com> wrote:
>> >
>> >> Max Leske wrote
>> >>>> In NB, how do I pass NULL into a function call without modifying the
>> >>>> argument type? e.g. my argument has type String. passing something like
>> >>>> `NBExternalAddress null` will be converted into a C string instead of
>> >>>> being passed through (I know, that seems to be the point in this case but
>> >>>> I couldn't find any other way to create NULL). Any suggestions?
>> >>
>> >> I think you just pass nil, no?
>> >
>> > One would think so, but no… :)
>> > NB will signal an exception because UndefinedObject is not of the expected type.
>> 
>> I remember an optCoerceNilToNull, but that seems to
>> 1) Only apply to pointer types (which could mean having to use char *, not String, and thus need to do encoding/decoding manually)
>> 2) Be scoped to entire call, not single parameter (may or may not be more than a philosophical objection)
>> 
>> Might be worth a shot though?
>> 
>> - optCoerceNilToNull is for pointers
>> 
>> for strings, there's an option:
>> - optStringOrNull
>> 
>> which, if enabled, adds additional check for nil in generated marshaller code,
>> so that by passing nil it will pass NULL to calling function.
> 
> Would probably aid discoverability quite a bit if optionAt:  was used consistently, and (at least the convenient-for-implementing-not-so-convenient-for-using option handling in) NBNativeCodeGen >> #doesNotUnderstand: removed…
> 
> removed? nope
> 
> doesNotUnderstand: message
> 
>     (message selector isUnary and: [ message selector beginsWith: 'opt'] )
>         ifTrue: [ ^ options includes: message selector ].
>         
>     ^ super doesNotUnderstand: message
>  
> The finder is unable to point me to users of optStringOrNull even when I know the selector, and the defaultOptions method (which was the first place I found with a list of options) contains far from a complete set of the total available options, it seems…
> 
> 
> My rationale behind it: 
> - there is no fixed list of options.. they can be introduced/removed depending from the place they actually used - most of the times this is in marshalling code.. and so best way to figure out is to see what marshaller does and expecting (NBExternalType subclasses).
> 
> To find out what marshaller behind specific type, one can use following expression:
> 
> NBFFICallout new resolveType: typename.
> 
> where type name is a string or symbol.. 
> like that:
> 
> NBFFICallout new resolveType: #String
> 
> gives
> 
> NBExternalString
> 
> and inspecting it further you can see what options there.
> 
> I'd like to point out that the complete set of options depends from implementation of various marshalling code.
> 
> i am open for any suggestions which could make options more accessible.
>  
> For example,
> 
> NativeBoost class >> allCalloutOptions
>     | symbols options package |
>     symbols := Symbol allSubInstances select: [ :ea | ea beginsWith: 'opt' ].
>     
>     options := Set new.
>     package := self package.
>     
>     symbols do: [ :symbol | 
>         | senders |
>         senders := SystemNavigation default allSendersOf: symbol.
>         (senders anySatisfy: [ :ea | ea methodClass package = package ]) ifTrue: [ options add: symbol ].
>     ].
>     ^ options
> 
> gives:
>  a Set(#optProxyLabels #optAllowByteArraysPtr #optReturnNullAsNil #optCoerceNilToNull #optUseStackPointer #optStdcall #optStringOrNull #optCheckFailOnEveryArgument #optDebug #optAllowExternalAddressPtr #optDirectProxyFnAddress #options: #optEmitCall #optCdecl #optFailOnReturnNull #optCheckIndirectArgBounds #optReserveCallgateSpace #optNoCleanup #optMayGC #optNoAlignment #optNonMovable #optReturnPtrAsInt #optReturnPtrAsExternalAddress)


Something that is possible to find using references/senders/implementers starting from some related place you know about/stumble across in the code is what I call accessible in a Smalltalk-context.

In this case, I already knew it was possible to provide options that modifies the way calls are built, so my starting point was NBFFICallout, where I quickly found the options inst var.
Going from there, to how the options are actually used, and who were using it, was (at least to me) close to impossible using those three tools, the way it’s implemented.

Requiring use of optionAt: would cut that down to a three-step process:
- References to options instvar
- Senders of optionAt:
- Voila!

Cheers,
Henry
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pharo.org/pipermail/pharo-dev_lists.pharo.org/attachments/20140410/ff6270a1/attachment-0002.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 842 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://lists.pharo.org/pipermail/pharo-dev_lists.pharo.org/attachments/20140410/ff6270a1/attachment.asc>


More information about the Pharo-dev mailing list