//entries ---> code <--- entries echo "Generating php_wxwidgets.h...\n"; $output = ""; foreach ($defIni as $className => $classDef) { foreach ($classDef as $fcName => $fc) { //Skip specification attributes like _pure_virtual, _implements, etc... if ($fcName[0] == "_") { continue; } if ($fcName == $className) { $fcName = "__construct"; if (isset($defClassProperties[$className])) { $output .= "PHP_METHOD(php_{$className}, __get);\n"; } } $fcName = php_method_name($fcName); $output .= "PHP_METHOD(php_{$className}, {$fcName});\n"; } if (isset($evnHandlers[$className])) { $output .= "PHP_METHOD(php_{$className}, Connect);\n"; } } $old = file_get_contents("source_templates/php_wxwidgets.h"); if (preg_match("/(.*?\\/\\/ entries --->)[^<]+(\\/\\/ <--- entries[^§]+)/sm", $old, $matches)) { $output = $matches[1] . "\n" . $output . $matches[2]; $hd = fopen("./../../php_wxwidgets.h", "w"); fwrite($hd, $output); fclose($hd); } //Update common.h by just upgrading the code betewen //entries ---> code <--- entries
$static = $method_definition["static"] ? "static " : ""; $return_type = $method_name != "class_name" ? get_method_type_link($method_definition["return_type"]) . " " : ""; $return_type = str_replace(array("<span class=\"parameter-name\">", "</span>"), "", $return_type); $return_type = trim($return_type, " \$"); $return_type = str_replace(" &", "&", $return_type); foreach ($method_definition["parameters_type"] as $parameter_index => $parameter_type) { $parameter_name = $method_definition["parameters_name"][$parameter_index]; $parameters .= "<span class=\"parameter-type\">" . get_method_type_link($parameter_type, $parameter_name, $method_name, $class_name) . "</span>"; if ($method_definition["parameters_default_value"][$parameter_index]) { $parameters .= "=" . "<span class=\"parameter-value\">" . $method_definition["parameters_default_value"][$parameter_index] . "</span>"; } $parameters .= ", "; } $parameters = rtrim($parameters, ", "); $parameters .= " )"; $content .= "{$static}<span class=\"return-type\">{$return_type}</span> <span class=\"method\">" . php_method_name($method_name) . "<span> {$parameters}<br />\n"; if ($method_definition["brief_description"]) { $content .= "<div class=\"function_description_bottom\">" . $method_definition["brief_description"] . "</div>"; } } $content .= "</ul>\n"; $content .= "<hr />\n\n"; } } if (file_exists("../doc/footer.html")) { $content .= file_get_contents("../doc/footer.html"); } else { $content .= $footer_html; } $content .= "\n</body>"; fwrite($class_file, $content);
if (isset($defEnums[0][$class_name])) { foreach ($defEnums[0][$class_name] as $enumName => $enumList) { foreach ($enumList as $enumOption => $enumValue) { $content .= "\tconst {$enumValue} = 1;\n"; } } $content .= "\n"; } foreach ($class_methods as $method_name => $method_definitions) { if ($method_name[0] != "_") { $content .= generata_documentation($method_name, $method_definitions, 1) . "\n"; $content .= "\t"; if ($method_definitions[0]["static"]) { $content .= " static "; } $content .= "function " . php_method_name($method_name) . "("; $arguments = ""; foreach ($method_definitions as $method_index => $method_definition) { foreach ($method_definition["parameters_type"] as $parameter_index => $parameter_type) { $argument_data = get_argument_declaration($parameter_type, $method_definition["parameters_name"][$parameter_index], $method_name, $class_name); if ($argument_data) { $arguments .= $argument_data; if ($method_definition["parameters_default_value"][$parameter_index]) { $argument_value = $method_definition["parameters_default_value"][$parameter_index]; if ($argument_value == "wxString()") { $argument_value = "''"; } elseif ($argument_value[0] == "(") { $argument_value = "null"; } elseif ($argument_value[0] == "_" && $argument_value[1] == "(") { $argument_value = str_replace(array("_(", ")"), "", $argument_value); } elseif ($argument_value[0] == "w" && $argument_value[1] == "x" && $argument_value[2] == "T" && $argument_value[3] == "(") {
<?php echo proto_begin($method_name, $class_name); ?> PHP_METHOD(php_<?php echo $class_name; ?> , <?php echo php_method_name($method_name); ?> ) { #ifdef USE_WXPHP_DEBUG php_printf("Invoking <?php echo $class_name; ?> ::<?php echo $method_name; ?> \n"); php_printf("===========================================\n"); #endif zo_<?php echo $class_name; ?> * current_object; wxphp_object_type current_object_type; <?php echo $class_name; ?>
/** * Recursive function to generate a list of class methods for the templates.h * * @param $classN The name of the class to which generate the methods * @param $ctor boolean value to indicate if constructors should be generated or not * @param $output A reference variable where the output of the function will be stored. * @param $multiple_inheritance If true will explictly return all methods it inherit from. * * @return array All function names */ function funcsOfClass($classN, $ctor = 0, &$output, $ar = array(), $multiple_inheritance = false) { global $defIni; $class_methods = ""; if (!isset($defIni[$classN])) { return array(); } $classDef3 = $classDef = $defIni[$classN]; foreach ($classDef as $funcName => $funcDef) { if ($funcName[0] == "_") { continue; } if ($funcDef[0]["virtual"] && $funcDef[0]["protected"] || $funcDef[0]["pure_virtual"] || "" . strpos($funcName, "On") . "" == "0") { continue; } $funcName2 = $funcName; if ($classN == $funcName) { if (!$ctor) { continue; } $funcName2 = "__construct"; } //Rename conflicting method names with PHP keywords $funcName2 = php_method_name($funcName2); if (in_array($funcName2, $ar)) { continue; } $ar[] = $funcName2; $class_methods .= "\tPHP_ME(php_{$classN}, {$funcName2}, NULL, "; if ($funcDef[0]["static"]) { $class_methods .= "ZEND_ACC_STATIC|"; } $class_methods .= "ZEND_ACC_PUBLIC"; if ($funcName2 == "__construct" && $ctor) { $class_methods .= "|ZEND_ACC_CTOR"; } $class_methods .= ")\n"; } //becarefull not to mark a subclasse that is derived from another //this should be recursive if (isset($classDef['_implements']) && count($classDef['_implements']) > 1 || $multiple_inheritance) { $multiple_inheritance = true; foreach ($classDef['_implements'] as $imp) { $ar = array_merge($ar, funcsOfClass($imp, 0, $output, $ar, $multiple_inheritance)); continue; if (!isset($defIni[$imp])) { continue; } $classDef2 = $defIni[$imp]; foreach ($classDef2 as $funcName2 => $funcDef2) { if ($funcName2[0] == "_") { //ignore implements and constructors continue; } $found = false; $funcNamer = $funcName2; if ($funcName2 == $imp) { $funcNamer = $classN; } foreach ($classDef3 as $funcName => $funcDef) { if ($funcNamer == $funcName) { $found = true; } } //if already exists functions with the same name, verify if equal args if ($found) { for ($i = 0; $i < count($funcDef2); $i += 2) { $found = false; for ($e = 0; $e < count($classDef[$funcNamer]); $e += 2) { if ($funcDef2[$i] == $classDef[$funcNamer][$e]) { $found = true; } } if (!$found) { $classDef[$funcNamer][] = $classDef2[$funcName2][$i]; $classDef[$funcNamer][] = $classDef2[$funcName2][$i + 1]; } } } elseif ($funcName2 == $imp) { // prevent foreign constructors //just skip it } else { if ($funcDef[0]["static"]) { $class_methods .= "\tPHP_ME(php_{$imp}, {$funcName2}, NULL, ZEND_ACC_STATIC|ZEND_ACC_PUBLIC)\n"; } else { $class_methods .= "\tPHP_ME(php_{$imp}, {$funcName2}, NULL, ZEND_ACC_PUBLIC)\n"; } } } } } $output .= $class_methods; return $ar; }