From: Brandon L Black Date: Thu, 4 Jan 2007 13:55:05 +0000 (+0000) Subject: some comments on how this is all going to play out X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=6b80069a5d388f792b6000d796b84cb4bebdbf05;p=gitmo%2FClass-C3.git some comments on how this is all going to play out --- diff --git a/lib/Class/C3.pm b/lib/Class/C3.pm index b5032a9..f049fe8 100644 --- a/lib/Class/C3.pm +++ b/lib/Class/C3.pm @@ -172,6 +172,7 @@ sub _remove_method_dispatch_table { ## functions for calculating C3 MRO +# XXX to be replaced with XS code in either case (IN_CORE or not), see C3.xs sub calculateMRO { my ($class, $merge_cache) = @_; if($C3_IN_CORE) { @@ -185,6 +186,8 @@ sub calculateMRO { } } +if(!$C3_IN_CORE) { eval { # only define these here if no C3 in the core, + # otherwise they're defined in C3.xs package # hide me from PAUSE next; @@ -261,6 +264,8 @@ our $VERSION = '0.01'; sub method { (next::method($_[0]) || return)->(@_) } +}} # End of "if(!$C3_IN_CORE) { eval {" + 1; __END__ diff --git a/lib/Class/C3.xs b/lib/Class/C3.xs index 6ca9870..be83a82 100644 --- a/lib/Class/C3.xs +++ b/lib/Class/C3.xs @@ -23,10 +23,14 @@ __dopoptosub_at(const PERL_CONTEXT *cxstk, I32 startingblock) { MODULE = Class::C3 PACKAGE = next +#ifdef XXX_NEW_PERL /* some sort of cpp check for a perl that has mro_linear */ + +/* we want to define next::can, next::method, and maybe::next::method */ + CV* canxs(self) - SV* self; - CODE: + SV* self + PPCODE: register I32 cxix = __dopoptosub_at(cxstack, cxstack_ix); register const PERL_CONTEXT *cx; register const PERL_CONTEXT *ccstack = cxstack; @@ -161,3 +165,13 @@ canxs(self) } +#else /* mro_linear stuff not in core, so do some helpers for the pure-perl variant */ + +/* we want to define two helper functions: + 1) A replacement for Alg::C3::merge based on mro_linear_c3, but without the mro_meta caching parts. + it should have optional merge cache support just like Alg::C3 does, but only support @ISA, not + generic parents. Call it Class::C3::calculateMRO_XS or something. + 2) A fast "fetch the most recent caller's package/sub-names", based on the xs can function above, + to speed up the top half of pure-perl next::method. +*/ +#endif