32 bit Integers and OOP conversion.

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

32 bit Integers and OOP conversion.

GLASS mailing list
Hello

I am writing an application using the Gembuilder for C API.
I am using GemStone/S 64 Bit 3.3 GemBuilder for C and GemStone/S 64 Bit 3.3.3

If possible, I'd like to be able to map an integer to its OOP (and back) without a database round-trip.

In gcioop.ht, there is a macro GCI_I32_TO_OOP that converts a 32bit C int to OopType using OOP_NUM_TAG_BITS and OOP_TAG_SMALLINT.
Can you identify all OopTypes that represent a SmallInteger in gemstone using OOP_TAG_SMALLINT and reverse the operations to get an int?

Regards
Gustav

_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass
Reply | Threaded
Open this post in threaded view
|

Re: 32 bit Integers and OOP conversion.

GLASS mailing list
For 32 bit ints, you can do it like this in C :


static inline OopType int32ToOop(int arg)
{
  return (((OopType)arg << 3) | 2) ;
}

static inline unsigned int OopToInt32(OopType anOop) {
  return (int) (anOop >> 3);
}
 
Norm


On 10/25/2017 2:30 AM, gustav de ridder via Glass wrote:
Hello

I am writing an application using the Gembuilder for C API.
I am using GemStone/S 64 Bit 3.3 GemBuilder for C and GemStone/S 64 Bit 3.3.3

If possible, I'd like to be able to map an integer to its OOP (and back) without a database round-trip.

In gcioop.ht, there is a macro GCI_I32_TO_OOP that converts a 32bit C int to OopType using OOP_NUM_TAG_BITS and OOP_TAG_SMALLINT.
Can you identify all OopTypes that represent a SmallInteger in gemstone using OOP_TAG_SMALLINT and reverse the operations to get an int?

Regards
Gustav


_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass


_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass