public function GetParameterTemplate(
        \Peg\Lib\Definitions\Element\Parameter $parameter,
        $namespace="",
        $type="declare"
    )
    {
        if(!$this->generator_name)
        {
            throw new \Exception(t("The generator name wasn't set."));
        }
        
        if($namespace)
        {
            $namespace = str_replace(
                array("\\", "::"),
                "_",
                $namespace
            ) . "_";
        }

        $function_name = strtolower($parameter->overload->function->name);

        $parameter_type = strtolower($parameter->type);

        $const = "";
        if($parameter->is_const)
        {
            $const .= "_const";
        }

        $ptr = "";
        if($parameter->is_pointer)
        {
            for($i=0; $i<$parameter->indirection_level; $i++)
            {
                $ptr .= "_ptr";
            }
        }

        $ref = "";
        if($parameter->is_reference)
        {
            $ref .= "_ref";
        }

        $array = "";
        if($parameter->is_array)
        {
            $array .= "_arr";
        }

        $override_function = $this->templates_path
            . "parameters/{$type}/overrides/"
            . $function_name . "_" . $parameter_type
            . $const
            . $ptr
            . $ref
            . $array
            . ".php"
        ;

        if(file_exists($override_function))
        {
            return $override_function;
        }

        $override = $this->templates_path
            . "parameters/{$type}/overrides/"
            . $parameter_type
            . $const
            . $ptr
            . $ref
            . $array
            . ".php"
        ;

        if(file_exists($override))
        {
            return $override;
        }

        $standard_type = $this->symbols->GetStandardType($parameter);

        $template = $this->templates_path
            . "parameters/{$type}/"
            . $standard_type
            . $const
            . $ptr
            . $ref
            . $array
            . ".php"
        ;

        if(!file_exists($template))
        {    
            return $this->templates_path
                . "parameters/{$type}/"
                . "default.php"
            ;
        }

        return $template;
    }
public function GetParameterTemplate(
        \Peg\Lib\Definitions\Element\Parameter $parameter,
        $namespace="",
        $type="declare"
    )
    {
        if(!$this->generator_name)
        {
            throw new \Exception(t("The generator name wasn't set."));
        }
        
        if($namespace)
        {
            $namespace = str_replace(
                array("\\", "::"),
                "_",
                $namespace
            ) . "_";
        }

        $function_name = strtolower($parameter->overload->function->name);

        $parameter_type = strtolower($parameter->type);

        $const = "";
        if($parameter->is_const)
        {
            $const .= "_const";
        }

        $ptr = "";
        if($parameter->is_pointer)
        {
            for($i=0; $i<$parameter->indirection_level; $i++)
            {
                $ptr .= "_ptr";
            }
        }

        $ref = "";
        if($parameter->is_reference)
        {
            $ref .= "_ref";
        }

        $array = "";
        if($parameter->is_array)
        {
            $array .= "_arr";
        }

        $override_function = $this->templates_path
            . "parameters/{$type}/overrides/"
            . $function_name . "_" . $parameter_type
            . $const
            . $ptr
            . $ref
            . $array
            . ".php"
        ;

        if(file_exists($override_function))
        {
            return $override_function;
        }

        $override = $this->templates_path
            . "parameters/{$type}/overrides/"
            . $parameter_type
            . $const
            . $ptr
            . $ref
            . $array
            . ".php"
        ;

        if(file_exists($override))
        {
            return $override;
        }

        $standard_type = $this->symbols->GetStandardType($parameter);

        $template = $this->templates_path
            . "parameters/{$type}/"
            . $standard_type
            . $const
            . $ptr
            . $ref
            . $array
            . ".php"
        ;

        if(!file_exists($template))
        {    
            return $this->templates_path
                . "parameters/{$type}/"
                . "default.php"
            ;
        }

        return $template;
    }
public function GetParameterTemplate ( \ Peg \ Lib \ Definitions \ Element \ Parameter $ parameter , $ namespace = "" , $ type = "declare" ) { if ( ! $ this -> generator_name ) { throw new \ Exception ( t ( "The generator name wasn't set." ) ) ; } if ( $ namespace ) { $ namespace = str_replace ( array ( "\\" , "::" ) , "_" , $ namespace ) . "_" ; } $ function_name = strtolower ( $ parameter -> overload -> function -> name ) ; $ parameter_type = strtolower ( $ parameter -> type ) ; $ const = "" ; if ( $ parameter -> is_const ) { $ const .= "_const" ; } $ ptr = "" ; if ( $ parameter -> is_pointer ) { for ( $ i = 0 ; $ i < $ parameter -> indirection_level ; $ i ++ ) { $ ptr .= "_ptr" ; } } $ ref = "" ; if ( $ parameter -> is_reference ) { $ ref .= "_ref" ; } $ array = "" ; if ( $ parameter -> is_array ) { $ array .= "_arr" ; } $ override_function = $ this -> templates_path . "parameters/{$type}/overrides/" . $ function_name . "_" . $ parameter_type . $ const . $ ptr . $ ref . $ array . ".php" ; if ( file_exists ( $ override_function ) ) { return $ override_function ; } $ override = $ this -> templates_path . "parameters/{$type}/overrides/" . $ parameter_type . $ const . $ ptr . $ ref . $ array . ".php" ; if ( file_exists ( $ override ) ) { return $ override ; } $ standard_type = $ this -> symbols -> GetStandardType ( $ parameter ) ; $ template = $ this -> templates_path . "parameters/{$type}/" . $ standard_type . $ const . $ ptr . $ ref . $ array . ".php" ; if ( ! file_exists ( $ template ) ) { return $ this -> templates_path . "parameters/{$type}/" . "default.php" ; } return $ template ; }
Retrieve the template path for parameters, also checks
if a valid override exists and returns that instead.
@param \Peg\Lib\Definitions\Element\Parameter $parameter Name of the function.
@param string $namespace
@param string $type Can be declare, parse_string, parse,
parse_string_ref, parse_reference or object_validate.
@return string Path to template file.
Retrieve the template path for parameters also checks if a valid override exists and returns that instead .