private function ExtractVariables(\DOMDocument $document, $namespace = "")
    {
        $xpath = new DOMXPath($document);

        $entries = $xpath->evaluate(
            "//compound[@kind='file'] | //compound[@kind='namespace']", 
            $document
        );

        for($i = 0; $i < $entries->length; $i++)
        {
            $kind = $entries->item($i)->getAttribute("kind");
            $refid = $entries->item($i)->getAttribute("refid");
            $name = $entries->item($i)->childNodes->item(0)->nodeValue;

            if($kind == "namespace")
                $namespace = str_replace("::", "\\", $name);
            else
                $namespace = "\\";

            $file_doc = new DOMDocument();
            $file_doc->load($this->definitions_path . "/$refid.xml");

            $file_xpath = new DOMXPath($file_doc);

            $file_members = $file_xpath->evaluate(
                "//memberdef[@kind='variable']", 
                $file_doc
            );

            for($member = 0; $member < $file_members->length; $member++)
            {
                $location = str_replace(
                    $this->headers_path, 
                    "", 
                    str_replace(
                        "\\", 
                        "/", 
                        $file_xpath->evaluate(
                            "location", 
                            $file_members->item($member)
                        )->item(0)->getAttribute("file")
                    )
                );

                $global_variable_name = $file_xpath->evaluate(
                    "name", 
                    $file_members->item($member)
                )->item(0)->nodeValue;
                
                $global_variable_type = $file_xpath->evaluate(
                    "type", 
                    $file_members->item($member)
                )->item(0)->nodeValue;
                
                $global_variable_description = $file_xpath->evaluate(
                    "briefdescription", 
                    $file_members->item($member)
                )->item(0)->nodeValue;

                $variable = new \Peg\Lib\Definitions\Element\GlobalVariable(
                    $global_variable_name, 
                    str_replace(
                        array(" *", " &"), 
                        array("*", "&"), 
                        $global_variable_type
                    ),
                    $global_variable_description
                );
                
                $this->symbols->AddGlobalVar($variable, $location, $namespace);
            }
        }
    }
private function ExtractVariables(\DOMDocument $document, $namespace = "")
    {
        $xpath = new DOMXPath($document);

        $entries = $xpath->evaluate(
            "//compound[@kind='file'] | //compound[@kind='namespace']", 
            $document
        );

        for($i = 0; $i < $entries->length; $i++)
        {
            $kind = $entries->item($i)->getAttribute("kind");
            $refid = $entries->item($i)->getAttribute("refid");
            $name = $entries->item($i)->childNodes->item(0)->nodeValue;

            if($kind == "namespace")
                $namespace = str_replace("::", "\\", $name);
            else
                $namespace = "\\";

            $file_doc = new DOMDocument();
            $file_doc->load($this->definitions_path . "/$refid.xml");

            $file_xpath = new DOMXPath($file_doc);

            $file_members = $file_xpath->evaluate(
                "//memberdef[@kind='variable']", 
                $file_doc
            );

            for($member = 0; $member < $file_members->length; $member++)
            {
                $location = str_replace(
                    $this->headers_path, 
                    "", 
                    str_replace(
                        "\\", 
                        "/", 
                        $file_xpath->evaluate(
                            "location", 
                            $file_members->item($member)
                        )->item(0)->getAttribute("file")
                    )
                );

                $global_variable_name = $file_xpath->evaluate(
                    "name", 
                    $file_members->item($member)
                )->item(0)->nodeValue;
                
                $global_variable_type = $file_xpath->evaluate(
                    "type", 
                    $file_members->item($member)
                )->item(0)->nodeValue;
                
                $global_variable_description = $file_xpath->evaluate(
                    "briefdescription", 
                    $file_members->item($member)
                )->item(0)->nodeValue;

                $variable = new \Peg\Lib\Definitions\Element\GlobalVariable(
                    $global_variable_name, 
                    str_replace(
                        array(" *", " &"), 
                        array("*", "&"), 
                        $global_variable_type
                    ),
                    $global_variable_description
                );
                
                $this->symbols->AddGlobalVar($variable, $location, $namespace);
            }
        }
    }
private function ExtractVariables ( \ DOMDocument $ document , $ namespace = "" ) { $ xpath = new DOMXPath ( $ document ) ; $ entries = $ xpath -> evaluate ( "//compound[@kind='file'] | //compound[@kind='namespace']" , $ document ) ; for ( $ i = 0 ; $ i < $ entries -> length ; $ i ++ ) { $ kind = $ entries -> item ( $ i ) -> getAttribute ( "kind" ) ; $ refid = $ entries -> item ( $ i ) -> getAttribute ( "refid" ) ; $ name = $ entries -> item ( $ i ) -> childNodes -> item ( 0 ) -> nodeValue ; if ( $ kind == "namespace" ) $ namespace = str_replace ( "::" , "\\" , $ name ) ; else $ namespace = "\\" ; $ file_doc = new DOMDocument ( ) ; $ file_doc -> load ( $ this -> definitions_path . "/$refid.xml" ) ; $ file_xpath = new DOMXPath ( $ file_doc ) ; $ file_members = $ file_xpath -> evaluate ( "//memberdef[@kind='variable']" , $ file_doc ) ; for ( $ member = 0 ; $ member < $ file_members -> length ; $ member ++ ) { $ location = str_replace ( $ this -> headers_path , "" , str_replace ( "\\" , "/" , $ file_xpath -> evaluate ( "location" , $ file_members -> item ( $ member ) ) -> item ( 0 ) -> getAttribute ( "file" ) ) ) ; $ global_variable_name = $ file_xpath -> evaluate ( "name" , $ file_members -> item ( $ member ) ) -> item ( 0 ) -> nodeValue ; $ global_variable_type = $ file_xpath -> evaluate ( "type" , $ file_members -> item ( $ member ) ) -> item ( 0 ) -> nodeValue ; $ global_variable_description = $ file_xpath -> evaluate ( "briefdescription" , $ file_members -> item ( $ member ) ) -> item ( 0 ) -> nodeValue ; $ variable = new \ Peg \ Lib \ Definitions \ Element \ GlobalVariable ( $ global_variable_name , str_replace ( array ( " *" , " &" ) , array ( "*" , "&" ) , $ global_variable_type ) , $ global_variable_description ) ; $ this -> symbols -> AddGlobalVar ( $ variable , $ location , $ namespace ) ; } } }
Extract global variables.
@param \DOMDocument $document
@param string $namespace
Extract global variables .