[omniORB] basic question about sequences
Michael
omniorb at bindone.de
Tue Aug 5 23:12:03 BST 2008
Hi Michel,
please check my last email:
> Anyway, you're right about initializing the out parameter, there
> should've been be a line
>
>seq_out = new seq_type;
> in my example
so
void Foo_impl::bar(const seq_type& seq_in, seq_type_out seq_out)
{
seq_out = new seq_type;
seq_out->length(seq_in.length());
for (unsigned int i=0; i<seq_in.length(); ++i)
{
seq_out[i] = seq_in[i]*2;
}
}
should work ok
debutant wrote:
> Thank you Michael, thank you Clarke !
>
> I tried first:
>
> seq_type* Foo_impl::bar(const seq_type& seq_in)
> {
> std::auto_ptr<seq_type> ret(new seq_type);
> ret->length(seq_in.length());
> for (unsigned int i=0; i<seq_in.length(); ++i)
> {
> (*ret)[i] = seq_in[i]*3;
> }
> return ret.release();
> }
>
> and it works well.
>
> then I tried:
>
> void Foo_impl::bar(const seq_type& seq_in, seq_type_out seq_out)
> {
> seq_out->length(seq_in.length());
> for (unsigned int i=0; i<seq_in.length(); ++i)
> {
> seq_out[i] = seq_in[i]*2;
> }
> }
>
> Line (3) gives me a problem (segmentation fault) (and (6) too).
>
> I looked at the .hh file generated by the idl compilation and saw:
>
> class seq_type_out {
> ...
> inline seq_type* operator->() { return _data; }
> ...
> }
>
> I tried:
>
> (seq_out.operator->())->length(seq_in.length());
>
> and got the same problem.
>
> It seems that there is something wrong with the class seq_type_out ...
>
> Thanks a lot for your help. I am still full of hope !
> Sincerely,
> Michel
>
More information about the omniORB-list
mailing list