VAST primitive

VA Smalltalk is a "100% VisualAge compatible" IDE that includes the original VisualAge technology and the popular VA Assist and WidgetKit add-ons.

Moderators: Eric Clayberg, wembley, tc, Diane Engles, solveig

VAST primitive

Postby mea405 » Tue Oct 16, 2007 10:08 am

Hi,

Could you give me some sample how return from primitive LargeInteger (int64)?

Thank you,
Maxim
mea405
 
Posts: 8
Joined: Thu Nov 09, 2006 3:40 am
Location: Moscow, Russia

Postby wembley » Wed Oct 17, 2007 4:43 am

Maxim -

I'm sorry, but I don't quite understand what you are asking. Do you want an example (in C) of a primitive that returns an int64? Or are you asking for a Smalltalk example of invoking a primitive that answers an int64? Or ?????
John O'Keefe [|], Principal Smalltalk Architect, Instantiations Inc.
wembley
Moderator
 
Posts: 405
Joined: Mon Oct 16, 2006 3:01 am
Location: Durham, NC

Postby mea405 » Wed Oct 17, 2007 8:53 pm

Yes, I would like get an example (in C) of a primitive that returns an int64 and an instance of user defined class.
Maxim
mea405
 
Posts: 8
Joined: Thu Nov 09, 2006 3:40 am
Location: Moscow, Russia

Postby marten » Wed Oct 17, 2007 11:55 pm

mea405 wrote:Yes, I would like get an example (in C) of a primitive that returns an int64 and an instance of user defined class.


Are you sure you want to write a primitive or would it be ok to call an external c-api library call instead of this ? The last thing is pretty simple, because the c-interface supports int64 for return values and parameters.

I noticed, that the helper files (for "real" primitives) do not have support for conversion to int64.

On the other hand - according to the documentation (chapter 11 - IBM Smalltalk Virtual Machine API) - you may have access only to some classes of the system

SmallInteger, True, False, UndefinedClass, Character, String, Array, ByteArray, Float, LargeInteger and DBString.

Thinking about that one would be able to return your int64 number as an instance of LargeInteger ...

Consider it twice, if you want to build primitives or simple external dll's ...


Marten
marten
[|]
 
Posts: 641
Joined: Sat Oct 14, 2006 7:10 am
Location: Hamburg - Germany

Postby mea405 » Thu Oct 18, 2007 12:34 am

marten wrote:
Are you sure you want to write a primitive or would it be ok to call an external c-api library call instead of this ? The last thing is pretty simple, because the c-interface supports int64 for return values and parameters.


We are using EsPostAsyncMessage to process driver callback in our DLL. Now we implemented creating LargeInteger in such way
//.............
EsObject samplePos;
samplePos = EsAllocateObject(
EsPrimVMContext,
EsPrimClassLargeInteger,
2, // size
0, // saves or NULL for saveList
(EsObject **) NULL);
if (samplePos != (EsObject) NULL)
{
EsLongAtPut(samplePos, 1, timeInfo->timeInfo.samplePosition.lo);
EsLongAtPut(samplePos, 2, timeInfo->timeInfo.samplePosition.hi);
};
//.............
It is necessary to transfer in the VAST some such values. Now we use for this purpose an Array, but would be elegant to transfer these values as instance variables of our class.
Maxim
mea405
 
Posts: 8
Joined: Thu Nov 09, 2006 3:40 am
Location: Moscow, Russia

Postby marten » Thu Oct 18, 2007 6:00 am

mea405 wrote:
marten wrote:
Are you sure you want to write a primitive or would it be ok to call an external c-api library call instead of this ? The last thing is pretty simple, because the c-interface supports int64 for return values and parameters.


We are using EsPostAsyncMessage to process driver callback in our DLL. Now we implemented creating LargeInteger in such way
//.............
EsObject samplePos;
samplePos = EsAllocateObject(
EsPrimVMContext,
EsPrimClassLargeInteger,
2, // size
0, // saves or NULL for saveList
(EsObject **) NULL);
if (samplePos != (EsObject) NULL)
{
EsLongAtPut(samplePos, 1, timeInfo->timeInfo.samplePosition.lo);
EsLongAtPut(samplePos, 2, timeInfo->timeInfo.samplePosition.hi);
};
//.............
It is necessary to transfer in the VAST some such values. Now we use for this purpose an Array, but would be elegant to transfer these values as instance variables of our class.


Would it be possible to write a simple DLL and use instances of EsEntryPoint (to create callbacks to the image) to handle that ?
marten
[|]
 
Posts: 641
Joined: Sat Oct 14, 2006 7:10 am
Location: Hamburg - Germany

Postby mea405 » Thu Oct 18, 2007 7:23 am

marten wrote: Would it be possible towrite a simple DLL and use instances of EsEntryPoint (to create callbacks to the image) to handle that ?


Obviously, it is impossible :]
Maxim
mea405
 
Posts: 8
Joined: Thu Nov 09, 2006 3:40 am
Location: Moscow, Russia

Postby marten » Fri Oct 19, 2007 12:00 am

mea405 wrote:
marten wrote: Would it be possible towrite a simple DLL and use instances of EsEntryPoint (to create callbacks to the image) to handle that ?


Obviously, it is impossible :]


Why ? I really would like to know! What are the advantages, drawbacks ?
marten
[|]
 
Posts: 641
Joined: Sat Oct 14, 2006 7:10 am
Location: Hamburg - Germany

Postby mea405 » Fri Oct 19, 2007 5:20 am

marten wrote:
mea405 wrote:
marten wrote: Would it be possible towrite a simple DLL and use instances of EsEntryPoint (to create callbacks to the image) to handle that ?


Obviously, it is impossible :]


Why ? I really would like to know! What are the advantages, drawbacks ?


From 'Programmer Reference':
External functions calling Smalltalk using EsEntryPoint must run in the same thread as Smalltalk.

We can attest - it is true.
Maxim
mea405
 
Posts: 8
Joined: Thu Nov 09, 2006 3:40 am
Location: Moscow, Russia


Return to VA Smalltalk 7.0, 7.5 & 8.0

Who is online

Users browsing this forum: Yahoo [Bot] and 1 guest