genIncludeHeaderFiles(); ?> #include "ps_title.h" #include "php_cli_process_title.h" #include "php_cli_process_title_arginfo.h" // global vars globalVars as $name => $type): ?> escapeGlobalVar($name) ?>; // class register functions classCeList as $ce): ?> zend_class_entry * ; // class entry zend_class_entry *classMap) . ']' ?>; // func zend_function *funcMap) . ']' ?>; // property uint32_t propMap) . ']' ?>; zend_class_entry *php_get_class(int class_id, const php::String &class_name) { if (UNEXPECTED([class_id] == nullptr)) { [class_id] = php::getClassEntrySafe(class_name); } return [class_id]; } zend_function *php_get_func(int func_id, const php::String &func_name) { if (UNEXPECTED([func_id] == nullptr)) { [func_id] = php::getFunction(func_name); } return [func_id]; } zend_function *php_get_method(int func_id, const php::Str &method_name, int class_id, const php::Str &class_name) { if (UNEXPECTED([func_id] == nullptr)) { auto ce = php_get_class(class_id, class_name); [func_id] = php::getMethod(ce, method_name); } return [func_id]; } uint32_t php_get_prop(int prop_id, const php::Str &prop_name, int class_id, const php::Str &class_name) { if (UNEXPECTED([prop_id] == 0)) { [prop_id] = php::getPropertyOffset(class_name, prop_name) + 1024; } return [prop_id] - 1024; } // literal strings php::Str [] = { literalStrings as $str => $index): ?> php::String{ZEND_STRL("escapeString($str)?>"), true}, // [] }; // constants constants as $name => $const): ?> type?> ; // class classes as $classDef) : if ($classDef->requireCtor) { echo "static zend_object* (*create_object_" . $classDef->getNamespacedName() . ")(zend_class_entry *class_type);"; } foreach ($classDef->constants as $constant) : if ($constant->type === Translator::TYPE_ARRAY) : $constName = Translator::PREFIX . $this->getNativeName($constant->name, $classDef->namespace, $classDef->name); echo Translator::TYPE_VAR . " " . $constName . ";\n"; endif; endforeach; endforeach; ?> // clang-format off static const zend_function_entry ext_functions[] = { PHP_FE(cli_set_process_title, arginfo_cli_set_process_title) PHP_FE(cli_get_process_title, arginfo_cli_get_process_title) functions as $functionDef): if ($this->buildMode === 'ext' and $functionDef->name === 'main') { continue; } if ($functionDef->method) { continue; } $zif_name = $this->escapeZendFnName($functionDef->getNamespacedName()); ?> namespace): ?> ZEND_NAMED_FE("escapeString($functionDef->getNamespacedName())?>", ZEND_FN(), arginfo_) ZEND_FE(, arginfo_) ZEND_FE_END }; // clang-format on PHP_MINIT_FUNCTION(getModuleName()?>) { zend_try { // class/interface class entries genClassPropertyInit()?> // register symbols registerSymbols as $registerSymbolFn): ?> (module_number); } zend_end_try(); return SUCCESS; } void php_app_init() { // register constants constants as $name => $const): ?> = value ?>; php::define("escapeString($const->name)?>", ); // global vars globalVars as $name => $type): ?> php::initGlobal("", escapeGlobalVar($name) ?>); // static property defaultStaticPropertyList as $prop): ?> php::setStaticProperty(genCharPtr($prop->class, true)?>, genCharPtr($prop->name)?>, default?>); // class array constants genClassArrayConstants();?> } void php_app_clean() { globalVars as $name => $type) : ?> escapeGlobalVar($name) ?>.unset(); php::unsetGlobal(""); constants as $name => $const): if ($const->type !== Translator::TYPE_VAR) { continue; } ?> .unset(); // class array constants classes as $classDef) : foreach ($classDef->constants as $constant) : if ($constant->type === Translator::TYPE_ARRAY) : $constName = Translator::PREFIX . $this->getNativeName($constant->name, $classDef->namespace, $classDef->name); echo $constName . ".unset();\n"; endif; endforeach; endforeach; ?> } PHP_RINIT_FUNCTION(getModuleName()?>) { php::request_init(); php_app_init(); buildMode === 'bin'): ?> functions['main']->argInfoList) == 2): ?> php::eval("global $argc, $argv; main($argc, $argv);"); php::eval("main();"); return SUCCESS; } PHP_RSHUTDOWN_FUNCTION(getModuleName()?>) { php_app_clean(); php::request_shutdown(); return SUCCESS; } zend_module_entry getModuleName()?>_module_entry = { STANDARD_MODULE_HEADER, "getModuleName()?>", ext_functions, PHP_MINIT(getModuleName()?>), nullptr, PHP_RINIT(getModuleName()?>), PHP_RSHUTDOWN(getModuleName()?>), nullptr, nullptr, STANDARD_MODULE_PROPERTIES, }; buildMode === 'ext'): ?> ZEND_GET_MODULE(getModuleName()?>); zend_module_entry *get_module() { return &getModuleName() ?>_module_entry; }