function write_param($type, $name, $default, $null_ok, $info, $in_constructor = null) { if ($null_ok) { $info->var_list->add('GtkTreePath', '*' . $name . ' = NULL'); $info->var_list->add('zval', '*php_' . $name . ' = NULL'); $info->arg_list[] = $name; $info->add_parse_list('V', '&php_' . $name); $info->pre_code[] = aprintf(self::null_tpl, array('name' => $name, 'on_error' => $info->error_action)); $info->post_code[] = aprintf(self::free_path_tpl, array('name' => $name)); } else { $info->var_list->add('GtkTreePath', '*' . $name); $info->var_list->add('zval', '*php_' . $name); $info->arg_list[] = $name; $info->add_parse_list('V', '&php_' . $name); $info->pre_code[] = aprintf(self::normal_tpl, array('name' => $name, 'on_error' => $info->error_action)); $info->post_code[] = aprintf(self::free_path_tpl, array('name' => $name)); } }
function write_class($class) { $this->log_print("\n%s\n%s\n", $class->c_name, str_repeat('~', 50)); $class_module = strtolower($class->in_module); $class_lname = strtolower($class->name); $create_func = 'NULL'; $extra_reg_info = ''; $ctor_defs = null; $prop_info = 'NULL'; $ctor_arginfo = ''; if ($class->def_type != 'interface') { /* interfaces don't have these */ list($ctor_defs, $ctor_arginfo) = $this->write_constructor($class); $prop_info = $this->write_prop_handlers($class); list($create_func, $extra_reg_info) = $this->write_object_handlers($class); } list($method_entries, $method_arginfo) = $this->write_methods($class); ksort($method_entries); $method_defs = $this->make_method_defs($class, $method_entries); $arginfo = $ctor_arginfo . $method_arginfo; if ($ctor_defs) { $method_defs = array_merge($ctor_defs, $method_defs); } if ($method_defs) { $this->fp->write($arginfo); $this->fp->write(sprintf(Templates::functions_decl, strtolower($class->c_name))); $this->fp->write(join('', $method_defs)); $this->fp->write(Templates::functions_decl_end); } if ($class->def_type == 'object' && $class->implements) { $iface_entries = array(); foreach ($class->implements as $interface) { $iface_entries[] = strtolower($interface) . '_ce'; } $extra_reg_info .= aprintf(Templates::implement_interface, array('ce' => $class->ce, 'ifaces' => join(', ', $iface_entries), 'num_ifaces' => count($iface_entries))); } /* Do not register gtype constants for interfaces, since interfaces will never be instantiated anyway. */ if ($class->def_type != 'interface') { $this->gtype_constants .= sprintf(Templates::gtype_constant, $class->ce, $class->typecode); } return array('ce' => $class->ce, 'class' => $class->in_module . $class->name, 'methods' => $method_defs ? strtolower($class->c_name) . '_methods' : 'NULL', 'parent' => $class->def_type == 'object' && $class->parent ? strtolower($class->parent) . '_ce' : 'NULL', 'ce_flags' => $class->ce_flags ? implode('|', $class->ce_flags) : 0, 'typecode' => $class->typecode, 'create_func' => $create_func, 'extra_reg_info' => $extra_reg_info, 'propinfo' => $prop_info); }
/** * Get modules' path * * @param PackageInterface $package * @return array|\Traversable */ public function getModulesPaths(PackageInterface $package) { $path = $this->getInstallPath($package); switch ($package->getType()) { case static::TYPE_MODULE: return array($path); case static::TYPE_MODULES: $extra = $package->getExtra(); $module = isset($extra['module-dir']) ? trim($extra['module-dir'], '/') : 'module'; return new CallbackFilterIterator(new FilesystemIterator($path . '/' . $module, FilesystemIterator::CURRENT_AS_PATHNAME | FilesystemIterator::KEY_AS_FILENAME | FilesystemIterator::SKIP_DOTS | FilesystemIterator::UNIX_PATHS), function ($current, $key, $iterator) { return $iterator->isDir() && '.' !== $key[0]; }); default: throw new RuntimeException(aprintf('%s: package-type "%s" does not supported', __METHOD__, $package->getType())); } }