You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.1 KiB
PHTML
40 lines
1.1 KiB
PHTML
3 years ago
|
<?php
|
||
|
|
||
|
if ( ! file_exists(__DIR__ . "/../resources/gl.xml")) {
|
||
|
copy("https://cvs.khronos.org/svn/repos/ogl/trunk/doc/registry/public/api/gl.xml", __DIR__ . "/../resources/gl.xml");
|
||
|
}
|
||
|
|
||
|
$xml = new DOMDocument();
|
||
|
$xml->loadXML(file_get_contents(__DIR__ . "/../resources/gl.xml"));
|
||
|
|
||
|
$commands = $xml->getElementsByTagName("commands")->item(0);
|
||
|
|
||
|
$data = file_get_contents(__DIR__ . "/../headers/gl.h");
|
||
|
|
||
|
$data .= "// GENERATED DATA START\n\n";
|
||
|
|
||
|
/** @var DOMNode $node */
|
||
|
foreach ($commands->childNodes as $node) {
|
||
|
if ($node->nodeName !== "command") {
|
||
|
continue;
|
||
|
}
|
||
|
|
||
|
/** @var DOMElement $node */
|
||
|
$proto = $node->getElementsByTagName("proto")->item(0);
|
||
|
|
||
|
/** @var DOMElement $name */
|
||
|
$name = $proto->getElementsByTagName("name")[0];
|
||
|
$name->remove();
|
||
|
|
||
|
$returnType = trim($proto->textContent);
|
||
|
$functionName = trim($name->textContent);
|
||
|
|
||
|
$args = [];
|
||
|
foreach ($node->getElementsByTagName("param") as $param) {
|
||
|
$args[] = trim($param->textContent);
|
||
|
}
|
||
|
|
||
|
$data .= "typedef $returnType (* FUNC_$functionName) (" . implode(", ", $args) . ");\n";
|
||
|
}
|
||
|
|
||
|
file_put_contents(__DIR__ . "/../headers/gl_generated.h", $data);
|