{
    "content": [
        {
            "type": "text",
            "text": "# ExtUtils::Constant::Base (perldoc)\n\n**Summary:** ExtUtils::Constant::Base - base class for ExtUtils::Constant objects\n\n**Synopsis:** require ExtUtils::Constant::Base;\n@ISA = 'ExtUtils::Constant::Base';\n\n## Section Outline\n\n- **NAME** (2 lines)\n- **SYNOPSIS** (3 lines)\n- **DESCRIPTION** (4 lines)\n- **USAGE** (136 lines)\n- **BUGS** (4 lines)\n- **AUTHOR** (2 lines)\n\n## Full Content\n\n### NAME\n\nExtUtils::Constant::Base - base class for ExtUtils::Constant objects\n\n### SYNOPSIS\n\nrequire ExtUtils::Constant::Base;\n@ISA = 'ExtUtils::Constant::Base';\n\n### DESCRIPTION\n\nExtUtils::Constant::Base provides a base implementation of methods to generate C code to give\nfast constant value lookup by named string. Currently it's mostly used ExtUtils::Constant::XS,\nwhich generates the lookup code for the constant() subroutine found in many XS modules.\n\n### USAGE\n\nExtUtils::Constant::Base exports no subroutines. The following methods are available\n\nheader\nA method returning a scalar containing definitions needed, typically for a C header file.\n\nmemEQclause argshashref\nA method to return a suitable C \"if\" statement to check whether *name* is equal to the C\nvariable \"name\". If *checkedat* is defined, then it is used to avoid \"memEQ\" for short\nnames, or to generate a comment to highlight the position of the character in the \"switch\"\nstatement.\n\nIf i<checkedat> is a reference to a scalar, then instead it gives the characters\npre-checked at the beginning, (and the number of chars by which the C variable name has been\nadvanced. These need to be chopped from the front of *name*).\n\ndumpnames arghashref, ITEM...\nAn internal function to generate the embedded perl code that will regenerate the constant\nsubroutines. *defaulttype*, *types* and *ITEM*s are the same as for Cconstant. *indent* is\ntreated as number of spaces to indent by. If \"declaretypes\" is true a $types is always\ndeclared in the perl code generated, if defined and false never declared, and if undefined\n$types is only declared if the values in *types* as passed in cannot be inferred from\n*defaulttypes* and the *ITEM*s.\n\nassign arghashref, VALUE...\nA method to return a suitable assignment clause. If *type* is aggregate (eg *PVN* expects\nboth pointer and length) then there should be multiple *VALUE*s for the components. *pre*\nand *post* if defined give snippets of C code to proceed and follow the assignment. *pre*\nwill be at the start of a block, so variables may be defined in it.\n\nreturnclause arghashref, ITEM\nA method to return a suitable \"#ifdef\" clause. *ITEM* is a hashref (as passed to\n\"Cconstant\" and \"matchclause\". *indent* is the number of spaces to indent, defaulting to\n6.\n\nswitchclause arghashref, NAMELEN, ITEMHASH, ITEM...\nAn internal method to generate a suitable \"switch\" clause, called by \"Cconstant\" *ITEM*s\nare in the hash ref format as given in the description of \"Cconstant\", and must all have\nthe names of the same length, given by *NAMELEN*. *ITEMHASH* is a reference to a hash, keyed\nby name, values being the hashrefs in the *ITEM* list. (No parameters are modified, and\nthere can be keys in the *ITEMHASH* that are not in the list of *ITEM*s without causing\nproblems - the hash is passed in to save generating it afresh for each call).\n\nparams WHAT\nAn \"internal\" method, subject to change, currently called to allow an overriding class to\ncache information that will then be passed into all the \"*param*\" calls. (Yes, having to\nread the source to make sense of this is considered a known bug). *WHAT* is be a hashref of\ntypes the constant function will return. In ExtUtils::Constant::XS this method is used to\nreturns a hashref keyed IV NV PV SV to show which combination of pointers will be needed in\nthe C argument list generated by Cconstantotherparamsdefinition and\nCconstantotherparams\n\ndogfood arghashref, ITEM...\nAn internal function to generate the embedded perl code that will regenerate the constant\nsubroutines. Parameters are the same as for Cconstant.\n\nCurrently the base class does nothing and returns an empty string.\n\nnormaliseitems args, defaulttype, seentypes, seenitems, ITEM...\nConvert the items to a normalised form. For 8 bit and Unicode values converts the item to an\narray of 1 or 2 items, both 8 bit and UTF-8 encoded.\n\nCconstant arghashref, ITEM...\nA function that returns a list of C subroutine definitions that return the value and type of\nconstants when passed the name by the XS wrapper. *ITEM...* gives a list of constant names.\nEach can either be a string, which is taken as a C macro name, or a reference to a hash with\nthe following keys\n\nname    The name of the constant, as seen by the perl code.\n\ntype    The type of the constant (*IV*, *NV* etc)\n\nvalue   A C expression for the value of the constant, or a list of C expressions if the type\nis aggregate. This defaults to the *name* if not given.\n\nmacro   The C pre-processor macro to use in the \"#ifdef\". This defaults to the *name*, and\nis mainly used if *value* is an \"enum\". If a reference an array is passed then the\nfirst element is used in place of the \"#ifdef\" line, and the second element in place\nof the \"#endif\". This allows pre-processor constructions such as\n\n#if defined (foo)\n#if !defined (bar)\n...\n#endif\n#endif\n\nto be used to determine if a constant is to be defined.\n\nA \"macro\" 1 signals that the constant is always defined, so the \"#if\"/\"#endif\" test\nis omitted.\n\ndefault Default value to use (instead of \"croak\"ing with \"your vendor has not defined...\")\nto return if the macro isn't defined. Specify a reference to an array with type\nfollowed by value(s).\n\npre     C code to use before the assignment of the value of the constant. This allows you to\nuse temporary variables to extract a value from part of a \"struct\" and return this\nas *value*. This C code is places at the start of a block, so you can declare\nvariables in it.\n\npost    C code to place between the assignment of value (to a temporary) and the return from\nthe function. This allows you to clear up anything in *pre*. Rarely needed.\n\ndefpre\ndefpost\nEquivalents of *pre* and *post* for the default value.\n\nutf8    Generated internally. Is zero or undefined if name is 7 bit ASCII, \"no\" if the name\nis 8 bit (and so should only match if SvUTF8() is false), \"yes\" if the name is utf8\nencoded.\n\nThe internals automatically clone any name with characters 128-255 but none 256+ (ie\none that could be either in bytes or utf8) into a second entry which is utf8\nencoded.\n\nweight  Optional sorting weight for names, to determine the order of linear testing when\nmultiple names fall in the same case of a switch clause. Higher comes earlier,\nundefined defaults to zero.\n\nIn the argument hashref, *package* is the name of the package, and is only used in comments\ninside the generated C code. *subname* defaults to \"constant\" if undefined.\n\n*defaulttype* is the type returned by \"ITEM\"s that don't specify their type. It defaults to\nthe value of \"defaulttype()\". *types* should be given either as a comma separated list of\ntypes that the C subroutine *subname* will generate or as a reference to a hash.\n*defaulttype* will be added to the list if not present, as will any types given in the list\nof *ITEM*s. The resultant list should be the same list of types that \"XSconstant\" is given.\n[Otherwise \"XSconstant\" and \"Cconstant\" may differ in the number of parameters to the\nconstant function. *indent* is currently unused and ignored. In future it may be used to\npass in information used to change the C indentation style used.] The best way to maintain\nconsistency is to pass in a hash reference and let this function update it.\n\n*breakout* governs when child functions of *subname* are generated. If there are *breakout*\nor more *ITEM*s with the same length of name, then the code to switch between them is placed\ninto a function named *subname**len*, for example \"constant5\" for names 5 characters long.\nThe default *breakout* is 3. A single \"ITEM\" is always inlined.\n\n### BUGS\n\nNot everything is documented yet.\n\nProbably others.\n\n### AUTHOR\n\nNicholas Clark <nick@ccl4.org> based on the code in \"h2xs\" by Larry Wall and others\n\n"
        }
    ],
    "structuredContent": {
        "command": "ExtUtils::Constant::Base",
        "section": "",
        "mode": "perldoc",
        "summary": "ExtUtils::Constant::Base - base class for ExtUtils::Constant objects",
        "synopsis": "require ExtUtils::Constant::Base;\n@ISA = 'ExtUtils::Constant::Base';",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 4,
                "subsections": []
            },
            {
                "name": "USAGE",
                "lines": 136,
                "subsections": []
            },
            {
                "name": "BUGS",
                "lines": 4,
                "subsections": []
            },
            {
                "name": "AUTHOR",
                "lines": 2,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "ExtUtils::Constant::Base - base class for ExtUtils::Constant objects\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "require ExtUtils::Constant::Base;\n@ISA = 'ExtUtils::Constant::Base';\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "ExtUtils::Constant::Base provides a base implementation of methods to generate C code to give\nfast constant value lookup by named string. Currently it's mostly used ExtUtils::Constant::XS,\nwhich generates the lookup code for the constant() subroutine found in many XS modules.\n",
                "subsections": []
            },
            "USAGE": {
                "content": "ExtUtils::Constant::Base exports no subroutines. The following methods are available\n\nheader\nA method returning a scalar containing definitions needed, typically for a C header file.\n\nmemEQclause argshashref\nA method to return a suitable C \"if\" statement to check whether *name* is equal to the C\nvariable \"name\". If *checkedat* is defined, then it is used to avoid \"memEQ\" for short\nnames, or to generate a comment to highlight the position of the character in the \"switch\"\nstatement.\n\nIf i<checkedat> is a reference to a scalar, then instead it gives the characters\npre-checked at the beginning, (and the number of chars by which the C variable name has been\nadvanced. These need to be chopped from the front of *name*).\n\ndumpnames arghashref, ITEM...\nAn internal function to generate the embedded perl code that will regenerate the constant\nsubroutines. *defaulttype*, *types* and *ITEM*s are the same as for Cconstant. *indent* is\ntreated as number of spaces to indent by. If \"declaretypes\" is true a $types is always\ndeclared in the perl code generated, if defined and false never declared, and if undefined\n$types is only declared if the values in *types* as passed in cannot be inferred from\n*defaulttypes* and the *ITEM*s.\n\nassign arghashref, VALUE...\nA method to return a suitable assignment clause. If *type* is aggregate (eg *PVN* expects\nboth pointer and length) then there should be multiple *VALUE*s for the components. *pre*\nand *post* if defined give snippets of C code to proceed and follow the assignment. *pre*\nwill be at the start of a block, so variables may be defined in it.\n\nreturnclause arghashref, ITEM\nA method to return a suitable \"#ifdef\" clause. *ITEM* is a hashref (as passed to\n\"Cconstant\" and \"matchclause\". *indent* is the number of spaces to indent, defaulting to\n6.\n\nswitchclause arghashref, NAMELEN, ITEMHASH, ITEM...\nAn internal method to generate a suitable \"switch\" clause, called by \"Cconstant\" *ITEM*s\nare in the hash ref format as given in the description of \"Cconstant\", and must all have\nthe names of the same length, given by *NAMELEN*. *ITEMHASH* is a reference to a hash, keyed\nby name, values being the hashrefs in the *ITEM* list. (No parameters are modified, and\nthere can be keys in the *ITEMHASH* that are not in the list of *ITEM*s without causing\nproblems - the hash is passed in to save generating it afresh for each call).\n\nparams WHAT\nAn \"internal\" method, subject to change, currently called to allow an overriding class to\ncache information that will then be passed into all the \"*param*\" calls. (Yes, having to\nread the source to make sense of this is considered a known bug). *WHAT* is be a hashref of\ntypes the constant function will return. In ExtUtils::Constant::XS this method is used to\nreturns a hashref keyed IV NV PV SV to show which combination of pointers will be needed in\nthe C argument list generated by Cconstantotherparamsdefinition and\nCconstantotherparams\n\ndogfood arghashref, ITEM...\nAn internal function to generate the embedded perl code that will regenerate the constant\nsubroutines. Parameters are the same as for Cconstant.\n\nCurrently the base class does nothing and returns an empty string.\n\nnormaliseitems args, defaulttype, seentypes, seenitems, ITEM...\nConvert the items to a normalised form. For 8 bit and Unicode values converts the item to an\narray of 1 or 2 items, both 8 bit and UTF-8 encoded.\n\nCconstant arghashref, ITEM...\nA function that returns a list of C subroutine definitions that return the value and type of\nconstants when passed the name by the XS wrapper. *ITEM...* gives a list of constant names.\nEach can either be a string, which is taken as a C macro name, or a reference to a hash with\nthe following keys\n\nname    The name of the constant, as seen by the perl code.\n\ntype    The type of the constant (*IV*, *NV* etc)\n\nvalue   A C expression for the value of the constant, or a list of C expressions if the type\nis aggregate. This defaults to the *name* if not given.\n\nmacro   The C pre-processor macro to use in the \"#ifdef\". This defaults to the *name*, and\nis mainly used if *value* is an \"enum\". If a reference an array is passed then the\nfirst element is used in place of the \"#ifdef\" line, and the second element in place\nof the \"#endif\". This allows pre-processor constructions such as\n\n#if defined (foo)\n#if !defined (bar)\n...\n#endif\n#endif\n\nto be used to determine if a constant is to be defined.\n\nA \"macro\" 1 signals that the constant is always defined, so the \"#if\"/\"#endif\" test\nis omitted.\n\ndefault Default value to use (instead of \"croak\"ing with \"your vendor has not defined...\")\nto return if the macro isn't defined. Specify a reference to an array with type\nfollowed by value(s).\n\npre     C code to use before the assignment of the value of the constant. This allows you to\nuse temporary variables to extract a value from part of a \"struct\" and return this\nas *value*. This C code is places at the start of a block, so you can declare\nvariables in it.\n\npost    C code to place between the assignment of value (to a temporary) and the return from\nthe function. This allows you to clear up anything in *pre*. Rarely needed.\n\ndefpre\ndefpost\nEquivalents of *pre* and *post* for the default value.\n\nutf8    Generated internally. Is zero or undefined if name is 7 bit ASCII, \"no\" if the name\nis 8 bit (and so should only match if SvUTF8() is false), \"yes\" if the name is utf8\nencoded.\n\nThe internals automatically clone any name with characters 128-255 but none 256+ (ie\none that could be either in bytes or utf8) into a second entry which is utf8\nencoded.\n\nweight  Optional sorting weight for names, to determine the order of linear testing when\nmultiple names fall in the same case of a switch clause. Higher comes earlier,\nundefined defaults to zero.\n\nIn the argument hashref, *package* is the name of the package, and is only used in comments\ninside the generated C code. *subname* defaults to \"constant\" if undefined.\n\n*defaulttype* is the type returned by \"ITEM\"s that don't specify their type. It defaults to\nthe value of \"defaulttype()\". *types* should be given either as a comma separated list of\ntypes that the C subroutine *subname* will generate or as a reference to a hash.\n*defaulttype* will be added to the list if not present, as will any types given in the list\nof *ITEM*s. The resultant list should be the same list of types that \"XSconstant\" is given.\n[Otherwise \"XSconstant\" and \"Cconstant\" may differ in the number of parameters to the\nconstant function. *indent* is currently unused and ignored. In future it may be used to\npass in information used to change the C indentation style used.] The best way to maintain\nconsistency is to pass in a hash reference and let this function update it.\n\n*breakout* governs when child functions of *subname* are generated. If there are *breakout*\nor more *ITEM*s with the same length of name, then the code to switch between them is placed\ninto a function named *subname**len*, for example \"constant5\" for names 5 characters long.\nThe default *breakout* is 3. A single \"ITEM\" is always inlined.\n",
                "subsections": []
            },
            "BUGS": {
                "content": "Not everything is documented yet.\n\nProbably others.\n",
                "subsections": []
            },
            "AUTHOR": {
                "content": "Nicholas Clark <nick@ccl4.org> based on the code in \"h2xs\" by Larry Wall and others\n",
                "subsections": []
            }
        }
    }
}