How call c function using ordinal

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

How call c function using ordinal

Dmytryk, Igor
How call c function using ordinal

When using DLL & C Connect I would like to declare a C - function that is called by its Ordinal number instead of name?

Where and when can I set the Ordinal?

Thanks,

Igor

Reply | Threaded
Open this post in threaded view
|

RE: How call c function using ordinal

Boris Popov, DeepCove Labs (SNN)
How call c function using ordinal

I had to do that for one library here, this should get you started. This is all on class side of your ExternalInterface subclass,

 

initialize

 self initializeOrdinals.

 

initializeOrdinals

 self ordinalsData readStream linesDo: [:line | self initializeOrdinalFromLine: line]

 

initializeOrdinalFromLine: string

 | tokens func def ordinal |

 string isEmpty ifTrue: [^nil].

 tokens := string tokensBasedOn: Character space.

 def := (tokens at: 2) tokensBasedOn: $@.

 def size ~= 2 ifTrue: [^nil].

 func := def first.

 func := func copyFrom: (func first = $_ ifTrue: [2] ifFalse: [1]) to: func size.

 ordinal := (tokens at: 4) asNumber.

 self initializeFunction: func withOrdinal: ordinal

 

initializeFunction: func withOrdinal: ordinal

 ((self instanceBehavior methodDictionary values

            select: [:ea | ea isKindOf: ExternalMethod])

                        detect: [:ea | (ea selector tokensBasedOn: $:) first asString = func asString]

                        ifNone: [self error: 'function not defined - ' , func])

                        ifNotNil: [:obj | obj ordinal: ordinal]

 

where ordinalsData was a string in form of,

 

ordinalsData

 ^'// _Func_Name1@12; Index 1;            Information not available

   // _Func_Name2@12; Index 2;             Information not available’

 

Etc,

 

Obviously a bit of hack, but worked just fine nonetheless. You can simplify it quite a bit if you control how your ordinal data file is constructed,

 

Hope this helps,

-Boris

--
+1.604.689.0322
DeepCove Labs Ltd.
4th floor 595 Howe Street
Vancouver, Canada V6C 2T5
http://tinyurl.com/r7uw4

[hidden email]

CONFIDENTIALITY NOTICE

This email is intended only for the persons named in the message
header. Unless otherwise indicated, it contains information that is
private and confidential. If you have received it in error, please
notify the sender and delete the entire message including any
attachments.

Thank you.


From: Dmytryk, Igor [mailto:[hidden email]]
Sent: Monday, June 25, 2007 10:14 AM
To: VWNC,
Subject: How call c function using ordinal

 

When using DLL & C Connect I would like to declare a C - function that is called by its Ordinal number instead of name?

Where and when can I set the Ordinal?

Thanks,

Igor