GNOME Bugzilla – Bug 109212
sequence of enum not implemented
Last modified: 2004-12-22 21:47:04 UTC
ORBit-cpp 1.3.5 ORBit 2.6.1 IDLEnum needs to redefine get_seq_typename since the implementation it inherits from IDLSimpleType doesn't work (there are no sequence traits for enums). The following patch provides an implementation of IDLEnum::get_seq_typename which compiles (RedHat Linux 8.0 g++ 3.2) and behaves for simple tests. Essentially I have added a generic sequence traits class (to orbit_simple_seq.h) which takes the CPP element type, the C element type, the C sequence type and the CORBA_Typecode (need for the allocation routines). IDLEnum::get_seq_typename uses this class template to provide the traits class needed by Simple{,Un}BoundedSeq. diff -r -C 3 ../orig/orbitcpp-1.3.5/orbitcpp/idl-compiler/types/IDLEnum.cc ./orbitcpp/idl-compiler/types/IDLEnum.cc *** ../orig/orbitcpp-1.3.5/orbitcpp/idl-compiler/types/IDLEnum.cc Thu Feb 6 07:48:28 2003 --- ./orbitcpp/idl-compiler/types/IDLEnum.cc Wed Mar 26 11:04:07 2003 *************** *** 66,68 **** --- 66,94 ---- return result; } + + string + IDLEnum::get_seq_typename (unsigned int length, + const IDLTypedef *active_typedef) const + { + string retval; + + char *tmp = 0; + char *traits = g_strdup_printf(IDL_IMPL_NS "::enum_seq_traits< %s, %s, CORBA_sequence_%s, TC_CORBA_sequence_%s>", + get_cpp_member_typename ().c_str (), + get_c_member_typename ().c_str (), + get_c_member_typename ().c_str (), + get_c_member_typename ().c_str ()); + if (length) + tmp = g_strdup_printf (IDL_IMPL_NS "::SimpleBoundedSeq< %s, %d>", + traits, length); + else + tmp = g_strdup_printf (IDL_IMPL_NS "::SimpleUnboundedSeq< %s >", + traits); + + g_free (traits); + retval = tmp; + g_free (tmp); + + return retval; + } diff -r -C 3 ../orig/orbitcpp-1.3.5/orbitcpp/idl-compiler/types/IDLEnum.h ./orbitcpp/idl-compiler/types/IDLEnum.h *** ../orig/orbitcpp-1.3.5/orbitcpp/idl-compiler/types/IDLEnum.h Thu Feb 6 07:48:28 2003 --- ./orbitcpp/idl-compiler/types/IDLEnum.h Tue Mar 25 10:32:57 2003 *************** *** 58,63 **** --- 58,66 ---- std::string discr_get_cpp_typename () const { return get_fixed_cpp_typename (); } + + std::string get_seq_typename (unsigned int length, + const IDLTypedef *active_typedef) const; }; #endif //ORBITCPP_TYPES_IDLENUM diff -r -C 3 ../orig/orbitcpp-1.3.5/orbitcpp/orb-cpp/orbitcpp_simple_seq.h ./orbitcpp/orb-cpp/orbitcpp_simple_seq.h *** ../orig/orbitcpp-1.3.5/orbitcpp/orb-cpp/orbitcpp_simple_seq.h Sun Feb 9 00:16:01 2003 --- ./orbitcpp/orb-cpp/orbitcpp_simple_seq.h Wed Mar 26 11:04:23 2003 *************** *** 179,184 **** --- 179,198 ---- _length = new_length; } }; + + template <class CPPElem, class CElem, class CElemSeq, CORBA_TypeCode seq_typecode> + struct enum_seq_traits { + typedef CPPElem value_t; + typedef CElem c_value_t; + typedef CElemSeq c_seq_t; + static c_seq_t* alloc_c () { + return (c_seq_t *)ORBit_small_alloc (seq_typecode); + } + + static c_value_t* alloc_c_buf (CORBA::ULong l) { + return (c_value_t *)ORBit_small_allocbuf(seq_typecode, l); + } + }; } // namespace _orbitcpp
The patch http://bugzilla.gnome.org/showattachment.cgi?attach_id=15219 attached to http://bugzilla.gnome.org/show_bug.cgi?id=108644 includes the patch inlined above.
Fixed as part of #108644