RE: [NeoStats-Devel] Core CTCP event handling

"M" <[email protected]> Mon, 5 Sep 2005 21:23:47 +0100
Newsgroups gmane.comp.neostats.devel
Message-ID <[email protected]>
Justin Hammond wrote:
> On 03 Sep 2005, at 3:26 AM, M wrote:
> > Justin Hammond wrote:
> > I don't really follow what you mean and cannot see anything in a 
> > recent commit that explains what the difference between a perl 
> > extension and a perl module is from a coding point of view
> or how one
> > is loaded and setup.
> >
> 
> Reason is that I havnt committed any code yet that makes any 
> difference between them,

I was going from your comment "Right now, Perl Modules can attach to other
module (bots etc, like adding commands to SecureServ) after last nights
commits" which I assume meant something had been committed.

> but if you follow that code path,
> you would see thats its impossible for a perl "interpreter" 
> to live inside a real module (because of the IS_STD_MOD or IS_PERL_MOD 
> macros etc.
> 
> My post above was how I was thinking about tackling the problems. My 
> question was do you see any problems, or a better way to do this?
> 
> 
> > If you just want to raise an event from NeoStats to both 
> modules and 
> > perl, then it is a trivial change to the if contructs used to issue 
> > the event in SendModuleEvent.
> >
> >
> 
> Well, in the current implementation, only one callback per 
> event per module is possible (because we use the arrays of 
> events). To support perl extensions, we would also have to 
> iterate through a perl event structure to handle any perl 
> callbacks that might be needed for the perl extension 
> (otherwise the module coder would have to re-invent a mini 
> event subsystem for each module he wants perl support for.

Why not just change:

if( IS_STANDARD_MOD( module_ptr ) )
event call
else if( IS_PERL_MOD( module_ptr ) )
perl call

To:

if( IS_STANDARD_MOD( module_ptr ) )
event call
if( perl pointer )
perl event call

We already have a per array entry perl pointer so I assume the following
would be the value to test:

if( module_ptr->event_list[event]->pe )

Make a similar change to the main handler call and we end up with:

if( module_ptr->event_list[event]->handler )
event call
if( module_ptr->event_list[event]->pe )
perl event call

So, a trivial change to the if construct and both perl and normal handlers
can be called whether they exist exclusively or together so will work for
normal modules, perl modules and some combination of both.

Does that achieve what you are aiming for?

Mark.