demerphq via RT wrote:
Show quoted text>What is the significance of "0x020200" and the other constants here?
The cv_private value incorporates flags describing the operation to be
performed by the sub and precomputed arity limits. 0x020200 corresponds
to min_arity=2 and max_arity=2. The various additions to cv_private
increment one or both of these sub-values.
The six subs created there share a single C body function, and are
differentiated only by the option flags in cv_private. The custom ops
likewise share one op_ppaddr function, and the operations they perform
are differentiated by the same flags, stored in op_private.
Show quoted text>Is p a string containing a prototype? The XS subs we had didn't have prototypes.
Yes, the subs have prototypes. The protoypes have no effect when the
subs are used as methods, so there's no break of compatibility for those
using the documented API. There is a change that could be detected by
code such as "Sereal::Decoder::decode($dec, @v)", that uses the methods
directly in an undocumented way.
The prototype, specifically the putting of argument expressions into
scalar context, is required in order to be able to resolve arity at
compile time. If this wasn't done, there would have to be a pushmark
op preceding the argument ops, and pp_sereal_decode() would need the
same code as xsfunc_sereal_decode() to check arity and resolve the
optional-parameter flags.
Show quoted text>The sub ck_entersub_args_sereal_decoder contains a lot of logic, I
>would say if you commented it pretty much line by line as to what the
>intent is it would make our job a lot easier.
It's pulling apart a standard entersub op tree. The variable names
give quite a few clues. To understand the code, it's more useful to
look at a B::Concise rendition of an op tree than to describe the action
line-by-line.
Show quoted text> we do need it to "Just Work" on relatively old
>perls (we support back to 5.8.5).
It should Just Work that far back.
-zefram