[Pharo-project] NB Types and C Types
Hello, In my app using NB and have a few questions on types. In one function I have an size_t *arg for an argument. Is NBUInt64 proper for this argument? I also have a DATE which uses OLE Automation date format which is described as: IO2GRequestFactory.fillMarketDataSnapshotRequestTime """ An OLE Automation date is implemented as a floating-point number whose integral component is the number of days before or after midnight, 30 December 1899, and whose fractional component represents the time on that day divided by 24. """ Would NBUInt64 be best or is NBUInt32 a better fit? I haven't seen a method for this particular date epoch, but I can easily write the method to handle conversion. Thanks for any wisdom and guidance. Jimmie
On 14 December 2012 20:48, Jimmie Houchin <jlhouchin@gmail.com> wrote:
Hello,
In my app using NB and have a few questions on types.
In one function I have an size_t *arg for an argument. Is NBUInt64 proper for this argument?
No. 'size_t*' is a pointer. A size_t type defined as an unsigned integer type, with range big enough to specify size(s) like array size, or a size of memory to allocate in bytes. On 32-bit systems size_t is unsigned 32-bit integer. And here how you can answer your question by yourself: NBFFICallout new resolveType: 'size_t*'
I also have a DATE which uses OLE Automation date format which is described as:
""" An OLE Automation date is implemented as a floating-point number whose integral component is the number of days before or after midnight, 30 December 1899, and whose fractional component represents the time on that day divided by 24. """
Would NBUInt64 be best or is NBUInt32 a better fit? I haven't seen a method for this particular date epoch, but I can easily write the method to handle conversion.
No. The C double type has a special discipline for returning it from function: - it is returned in FP register, unlike rest which using EAX/EDX registers. So, if you use either NBUInt64 or NBUInt32 you won't be able to get actual values which function returns. So, you should use 'double' type, which is alias for NBFloat64
Thanks for any wisdom and guidance.
Jimmie
-- Best regards, Igor Stasenko.
On 12/15/2012 6:00 AM, Igor Stasenko wrote:
> On 14 December 2012 20:48, Jimmie Houchin <jlhouchin@gmail.com> wrote:
>> Hello,
>>
>> In my app using NB and have a few questions on types.
>>
>> In one function I have an size_t *arg
>> for an argument. Is NBUInt64 proper for this argument?
> No. 'size_t*' is a pointer.
> A size_t type defined as an unsigned integer type, with range big
> enough to specify size(s)
> like array size, or a size of memory to allocate in bytes.
> On 32-bit systems size_t is unsigned 32-bit integer.
>
> And here how you can answer your question by yourself:
>
> NBFFICallout new resolveType: 'size_t*'
>> I also have a DATE which uses OLE Automation date format which is described
>> as:
>>
>> """
>> An OLE Automation date is implemented as a floating-point number whose
>> integral component is the number of days before or after midnight, 30
>> December 1899, and whose fractional component represents the time on that
>> day divided by 24.
>> """
>>
>> Would NBUInt64 be best or is NBUInt32 a better fit? I haven't seen a method
>> for this particular date epoch, but I can easily write the method to handle
>> conversion.
> No. The C double type has a special discipline for returning it from function:
> - it is returned in FP register, unlike rest which using EAX/EDX registers.
> So, if you use either NBUInt64 or NBUInt32 you won't be able to get
> actual values which function returns.
>
> So, you should use 'double' type, which is alias for NBFloat64
Thank you very much for this reply.
Educating me and everyone else on the
NBFFICallout new resolveType: 'size_t*'
It will come in handy.
I don't know why I typed NBUInt64/32 for the double. I had NBFloat64 in
my code. I must have had it on my mind from the first question.
I Googled for both of these before inquiring. I saw debates on the size
of the size_t type. I just wanted confirmation and it seems it was
necessary.
Again thanks.
Jimmie
participants (2)
-
Igor Stasenko -
Jimmie Houchin