user3718463
user3718463

Reputation: 265

How com provide language neutral data types

I have been studing COM for a while now and i understand how COM can provide langugae neutral code through using well known binary interfaces, but what i don't get until now is how COM provide language neutrak data types so for example if the implementation language of COM component was wrtitten in C++ and the consumer of the COM component was written in Java and suppose that we have an interface function like that

int sum(int x, int y)

So integer objects in C++ is different than integer objects in Java ,so how COM implement neutral data types ?

Upvotes: 0

Views: 192

Answers (1)

gbjbaanb
gbjbaanb

Reputation: 52679

COM defines what the types it supports are. So an int (VT_I4 for example) is a 4-byte integer type in little endian format. A language that wants to support COM and uses big endian (for example) would have to convert it to little endian first.

Strings are defined as length-prefixed character arrays, so a language that uses some other format...you guessed, has to convert to the COM string type.

Arrays are defined a complex SafeArray types, you want an array, you have to construct a Safearray to pass over the COM interface.

This is not much different from network programming - if you've ever seen the functions hton() and ntoh() which convert between the formats used by the client machine and the network format defined by whoever invented the data formats used by sockets, you'll see that a common format is very common.

Upvotes: 2

Related Questions