[omniORB] Passing a Sequence from Python to C++

Duncan Grisby duncan at grisby.org
Mon Feb 18 14:25:40 GMT 2008


On Sunday 17 February, EntonH wrote:

[...]
> struct param
> {
> 	string value1;
> 	any value2;
> };
> 	
> typedef sequence param ParSeq;
> 
> any init(in ParSeq par_list);
> 
> So you think this should work?
> 
> list1 = []
> list1.append(
> idlfile.param("Character",CORBA.Any(CORBA.TC_string,"good")))
> list1.append( idlfile.param("Age",CORBA.Any(CORBA._tc_long,long(24))))

This is fine so far, although the mapping for CORBA long is Python int,
not Python long (which is an arbitrary scale integer). long can be used
where int is expected, though, so you'll get away with it.

> list2 = []
> list2.append( idlfile.param("Character",CORBA.Any(CORBA.TC_string,"bad")))
> list2.append( idlfile.param("Age",CORBA.Any(CORBA._tc_long,long(27))))
> 
> list_all =  []
> list_all.append (idlfile.param("1",CORBA.Any(CORBA._tc_any,list1)))
> list_all.append (idlfile.param("2",CORBA.Any(CORBA._tc_any,list2)))

This is the problem. You're setting the value in the struct to an Any
that itself claims to contain an Any, but you've put in a list of param
structs. It will work if you use idlfile._tc_ParSeq, which is the
TypeCode of your ParSeq typedef.

This seems like a very contrived and complex example.

Duncan.

-- 
 -- Duncan Grisby         --
  -- duncan at grisby.org     --
   -- http://www.grisby.org --



More information about the omniORB-list mailing list