summaryrefslogtreecommitdiff
path: root/proto.h
Commit message (Collapse)AuthorAgeFilesLines
* Change S_doopen_pm() and S_check_type_and_open() to take an SV parameter.Nicholas Clark2010-11-091-2/+2
| | | | | Previously S_doopen_pm() took a char */STRLEN pair, but it happened that the pointer was always from an SV. So pass the SV directly.
* [perl #75176] Symbol::delete_package does not free certain memory associated ↵Father Chrysostomos2010-11-081-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | with package::ISA This commit makes @ISA changes and package aliasing update PL_isarev properly, removing old, unnecessary entries in addition to adding new entries. So now it is capable of shrinking, not just growing. ------------ Gory Details ------------ There is a chicken-and-egg problem when it comes to calling mro_isa_changed_in on the affected classes: When an isa linearisation is recalculated, it uses the existing linearisations of the super- classes (if any) (or at least the DFS implementation does). Since an assigned package (e.g., the *b:: in *a:: = *b::) can contain nested packages that inherit from each other in any order (b::c isa b::c::d or b::c::e isa b::c), this means that mro_isa_changed_in *must not* be called on any stash while another stash contains stale data. So mro_package_moved has been restructured. It is no longer recurs- ive. The recursive code for iterating through nested stashes has been moved into a separate, static routine: mro_gather_and_rename. Instead of calling mro_isa_changed_in during the iteration, it adds all the classes to ‘the big hash’, which mro_package_moved holds a pointer to. When mro_gather_and_rename returns, mro_package_moved iterates through the big hash twice: the first time to wipe caches; the second to call mro_isa_changed_in on all the stashes. This ‘big hash’ is now used in place of the seen_stashes that mro_package_moved used before. Both mro_package_moved and mro_isa_changed_in now use the existing mrometa->isa hash to determine which classes used to be superclasses of the stash in question. A separate routine, S_mro_clean_isarev, deletes entries mention in isa, except for those that still exist in the new isa hash. mro_isa_changed_in now does two iterations through isarev, just like mro_package_moved. It has to call get_linear_isa on the subclasses so that it can see what is in the new meta->isa hash created thereby. Consequently, it has to make sure that all the subclasses have their caches deleted before it can update anything. It makes the same changes to isarev for each subclass that are made further down on the class for which mro_isa_changed_in was called. Yes, it is repetitive. But calling mro_isa_changed_in recursively has more overhead and would do more unnecessary work. (Maybe we could make some macros for this repetitive code.) The loop through the superclasses near the end of mro_isa_changed_in no longer adds the subclasses to all the superclasses’ isarev hashes, because that is taken care of further up. ------------ Side Effects ------------ One result of this change is that mro::is_universal no longer returns true for classes that are no longer universal. I consider that a bug fix. ------------- Miscellaneous ------------- This also removes obsolete comments in mro_isa_changed_in, concerning fake and universal flags on stashes, that have been invalid since dd69841bebe.
* utf8.c: Add function to create inversion of swashKarl Williamson2010-11-071-0/+6
| | | | | | | | | | | | This adds _swash_inversion_hash() which takes a mapping swash and returns a hash that is the inverse relation. That is, given a code point, it allows quick lookup of all code points that map to it. The function is not for public use, as it will likely be revised, so is not in the public API, and it's name begins with underscore. It does not deal with multi-char mappings at this time, nor other swash complications.
* Add Perl_amagic_deref_call() to implement the bulk of tryAMAGICunDEREF_var().Nicholas Clark2010-11-031-0/+5
| | | | | | | | | This removes around 300 bytes of object code from each place it was previously inlined. It also provides a better interface - quite a lot of the core currently bodges things by creating a local variable C<SV **sp = &sv> to use the macro. Change the XS::APItest wrapper to amagic_deref_call().
* Add transr op typeFather Chrysostomos2010-11-021-0/+1
| | | | | for the upcoming y///r feature. There are not enough flag bits, hence the extra type.
* RT #76248: double-freed SV with nested sig-handlerDavid Mitchell2010-11-011-5/+1
| | | | | | | | | | | | | | | | | | | There was some buggy code in Perl_sighandler() related to getting an SV with the signal name to pass to the perl-level handler function. ` Basically: on threaded builds, a sig handler that died leaked PL_psig_name[sig]; on unthreaded builds, in a recursive handler that died, PL_sig_sv was prematurely freed. PL_sig_sv was originally just a file static var that was not recursion-save anyway, and got promoted to perlvars.h when it should instead have been done away with. So I've got rid of it now, and rationalised the code, which fixed the two issues listed above. Also added an assert which makes the dodgy manual popping of the save stack slightly less dodgy.
* Remove S_get_isa_hashFather Chrysostomos2010-10-311-5/+0
| | | | It no longer serves much purpose, as of 7311f41d6.
* Allow push/pop/keys/etc to act on referencesDavid Golden2010-10-311-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | All built-in functions that operate directly on array or hash containers now also accept hard references to arrays or hashes: |----------------------------+---------------------------| | Traditional syntax | Terse syntax | |----------------------------+---------------------------| | push @$arrayref, @stuff | push $arrayref, @stuff | | unshift @$arrayref, @stuff | unshift $arrayref, @stuff | | pop @$arrayref | pop $arrayref | | shift @$arrayref | shift $arrayref | | splice @$arrayref, 0, 2 | splice $arrayref, 0, 2 | | keys %$hashref | keys $hashref | | keys @$arrayref | keys $arrayref | | values %$hashref | values $hashref | | values @$arrayref | values $arrayref | | ($k,$v) = each %$hashref | ($k,$v) = each $hashref | | ($k,$v) = each @$arrayref | ($k,$v) = each $arrayref | |----------------------------+---------------------------| This allows these built-in functions to act on long dereferencing chains or on the return value of subroutines without needing to wrap them in C<@{}> or C<%{}>: push @{$obj->tags}, $new_tag; # old way push $obj->tags, $new_tag; # new way for ( keys %{$hoh->{genres}{artists}} ) {...} # old way for ( keys $hoh->{genres}{artists} ) {...} # new way For C<push>, C<unshift> and C<splice>, the reference will auto-vivify if it is not defined, just as if it were wrapped with C<@{}>. Calling C<keys> or C<values> directly on a reference gives a substantial performance improvement over explicit dereferencing. For C<keys>, C<values>, C<each>, when overloaded dereferencing is present, the overloaded dereference is used instead of dereferencing the underlying reftype. Warnings are issued about assumptions made in the following three ambiguous cases: (a) If both %{} and @{} overloading exists, %{} is used (b) If %{} overloading exists on a blessed arrayref, %{} is used (c) If @{} overloading exists on a blessed hashref, @{} is used
* reginclass: add some consts to prototypeKarl Williamson2010-10-311-1/+1
|
* Renaming of stashes should not be visible from PerlFather Chrysostomos2010-10-271-12/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | Change 35759254 made stashes get renamed when moved around. This had an unintended consequence: Typeglobs, ref() return values, stringifi- cation of blessed references and __PACKAGE__ are all affected by this. This commit makes a new distinction between stashes’ names and effect- ive names. Stash names are now unaffected when the stashes move around. Only the effective names are affected. (The apparent presence of any puns in the previous sentence is purely incidental and most likely the result of the reader’s inferential propensity.) To this end a new HvENAME_get macro is introduced, returning the first effective name (what HvNAME_get was returning). (Only one effective name needs to be in effect at a time.) hv_add_name and hv_delete_name have been renamed hv_add_ename and hv_delete_ename. hv_name_set is modified to leave the effective names in place unless the name is being set to NULL. These names are now stored in HvAUX as follows: When xhv_name_count is 0, xhv_name is a HEK pointer, containing the name which is also the effective name. When xhv_name_count is not zero, then xhv_name is a pointer to an array of HEK pointers. If xhv_name_count is positive, the first HEK is the name *and* one of the effective names. When xhv_name_count is negative, the first HEK is the name and subsequent HEKs are the effective names.
* new API functions op_scope and op_lvalueZefram2010-10-261-2/+2
| | | | | | The function scope() goes into the API as op_scope(), and mod() goes into the API as op_lvalue(). Both marked experimental, because their behaviour is a little quirky and not trivially dequirkable.
* add CvSTASH_set() macro and make CvSTASH() rvalue onlyZefram2010-10-251-0/+5
| | | | | | Now that CvSTASH requires backreference bookkeeping, stop people from directly assigning to it (by using CvSTASH() as an lvalue), and instead force them to use CvSTASH_set().
* Implement DIR* cloning on WindowsJan Dubois2010-10-251-2/+5
| | | | | | | | | | | | | | | | | | There doesn't seem to be a mechanism to clone FileFind handles on Windows. Therefore this implementation just reads all remaining entries into a cache buffer and closes the handle. All further readdir() requests will be fulfilled from the cache buffer, in both the original and the new interpreter. This fixes bug 75154 on Windows (all tests in t/op/threads-dirh.t pass). This commit also changes the return value of win32_telldir() to -1 for directory handles that have been read until the end. The previous return value was (NULL - dirp->start), which technically is not valid C code. API change alert: Perl_dirp_dup() gets an additional CLONE_PARAMS parameter in this change (like all the other Perl_*_dup() functions).
* function to parse isolated labelZefram2010-10-251-0/+1
| | | | | | | New API function parse_label() parses a label, separate from statements. If a label has not already been lexed and queued up, it does not use yylex(), but parses the label itself at the character level, to avoid unwanted lexing past an absent optional label.
* function to parse unlabelled statementZefram2010-10-251-0/+1
| | | | | New API function parse_barestmt() parses a pure statement, with no label, and returns just the statement's core ops, not attaching a state op.
* stop passing line numbers into op constructor functionsZefram2010-10-251-3/+3
| | | | | | | | | Remove the line number parameter from newWHILEOP() and newFOROP() functions. Instead, the line number for the impending COP is set by parser code after constructing the ops. (In fact the parser was doing this anyway in most cases.) This brings newWHILEOP() and newFOROP() in line with the other op constructors, in that they do not concern themselves with COPs.
* refactor and regularise label/statement grammarZefram2010-10-251-2/+2
| | | | | | | | | | | | | | | | | | | | Refactoring of the grammar around statements. New production <barestmt> encompasses a statement without label. It includes all statement types, including declarations, with no unnecessary intermediate non-terminals. It generates an op tree for the statement's content, with no leading state op. The <fullstmt> production has just one rule, consisting of optional label followed by <barestmt>. It puts a state op on the front of the statement's content ops. To support the regular statement op structure, the op sequence for for(;;) loops no longer has a second state op between the initialisation and the loop. Instead, the unstack op type is slightly adapted to achieve the stack clearing without a state op. The newFOROP() constructor function no longer generates a state op, that now being the job of the <fullstmt> production. Consequently it no longer takes a parameter stating what label is to go in the state op. This brings it in line with the other op constructors.
* Rename stashes when they move aroundFather Chrysostomos2010-10-241-1/+1
| | | | | | | | | | | | | | | | | | | | | | This is yet another patch in preparation for [perl #75176] (I keep saying that.). It uses the recently-added functions hv_name_add and hv_name_delete, to add and remove names when mro_package_moved is called. mro_package_moved’s calling convention needed to change to make this work, which is the bulk of the patch. Code that was calling mro_package_moved was also doing it sometimes when it was unnecessary. If the stash being assigned over had no name, then there was no possibiiity of its being in the symbol table. This probably fixes [perl #77358] (isa warnings), though I have not tested that yet. One user-visible change this introduces is that a detached glob whose stash loses its name will no longer stringify the same way (a bit like a glob that loses its stash pointer; except that it becomes *__ANON__::foo instead of "").
* Add functions for adding and deleting stash namesFather Chrysostomos2010-10-221-0/+12
|
* full API for cop hint hashesZefram2010-10-211-32/+32
| | | | | | | | | | | | | Expose cop hint hashes as a type COPHH, with a cophh_* API which is a macro layer over the refcounted_he_* API. The documentation for cophh_* describes purely API-visible behaviour, whereas the refcounted_he_* documentation describes the functions mainly in terms of the implementation. Revise the cop_hints_* API, using the flags parameter consistently and reimplementing in terms of cophh_*. Use the cophh_* and cop_hints_* functions consistently where appropriate. [Modified by the committer to update two calls to Perl_refcounted_he_fetch recently added to newPMOP.]
* function to parse Perl code blockZefram2010-10-211-0/+1
| | | | | New API function parse_block() parses a code block, including surrounding braces. The block is a lexical scope, but not inherently a dynamic scope.
* add lex_start to the APIZefram2010-10-211-1/+1
| | | | | lex_start() is added to the API, marked experimental, and documented. It also gains a flags parameter for foreseeable future use.
* remove redundant lex_endZefram2010-10-211-1/+0
| | | | | | | The lex_end() function is redundant, because the lexer context object is actually finalised by parser_free(), triggered by the save stack. The lex_end() function has historically been empty, except when the PL_doextract global was being misused to store lexer state.
* remove filter inheritance option from lex_startZefram2010-10-211-1/+1
| | | | | | | | The only uses of lex_start that had the new_filter parameter false, to make the new lexer context share source filters with the previous lexer context, were uses with rsfp null, which therefore never invoked source filters. Inheriting source filters from a logically unrelated file seems like a silly idea anyway.
* embed.pl -> regen/embed.plFather Chrysostomos2010-10-131-2/+2
| | | | so newcomers can find it more easily
* [perl #78362] Make mro_package_moved check for recursionFather Chrysostomos2010-10-121-1/+1
| | | | | The existence of main::main::... caused mro_package_moved to break Text::Template, and probably Acme::Meta as well.
* Add LINKLIST to the API.Ben Morrow2010-10-121-5/+5
| | | | | Also rename the underlying function to op_linklist, to match the other API op functions.
* APIify op list constructorsZefram2010-10-121-3/+3
| | | | | | Put into the API op_append_elem, op_prepend_elem, and op_append_list. All renamed from op_-less internal names. Parameter types for op_append_list changed to match the rest of the op API and avoid some casting.
* Reset isa caches on nonexistent substashes when stash trees are movedFather Chrysostomos2010-10-121-5/+1
| | | | | | | | | | | | | | | | | This fixes the problem of isa cache linearisations’ and method caches’ not being reset on nonexistent packages when they are replaced with real packages as a result of parent stashes’ being moved. This can happen in cases like this: @left::ISA = 'outer::inner'; @right::ISA = 'clone::inner'; {package outer::inner} *clone:: = \%outer::; print "ok 1", "\n" if left->isa("clone::inner"); print "ok 2", "\n" if right->isa("outer::inner"); This changes mro_package_moved’s parameter list as documented in the diff for mro.c. See also the new comments in that function.
* Allow mro_isa_changed_in to be called on nonexistent packagesFather Chrysostomos2010-10-111-4/+3
| | | | | | | | | | | | | | | | | This is necessary for an upcoming bug fix. (For this bug: @left::ISA = 'outer::inner'; @right::ISA = 'clone::inner'; *clone:: = \%outer::; print left->isa('clone::inner'),"\n"; print right->isa('outer::inner'),"\n"; ) This commit actually replaces mro_isa_changed_in with mro_isa_changed_in3. See the docs for it in the diff for mro.c.
* plugin mechanism to rewrite calls to a subroutineZefram2010-10-101-0/+48
| | | | | | | | | | | | | | | | | | | | | | | | New magic type PERL_MAGIC_checkcall attaches a function to a CV, which will be called as the second half of the op checker for an entersub op calling that CV. Default state, in the absence of this magic, is to process the CV's prototype if it has one, or apply list context to all the arguments if not. New API functions cv_get_call_checker() and cv_set_call_checker() provide a clean interface to this facility, hiding the internal use of magic. Expose in the API the new functions rv2cv_op_cv(), ck_entersub_args_list(), ck_entersub_args_proto(), and ck_entersub_args_proto_or_list(), which are meaningful segments of standard entersub op checking and are likely to be useful in plugged-in call checker functions. Expose new API function op_contextualize(), which is a public interface to the internal scalar()/list()/scalarvoid() functions. This API is likely to be required in most plugged-in call checker functions. Incidentally add new function mg_free_type(), in the API, which will remove magic of one type from an SV. (mg_free() removes all magic, and there isn't anything else more selective.)
* make sv_clear() iterate over AVsDavid Mitchell2010-10-111-2/+2
| | | | | | | | | | | | | In sv_clear(), rather than calling av_undef(), iterate over the AV's elements. This is the first stage in making sv_clear() non-recursive, and thus non-stack-blowing when freeing deeply nested structures. Since we no longer have the stack to maintain the chain of AVs currently being iterated over, we instead store a pointer to the previous AV in the AvARRAY[AvMAX] slot of the currently-being-iterated AV. Since our first action is to pop the first SV, that slot is guaranteed to be free, and (in theory) nothing should be messing with the AV while we iterate over its elements, so that slot should remain undisturbed.
* Reset isa on stash manipulationFather Chrysostomos2010-10-091-0/+5
| | | | | | | | | | | | This only applies to glob-to-glob assignments and deletions of stash elements. Other types of stash manipulation are dealt with by subse- quent patches. It adds mro_package_moved, a private function that iterates through subpackages, calling mro_isa_changed_in on each. This is related to [perl #75176], but is not the same bug. It simply got in the way of fixing [perl #75176].
* Create populate_isa() to de-duplicate logic to populate @ISA.Nicholas Clark2010-10-091-0/+5
| | | | | | | Previously yylex() was conditionally populating @AnyDBM_File::ISA (if it was not set, and the token dbmopen was seen), and init_predump_symbols() was populating @IO::File::ISA (unconditionally, but this is so early that nothing previously could have set it). This refactoring eliminates code duplication.
* Remove now-unused parameters from S_gv_magicalize_isa().Nicholas Clark2010-10-091-4/+3
| | | | 997daa56862a0fc7 eliminated the need for passing these in.
* Convert the implementation of XS_APIVERSION_BOOTCHECK to a function.Nicholas Clark2010-10-081-0/+6
| | | | | | The previous macro generated over .5K of object code. This is in every shared object, and is only called once. Hence this change increases the perl binary by about .5K (once), to save .5K for every XS module loaded.
* Change vverify() to return HV or NULL (RT#78286)David Golden2010-10-081-1/+1
| | | | | | | | | | Multiple code paths were dereferencing version objects without checking the underlying type, which could result in segmentation faults per RT#78286 This patch consolidates all dereferencing into vverify() and has vverify return the underlying HV or NULL instead of a boolean value.
* Convert the implementation of XS_VERSION_BOOTCHECK to a function from a macro.Nicholas Clark2010-10-071-0/+5
| | | | | | The macro expansion generates over 1K of object code. This is in every shared object, and is only called once. Hence this change increases the perl binary by about 1K (once), to save 1K for every XS module loaded.
* [PATCH] function to parse Perl statement sequenceZefram2010-10-041-0/+1
| | | | | New API function parse_stmtseq() parses a sequence of statements, up to closing brace or EOF.
* Sort embed.fnc by CPP macro and then function name, before generating files.Nicholas Clark2010-09-301-3901/+3855
| | | | | Additionally, sort embed.h by public API, then core-or-ext, and finally core only. This reduces the number of #if/#endif pairs in embed.h and proto.h
* Normalise all the pre-processor directives in embed.h and proto.hNicholas Clark2010-09-291-85/+85
| | | | | Remove all whitespace after the # Change #ifdef to #if defined and #ifndef to #if !defined
* Skip the blank lines when processing embed.fncNicholas Clark2010-09-291-77/+0
| | | | This has the side effect of simplifying the generated embed.h and proto.h
* Change embed.fnc's vi modeline comment from /* */ to :Nicholas Clark2010-09-291-3/+0
| | | | This means that it isn't (needlessly) copied into proto.h
* Remove the {START,END}_EXTERN_C macros from within embed.fncNicholas Clark2010-09-291-8/+0
| | | | | | | These, and the "functions with flag 'n' should come before here" comments are holdouts from the long-gone PERL_OBJECT implementation. This doesn't change the linkage type of any externally visible functions under g++ - just some static functions. This follows on from 77d8c8d52bcb3950.
* systematically provide pv/pvn/pvs/sv quartetsZefram2010-09-281-0/+32
| | | | | Anywhere an API function takes a string in pvn form, ensure that there are corresponding pv, pvs, and sv APIs.
* Remove empty preprocessor directive in embed.fncAndy Dougherty2010-09-271-1/+0
|
* Move OP prototypes from pp_proto.h to proto.hNicholas Clark2010-09-271-247/+619
| | | | | | | | | | | | Make embed.pl fully responsible for generating prototypes and embedding macros for pp_* and ck_* functions, placing them in embed.h and proto.h opcode.pl no longer generates pp_proto.h Remove the (effectively) duplicate explicit entries for (all but 2) ck_* functions from embed.fnc We can't actually remove pp_proto.h from the distribution *yet*, as ExtUtils::MM_Unix and ExtUtils::MM_VMS have hardcoded lists of the installed headers. Once this is resolved, we can.
* Move the generation of {START,END}_EXTERN_C from embed.fnc to embed.plNicholas Clark2010-09-271-1/+1
|
* [perl #76814] FETCH called twice - !Father Chrysostomos2010-09-241-2/+5
| | | | | | This fixes ! by changing sv_2bool to sv_2bool_flags (with a macro wrapper) and adding SvTRUE_nomg. It also corrects the docs that state incorrectly that SvTRUE does not handle magic.
* [perl #76814] FETCH called twice - string comparison opsFather Chrysostomos2010-09-241-3/+10
| | | | | | This patch changes sv_eq, sv_cmp, sv_cmp_locale and sv_collxfrm to _flags forms, with macros under the old names for sv_eq and sv_collxfrm, but functions for sv_cmp* since pp_sort.c needs them.