2015-05-06 16:40 GMT+02:00 Esteban Lorenzano <[hidden email]>:
OS-Windows (by TorstenBergmann) not OSWindow :) It is needed for the shared pool WinTypes, but without OS-Window, he can use NBWinTypes instead.
|
|
A few easily fixed Type/pointers to Types mixups, and a slipup where two different classes are confused for the same aside, the real show stopper, if I haven't missed something entirely, is that the struct parser/NB in general does not handle const sized arrays*, which is used in a few of the required structs. Extending the parser should be relatively straight forward, along the lines of adding stream peek: #'[' ifTrue: [stream next. type := SizedExternalArrayType type: type size: stream next. stream next = #']' ifFalse: [self error: 'Missing closing bracket for ', type printString]] to NBExtenralStructureFields >> #parseFields:... after the name is read. Coding SizedExternalArrayType is a bit more work though... Cheers,*The end goal would be to be able to generate accessors/read/write for a simple test-struct such as #fieldsDesc char ip[MyClassVar +2];^#( ) On Wed, May 6, 2015 at 5:28 PM, Esteban Lorenzano <[hidden email]> wrote:
|
In reply to this post by philippeback
2015-05-06 13:38 GMT+02:00 [hidden email] <[hidden email]>:
IpAdapterInfo class>>#fieldsDesc ^#( IpAdapterInfo* Next; DWORD ComboIndex; .... This would work
|
In reply to this post by Henrik Sperre Johansen
2015-05-06 22:47 GMT+02:00 Henrik Sperre Johansen <[hidden email]>:
Yes, a parser for this would be great. I tried it with a little hack NBExternalStructure subclass: #Char_260 ... Char_260 class>>#fieldDesc ^ #(char data) Char_260 class>>instanceSize ^ 260 You need another accessor for accessing the data, otherwise you'll only get the first char. AND I don't know how the external memory is handle, probably it is never freed :) Now a complete example (attached code) call it with GetMacWin32 getMacAddress
NHE-Test-NicolaiHess.1.mcz (3K) Download Attachment |
Ups, one method was in the *generated-code-protocol and will be removed on package load. You need to add the methodBYTE_8>>asString ^ self address hex 2015-05-07 1:06 GMT+02:00 Nicolai Hess <[hidden email]>:
|
In reply to this post by Nicolai Hess
On Thu, May 7, 2015 at 1:06 AM, Nicolai Hess <[hidden email]> wrote:
Code loads fine on my 3.0 But hiccup on: resolveType: aTypeName " a type name could be - a class variable name - a class name - a type name - a type name, followed by arbitrary number pointer chars - $*" | name newName resolver binding ptrArity | newName := aTypeName. ptrArity := 0. "resolve aliases and pointers" [ name := newName trimRight. <<<--------------- HERE - as newName is a subclass of NBExternalStructure, so no trimRight newName := self aliasForType: name. newName last = $* ifTrue: [ ptrArity := ptrArity + 1. newName := newName allButLast ]. name = newName ] whileFalse. I changed to name := newName asString trimRight. Call worked then but output gives this: GetMacWin32 getMacAddress 'BYTE_8 ( data: $¼ <-- some weird string here )' Also, I wonder why you call the primGet... twice getMacAddressOf: iInterface | ptr ptr2 nul ret | ptr := NativeBoost allocate: 4. nul := NativeBoost allocate: 0. ptr nbUInt32AtOffset: 0 put: 0. ret := self primGetAdaptersInfo: nul length: ptr. ret = 111 "ERROR_BUFFER_OVERFLOW" ifTrue: [ | size | size := ptr nbUInt32AtOffset: 0. ptr2 := NativeBoost allocate: size. ret := self primGetAdaptersInfo: ptr2 length: ptr. ret = 0 "NO_ERROR" ifTrue: [ | pip numberOfInterfaces| numberOfInterfaces := size / IpAdapterInfo instanceSize. (iInterface between:1 and: numberOfInterfaces) ifFalse:[ ^ nil]. pip := (NBExternalArray ofType: IpAdapterInfo) onAddress: ptr2 size: numberOfInterfaces. ^ (pip at:iInterface ) Address asString]]. ^ nil Phil
--- Philippe Back Visible Performance Improvements Mob: +32(0) 478 650 140 | Fax: +32 (0) 70 408 027 Blog: http://philippeback.be | Twitter: @philippeback High Octane SPRL rue cour Boisacq 101 | 1301 Bierges | Belgium Pharo Consortium Member - http://consortium.pharo.org/ Featured on the Software Process and Measurement Cast - http://spamcast.libsyn.com Sparx Systems Enterprise Architect and Ability Engineering EADocX Value Added Reseller |
In reply to this post by Thierry Goubier
Hi Thierry, I'm in my holidays in Madrid, but let me know if you or anyone need access to the repository and it will be granted.2015-05-06 5:10 GMT-03:00 Thierry Goubier <[hidden email]>:
|
In reply to this post by philippeback
Hi Nicolas,
Thank you for looking at the code. I was away and could not try your code. On Thu, May 7, 2015 at 9:27 AM, [hidden email] <[hidden email]> wrote:
same here.
this worked for me.
It worked for me, I didn't encounter the problem of strange characters. I get: 000c29ab70960000 The last 4 trailing zeros are not the part of the mac address and I am not sure why these are getting added. I'll have a look at your code. thanks again. usman
|
I had a #asString method in the BYTE_8 class that I put by accident in the *generated-code... protocol This method will be removed if the generated methods are regenerated.Just add a new method: BYTE_8>>asString ^ self address hex 2015-05-12 21:32 GMT+02:00 Usman Bhatti <[hidden email]>:
|
Free forum by Nabble | Edit this page |