Wednesday, April 19, 2006

Structure Declaration in IDL and its C++ mapping

CORBA IDL Series Continued (Part 4)

Declaration in IDL - Duplicated here for readability.

<struct_type> ::= “struct” <identifier> “{” <member_list> “}”

<member_list> ::= <member>+

<member> ::= <type_spec> <declarators> “;”


IDL allows recursion of structures by having members which are sequence types of its own incomplete type. Note that a structure (or for that matter union) is termed incomplete until its definition is completed with a closing "{". Recursion is allowed by using the following techniques
  1. Anonymous sequence member (Deprecated usage)
  2. Sequence using forward declaraed struct type.

The examples below illustrate the two -

struct Foo {
long value;
sequence<Foo> chain; // anonymous sequence member

struct Bar; // Forward declaration
typedef sequence<Bar> BarSequence; // sequence of incomplete type
struct Bar {
long value;
BarSequence chain; // recursion

Some rules regarding the above -
  • As said earlier, when structures are forward declared, they are termed incomplete as their definition is still not seen. It is a rule that the structure should be completed in the same IDL file. So, forward declaration of structures defined in other IDLs is not permitted.
  • When sequences are thus used for recursion, the sequence should be member of the structure definition defining the incomplete struct contained in the recursion.
  • Incomplete type definitions can only appear as element type of a sequence definition and such as sequence is called Incomplete Sequence Type.
  • Incomplete Sequence types can appear only as element types of another sequence or as a member of structure or union.
Mutual recursion is not possible because of the above rule. For example, the snippet below is illegal -

struct Foo;
typedef sequence<Foo> FooSeq;
struct Bar {
FooSeq chain; // illegal as Foo is incomplete
struct Foo {
long l;

The same rules apply to unions as well.

Please note that incomplete structures and unions are said to be complete after it has been defined. Hence any such sequence can also be used after the structure is defined.

Structure C++ Mapping

A structure is mapped to to C++ struct or a class with default and copy constructor, assignment operator and a destructor. All the members are publically accessible and the memory management of the internal members is internal to the structure and users of the structure dont have to worry about that. What this means is that the default constructor initializes all the data members appropriately, the copy constructor does a deep copy of the members (such as duplicating object references, copy string data etc), assignment operator first releases the current member memory and then does deep copy and the destructor deletes all member memory.

Fixed and Variable length structures

If a structure contains any variable lenght members such as object reference or string, then the structure is called Variable Length Structure. This has implications when passing the structure though an operation.

For example consider the following IDL

struct Foo {
long l; // Fixed len
struct Bar {
string s; // Variable len
interface I {
Bar op1(in Bar, inout Bar, out Bar);
Foo op2(in Foo, inout Foo, out Foo);

When sending in and reading out fixed length structures, since the memory needed is fixed, the caller is responsible for allocating the memory. However for variable length structures, the caller needs to allocate only for the in and inout parameters and the callee will allocate for inout and out parameters. So, the mapping for the two operation becomes -

class I ... {
virtual Bar op1(const Bar&, Bar&, Bar&); // For Fixed length
virtual Foo* op2(const Foo&, Foo&, Foo*&); // For Variable length

Var types

To hide the above complication, the mapping provides a helper class call var class. For every structure T, a helper class T_var is also generated.

Some of the salient features of this var types is

  • pointer constructor owns the pointer
  • copy constructor deep copies the structure
  • assignment operator releases old and then deep copies
  • destructor deletes the contained structure.
  • Also hides the parameter passing complications.

With the _var type, the above operations can be consistent as follows -

virtual Bar_var op1(const Bar_var&, Bar_var&, Bar_var&); // For Fixed
virtual Foo_var op2(const Foo_var&, Foo_var&, Foo_var&); // For Variable

The T_var type also has in(), inout(), out() and _retn() functions. To avoid any C++ compiler bug which does not allow correct casting, we could use these functions when making calls. For example,

Foo_var f = ...;
f = obj->op2(, f.inout(), f.out());
return f._retn();


Blogger ninest123 Ninest said...

ninest123 10.27
tiffany jewelry, michael kors outlet, oakley sunglasses wholesale, ugg boots, louis vuitton, jordan shoes, nike air max, burberry outlet, uggs outlet, prada outlet, louis vuitton, ugg boots, louis vuitton outlet, michael kors outlet store, ray ban sunglasses, louis vuitton outlet, replica watches, replica watches, uggs outlet, michael kors outlet, polo ralph lauren outlet online, nike free, ray ban sunglasses, oakley sunglasses, christian louboutin outlet, michael kors outlet online, longchamp outlet, louis vuitton outlet, christian louboutin, tiffany and co, prada handbags, cheap oakley sunglasses, polo outlet, longchamp outlet, tory burch outlet, longchamp outlet, nike outlet, oakley sunglasses, oakley sunglasses, ray ban sunglasses, christian louboutin shoes, christian louboutin uk, chanel handbags, uggs on sale, burberry handbags, nike air max, kate spade outlet, michael kors outlet online

9:46 AM  
Blogger ninest123 Ninest said...

hollister uk, nike roshe run uk, sac longchamp pas cher, nike air max uk, north face, vans pas cher, michael kors, kate spade, nike blazer pas cher, longchamp pas cher, ray ban uk, nike free run, abercrombie and fitch uk, louboutin pas cher, coach outlet store online, timberland pas cher, nike roshe, north face uk, polo ralph lauren, oakley pas cher, nike air max, sac vanessa bruno, hollister pas cher, polo lacoste, true religion outlet, ralph lauren uk, nike tn, sac hermes, ray ban pas cher, coach outlet, jordan pas cher, michael kors, coach purses, nike air force, true religion jeans, lululemon canada, michael kors pas cher, mulberry uk, nike air max uk, true religion outlet, burberry pas cher, michael kors outlet, nike free uk, converse pas cher, coach outlet, hogan outlet, new balance, guess pas cher, true religion outlet, air max

9:47 AM  
Blogger ninest123 Ninest said...

bottega veneta, new balance shoes, nike air max, soccer jerseys, louboutin, giuseppe zanotti outlet, lululemon, mac cosmetics, vans, nike trainers uk, vans outlet, abercrombie and fitch, reebok outlet, nike air max, converse, iphone 6 cases, insanity workout, ghd hair, hollister clothing, converse outlet, oakley, nfl jerseys, baseball bats, herve leger, gucci, nike huaraches, mont blanc pens, north face outlet, ferragamo shoes, valentino shoes, north face outlet, p90x workout, longchamp uk, nike roshe run, soccer shoes, wedding dresses, timberland boots, hollister, hermes belt, hollister, ralph lauren, jimmy choo outlet, chi flat iron, asics running shoes, ray ban, instyler, mcm handbags, beats by dre, celine handbags, babyliss, gucci handbags, michael kors outlet online

9:48 AM  
Blogger ninest123 Ninest said...

toms shoes, ugg, ugg uk, moncler, moncler, juicy couture outlet, hollister, ugg,uggs,uggs canada, michael kors outlet online, canada goose outlet, lancel, wedding dresses, moncler outlet, canada goose, swarovski, barbour uk, moncler, canada goose outlet, louis vuitton, ugg,ugg australia,ugg italia, louis vuitton, moncler uk, louis vuitton, ugg pas cher, louis vuitton, montre pas cher, links of london, marc jacobs, barbour, louis vuitton, canada goose uk, michael kors handbags, canada goose outlet, pandora charms, supra shoes, replica watches, canada goose, juicy couture outlet, coach outlet, karen millen uk, moncler outlet, moncler, pandora uk, doudoune moncler, thomas sabo, swarovski crystal, pandora jewelry, canada goose jackets, michael kors outlet, canada goose, doke gabbana, pandora jewelry
ninest123 10.27

9:49 AM  
Blogger 艾丰 said...

longchamp outlet
true religion sale
true religion outlet
fitflops shoes
fitflops sale
fitflops sale clearance
fitflops sale
fitflops shoes
michael kors outlet
michael kors outlet
michael kors outlet
tiffany and co
tiffany jewellery
beats by dr dre
beats by dre
oakley sunglasses
oakley sunglasses
ray-ban sunglasses
ray ban sunglasses
hollister uk
lululemon outlet
ugg outlet
ugg boots
ugg boots
rolex watches
mulberry handbags
mulberry bags
mulberry outlet
mulberry sale
mulberry handbags
mulberry handbags
louis vuitton handbags
louis vuitton handbags
toms shoes

10:59 AM  
Blogger oakleyses said...

christian louboutin uk, louis vuitton outlet, christian louboutin shoes, michael kors pas cher, louis vuitton outlet, sac longchamp pas cher, prada handbags, gucci handbags, tiffany and co, polo ralph lauren outlet online, christian louboutin outlet, cheap oakley sunglasses, longchamp outlet, uggs on sale, polo outlet, louis vuitton, nike air max, oakley sunglasses, longchamp outlet, nike free, nike outlet, longchamp outlet, longchamp pas cher, chanel handbags, nike air max, oakley sunglasses, nike free run, tiffany jewelry, oakley sunglasses wholesale, louboutin pas cher, ray ban sunglasses, ugg boots, replica watches, air max, louis vuitton outlet, oakley sunglasses, nike roshe, louis vuitton, tory burch outlet, ray ban sunglasses, jordan shoes, christian louboutin, prada outlet, polo ralph lauren, burberry pas cher, ugg boots, jordan pas cher, kate spade outlet, ray ban sunglasses

8:37 AM  
Blogger oakleyses said...

hollister, oakley, celine handbags, instyler, nike trainers uk, ghd hair, converse outlet, hollister clothing, hermes belt, beats by dre, ray ban, lancel, herve leger, timberland boots, nike air max, chi flat iron, longchamp uk, asics running shoes, vans, nike air max, insanity workout, reebok outlet, giuseppe zanotti outlet, abercrombie and fitch, nike roshe run, north face outlet, louboutin, jimmy choo outlet, iphone cases, gucci, mcm handbags, north face outlet, valentino shoes, soccer shoes, hollister, wedding dresses, babyliss, bottega veneta, baseball bats, p90x workout, nfl jerseys, nike huaraches, new balance shoes, soccer jerseys, mont blanc pens, ralph lauren, vans outlet, mac cosmetics, ferragamo shoes, lululemon

8:43 AM  
Blogger oakleyses said...

hollister, louis vuitton, moncler outlet, pandora uk, moncler, canada goose outlet, ugg,ugg australia,ugg italia, marc jacobs, toms shoes, moncler outlet, louis vuitton, canada goose, swarovski crystal, supra shoes, moncler, ugg, juicy couture outlet, wedding dresses, thomas sabo, karen millen uk, ugg pas cher, canada goose jackets, pandora jewelry, louis vuitton, moncler, swarovski, pandora jewelry, links of london, moncler uk, louis vuitton, coach outlet, ugg uk, canada goose uk, ugg,uggs,uggs canada, canada goose, doudoune moncler, louis vuitton, pandora charms, juicy couture outlet, canada goose outlet, canada goose outlet, canada goose, moncler, replica watches, montre pas cher

8:45 AM  
Blogger Liu Liu said...

Nick Saban’s relatively brief time as head coach of the Miami Dolphins is not looked upon fondly by most fans of the team. He went 15-17 christian louboutin shoes in his two seasons, but basically quit on the nfl jerseys store team in the final weeks Nike Air Max 90 of the 2006 season, focused more on his next job, at the University of Alabama, instead of the one he christian louboutin uk was under contract for.And at least one player who played – or at Christian Louboutin Women Flat least practiced – under Saban during those ill-fated christian louboutin men flat final weeks Nike Roshe Run hasn’t forgotten NFL Jerseys how Nike Free Run he was louboutin outlet treated. According to Nike Air Max 2015 Shoes receiver P.K. Sam, a journeyman cheap nfl jerseys who spent time with five NFL teams as well as two CFL clubs, Saban cut wholesale nfl jerseys him after he left the team christian louboutin Panettone spiked leather wallet briefly to see his dying father

2:56 PM  

Post a Comment

<< Home