This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Mike Emmel wrote:I was wondering what people would think about extending the gcjx visitor to also forward user data.
I.e visit_method (model_method * method, const list<ref_variable_decl> & params, const ref_block &block)
would becomes
visit_method (model_method * method, const list<ref_variable_decl> & params, const ref_block &block, void * visitorData );
If I understand you correctly, you want the Visitor to say:
someObject->visit (this, opaqueBlob);
and then the visited object (Visitee?) to call back the appropriate visit_snafu() method like:
visitorObject->visit_snafu (this, foo, bar, opaqueBlob);
Right?
That's certainly the way most people implement these kind of things int the C language, so you don't need to put your context data (opaqueBlob) on global or thread-local memory, which is very unclean and error-prone.
But in the OO case, you can just attach the context data inside the visitorObject, which, if I understand correctly, is forwarded across all the call tree. Anonymous subclasses of visitorObject might be handy.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |