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

EntonH entonh at gmx.de
Fri Feb 15 04:43:06 GMT 2008


Hello,

thanks for your reply.

I modified my idl-file like this:
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))))

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)))

obj.init(list_all)

How should i modify my C++-function to accept this "par_list"?

Greetings,
EntonH






Sequences are mapped to python lists or tuples.
1.3.2 of the omg python languange mapping has this:

The sequence template is mapped to sequence objects (e.g., tuples or
lists).
Applications should not assume that values of a sequence type are
mutable. Sequences
and arrays of octets and characters are mapped to the string type for
efficiency reasons.
For example, given the IDL definitions
typedef sequence<long> LongList;
interface VectorOps{
long sum(in LongList l);
};
a client could invoke the operation
print obj.sum([1,2,3])



Thus in your case
sequence_of_params = [param1,param2]

-- 
View this message in context: http://www.nabble.com/Passing-a-Sequence-from-Python-to-C%2B%2B-tp15495850p15500295.html
Sent from the OmniORB - User mailing list archive at Nabble.com.




More information about the omniORB-list mailing list