Re: cpp: a new approach to stub generation



Sounds very sensible.

On Mon, 2002-03-11 at 17:43, ERDI Gergo wrote:
> so I'm fighting my way throught the horrible mess that is the cpp idl
> compiler, and fixing some reinterpret_cast<>'s with sometimes equally
> broken solutions, and I've realized that much of the custom code generator
> code from the various IDLType subclasses could be removed with adding
> three clever new virtual methods to IDLType:
> 
> 	virtual void stub_c_to_cpp (ostream      &ostr,
> 				    Indent       &indent,
> 				    string const &c_obj_name,
> 				    string const &cpp_obj_name) const = 0;
> 	virtual void stub_c_to_cpp_ref (ostream      &ostr,
> 					Indent       &indent,
> 					string const &c_obj_name,
> 					string const &cpp_obj_name) const = 0;
> 	virtual void stub_cpp_to_c (ostream      &ostr,
> 				    Indent       &indent,
> 				    string const &cpp_obj_name,
> 				    string const &c_obj_name) const = 0;
> 
> Most of the IDLType subclasses would only need to override these, if the
> IDLType methods are written to use these.
> For example, lots of subclasses implement writeUnionAccessors, while the
> following implementation in IDLType would be enough for all of them:
> 
> void
> IDLType::writeUnionAccessors (ostream          &ostr,
> 			      Indent           &indent,
> 			      string const     &id,
> 			      string const     &discriminatorVal,
> 			      IDLTypedef const *activeTypedef = 0) const
> {
> 	string typespec, dcl;
> 	getCPPStubDeclarator (IDL_PARAM_IN, "", typespec, dcl,
> activeTypedef);
> 	string c_member = "m_target._u." + id;
> 
> 	ostr << indent << typespec << dcl << " " << id << "() const {" <<
> endl;
> 	stub_c_to_cpp_ref (ostr, ++indent, c_member, "_cpp_retval");
> 	ostr << indent << "return _cpp_retval;" << endl;
> 	ostr << --indent << "}" << endl << endl;
> }
> 
> Should I go on and do this? Comments welcome,
> 
> 	Gergo
> 
> -- 
>    .--= ULLA! =---------------------.   `We are not here to give users what
>    \     http://cactus.rulez.org     \   they want'  -- RMS, at GUADEC 2001
>     `---= cactus@cactus.rulez.org =---'
> Ki volt Casper, mielôtt meghalt?
> 
> _______________________________________________
> orbit-list mailing list
> orbit-list@gnome.org
> http://mail.gnome.org/mailman/listinfo/orbit-list
-- 
Murray Cumming
murrayc@usa.net
www.murrayc.com




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]