Only in lasso: .git Only in lasso: .gitignore Only in lasso-2.8.2: .tarball-version Only in lasso-2.8.2: .version Only in lasso-2.8.2: aclocal.m4 diff '--exclude=ChangeLog' -ur lasso-2.8.2/bindings/bindings.py lasso/bindings/bindings.py --- lasso-2.8.2/bindings/bindings.py 2021-09-12 01:20:25.844637900 +0800 +++ lasso/bindings/bindings.py 2024-10-26 11:06:24.458046500 +0800 @@ -23,16 +23,9 @@ import os import re -from six import print_, PY3 import sys from utils import * -if PY3: - do_open = lambda *args, **kwargs: open(*args, encoding='utf-8', **kwargs) -else: - do_open = open - - from optparse import OptionParser try: @@ -166,10 +159,10 @@ if not 'Makefile.am' in filenames: # not a source dir continue - makefile_am = do_open(os.path.join(base, 'Makefile.am')).read() + makefile_am = open(os.path.join(base, 'Makefile.am')).read() filenames = [x for x in filenames if x.endswith('.c') if x in makefile_am] for filename in filenames: - s = do_open(os.path.join(base, filename)).read() + s = open(os.path.join(base, filename)).read() docstrings = regex.findall(s) for d in docstrings: docstring = '\n'.join([x[3:] for x in d.splitlines()]) @@ -247,7 +240,7 @@ try: arg = [x for x in self.args if x[1] == param.attrib.get('name')][0] except IndexError: - print_('W: no such param (%s) in function (%s)' % ( + print('W: no such param (%s) in function (%s)' % ( param.attrib.get('name'), self.name), file=sys.stderr) continue if param.attrib.get('optional') == 'true': @@ -410,7 +403,7 @@ in_struct_private = False in_ifdef_zero = False - lines = do_open(header_file).readlines() + lines = open(header_file).readlines() i = 0 while i < len(lines): line = lines[i] @@ -435,7 +428,7 @@ enum_name = line[2:].strip().strip(';') binding.enums.append(enum_name) else: - m = re.match('\s*([a-zA-Z0-9_]+)', line) + m = re.match(r'\s*([a-zA-Z0-9_]+)', line) if m: binding.constants.append(('i', m.group(1))) elif line.startswith('#define'): @@ -475,7 +468,7 @@ if not in_struct.name in binding.structs_toskip: binding.structs.append(in_struct) else: - print_('W: skipping structure %s due to overrides.xml' % in_struct.name, file=sys.stderr) + print('W: skipping structure %s due to overrides.xml' % in_struct.name, file=sys.stderr) in_struct = None elif '/*< public >*/' in line: in_struct_private = False @@ -489,13 +482,13 @@ # TODO: Add parsing of OFTYPE # Transform struct to typedef # example: "struct _LassoAssertion" -> "LassoAssertion" - line = re.sub('\s+struct _', ' ', line) - member_match = re.match('\s+(\w+)\s+(\*?\w+)', line) + line = re.sub(r'\s+struct _', ' ', line) + member_match = re.match(r'\s+(\w+)\s+(\*?\w+)', line) if member_match: member_type, member_name = normalise_var(member_match.group(1), member_match.group(2)) field = (member_type, member_name, {}) if member_type == 'void*': - print_('W: skipping field %s.%s' % (in_struct.name, member_name), file=sys.stderr) + print('W: skipping field %s.%s' % (in_struct.name, member_name), file=sys.stderr) else: if is_glist(field) or is_hashtable(field): found = re.search(r' of ([^*]*)', line) @@ -544,13 +537,13 @@ type = clean_type(type) f.args.append(list((type, name, {}))) else: - print_('failed to process:', arg, 'in line:', line, file=sys.stderr) + print('failed to process:', arg, 'in line:', line, file=sys.stderr) f.skip = True f.apply_overrides() if not f.skip: binding.functions.append(f) else: - print_('W: skipping function', f, file=sys.stderr) + print('W: skipping function', f, file=sys.stderr) i += 1 Only in lasso/bindings/java: __init__.py Only in lasso/bindings/java: GObject.java Only in lasso/bindings/java: lang.py Only in lasso/bindings/java: LassoException_top.java Only in lasso-2.8.2/bindings/java: Makefile.in Only in lasso/bindings/java: tests Only in lasso/bindings/java: wrapper_bottom.c Only in lasso/bindings/java: wrapper_top.c Only in lasso-2.8.2/bindings: Makefile.in diff '--exclude=ChangeLog' -ur lasso-2.8.2/bindings/overrides.xml lasso/bindings/overrides.xml --- lasso-2.8.2/bindings/overrides.xml 2021-09-12 01:20:25.844637900 +0800 +++ lasso/bindings/overrides.xml 2024-10-26 11:06:24.465045200 +0800 @@ -23,6 +23,7 @@ + _cptr->typename to see if it got the # right class type - six.print_(' public $_cptr = null;', file=self.fd) - six.print_('', file=self.fd) - six.print_(' public function __construct(%s) {' % php_args, file=self.fd) - six.print_(' $this->_cptr = %s(%s);' % (m.name, c_args), file=self.fd) - six.print_(' if (is_null($this->_cptr)) { throw new Exception("Constructor for ', klass.name, ' failed "); }', file=self.fd) - six.print_(' }', file=self.fd) - six.print_('', file=self.fd) + print(' public $_cptr = null;', file=self.fd) + print('', file=self.fd) + print(' public function __construct(%s) {' % php_args, file=self.fd) + print(' $this->_cptr = %s(%s);' % (m.name, c_args), file=self.fd) + print(' if (is_null($this->_cptr)) { throw new Exception("Constructor for ', klass.name, ' failed "); }', file=self.fd) + print(' }', file=self.fd) + print('', file=self.fd) elif name.startswith(method_prefix) and m.args \ and clean_type(unconstify(m.args[0][0])) != klass.name: @@ -186,10 +185,10 @@ c_args.append('$%s' % arg_name) php_args = ', '.join(php_args) c_args = ', '.join(c_args) - six.print_(' public static function %s(%s) {' % (php_name, php_args), file=self.fd) - six.print_(' return cptrToPhp(%s(%s));' % (m.name, c_args), file=self.fd) - six.print_(' }', file=self.fd) - six.print_('', file=self.fd) + print(' public static function %s(%s) {' % (php_name, php_args), file=self.fd) + print(' return cptrToPhp(%s(%s));' % (m.name, c_args), file=self.fd) + print(' }', file=self.fd) + print('', file=self.fd) @@ -201,50 +200,50 @@ 'class': c.name } - six.print_('''\ + print('''\ /** * @return %(docstring)s */ protected function get_%(name)s() {''' % d, file=self.fd) - six.print_(' $t = %(class)s_%(name)s_get($this->_cptr);' % d, file=self.fd) + print(' $t = %(class)s_%(name)s_get($this->_cptr);' % d, file=self.fd) if self.is_object(m): - six.print_(' $t = cptrToPhp($t);', file=self.fd) + print(' $t = cptrToPhp($t);', file=self.fd) elif (is_glist(m) or is_hashtable(m)) and self.is_object(element_type(m)): - six.print_(' foreach ($t as $key => $item) {', file=self.fd) - six.print_(' $t[$key] = cptrToPhp($item);', file=self.fd) - six.print_(' }', file=self.fd) + print(' foreach ($t as $key => $item) {', file=self.fd) + print(' $t[$key] = cptrToPhp($item);', file=self.fd) + print(' }', file=self.fd) elif is_hashtable(m) or (is_glist(m) and (is_cstring(element_type(m)) \ or is_xml_node(element_type(m)))) or is_int(m, self.binding_data) \ or is_boolean(m) or is_cstring(m) or is_xml_node(m): pass else: raise Exception('Cannot generate a Php getter %s.%s' % (c,m)) - six.print_(' return $t;', file=self.fd) - six.print_(' }', file=self.fd) + print(' return $t;', file=self.fd) + print(' }', file=self.fd) def generate_setter(self, c, m): d = { 'type': arg_type(m), 'name': format_as_camelcase(arg_name(m)), 'docstring': self.get_docstring_return_type(arg_type(m)), 'class': c.name } - six.print_(' protected function set_%(name)s($value) {' % d, file=self.fd) + print(' protected function set_%(name)s($value) {' % d, file=self.fd) if self.is_object(m): - six.print_(' $value = $value->_cptr;', file=self.fd) + print(' $value = $value->_cptr;', file=self.fd) elif (is_glist(m) or is_hashtable(m)) and self.is_object(element_type(m)): - six.print_(' $array = array();', file=self.fd) - six.print_(' if (!is_null($value)) {', file=self.fd) - six.print_(' foreach ($value as $key => $item) {', file=self.fd) - six.print_(' $array[$key] = $item->_cptr;', file=self.fd) - six.print_(' }', file=self.fd) - six.print_(' }', file=self.fd) - six.print_(' $value = $array;', file=self.fd) + print(' $array = array();', file=self.fd) + print(' if (!is_null($value)) {', file=self.fd) + print(' foreach ($value as $key => $item) {', file=self.fd) + print(' $array[$key] = $item->_cptr;', file=self.fd) + print(' }', file=self.fd) + print(' }', file=self.fd) + print(' $value = $array;', file=self.fd) elif is_hashtable(m) or (is_glist(m) and (is_cstring(element_type(m)) \ or is_xml_node(element_type(m)))) or is_int(m, self.binding_data) \ or is_boolean(m) or is_cstring(m) or is_xml_node(m): pass else: raise Exception('Cannot generate a Php setter %s.%s' % (c,m)) - six.print_(' %(class)s_%(name)s_set($this->_cptr, $value);' % d, file=self.fd) - six.print_(' }', file=self.fd) - six.print_('', file=self.fd) + print(' %(class)s_%(name)s_set($this->_cptr, $value);' % d, file=self.fd) + print(' }', file=self.fd) + print('', file=self.fd) def generate_getters_and_setters(self, klass): for m in klass.members: @@ -272,27 +271,27 @@ mname = re.match(r'lasso_.*_get_(\w+)', meth_name).group(1) mname = format_as_camelcase(mname) - six.print_(' /**', file=self.fd) - six.print_(' * @return %s' % self.get_docstring_return_type(m.return_type), file=self.fd) - six.print_(' */', file=self.fd) - six.print_(' protected function get_%s() {' % mname, file=self.fd) + print(' /**', file=self.fd) + print(' * @return %s' % self.get_docstring_return_type(m.return_type), file=self.fd) + print(' */', file=self.fd) + print(' protected function get_%s() {' % mname, file=self.fd) if self.is_object(m.return_type): - six.print_(' $cptr = %s($this->_cptr);' % meth_name, file=self.fd) - six.print_(' if (! is_null($cptr)) {', file=self.fd) - six.print_(' return cptrToPhp($cptr);', file=self.fd) - six.print_(' }', file=self.fd) - six.print_(' return null;', file=self.fd) + print(' $cptr = %s($this->_cptr);' % meth_name, file=self.fd) + print(' if (! is_null($cptr)) {', file=self.fd) + print(' return cptrToPhp($cptr);', file=self.fd) + print(' }', file=self.fd) + print(' return null;', file=self.fd) else: - six.print_(' return %s($this->_cptr);' % meth_name, file=self.fd) - six.print_(' }', file=self.fd) + print(' return %s($this->_cptr);' % meth_name, file=self.fd) + print(' }', file=self.fd) if setter: - six.print_(' protected function set_%s($value) {' % mname, file=self.fd) + print(' protected function set_%s($value) {' % mname, file=self.fd) if self.is_object(m.return_type): - six.print_(' %s($this->_cptr, $value->_cptr);' % setter.name, file=self.fd) + print(' %s($this->_cptr, $value->_cptr);' % setter.name, file=self.fd) else: - six.print_(' %s($this->_cptr, $value);' % setter.name, file=self.fd) - six.print_(' }', file=self.fd) - six.print_('', file=self.fd) + print(' %s($this->_cptr, $value);' % setter.name, file=self.fd) + print(' }', file=self.fd) + print('', file=self.fd) # second pass on methods, real methods method_prefix = format_as_underscored(klass.name) + '_' @@ -301,7 +300,7 @@ m.name.endswith('_new_full'): continue if not m.name.startswith(method_prefix): - six.print_('W:', m.name, 'vs', method_prefix, file=sys.stderr) + print('W:', m.name, 'vs', method_prefix, file=sys.stderr) continue if m.rename: @@ -327,7 +326,7 @@ elif defval.startswith('b:'): # boolean php_args.append('%s = %s' % (arg_name, defval[2:])) else: - six.print_("E: don't know what to do with %s" % defval, file=sys.stderr) + print("E: don't know what to do with %s" % defval, file=sys.stderr) sys.exit(1) else: php_args.append('%s = null' % arg_name) @@ -357,26 +356,26 @@ c_args = '' if m.docstring: - six.print_(self.generate_docstring(m, mname, 4), file=self.fd) - six.print_(' public function %s(%s) {' % ( + print(self.generate_docstring(m, mname, 4), file=self.fd) + print(' public function %s(%s) {' % ( format_underscore_as_camelcase(mname), php_args), file=self.fd) if m.return_type == 'void': - six.print_(' %s($this->_cptr%s);' % (cname, c_args), file=self.fd) + print(' %s($this->_cptr%s);' % (cname, c_args), file=self.fd) elif is_rc(m.return_type): - six.print_(' $rc = %s($this->_cptr%s);' % (cname, c_args), file=self.fd) - six.print_(' if ($rc == 0) {', file=self.fd) - six.print_(' return 0;', file=self.fd) - six.print_(' } else if ($rc > 0) {', file=self.fd) # recoverable error - six.print_(' return $rc;', file=self.fd) - six.print_(' } else if ($rc < 0) {', file=self.fd) # unrecoverable error - six.print_(' LassoError::throw_on_rc($rc);', file=self.fd) - six.print_(' }', file=self.fd) + print(' $rc = %s($this->_cptr%s);' % (cname, c_args), file=self.fd) + print(' if ($rc == 0) {', file=self.fd) + print(' return 0;', file=self.fd) + print(' } else if ($rc > 0) {', file=self.fd) # recoverable error + print(' return $rc;', file=self.fd) + print(' } else if ($rc < 0) {', file=self.fd) # unrecoverable error + print(' LassoError::throw_on_rc($rc);', file=self.fd) + print(' }', file=self.fd) else: - six.print_(' return %s($this->_cptr%s);' % (cname, c_args), file=self.fd) - six.print_(' }', file=self.fd) - six.print_('', file=self.fd) + print(' return %s($this->_cptr%s);' % (cname, c_args), file=self.fd) + print(' }', file=self.fd) + print('', file=self.fd) - six.print_('', file=self.fd) + print('', file=self.fd) def generate_docstring(self, func, method_name, indent): docstring = func.docstring.orig_docstring @@ -393,7 +392,7 @@ elif type == '%': # %TRUE, %FALSE if var in ('TRUE', 'FALSE'): return var - six.print_('W: unknown docstring thingie \'%s\' in \'%s\'' % (s.group(1), func.docstring.orig_docstring), + print('W: unknown docstring thingie \'%s\' in \'%s\'' % (s.group(1), func.docstring.orig_docstring), file=sys.stderr) elif type == '@': if var == first_arg_name: @@ -437,7 +436,7 @@ cat = exc_cat.attrib.get('name') done_cats.append(cat) parent_cat = exc_cat.attrib.get('parent', '') - six.print_('''\ + print('''\ /** * @package Lasso */ @@ -462,7 +461,7 @@ else: parent_cat = '' - six.print_('''\ + print('''\ /** * @package Lasso */ @@ -470,7 +469,7 @@ ''' % (cat, parent_cat), file=self.fd) if detail not in exceptions_dict: - six.print_('''\ + print('''\ /** * @package Lasso */ @@ -480,7 +479,7 @@ ''' % (detail, cat, c[1]), file=self.fd) exceptions_dict[detail] = c[1] - six.print_('''\ + print('''\ /** * @package Lasso */ @@ -488,9 +487,9 @@ private static $exceptions_dict = array(''', file=self.fd) for k, v in exceptions_dict.items(): - six.print_(' %s => "Lasso%sError",' % (v, k), file=self.fd) + print(' %s => "Lasso%sError",' % (v, k), file=self.fd) - six.print_('''\ + print('''\ ); public static function throw_on_rc($rc) { @@ -504,6 +503,6 @@ ''', file=self.fd) def generate_footer(self): - six.print_('''\ + print('''\ ?>''', file=self.fd) Only in lasso-2.8.2/bindings/php5/tests: Makefile.in diff '--exclude=ChangeLog' -ur lasso-2.8.2/bindings/php5/wrapper_header.py lasso/bindings/php5/wrapper_header.py --- lasso-2.8.2/bindings/php5/wrapper_header.py 2020-12-17 17:22:08.726895000 +0800 +++ lasso/bindings/php5/wrapper_header.py 2024-10-26 11:06:24.477094400 +0800 @@ -17,7 +17,6 @@ # # You should have received a copy of the GNU General Public License # along with this program; if not, see . -import six class WrapperHeader: def __init__(self, binding_data, fd, functions_list): @@ -32,7 +31,7 @@ def generate_header(self): # FIXME: Get the current version and name - six.print_('''\ + print('''\ /* this file has been generated automatically; do not edit */ #include "../../config.h" @@ -51,11 +50,11 @@ def generate_functions_list(self): for m in self.functions_list: - six.print_('PHP_FUNCTION(%s);' % m, file=self.fd) - six.print_('', file=self.fd) + print('PHP_FUNCTION(%s);' % m, file=self.fd) + print('', file=self.fd) def generate_footer(self): - six.print_('''\ + print('''\ extern zend_module_entry lasso_module_entry; #define phpext_lasso_ptr &lasso_module_entry diff '--exclude=ChangeLog' -ur lasso-2.8.2/bindings/php5/wrapper_source.py lasso/bindings/php5/wrapper_source.py --- lasso-2.8.2/bindings/php5/wrapper_source.py 2021-05-18 04:00:09.035310500 +0800 +++ lasso/bindings/php5/wrapper_source.py 2024-10-26 11:06:24.478101400 +0800 @@ -20,7 +20,6 @@ import sys import os -import six from utils import * @@ -53,17 +52,17 @@ self.functions_list.append('lasso_init') self.functions_list.append('lasso_shutdown') - six.print_('''\ + print('''\ /* this file has been generated automatically; do not edit */ ''', file=self.fd) - six.print_(open(os.path.join(self.src_dir,'wrapper_source_top.c')).read(), file=self.fd) + print(open(os.path.join(self.src_dir,'wrapper_source_top.c')).read(), file=self.fd) for h in self.binding_data.headers: - six.print_('#include <%s>' % h, file=self.fd) - six.print_('', file=self.fd) + print('#include <%s>' % h, file=self.fd) + print('', file=self.fd) - six.print_('''\ + print('''\ PHP_MINIT_FUNCTION(lasso) { le_lasso_server = zend_register_list_destructors_ex(php_gobject_generic_destructor, NULL, PHP_LASSO_SERVER_RES_NAME, module_number); @@ -71,25 +70,25 @@ ''', file=self.fd) def generate_constants(self): - six.print_(' /* Constants (both enums and defines) */', file=self.fd) + print(' /* Constants (both enums and defines) */', file=self.fd) for c in self.binding_data.constants: if c[0] == 'i': - six.print_(' REGISTER_LONG_CONSTANT("%s", %s, CONST_CS|CONST_PERSISTENT);' % (c[1], c[1]), file=self.fd) + print(' REGISTER_LONG_CONSTANT("%s", %s, CONST_CS|CONST_PERSISTENT);' % (c[1], c[1]), file=self.fd) elif c[0] == 's': - six.print_(' REGISTER_STRING_CONSTANT("%s", (char*) %s, CONST_CS|CONST_PERSISTENT);' % (c[1], c[1]), file=self.fd) + print(' REGISTER_STRING_CONSTANT("%s", (char*) %s, CONST_CS|CONST_PERSISTENT);' % (c[1], c[1]), file=self.fd) elif c[0] == 'b': - six.print_('''\ + print('''\ #ifdef %s REGISTER_LONG_CONSTANT("%s", 1, CONST_CS|CONST_PERSISTENT); #else REGISTER_LONG_CONSTANT("%s", 0, CONST_CS|CONST_PERSISTENT); #endif''' % (c[1], c[1], c[1]), file=self.fd) else: - six.print_('E: unknown constant type: %r' % c[0], file=sys.stderr) - six.print_('', file=self.fd) + print('E: unknown constant type: %r' % c[0], file=sys.stderr) + print('', file=self.fd) def generate_middle(self): - six.print_('''\ + print('''\ return SUCCESS; } @@ -107,21 +106,21 @@ # first we free the previous value p = (zval_name, c_variable) q = { 'zval_name' : zval_name, 'c_variable' : c_variable } - six.print_(' zval_dtor(%s);' % zval_name, file=self.fd) + print(' zval_dtor(%s);' % zval_name, file=self.fd) if is_pointer(type): - six.print_(' if (! %s) {' % c_variable, file=self.fd) - six.print_(' ZVAL_NULL(%s);' % zval_name, file=self.fd) - six.print_(' } else {', file=self.fd) + print(' if (! %s) {' % c_variable, file=self.fd) + print(' ZVAL_NULL(%s);' % zval_name, file=self.fd) + print(' } else {', file=self.fd) if is_int(type, self.binding_data): - six.print_(' ZVAL_LONG(%s, %s);' % p, file=self.fd) + print(' ZVAL_LONG(%s, %s);' % p, file=self.fd) elif is_boolean(type): - six.print_(' ZVAL_BOOL(%s, %s);' % p, file=self.fd) + print(' ZVAL_BOOL(%s, %s);' % p, file=self.fd) elif is_cstring(type): - six.print_(' ZVAL_STRING(%s, (char*)%s, 1);' % p, file=self.fd) + print(' ZVAL_STRING(%s, (char*)%s, 1);' % p, file=self.fd) if free and not is_const(type): - six.print_('g_free(%s)' % c_variable, file=self.fd) + print('g_free(%s)' % c_variable, file=self.fd) elif arg_type(type) == 'xmlNode*': - six.print_('''\ + print('''\ { char* xmlString = get_string_from_xml_node(%(c_variable)s); if (xmlString) { @@ -146,11 +145,11 @@ free_function = 'g_list_free(%(c_variable)s);' else: raise Exception('unknown element-type: ' + repr(type)) - six.print_(' %s((GList*)%s, &%s);' % (function, c_variable, zval_name), file=self.fd) + print(' %s((GList*)%s, &%s);' % (function, c_variable, zval_name), file=self.fd) if free: - six.print_(' ', free_function % q, file=self.fd) + print(' ', free_function % q, file=self.fd) elif is_object(type): - six.print_('''\ + print('''\ if (G_IS_OBJECT(%(c_variable)s)) { PhpGObjectPtr *obj = PhpGObjectPtr_New(G_OBJECT(%(c_variable)s)); ZEND_REGISTER_RESOURCE(%(zval_name)s, obj, le_lasso_server); @@ -158,7 +157,7 @@ ZVAL_NULL(%(zval_name)s); }''' % q, file=self.fd) if free: - six.print_('''\ + print('''\ if (%(c_variable)s) { g_object_unref(%(c_variable)s); // If constructor ref is off by one' }''' % q, file=self.fd) @@ -166,7 +165,7 @@ else: raise Exception('unknown type: ' + repr(type) + unconstify(arg_type(type))) if is_pointer(type): - six.print_(' }', file=self.fd) + print(' }', file=self.fd) @@ -175,20 +174,20 @@ return if is_boolean(arg): - six.print_(' RETVAL_BOOL(return_c_value);', file=self.fd) + print(' RETVAL_BOOL(return_c_value);', file=self.fd) elif is_int(arg, self.binding_data): - six.print_(' RETVAL_LONG(return_c_value);', file=self.fd) + print(' RETVAL_LONG(return_c_value);', file=self.fd) elif is_cstring(arg): - six.print_('''\ + print('''\ if (return_c_value) { RETVAL_STRING((char*)return_c_value, 1); } else { RETVAL_NULL(); }''', file=self.fd) if free: - six.print_(' free(return_c_value);', file=self.fd) + print(' free(return_c_value);', file=self.fd) elif is_xml_node(arg): - six.print_('''\ + print('''\ { char* xmlString = get_string_from_xml_node(return_c_value); if (xmlString) { @@ -199,44 +198,44 @@ } ''', file=self.fd) if free: - six.print_(' lasso_release_xml_node(return_c_value);', file=self.fd) + print(' lasso_release_xml_node(return_c_value);', file=self.fd) elif is_glist(arg): el_type = element_type(arg) if is_cstring(el_type): - six.print_('''\ + print('''\ set_array_from_list_of_strings((GList*)return_c_value, &return_value); ''', file=self.fd) if free: - six.print_(' lasso_release_list_of_strings(return_c_value);', file=self.fd) + print(' lasso_release_list_of_strings(return_c_value);', file=self.fd) elif is_xml_node(el_type): - six.print_('''\ + print('''\ set_array_from_list_of_xmlnodes((GList*)return_c_value, &return_value); ''', file=self.fd) if free or is_transfer_full(arg): - six.print_(' lasso_release_list_of_xml_node(return_c_value);', file=self.fd) + print(' lasso_release_list_of_xml_node(return_c_value);', file=self.fd) elif is_object(el_type): - six.print_('''\ + print('''\ set_array_from_list_of_objects((GList*)return_c_value, &return_value); ''', file=self.fd) if free: - six.print_(' lasso_release_list_of_gobjects(return_c_value);', file=self.fd) + print(' lasso_release_list_of_gobjects(return_c_value);', file=self.fd) else: raise Exception('cannot return value for %s' % (arg,)) elif is_hashtable(arg): el_type = element_type(arg) if is_object(el_type): - six.print_('''\ + print('''\ set_array_from_hashtable_of_objects(return_c_value, &return_value); ''', file=self.fd) else: if not is_cstring(arg): - six.print_('W: %s has no explicit string annotation' % (arg,), + print('W: %s has no explicit string annotation' % (arg,), file=sys.stderr) - six.print_('''\ + print('''\ set_array_from_hashtable_of_strings(return_c_value, &return_value); ''', file=self.fd) elif is_object(arg): - six.print_('''\ + print('''\ if (return_c_value) { PhpGObjectPtr *self; self = PhpGObjectPtr_New(G_OBJECT(return_c_value)); @@ -245,7 +244,7 @@ RETVAL_NULL(); }''', file=self.fd) if free: - six.print_(' lasso_release_gobject(return_c_value);', file=self.fd) + print(' lasso_release_gobject(return_c_value);', file=self.fd) else: raise Exception('cannot return value for %s' % (arg,)) @@ -257,61 +256,61 @@ else: name = m.name self.functions_list.append(name) - six.print_('''PHP_FUNCTION(%s) + print('''PHP_FUNCTION(%s) {''' % name, file=self.fd) parse_tuple_format = [] parse_tuple_args = [] for arg in m.args: if is_out(arg): - six.print_(' zval *php_out_%s = NULL;' % arg_name(arg), file=self.fd) - six.print_(' %s %s;' % (var_type(arg), arg_name(arg)), file=self.fd) + print(' zval *php_out_%s = NULL;' % arg_name(arg), file=self.fd) + print(' %s %s;' % (var_type(arg), arg_name(arg)), file=self.fd) parse_tuple_format.append('z!') parse_tuple_args.append('&php_out_%s' % arg_name(arg)) elif is_cstring(arg): parse_tuple_format.append('s!') parse_tuple_args.append('&%s_str, &%s_len' % (arg_name(arg), arg_name(arg))) - six.print_(' %s %s = NULL;' % ('char*', arg_name(arg)), file=self.fd) - six.print_(' %s %s_str = NULL;' % ('char*', arg_name(arg)), file=self.fd) - six.print_(' %s %s_len = 0;' % ('int', arg_name(arg)), file=self.fd) + print(' %s %s = NULL;' % ('char*', arg_name(arg)), file=self.fd) + print(' %s %s_str = NULL;' % ('char*', arg_name(arg)), file=self.fd) + print(' %s %s_len = 0;' % ('int', arg_name(arg)), file=self.fd) elif is_int(arg, self.binding_data) or is_boolean(arg): parse_tuple_format.append('l') parse_tuple_args.append('&%s' % arg_name(arg)) - six.print_(' %s %s;' % ('long', arg_name(arg)), file=self.fd) + print(' %s %s;' % ('long', arg_name(arg)), file=self.fd) elif is_time_t_pointer(arg): parse_tuple_format.append('l') parse_tuple_args.append('&%s' % (arg_name(arg),)) - six.print_(' time_t %s = 0;' % (arg_name(arg),), file=self.fd) + print(' time_t %s = 0;' % (arg_name(arg),), file=self.fd) elif is_xml_node(arg): parse_tuple_format.append('s!') parse_tuple_args.append('&%s_str, &%s_len' % (arg_name(arg), arg_name(arg))) - six.print_(' %s %s = NULL;' % ('xmlNode*', arg_name(arg)), file=self.fd) - six.print_(' %s %s_str = NULL;' % ('char*', arg_name(arg)), file=self.fd) - six.print_(' %s %s_len = 0;' % ('int', arg_name(arg)), file=self.fd) + print(' %s %s = NULL;' % ('xmlNode*', arg_name(arg)), file=self.fd) + print(' %s %s_str = NULL;' % ('char*', arg_name(arg)), file=self.fd) + print(' %s %s_len = 0;' % ('int', arg_name(arg)), file=self.fd) elif is_glist(arg): parse_tuple_format.append('a!') parse_tuple_args.append('&zval_%s' % arg_name(arg)) - six.print_(' %s zval_%s = NULL;' % ('zval*', arg_name(arg)), file=self.fd) - six.print_(' %s %s = NULL;' % ('GList*', arg_name(arg)), file=self.fd) + print(' %s zval_%s = NULL;' % ('zval*', arg_name(arg)), file=self.fd) + print(' %s %s = NULL;' % ('GList*', arg_name(arg)), file=self.fd) elif is_object(arg): parse_tuple_format.append('r') parse_tuple_args.append('&zval_%s' % arg_name(arg)) - six.print_(' %s %s = NULL;' % (arg_type(arg), arg_name(arg)), file=self.fd) - six.print_(' %s zval_%s = NULL;' % ('zval*', arg_name(arg)), file=self.fd) - six.print_(' %s cvt_%s = NULL;' % ('PhpGObjectPtr*', arg_name(arg)), file=self.fd) + print(' %s %s = NULL;' % (arg_type(arg), arg_name(arg)), file=self.fd) + print(' %s zval_%s = NULL;' % ('zval*', arg_name(arg)), file=self.fd) + print(' %s cvt_%s = NULL;' % ('PhpGObjectPtr*', arg_name(arg)), file=self.fd) else: raise Exception('Unsupported type %s %s' % (arg, m)) if m.return_type: - six.print_(' %s return_c_value;' % m.return_type, file=self.fd) + print(' %s return_c_value;' % m.return_type, file=self.fd) if m.return_type is not None and self.is_object(m.return_arg): - six.print_(' G_GNUC_UNUSED PhpGObjectPtr *self;', file=self.fd) - six.print_('', file=self.fd) + print(' G_GNUC_UNUSED PhpGObjectPtr *self;', file=self.fd) + print('', file=self.fd) parse_tuple_args = ', '.join(parse_tuple_args) if parse_tuple_args: parse_tuple_args = ', ' + parse_tuple_args - six.print_('''\ + print('''\ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "%s"%s) == FAILURE) { RETURN_FALSE; } @@ -321,22 +320,22 @@ if is_out(arg): continue elif is_xml_node(arg): - six.print_('''\ + print('''\ %(name)s = get_xml_node_from_string(%(name)s_str);''' % {'name': arg[1]}, file=self.fd) elif f.startswith('s'): - six.print_('''\ + print('''\ %(name)s = %(name)s_str;''' % {'name': arg[1]}, file=self.fd) elif f.startswith('r'): - six.print_(' ZEND_FETCH_RESOURCE(cvt_%s, PhpGObjectPtr *, &zval_%s, -1, PHP_LASSO_SERVER_RES_NAME, le_lasso_server);' % (arg[1], arg[1]), file=self.fd) - six.print_(' %s = (%s)cvt_%s->obj;' % (arg[1], arg[0], arg[1]), file=self.fd) + print(' ZEND_FETCH_RESOURCE(cvt_%s, PhpGObjectPtr *, &zval_%s, -1, PHP_LASSO_SERVER_RES_NAME, le_lasso_server);' % (arg[1], arg[1]), file=self.fd) + print(' %s = (%s)cvt_%s->obj;' % (arg[1], arg[0], arg[1]), file=self.fd) elif f.startswith('a'): el_type = element_type(arg) if is_cstring(el_type): - six.print_(' %(name)s = get_list_from_array_of_strings(zval_%(name)s);' % {'name': arg[1]}, file=self.fd) + print(' %(name)s = get_list_from_array_of_strings(zval_%(name)s);' % {'name': arg[1]}, file=self.fd) elif is_object(el_type): - six.print_(' %(name)s = get_list_from_array_of_objects(zval_%(name)s);' % {'name': arg[1]}, file=self.fd) + print(' %(name)s = get_list_from_array_of_objects(zval_%(name)s);' % {'name': arg[1]}, file=self.fd) else: - six.print_('E: In %(function)s arg %(name)s is of type GList<%(elem)s>' % { 'function': m.name, 'name': arg[1], 'elem': el_type }, file=sys.stderr) + print('E: In %(function)s arg %(name)s is of type GList<%(elem)s>' % { 'function': m.name, 'name': arg[1], 'elem': el_type }, file=sys.stderr) elif f == 'l': pass else: @@ -344,17 +343,17 @@ if m.return_type is not None: - six.print_(' return_c_value = ', file=self.fd) + print(' return_c_value = ', file=self.fd) if 'new' in m.name: - six.print_('(%s)' % m.return_type, file=self.fd) + print('(%s)' % m.return_type, file=self.fd) else: - six.print_(' ', file=self.fd) + print(' ', file=self.fd) def special(x): if is_time_t_pointer(x): return '%(name)s ? &%(name)s : NULL' % { 'name': arg_name(x) } else: return ref_name(x) - six.print_('%s(%s);' % (m.name, ', '.join([special(x) for x in m.args])), file=self.fd) + print('%s(%s);' % (m.name, ', '.join([special(x) for x in m.args])), file=self.fd) # Free the converted arguments for f, arg in zip(parse_tuple_format, m.args): @@ -365,21 +364,21 @@ self.set_zval('php_out_%s' % argname, argname, unref_type(arg), free = free) pass elif argtype == 'xmlNode*': - six.print_(' xmlFree(%s);' % argname, file=self.fd) + print(' xmlFree(%s);' % argname, file=self.fd) elif f.startswith('a'): el_type = element_type(arg) if is_cstring(el_type): - six.print_(' if (%(name)s) {' % { 'name': arg[1] }, file=self.fd) - six.print_(' free_glist(&%(name)s,(GFunc)free);' % { 'name': arg[1] }, file=self.fd) - six.print_(' }', file=self.fd) + print(' if (%(name)s) {' % { 'name': arg[1] }, file=self.fd) + print(' free_glist(&%(name)s,(GFunc)free);' % { 'name': arg[1] }, file=self.fd) + print(' }', file=self.fd) try: self.return_value(m.return_arg, is_transfer_full(m.return_arg, default=True)) except: raise Exception('Cannot return value for function %s' % m) - six.print_('}', file=self.fd) - six.print_('', file=self.fd) + print('}', file=self.fd) + print('', file=self.fd) def generate_members(self, c): for m in c.members: @@ -392,16 +391,16 @@ type = arg_type(m) function_name = '%s_%s_get' % (klassname, format_as_camelcase(name)) - six.print_('''PHP_FUNCTION(%s) + print('''PHP_FUNCTION(%s) {''' % function_name, file=self.fd) self.functions_list.append(function_name) - six.print_(' %s return_c_value;' % type, file=self.fd) - six.print_(' %s* this;' % klassname, file=self.fd) - six.print_(' zval* zval_this;', file=self.fd) - six.print_(' PhpGObjectPtr *cvt_this;', file=self.fd) - six.print_('', file=self.fd) - six.print_('''\ + print(' %s return_c_value;' % type, file=self.fd) + print(' %s* this;' % klassname, file=self.fd) + print(' zval* zval_this;', file=self.fd) + print(' PhpGObjectPtr *cvt_this;', file=self.fd) + print('', file=self.fd) + print('''\ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zval_this) == FAILURE) { RETURN_FALSE; } @@ -409,23 +408,23 @@ ZEND_FETCH_RESOURCE(cvt_this, PhpGObjectPtr *, &zval_this, -1, PHP_LASSO_SERVER_RES_NAME, le_lasso_server); this = (%s*)cvt_this->obj; ''' % (klassname), file=self.fd) - six.print_(' return_c_value = (%s)this->%s;' % (type, name), file=self.fd) + print(' return_c_value = (%s)this->%s;' % (type, name), file=self.fd) self.return_value(m) - six.print_('}', file=self.fd) - six.print_('', file=self.fd) + print('}', file=self.fd) + print('', file=self.fd) def generate_setter(self, c, m): klassname = c.name name = arg_name(m) type = arg_type(m) function_name = '%s_%s_set' % (klassname, format_as_camelcase(name)) - six.print_('''PHP_FUNCTION(%s) + print('''PHP_FUNCTION(%s) {''' % function_name, file=self.fd) self.functions_list.append(function_name) - six.print_(' %s* this;' % klassname, file=self.fd) - six.print_(' zval* zval_this;', file=self.fd) - six.print_(' PhpGObjectPtr *cvt_this;', file=self.fd) + print(' %s* this;' % klassname, file=self.fd) + print(' zval* zval_this;', file=self.fd) + print(' PhpGObjectPtr *cvt_this;', file=self.fd) # FIXME: This bloc should be factorised parse_tuple_format = '' @@ -434,41 +433,41 @@ # arg_type = arg_type.replace('const ', '') parse_tuple_format += 's' parse_tuple_args.append('&%s_str, &%s_len' % (name, name)) - six.print_(' %s %s_str = NULL;' % ('char*', name), file=self.fd) - six.print_(' %s %s_len = 0;' % ('int', name), file=self.fd) + print(' %s %s_str = NULL;' % ('char*', name), file=self.fd) + print(' %s %s_len = 0;' % ('int', name), file=self.fd) elif is_int(m, self.binding_data) or is_boolean(m): parse_tuple_format += 'l' parse_tuple_args.append('&%s' % name) - six.print_(' %s %s;' % ('long', name), file=self.fd) + print(' %s %s;' % ('long', name), file=self.fd) # Must also handle lists of Objects elif is_glist(m) or is_hashtable(m): parse_tuple_format += 'a' parse_tuple_args.append('&zval_%s' % name) - six.print_(' %s zval_%s;' % ('zval*', name), file=self.fd) + print(' %s zval_%s;' % ('zval*', name), file=self.fd) elif is_object(m): parse_tuple_format += 'r' parse_tuple_args.append('&zval_%s' % name) - six.print_(' %s zval_%s = NULL;' % ('zval*', name), file=self.fd) - six.print_(' %s cvt_%s = NULL;' % ('PhpGObjectPtr*', name), file=self.fd) + print(' %s zval_%s = NULL;' % ('zval*', name), file=self.fd) + print(' %s cvt_%s = NULL;' % ('PhpGObjectPtr*', name), file=self.fd) else: raise Exception('Cannot make a setter for %s.%s' % (c,m)) if parse_tuple_args: parse_tuple_arg = parse_tuple_args[0] else: - six.print_('}', file=self.fd) - six.print_('', file=self.fd) + print('}', file=self.fd) + print('', file=self.fd) return - six.print_('', file=self.fd) - six.print_('''\ + print('', file=self.fd) + print('''\ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r%s", &zval_this, %s) == FAILURE) { return; } ''' % (parse_tuple_format, parse_tuple_arg), file=self.fd) # Get 'this' object - six.print_('''\ + print('''\ ZEND_FETCH_RESOURCE(cvt_this, PhpGObjectPtr *, &zval_this, -1, PHP_LASSO_SERVER_RES_NAME, le_lasso_server); this = (%s*)cvt_this->obj; ''' % klassname, file=self.fd) @@ -476,51 +475,51 @@ # Set new value d = { 'name': name, 'type': type } if is_int(m, self.binding_data) or is_boolean(m): - six.print_(' this->%s = %s;' % (name, name), file=self.fd) + print(' this->%s = %s;' % (name, name), file=self.fd) elif is_cstring(m): - six.print_(' lasso_assign_string(this->%(name)s, %(name)s_str);' % d, file=self.fd) + print(' lasso_assign_string(this->%(name)s, %(name)s_str);' % d, file=self.fd) elif is_xml_node(m): - six.print_(' lasso_assign_new_xml_node(this->%(name)s, get_xml_node_from_string(%(name)s_str));' % d, file=self.fd) + print(' lasso_assign_new_xml_node(this->%(name)s, get_xml_node_from_string(%(name)s_str));' % d, file=self.fd) elif is_glist(m): el_type = element_type(m) if is_cstring(el_type): - six.print_(' lasso_assign_new_list_of_strings(this->%(name)s, get_list_from_array_of_strings(zval_%(name)s));' % d, file=self.fd) + print(' lasso_assign_new_list_of_strings(this->%(name)s, get_list_from_array_of_strings(zval_%(name)s));' % d, file=self.fd) elif is_xml_node(el_type): - six.print_(' lasso_assign_new_list_of_xml_node(this->%(name)s, get_list_from_array_of_xmlnodes(zval_%(name)s))' % d, file=self.fd) + print(' lasso_assign_new_list_of_xml_node(this->%(name)s, get_list_from_array_of_xmlnodes(zval_%(name)s))' % d, file=self.fd) elif is_object(el_type): - six.print_(' lasso_assign_new_list_of_gobjects(this->%(name)s, get_list_from_array_of_objects(zval_%(name)s));' % d, file=self.fd) + print(' lasso_assign_new_list_of_gobjects(this->%(name)s, get_list_from_array_of_objects(zval_%(name)s));' % d, file=self.fd) else: raise Exception('Cannot create C setter for %s.%s' % (c,m)) elif is_hashtable(m): el_type = element_type(m) - six.print_('''\ + print('''\ { GHashTable *oldhash = this->%(name)s;''' % d, file=self.fd) if is_object(el_type): - six.print_(' this->%(name)s = get_hashtable_from_array_of_objects(zval_%(name)s);' % d, file=self.fd) + print(' this->%(name)s = get_hashtable_from_array_of_objects(zval_%(name)s);' % d, file=self.fd) else: - six.print_(' this->%(name)s = get_hashtable_from_array_of_strings(zval_%(name)s);' % d, file=self.fd) - six.print_(' g_hash_table_destroy(oldhash);', file=self.fd) - six.print_(' }', file=self.fd) + print(' this->%(name)s = get_hashtable_from_array_of_strings(zval_%(name)s);' % d, file=self.fd) + print(' g_hash_table_destroy(oldhash);', file=self.fd) + print(' }', file=self.fd) elif is_object(m): - six.print_(' ZEND_FETCH_RESOURCE(cvt_%(name)s, PhpGObjectPtr*, &zval_%(name)s, -1, PHP_LASSO_SERVER_RES_NAME, le_lasso_server);' % d, file=self.fd) - six.print_(' lasso_assign_gobject(this->%(name)s, cvt_%(name)s->obj);' % d, file=self.fd) + print(' ZEND_FETCH_RESOURCE(cvt_%(name)s, PhpGObjectPtr*, &zval_%(name)s, -1, PHP_LASSO_SERVER_RES_NAME, le_lasso_server);' % d, file=self.fd) + print(' lasso_assign_gobject(this->%(name)s, cvt_%(name)s->obj);' % d, file=self.fd) - six.print_('}', file=self.fd) - six.print_('', file=self.fd) + print('}', file=self.fd) + print('', file=self.fd) def generate_functions_list(self): - six.print_('''\ + print('''\ static zend_function_entry lasso_functions[] = {''', file=self.fd) for m in self.functions_list: - six.print_(' PHP_FE(%s, NULL)' % m, file=self.fd) - six.print_('''\ + print(' PHP_FE(%s, NULL)' % m, file=self.fd) + print('''\ {NULL, NULL, NULL, 0, 0} }; ''', file=self.fd) def generate_footer(self): - six.print_('''\ + print('''\ zend_module_entry lasso_module_entry = { #if ZEND_MODULE_API_NO >= 20010901 STANDARD_MODULE_HEADER, Only in lasso-2.8.2/bindings/php7/examples: Makefile.in Only in lasso-2.8.2/bindings/php7: Makefile.in diff '--exclude=ChangeLog' -ur lasso-2.8.2/bindings/php7/php_code.py lasso/bindings/php7/php_code.py --- lasso-2.8.2/bindings/php7/php_code.py 2021-09-12 01:20:25.848637900 +0800 +++ lasso/bindings/php7/php_code.py 2024-10-26 11:06:24.482101500 +0800 @@ -20,7 +20,6 @@ import re import sys -import six from utils import * @@ -40,7 +39,7 @@ self.generate_footer() def generate_header(self): - six.print_('''\ + print('''\ _cptr->typename to see if it got the # right class type - six.print_(' public $_cptr = null;', file=self.fd) - six.print_('', file=self.fd) - six.print_(' public function __construct(%s) {' % php_args, file=self.fd) - six.print_(' $this->_cptr = %s(%s);' % (m.name, c_args), file=self.fd) - six.print_(' if (is_null($this->_cptr)) { throw new Exception("Constructor for ', klass.name, ' failed "); }', file=self.fd) - six.print_(' }', file=self.fd) - six.print_('', file=self.fd) + print(' public $_cptr = null;', file=self.fd) + print('', file=self.fd) + print(' public function __construct(%s) {' % php_args, file=self.fd) + print(' $this->_cptr = %s(%s);' % (m.name, c_args), file=self.fd) + print(' if (is_null($this->_cptr)) { throw new Exception("Constructor for ', klass.name, ' failed "); }', file=self.fd) + print(' }', file=self.fd) + print('', file=self.fd) elif name.startswith(method_prefix) and m.args \ and clean_type(unconstify(m.args[0][0])) != klass.name: @@ -185,10 +184,10 @@ c_args.append('$%s' % arg_name) php_args = ', '.join(php_args) c_args = ', '.join(c_args) - six.print_(' public static function %s(%s) {' % (php_name, php_args), file=self.fd) - six.print_(' return cptrToPhp(%s(%s));' % (m.name, c_args), file=self.fd) - six.print_(' }', file=self.fd) - six.print_('', file=self.fd) + print(' public static function %s(%s) {' % (php_name, php_args), file=self.fd) + print(' return cptrToPhp(%s(%s));' % (m.name, c_args), file=self.fd) + print(' }', file=self.fd) + print('', file=self.fd) @@ -200,50 +199,50 @@ 'class': c.name } - six.print_('''\ + print('''\ /** * @return %(docstring)s */ protected function get_%(name)s() {''' % d, file=self.fd) - six.print_(' $t = %(class)s_%(name)s_get($this->_cptr);' % d, file=self.fd) + print(' $t = %(class)s_%(name)s_get($this->_cptr);' % d, file=self.fd) if self.is_object(m): - six.print_(' $t = cptrToPhp($t);', file=self.fd) + print(' $t = cptrToPhp($t);', file=self.fd) elif (is_glist(m) or is_hashtable(m)) and self.is_object(element_type(m)): - six.print_(' foreach ($t as $key => $item) {', file=self.fd) - six.print_(' $t[$key] = cptrToPhp($item);', file=self.fd) - six.print_(' }', file=self.fd) + print(' foreach ($t as $key => $item) {', file=self.fd) + print(' $t[$key] = cptrToPhp($item);', file=self.fd) + print(' }', file=self.fd) elif is_hashtable(m) or (is_glist(m) and (is_cstring(element_type(m)) \ or is_xml_node(element_type(m)))) or is_int(m, self.binding_data) \ or is_boolean(m) or is_cstring(m) or is_xml_node(m): pass else: raise Exception('Cannot generate a Php getter %s.%s' % (c,m)) - six.print_(' return $t;', file=self.fd) - six.print_(' }', file=self.fd) + print(' return $t;', file=self.fd) + print(' }', file=self.fd) def generate_setter(self, c, m): d = { 'type': arg_type(m), 'name': format_as_camelcase(arg_name(m)), 'docstring': self.get_docstring_return_type(arg_type(m)), 'class': c.name } - six.print_(' protected function set_%(name)s($value) {' % d, file=self.fd) + print(' protected function set_%(name)s($value) {' % d, file=self.fd) if self.is_object(m): - six.print_(' $value = $value->_cptr;', file=self.fd) + print(' $value = $value->_cptr;', file=self.fd) elif (is_glist(m) or is_hashtable(m)) and self.is_object(element_type(m)): - six.print_(' $array = array();', file=self.fd) - six.print_(' if (!is_null($value)) {', file=self.fd) - six.print_(' foreach ($value as $key => $item) {', file=self.fd) - six.print_(' $array[$key] = $item->_cptr;', file=self.fd) - six.print_(' }', file=self.fd) - six.print_(' }', file=self.fd) - six.print_(' $value = $array;', file=self.fd) + print(' $array = array();', file=self.fd) + print(' if (!is_null($value)) {', file=self.fd) + print(' foreach ($value as $key => $item) {', file=self.fd) + print(' $array[$key] = $item->_cptr;', file=self.fd) + print(' }', file=self.fd) + print(' }', file=self.fd) + print(' $value = $array;', file=self.fd) elif is_hashtable(m) or (is_glist(m) and (is_cstring(element_type(m)) \ or is_xml_node(element_type(m)))) or is_int(m, self.binding_data) \ or is_boolean(m) or is_cstring(m) or is_xml_node(m): pass else: raise Exception('Cannot generate a Php setter %s.%s' % (c,m)) - six.print_(' %(class)s_%(name)s_set($this->_cptr, $value);' % d, file=self.fd) - six.print_(' }', file=self.fd) - six.print_('', file=self.fd) + print(' %(class)s_%(name)s_set($this->_cptr, $value);' % d, file=self.fd) + print(' }', file=self.fd) + print('', file=self.fd) def generate_getters_and_setters(self, klass): for m in klass.members: @@ -271,27 +270,27 @@ mname = re.match(r'lasso_.*_get_(\w+)', meth_name).group(1) mname = format_as_camelcase(mname) - six.print_(' /**', file=self.fd) - six.print_(' * @return %s' % self.get_docstring_return_type(m.return_type), file=self.fd) - six.print_(' */', file=self.fd) - six.print_(' protected function get_%s() {' % mname, file=self.fd) + print(' /**', file=self.fd) + print(' * @return %s' % self.get_docstring_return_type(m.return_type), file=self.fd) + print(' */', file=self.fd) + print(' protected function get_%s() {' % mname, file=self.fd) if self.is_object(m.return_type): - six.print_(' $cptr = %s($this->_cptr);' % meth_name, file=self.fd) - six.print_(' if (! is_null($cptr)) {', file=self.fd) - six.print_(' return cptrToPhp($cptr);', file=self.fd) - six.print_(' }', file=self.fd) - six.print_(' return null;', file=self.fd) + print(' $cptr = %s($this->_cptr);' % meth_name, file=self.fd) + print(' if (! is_null($cptr)) {', file=self.fd) + print(' return cptrToPhp($cptr);', file=self.fd) + print(' }', file=self.fd) + print(' return null;', file=self.fd) else: - six.print_(' return %s($this->_cptr);' % meth_name, file=self.fd) - six.print_(' }', file=self.fd) + print(' return %s($this->_cptr);' % meth_name, file=self.fd) + print(' }', file=self.fd) if setter: - six.print_(' protected function set_%s($value) {' % mname, file=self.fd) + print(' protected function set_%s($value) {' % mname, file=self.fd) if self.is_object(m.return_type): - six.print_(' %s($this->_cptr, $value->_cptr);' % setter.name, file=self.fd) + print(' %s($this->_cptr, $value->_cptr);' % setter.name, file=self.fd) else: - six.print_(' %s($this->_cptr, $value);' % setter.name, file=self.fd) - six.print_(' }', file=self.fd) - six.print_('', file=self.fd) + print(' %s($this->_cptr, $value);' % setter.name, file=self.fd) + print(' }', file=self.fd) + print('', file=self.fd) # second pass on methods, real methods method_prefix = format_as_underscored(klass.name) + '_' @@ -356,26 +355,26 @@ c_args = '' if m.docstring: - six.print_(self.generate_docstring(m, mname, 4), file=self.fd) - six.print_(' public function %s(%s) {' % ( + print(self.generate_docstring(m, mname, 4), file=self.fd) + print(' public function %s(%s) {' % ( format_underscore_as_camelcase(mname), php_args), file=self.fd) if m.return_type == 'void': - six.print_(' %s($this->_cptr%s);' % (cname, c_args), file=self.fd) + print(' %s($this->_cptr%s);' % (cname, c_args), file=self.fd) elif is_rc(m.return_type): - six.print_(' $rc = %s($this->_cptr%s);' % (cname, c_args), file=self.fd) - six.print_(' if ($rc == 0) {', file=self.fd) - six.print_(' return 0;', file=self.fd) - six.print_(' } else if ($rc > 0) {', file=self.fd) # recoverable error - six.print_(' return $rc;', file=self.fd) - six.print_(' } else if ($rc < 0) {', file=self.fd) # unrecoverable error - six.print_(' LassoError::throw_on_rc($rc);', file=self.fd) - six.print_(' }', file=self.fd) + print(' $rc = %s($this->_cptr%s);' % (cname, c_args), file=self.fd) + print(' if ($rc == 0) {', file=self.fd) + print(' return 0;', file=self.fd) + print(' } else if ($rc > 0) {', file=self.fd) # recoverable error + print(' return $rc;', file=self.fd) + print(' } else if ($rc < 0) {', file=self.fd) # unrecoverable error + print(' LassoError::throw_on_rc($rc);', file=self.fd) + print(' }', file=self.fd) else: - six.print_(' return %s($this->_cptr%s);' % (cname, c_args), file=self.fd) - six.print_(' }', file=self.fd) - six.print_('', file=self.fd) + print(' return %s($this->_cptr%s);' % (cname, c_args), file=self.fd) + print(' }', file=self.fd) + print('', file=self.fd) - six.print_('', file=self.fd) + print('', file=self.fd) def generate_docstring(self, func, method_name, indent): docstring = func.docstring.orig_docstring @@ -435,7 +434,7 @@ cat = exc_cat.attrib.get('name') done_cats.append(cat) parent_cat = exc_cat.attrib.get('parent', '') - six.print_('''\ + print('''\ /** * @package Lasso */ @@ -460,7 +459,7 @@ else: parent_cat = '' - six.print_('''\ + print('''\ /** * @package Lasso */ @@ -468,7 +467,7 @@ ''' % (cat, parent_cat), file=self.fd) if detail not in exceptions_dict: - six.print_('''\ + print('''\ /** * @package Lasso */ @@ -478,7 +477,7 @@ ''' % (detail, cat, c[1]), file=self.fd) exceptions_dict[detail] = c[1] - six.print_('''\ + print('''\ /** * @package Lasso */ @@ -486,9 +485,9 @@ private static $exceptions_dict = array(''', file=self.fd) for k, v in exceptions_dict.items(): - six.print_(' %s => "Lasso%sError",' % (v, k), file=self.fd) + print(' %s => "Lasso%sError",' % (v, k), file=self.fd) - six.print_('''\ + print('''\ ); public static function throw_on_rc($rc) { @@ -502,6 +501,6 @@ ''', file=self.fd) def generate_footer(self): - six.print_('''\ + print('''\ ?>''', file=self.fd) Only in lasso-2.8.2/bindings/php7/tests: Makefile.in diff '--exclude=ChangeLog' -ur lasso-2.8.2/bindings/php7/wrapper_header.py lasso/bindings/php7/wrapper_header.py --- lasso-2.8.2/bindings/php7/wrapper_header.py 2021-05-18 04:00:09.047310300 +0800 +++ lasso/bindings/php7/wrapper_header.py 2024-10-26 11:06:24.484842300 +0800 @@ -17,7 +17,6 @@ # # You should have received a copy of the GNU General Public License # along with this program; if not, see . -import six class WrapperHeader: def __init__(self, binding_data, fd, functions_list): @@ -32,7 +31,7 @@ def generate_header(self): # FIXME: Get the current version and name - six.print_('''\ + print('''\ /* this file has been generated automatically; do not edit */ #include "../../config.h" @@ -51,11 +50,11 @@ def generate_functions_list(self): for m in self.functions_list: - six.print_('PHP_FUNCTION(%s);' % m, file=self.fd) - six.print_('', file=self.fd) + print('PHP_FUNCTION(%s);' % m, file=self.fd) + print('', file=self.fd) def generate_footer(self): - six.print_('''\ + print('''\ extern zend_module_entry lasso_module_entry; #define phpext_lasso_ptr &lasso_module_entry diff '--exclude=ChangeLog' -ur lasso-2.8.2/bindings/php7/wrapper_source.py lasso/bindings/php7/wrapper_source.py --- lasso-2.8.2/bindings/php7/wrapper_source.py 2021-05-18 04:00:09.047310300 +0800 +++ lasso/bindings/php7/wrapper_source.py 2024-10-26 11:06:24.485848800 +0800 @@ -20,7 +20,6 @@ import sys import os -import six from utils import * @@ -53,17 +52,17 @@ self.functions_list.append('lasso_init') self.functions_list.append('lasso_shutdown') - six.print_('''\ + print('''\ /* this file has been generated automatically; do not edit */ ''', file=self.fd) - six.print_(open(os.path.join(self.src_dir,'wrapper_source_top.c')).read(), file=self.fd) + print(open(os.path.join(self.src_dir,'wrapper_source_top.c')).read(), file=self.fd) for h in self.binding_data.headers: - six.print_('#include <%s>' % h, file=self.fd) - six.print_('', file=self.fd) + print('#include <%s>' % h, file=self.fd) + print('', file=self.fd) - six.print_('''\ + print('''\ PHP_MINIT_FUNCTION(lasso) { le_lasso_server = zend_register_list_destructors_ex(php_gobject_generic_destructor, NULL, PHP_LASSO_SERVER_RES_NAME, module_number); @@ -71,25 +70,25 @@ ''', file=self.fd) def generate_constants(self): - six.print_(' /* Constants (both enums and defines) */', file=self.fd) + print(' /* Constants (both enums and defines) */', file=self.fd) for c in self.binding_data.constants: if c[0] == 'i': - six.print_(' REGISTER_LONG_CONSTANT("%s", %s, CONST_CS|CONST_PERSISTENT);' % (c[1], c[1]), file=self.fd) + print(' REGISTER_LONG_CONSTANT("%s", %s, CONST_CS|CONST_PERSISTENT);' % (c[1], c[1]), file=self.fd) elif c[0] == 's': - six.print_(' REGISTER_STRING_CONSTANT("%s", (char*) %s, CONST_CS|CONST_PERSISTENT);' % (c[1], c[1]), file=self.fd) + print(' REGISTER_STRING_CONSTANT("%s", (char*) %s, CONST_CS|CONST_PERSISTENT);' % (c[1], c[1]), file=self.fd) elif c[0] == 'b': - six.print_('''\ + print('''\ #ifdef %s REGISTER_LONG_CONSTANT("%s", 1, CONST_CS|CONST_PERSISTENT); #else REGISTER_LONG_CONSTANT("%s", 0, CONST_CS|CONST_PERSISTENT); #endif''' % (c[1], c[1], c[1]), file=self.fd) else: - six.print_('E: unknown constant type: %r' % c[0], file=sys.stderr) - six.print_('', file=self.fd) + print('E: unknown constant type: %r' % c[0], file=sys.stderr) + print('', file=self.fd) def generate_middle(self): - six.print_('''\ + print('''\ return SUCCESS; } @@ -107,21 +106,21 @@ # first we free the previous value p = (zval_name, c_variable) q = { 'zval_name' : zval_name, 'c_variable' : c_variable } - six.print_(' zval_dtor(%s);' % zval_name, file=self.fd) + print(' zval_dtor(%s);' % zval_name, file=self.fd) if is_pointer(type): - six.print_(' if (! %s) {' % c_variable, file=self.fd) - six.print_(' ZVAL_NULL(%s);' % zval_name, file=self.fd) - six.print_(' } else {', file=self.fd) + print(' if (! %s) {' % c_variable, file=self.fd) + print(' ZVAL_NULL(%s);' % zval_name, file=self.fd) + print(' } else {', file=self.fd) if is_int(type, self.binding_data): - six.print_(' ZVAL_LONG(%s, %s);' % p, file=self.fd) + print(' ZVAL_LONG(%s, %s);' % p, file=self.fd) elif is_boolean(type): - six.print_(' ZVAL_BOOL(%s, %s);' % p, file=self.fd) + print(' ZVAL_BOOL(%s, %s);' % p, file=self.fd) elif is_cstring(type): - six.print_(' ZVAL_STRING(%s, (char*)%s);' % p, file=self.fd) + print(' ZVAL_STRING(%s, (char*)%s);' % p, file=self.fd) if free and not is_const(type): - six.print_('g_free(%s)' % c_variable, file=self.fd) + print('g_free(%s)' % c_variable, file=self.fd) elif arg_type(type) == 'xmlNode*': - six.print_('''\ + print('''\ { char* xmlString = get_string_from_xml_node(%(c_variable)s); if (xmlString) { @@ -146,11 +145,11 @@ free_function = 'g_list_free(%(c_variable)s);' else: raise Exception('unknown element-type: ' + repr(type)) - six.print_(' %s((GList*)%s, &%s);' % (function, c_variable, zval_name), file=self.fd) + print(' %s((GList*)%s, &%s);' % (function, c_variable, zval_name), file=self.fd) if free: - six.print_(' ', free_function % q, file=self.fd) + print(' ', free_function % q, file=self.fd) elif is_object(type): - six.print_('''\ + print('''\ if (G_IS_OBJECT(%(c_variable)s)) { PhpGObjectPtr *obj = PhpGObjectPtr_New(G_OBJECT(%(c_variable)s)); zend_resource *res = zend_register_resource(obj, le_lasso_server); @@ -159,7 +158,7 @@ ZVAL_NULL(%(zval_name)s); }''' % q, file=self.fd) if free: - six.print_('''\ + print('''\ if (%(c_variable)s) { g_object_unref(%(c_variable)s); // If constructor ref is off by one' }''' % q, file=self.fd) @@ -167,7 +166,7 @@ else: raise Exception('unknown type: ' + repr(type) + unconstify(arg_type(type))) if is_pointer(type): - six.print_(' }', file=self.fd) + print(' }', file=self.fd) @@ -176,20 +175,20 @@ return if is_boolean(arg): - six.print_(' RETVAL_BOOL(return_c_value);', file=self.fd) + print(' RETVAL_BOOL(return_c_value);', file=self.fd) elif is_int(arg, self.binding_data): - six.print_(' RETVAL_LONG(return_c_value);', file=self.fd) + print(' RETVAL_LONG(return_c_value);', file=self.fd) elif is_cstring(arg): - six.print_('''\ + print('''\ if (return_c_value) { RETVAL_STRING((char*)return_c_value); } else { RETVAL_NULL(); }''', file=self.fd) if free: - six.print_(' free(return_c_value);', file=self.fd) + print(' free(return_c_value);', file=self.fd) elif is_xml_node(arg): - six.print_('''\ + print('''\ { char* xmlString = get_string_from_xml_node(return_c_value); if (xmlString) { @@ -200,43 +199,43 @@ } ''', file=self.fd) if free: - six.print_(' lasso_release_xml_node(return_c_value);', file=self.fd) + print(' lasso_release_xml_node(return_c_value);', file=self.fd) elif is_glist(arg): el_type = element_type(arg) if is_cstring(el_type): - six.print_('''\ + print('''\ set_array_from_list_of_strings((GList*)return_c_value, &return_value); ''', file=self.fd) if free: - six.print_(' lasso_release_list_of_strings(return_c_value);', file=self.fd) + print(' lasso_release_list_of_strings(return_c_value);', file=self.fd) elif is_xml_node(el_type): - six.print_('''\ + print('''\ set_array_from_list_of_xmlnodes((GList*)return_c_value, &return_value); ''', file=self.fd) if free or is_transfer_full(arg): - six.print_(' lasso_release_list_of_xml_node(return_c_value);', file=self.fd) + print(' lasso_release_list_of_xml_node(return_c_value);', file=self.fd) elif is_object(el_type): - six.print_('''\ + print('''\ set_array_from_list_of_objects((GList*)return_c_value, &return_value); ''', file=self.fd) if free: - six.print_(' lasso_release_list_of_gobjects(return_c_value);', file=self.fd) + print(' lasso_release_list_of_gobjects(return_c_value);', file=self.fd) else: raise Exception('cannot return value for %s' % (arg,)) elif is_hashtable(arg): el_type = element_type(arg) if is_object(el_type): - six.print_('''\ + print('''\ set_array_from_hashtable_of_objects(return_c_value, &return_value); ''', file=self.fd) else: if not is_cstring(arg): print >>sys.stderr, 'W: %s has no explicit string annotation' % (arg,) - six.print_('''\ + print('''\ set_array_from_hashtable_of_strings(return_c_value, &return_value); ''', file=self.fd) elif is_object(arg): - six.print_('''\ + print('''\ if (return_c_value) { PhpGObjectPtr *self; self = PhpGObjectPtr_New(G_OBJECT(return_c_value)); @@ -246,7 +245,7 @@ RETVAL_NULL(); }''', file=self.fd) if free: - six.print_(' lasso_release_gobject(return_c_value);', file=self.fd) + print(' lasso_release_gobject(return_c_value);', file=self.fd) else: raise Exception('cannot return value for %s' % (arg,)) @@ -258,26 +257,26 @@ else: name = m.name self.functions_list.append(name) - six.print_('''PHP_FUNCTION(%s) + print('''PHP_FUNCTION(%s) {''' % name, file=self.fd) parse_tuple_format = [] parse_tuple_args = [] for arg in m.args: if is_out(arg): - six.print_(' zval *php_out_%s = NULL;' % arg_name(arg), file=self.fd) - six.print_(' %s %s;' % (var_type(arg), arg_name(arg)), file=self.fd) + print(' zval *php_out_%s = NULL;' % arg_name(arg), file=self.fd) + print(' %s %s;' % (var_type(arg), arg_name(arg)), file=self.fd) parse_tuple_format.append('z!') parse_tuple_args.append('&php_out_%s' % arg_name(arg)) elif is_cstring(arg): parse_tuple_format.append('s!') parse_tuple_args.append('&%s_str, &%s_len' % (arg_name(arg), arg_name(arg))) - six.print_(' %s %s = NULL;' % ('char*', arg_name(arg)), file=self.fd) - six.print_(' %s %s_str = NULL;' % ('char*', arg_name(arg)), file=self.fd) - six.print_(' %s %s_len = 0;' % ('size_t', arg_name(arg)), file=self.fd) + print(' %s %s = NULL;' % ('char*', arg_name(arg)), file=self.fd) + print(' %s %s_str = NULL;' % ('char*', arg_name(arg)), file=self.fd) + print(' %s %s_len = 0;' % ('size_t', arg_name(arg)), file=self.fd) elif is_int(arg, self.binding_data) or is_boolean(arg): parse_tuple_format.append('l') parse_tuple_args.append('&%s' % arg_name(arg)) - six.print_(' %s %s;' % ('long', arg_name(arg)), file=self.fd) + print(' %s %s;' % ('long', arg_name(arg)), file=self.fd) elif is_time_t_pointer(arg): parse_tuple_format.append('l') parse_tuple_args.append('&%s' % (arg_name(arg),)) @@ -285,34 +284,34 @@ elif is_xml_node(arg): parse_tuple_format.append('s!') parse_tuple_args.append('&%s_str, &%s_len' % (arg_name(arg), arg_name(arg))) - six.print_(' %s %s = NULL;' % ('xmlNode*', arg_name(arg)), file=self.fd) - six.print_(' %s %s_str = NULL;' % ('char*', arg_name(arg)), file=self.fd) - six.print_(' %s %s_len = 0;' % ('size_t', arg_name(arg)), file=self.fd) + print(' %s %s = NULL;' % ('xmlNode*', arg_name(arg)), file=self.fd) + print(' %s %s_str = NULL;' % ('char*', arg_name(arg)), file=self.fd) + print(' %s %s_len = 0;' % ('size_t', arg_name(arg)), file=self.fd) elif is_glist(arg): parse_tuple_format.append('a!') parse_tuple_args.append('&zval_%s' % arg_name(arg)) - six.print_(' %s zval_%s = NULL;' % ('zval*', arg_name(arg)), file=self.fd) - six.print_(' %s %s = NULL;' % ('GList*', arg_name(arg)), file=self.fd) + print(' %s zval_%s = NULL;' % ('zval*', arg_name(arg)), file=self.fd) + print(' %s %s = NULL;' % ('GList*', arg_name(arg)), file=self.fd) elif is_object(arg): parse_tuple_format.append('r') parse_tuple_args.append('&zval_%s' % arg_name(arg)) - six.print_(' %s %s = NULL;' % (arg_type(arg), arg_name(arg)), file=self.fd) - six.print_(' %s zval_%s = NULL;' % ('zval*', arg_name(arg)), file=self.fd) - six.print_(' %s cvt_%s = NULL;' % ('PhpGObjectPtr*', arg_name(arg)), file=self.fd) + print(' %s %s = NULL;' % (arg_type(arg), arg_name(arg)), file=self.fd) + print(' %s zval_%s = NULL;' % ('zval*', arg_name(arg)), file=self.fd) + print(' %s cvt_%s = NULL;' % ('PhpGObjectPtr*', arg_name(arg)), file=self.fd) else: raise Exception('Unsupported type %s %s' % (arg, m)) if m.return_type: - six.print_(' %s return_c_value;' % m.return_type, file=self.fd) + print(' %s return_c_value;' % m.return_type, file=self.fd) if m.return_type is not None and self.is_object(m.return_arg): - six.print_(' G_GNUC_UNUSED PhpGObjectPtr *self;', file=self.fd) - six.print_('', file=self.fd) + print(' G_GNUC_UNUSED PhpGObjectPtr *self;', file=self.fd) + print('', file=self.fd) parse_tuple_args = ', '.join(parse_tuple_args) if parse_tuple_args: parse_tuple_args = ', ' + parse_tuple_args - six.print_('''\ + print('''\ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "%s"%s) == FAILURE) { RETURN_FALSE; } @@ -322,24 +321,24 @@ if is_out(arg): continue elif is_xml_node(arg): - six.print_('''\ + print('''\ %(name)s = get_xml_node_from_string(%(name)s_str);''' % {'name': arg[1]}, file=self.fd) elif f.startswith('s'): - six.print_('''\ + print('''\ %(name)s = %(name)s_str;''' % {'name': arg[1]}, file=self.fd) elif f.startswith('r'): - six.print_(' if ((cvt_%s = (PhpGObjectPtr *)zend_fetch_resource(Z_RES_P(zval_%s), PHP_LASSO_SERVER_RES_NAME, le_lasso_server)) == NULL) {' % (arg[1], arg[1]), file=self.fd) - six.print_(' RETURN_FALSE;', file=self.fd) - six.print_(' }', file=self.fd) - six.print_(' %s = (%s)cvt_%s->obj;' % (arg[1], arg[0], arg[1]), file=self.fd) + print(' if ((cvt_%s = (PhpGObjectPtr *)zend_fetch_resource(Z_RES_P(zval_%s), PHP_LASSO_SERVER_RES_NAME, le_lasso_server)) == NULL) {' % (arg[1], arg[1]), file=self.fd) + print(' RETURN_FALSE;', file=self.fd) + print(' }', file=self.fd) + print(' %s = (%s)cvt_%s->obj;' % (arg[1], arg[0], arg[1]), file=self.fd) elif f.startswith('a'): el_type = element_type(arg) if is_cstring(el_type): - six.print_(' %(name)s = get_list_from_array_of_strings(zval_%(name)s);' % {'name': arg[1]}, file=self.fd) + print(' %(name)s = get_list_from_array_of_strings(zval_%(name)s);' % {'name': arg[1]}, file=self.fd) elif is_object(el_type): - six.print_(' %(name)s = get_list_from_array_of_objects(zval_%(name)s);' % {'name': arg[1]}, file=self.fd) + print(' %(name)s = get_list_from_array_of_objects(zval_%(name)s);' % {'name': arg[1]}, file=self.fd) else: - six.print_('E: In %(function)s arg %(name)s is of type GList<%(elem)s>' % { 'function': m.name, 'name': arg[1], 'elem': el_type }, file=sys.stderr) + print('E: In %(function)s arg %(name)s is of type GList<%(elem)s>' % { 'function': m.name, 'name': arg[1], 'elem': el_type }, file=sys.stderr) elif f == 'l': pass else: @@ -347,17 +346,17 @@ if m.return_type is not None: - six.print_(' return_c_value = ', file=self.fd) + print(' return_c_value = ', file=self.fd) if 'new' in m.name: - six.print_('(%s)' % m.return_type, file=self.fd) + print('(%s)' % m.return_type, file=self.fd) else: - six.print_(' ', file=self.fd) + print(' ', file=self.fd) def special(x): if is_time_t_pointer(x): return '%(name)s ? &%(name)s : NULL' % { 'name': arg_name(x) } else: return ref_name(x) - six.print_('%s(%s);' % (m.name, ', '.join([special(x) for x in m.args])), file=self.fd) + print('%s(%s);' % (m.name, ', '.join([special(x) for x in m.args])), file=self.fd) # Free the converted arguments for f, arg in zip(parse_tuple_format, m.args): @@ -368,21 +367,21 @@ self.set_zval('php_out_%s' % argname, argname, unref_type(arg), free = free) pass elif argtype == 'xmlNode*': - six.print_(' xmlFree(%s);' % argname, file=self.fd) + print(' xmlFree(%s);' % argname, file=self.fd) elif f.startswith('a'): el_type = element_type(arg) if is_cstring(el_type): - six.print_(' if (%(name)s) {' % { 'name': arg[1] }, file=self.fd) - six.print_(' free_glist(&%(name)s,(GFunc)free);' % { 'name': arg[1] }, file=self.fd) - six.print_(' }', file=self.fd) + print(' if (%(name)s) {' % { 'name': arg[1] }, file=self.fd) + print(' free_glist(&%(name)s,(GFunc)free);' % { 'name': arg[1] }, file=self.fd) + print(' }', file=self.fd) try: self.return_value(m.return_arg, is_transfer_full(m.return_arg, default=True)) except: raise Exception('Cannot return value for function %s' % m) - six.print_('}', file=self.fd) - six.print_('', file=self.fd) + print('}', file=self.fd) + print('', file=self.fd) def generate_members(self, c): for m in c.members: @@ -395,16 +394,16 @@ type = arg_type(m) function_name = '%s_%s_get' % (klassname, format_as_camelcase(name)) - six.print_('''PHP_FUNCTION(%s) + print('''PHP_FUNCTION(%s) {''' % function_name, file=self.fd) self.functions_list.append(function_name) - six.print_(' %s return_c_value;' % type, file=self.fd) - six.print_(' %s* this;' % klassname, file=self.fd) - six.print_(' zval* zval_this;', file=self.fd) - six.print_(' PhpGObjectPtr *cvt_this;', file=self.fd) - six.print_('', file=self.fd) - six.print_('''\ + print(' %s return_c_value;' % type, file=self.fd) + print(' %s* this;' % klassname, file=self.fd) + print(' zval* zval_this;', file=self.fd) + print(' PhpGObjectPtr *cvt_this;', file=self.fd) + print('', file=self.fd) + print('''\ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zval_this) == FAILURE) { RETURN_FALSE; } @@ -414,23 +413,23 @@ } this = (%s*)cvt_this->obj; ''' % (klassname), file=self.fd) - six.print_(' return_c_value = (%s)this->%s;' % (type, name), file=self.fd) + print(' return_c_value = (%s)this->%s;' % (type, name), file=self.fd) self.return_value(m) - six.print_('}', file=self.fd) - six.print_('', file=self.fd) + print('}', file=self.fd) + print('', file=self.fd) def generate_setter(self, c, m): klassname = c.name name = arg_name(m) type = arg_type(m) function_name = '%s_%s_set' % (klassname, format_as_camelcase(name)) - six.print_('''PHP_FUNCTION(%s) + print('''PHP_FUNCTION(%s) {''' % function_name, file=self.fd) self.functions_list.append(function_name) - six.print_(' %s* this;' % klassname, file=self.fd) - six.print_(' zval* zval_this;', file=self.fd) - six.print_(' PhpGObjectPtr *cvt_this;', file=self.fd) + print(' %s* this;' % klassname, file=self.fd) + print(' zval* zval_this;', file=self.fd) + print(' PhpGObjectPtr *cvt_this;', file=self.fd) # FIXME: This bloc should be factorised parse_tuple_format = '' @@ -439,41 +438,41 @@ # arg_type = arg_type.replace('const ', '') parse_tuple_format += 's' parse_tuple_args.append('&%s_str, &%s_len' % (name, name)) - six.print_(' %s %s_str = NULL;' % ('char*', name), file=self.fd) - six.print_(' %s %s_len = 0;' % ('size_t', name), file=self.fd) + print(' %s %s_str = NULL;' % ('char*', name), file=self.fd) + print(' %s %s_len = 0;' % ('size_t', name), file=self.fd) elif is_int(m, self.binding_data) or is_boolean(m): parse_tuple_format += 'l' parse_tuple_args.append('&%s' % name) - six.print_(' %s %s;' % ('long', name), file=self.fd) + print(' %s %s;' % ('long', name), file=self.fd) # Must also handle lists of Objects elif is_glist(m) or is_hashtable(m): parse_tuple_format += 'a' parse_tuple_args.append('&zval_%s' % name) - six.print_(' %s zval_%s;' % ('zval*', name), file=self.fd) + print(' %s zval_%s;' % ('zval*', name), file=self.fd) elif is_object(m): parse_tuple_format += 'r' parse_tuple_args.append('&zval_%s' % name) - six.print_(' %s zval_%s = NULL;' % ('zval*', name), file=self.fd) - six.print_(' %s cvt_%s = NULL;' % ('PhpGObjectPtr*', name), file=self.fd) + print(' %s zval_%s = NULL;' % ('zval*', name), file=self.fd) + print(' %s cvt_%s = NULL;' % ('PhpGObjectPtr*', name), file=self.fd) else: raise Exception('Cannot make a setter for %s.%s' % (c,m)) if parse_tuple_args: parse_tuple_arg = parse_tuple_args[0] else: - six.print_('}', file=self.fd) - six.print_('', file=self.fd) + print('}', file=self.fd) + print('', file=self.fd) return - six.print_('', file=self.fd) - six.print_('''\ + print('', file=self.fd) + print('''\ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r%s", &zval_this, %s) == FAILURE) { return; } ''' % (parse_tuple_format, parse_tuple_arg), file=self.fd) # Get 'this' object - six.print_('''\ + print('''\ if ((cvt_this = (PhpGObjectPtr *)zend_fetch_resource(Z_RES_P(zval_this), PHP_LASSO_SERVER_RES_NAME, le_lasso_server)) == NULL) { RETURN_FALSE; } @@ -483,53 +482,53 @@ # Set new value d = { 'name': name, 'type': type } if is_int(m, self.binding_data) or is_boolean(m): - six.print_(' this->%s = %s;' % (name, name), file=self.fd) + print(' this->%s = %s;' % (name, name), file=self.fd) elif is_cstring(m): - six.print_(' lasso_assign_string(this->%(name)s, %(name)s_str);' % d, file=self.fd) + print(' lasso_assign_string(this->%(name)s, %(name)s_str);' % d, file=self.fd) elif is_xml_node(m): - six.print_(' lasso_assign_new_xml_node(this->%(name)s, get_xml_node_from_string(%(name)s_str));' % d, file=self.fd) + print(' lasso_assign_new_xml_node(this->%(name)s, get_xml_node_from_string(%(name)s_str));' % d, file=self.fd) elif is_glist(m): el_type = element_type(m) if is_cstring(el_type): - six.print_(' lasso_assign_new_list_of_strings(this->%(name)s, get_list_from_array_of_strings(zval_%(name)s));' % d, file=self.fd) + print(' lasso_assign_new_list_of_strings(this->%(name)s, get_list_from_array_of_strings(zval_%(name)s));' % d, file=self.fd) elif is_xml_node(el_type): - six.print_(' lasso_assign_new_list_of_xml_node(this->%(name)s, get_list_from_array_of_xmlnodes(zval_%(name)s))' % d, file=self.fd) + print(' lasso_assign_new_list_of_xml_node(this->%(name)s, get_list_from_array_of_xmlnodes(zval_%(name)s))' % d, file=self.fd) elif is_object(el_type): - six.print_(' lasso_assign_new_list_of_gobjects(this->%(name)s, get_list_from_array_of_objects(zval_%(name)s));' % d, file=self.fd) + print(' lasso_assign_new_list_of_gobjects(this->%(name)s, get_list_from_array_of_objects(zval_%(name)s));' % d, file=self.fd) else: raise Exception('Cannot create C setter for %s.%s' % (c,m)) elif is_hashtable(m): el_type = element_type(m) - six.print_('''\ + print('''\ { GHashTable *oldhash = this->%(name)s;''' % d, file=self.fd) if is_object(el_type): - six.print_(' this->%(name)s = get_hashtable_from_array_of_objects(zval_%(name)s);' % d, file=self.fd) + print(' this->%(name)s = get_hashtable_from_array_of_objects(zval_%(name)s);' % d, file=self.fd) else: - six.print_(' this->%(name)s = get_hashtable_from_array_of_strings(zval_%(name)s);' % d, file=self.fd) - six.print_(' g_hash_table_destroy(oldhash);', file=self.fd) - six.print_(' }', file=self.fd) + print(' this->%(name)s = get_hashtable_from_array_of_strings(zval_%(name)s);' % d, file=self.fd) + print(' g_hash_table_destroy(oldhash);', file=self.fd) + print(' }', file=self.fd) elif is_object(m): - six.print_(' if ((cvt_%(name)s = (PhpGObjectPtr*)zend_fetch_resource(Z_RES_P(zval_%(name)s), PHP_LASSO_SERVER_RES_NAME, le_lasso_server)) == NULL) {' % d, file=self.fd) - six.print_(' RETURN_FALSE;', file=self.fd) - six.print_(' }', file=self.fd) - six.print_(' lasso_assign_gobject(this->%(name)s, cvt_%(name)s->obj);' % d, file=self.fd) + print(' if ((cvt_%(name)s = (PhpGObjectPtr*)zend_fetch_resource(Z_RES_P(zval_%(name)s), PHP_LASSO_SERVER_RES_NAME, le_lasso_server)) == NULL) {' % d, file=self.fd) + print(' RETURN_FALSE;', file=self.fd) + print(' }', file=self.fd) + print(' lasso_assign_gobject(this->%(name)s, cvt_%(name)s->obj);' % d, file=self.fd) - six.print_('}', file=self.fd) - six.print_('', file=self.fd) + print('}', file=self.fd) + print('', file=self.fd) def generate_functions_list(self): - six.print_('''\ + print('''\ static zend_function_entry lasso_functions[] = {''', file=self.fd) for m in self.functions_list: - six.print_(' PHP_FE(%s, NULL)' % m, file=self.fd) - six.print_('''\ + print(' PHP_FE(%s, NULL)' % m, file=self.fd) + print('''\ {NULL, NULL, NULL, 0, 0} }; ''', file=self.fd) def generate_footer(self): - six.print_('''\ + print('''\ zend_module_entry lasso_module_entry = { #if ZEND_MODULE_API_NO >= 20010901 STANDARD_MODULE_HEADER, diff '--exclude=ChangeLog' -ur lasso-2.8.2/bindings/python/examples/get_attributes_from_assertion.py lasso/bindings/python/examples/get_attributes_from_assertion.py --- lasso-2.8.2/bindings/python/examples/get_attributes_from_assertion.py 2021-05-18 04:00:09.051310300 +0800 +++ lasso/bindings/python/examples/get_attributes_from_assertion.py 2024-10-26 11:06:24.486848700 +0800 @@ -1,10 +1,9 @@ # Example SP Python code to get attributes from an assertion -from six import print_ for attribute in assertion.attributeStatement[0].attribute: if attribute.name == lasso.SAML2_ATTRIBUTE_NAME_EPR: continue - print_('attribute : ' + attribute.name) + print('attribute : ' + attribute.name) for value in attribute.attributeValue: - print_(' value : ' + value.any[0].content) + print(' value : ' + value.any[0].content) diff '--exclude=ChangeLog' -ur lasso-2.8.2/bindings/python/lang.py lasso/bindings/python/lang.py --- lasso-2.8.2/bindings/python/lang.py 2021-09-28 16:24:47.113979000 +0800 +++ lasso/bindings/python/lang.py 2024-10-26 11:06:24.488050700 +0800 @@ -19,7 +19,6 @@ # along with this program; if not, see . import os -from six import print_ import sys import re import textwrap @@ -34,9 +33,9 @@ if not '=' in x: non_opt = True elif non_opt: - print_('W: changed', x, file=sys.stderr, end=' ') + print('W: changed', x, file=sys.stderr, end=' ') x = re.sub(' *=.*', '', x) - print_('to', x, file=sys.stderr) + print('to', x, file=sys.stderr) new_args.append(x) new_args.reverse() return new_args @@ -73,17 +72,17 @@ if not name: raise Exception('Cannot free, missing a name') if is_cstring(type): - print_(' lasso_release_string(%s);' % name, file=fd) + print(' lasso_release_string(%s);' % name, file=fd) elif is_int(type, self.binding_data) or is_boolean(type): pass elif is_xml_node(type): - print_(' lasso_release_xml_node(%s);' % name, file=fd) + print(' lasso_release_xml_node(%s);' % name, file=fd) elif is_glist(type): etype = element_type(type) if is_cstring(etype): - print_(' lasso_release_list_of_strings(%s);' % name, file=fd) + print(' lasso_release_list_of_strings(%s);' % name, file=fd) elif is_object(etype): - print_(' lasso_release_list_of_gobjects(%s);' % name, file=fd) + print(' lasso_release_list_of_gobjects(%s);' % name, file=fd) else: raise Exception('Unsupported caller owned return type %s' % ((repr(type), name),)) elif is_hashtable(type): @@ -91,11 +90,11 @@ k_type = key_type(type) v_type = value_type(type) if is_cstring(el_type) or (is_cstring(k_type) and is_cstring(v_type)): - print_(' if (%s) { g_hash_table_destroy(%s); }' % (name, name), file=fd) + print(' if (%s) { g_hash_table_destroy(%s); }' % (name, name), file=fd) else: raise Exception('Unsupported free value of type GHashTable: %s' % type) elif is_object(type): - print_(' if (return_value) g_object_unref(%s);' % name, file=fd) + print(' if (return_value) g_object_unref(%s);' % name, file=fd) else: raise Exception('Unsupported caller owned return type %s' % ((repr(type), name),)) @@ -116,7 +115,7 @@ fd.close() def generate_header(self, fd): - print_('''\ + print('''\ # this file has been generated automatically; do not edit import _lasso @@ -172,7 +171,7 @@ def generate_exceptions(self, fd): done_cats = [] - print_('''\ + print('''\ class Error(Exception): code = None @@ -206,7 +205,7 @@ cat = exc_cat.attrib.get('name') done_cats.append(cat) parent_cat = exc_cat.attrib.get('parent', '') - print_('''\ + print('''\ class %sError(%sError): pass ''' % (cat, parent_cat), file=fd) @@ -229,7 +228,7 @@ else: parent_cat = '' - print_('''\ + print('''\ class %sError(%sError): pass ''' % (cat, parent_cat), file=fd) @@ -247,19 +246,19 @@ # ordering would change) continue - print_('''\ + print('''\ class %sError(%sError): pass ''' % (detail, cat), file=fd) - print_('exceptions_dict = {', file=fd) + print('exceptions_dict = {', file=fd) for k, v in exceptions_dict.items(): - print_(' _lasso.%s: %sError,' % (v, k), file=fd) - print_('}', file=fd) - print_('', file=fd) + print(' _lasso.%s: %sError,' % (v, k), file=fd) + print('}', file=fd) + print('', file=fd) def generate_footer(self, fd): - print_(''' + print(''' def _profileGetIssuer(cls, *args, **kwargs): return profileGetIssuer(*args, **kwargs) @@ -304,19 +303,19 @@ ''', file=fd) def generate_constants(self, fd): - print_('### Constants (both enums and defines)', file=fd) + print('### Constants (both enums and defines)', file=fd) for c in self.binding_data.constants: - print_('%s = _lasso.%s' % (c[1][6:], c[1][6:]), file=fd) + print('%s = _lasso.%s' % (c[1][6:], c[1][6:]), file=fd) for c in self.binding_data.overrides.findall('constant'): name = c.attrib.get('name') if c.attrib.get('value'): name = name[6:] # dropping LASSO_ value = c.attrib.get('value') if value == 'True': - print_('%s = True' % name, file=fd) + print('%s = True' % name, file=fd) else: - print_('E: unknown value for constant: %r' % value, file=sys.stderr) - print_('', file=fd) + print('E: unknown value for constant: %r' % value, file=sys.stderr) + print('', file=fd) def generate_class(self, clss, fd): klassname = clss.name[5:] # remove Lasso from class name @@ -325,7 +324,7 @@ else: parentname = clss.parent[5:] - print_('''class %(klassname)s(%(parentname)s):''' % locals(), file=fd) + print('''class %(klassname)s(%(parentname)s):''' % locals(), file=fd) methods = clss.methods[:] # constructor(s) @@ -348,14 +347,14 @@ c_args = ', '.join(c_args) py_args = ', ' + ', '.join(py_args) - print_(' def __init__(self%s):' % py_args, file=fd) + print(' def __init__(self%s):' % py_args, file=fd) # XXX: could check self._cptr.typename to see if it got the # right class type - print_(' self._cptr = _lasso.%s(%s)' % ( + print(' self._cptr = _lasso.%s(%s)' % ( m.name[6:], c_args), file=fd) - print_(' if self._cptr is None:', file=fd) - print_(' raise Error(\'failed to create object\')', file=fd) - print_('', file=fd) + print(' if self._cptr is None:', file=fd) + print(' raise Error(\'failed to create object\')', file=fd) + print('', file=fd) for m in self.binding_data.functions: if m.name.startswith(method_prefix + 'new_'): @@ -379,13 +378,13 @@ if '=' in x: opt = True elif opt: - print_('W: non-optional follows optional,', m, file=sys.stderr) + print('W: non-optional follows optional,', m, file=sys.stderr) c_args = ', '.join(c_args) py_args = ', ' + ', '.join(py_args) - print_(' @classmethod', file=fd) - print_(' def %s(cls%s):' % (constructor_name, py_args), file=fd) - print_(' return cptrToPy(_lasso.%s(%s))' % (m.name[6:], c_args), file=fd) - print_('', file=fd) + print(' @classmethod', file=fd) + print(' def %s(cls%s):' % (constructor_name, py_args), file=fd) + print(' return cptrToPy(_lasso.%s(%s))' % (m.name[6:], c_args), file=fd) + print('', file=fd) # create properties for members for m in clss.members: @@ -393,13 +392,13 @@ mname = format_as_camelcase(m[1]) options = m[2] # getter - print_(' def get_%s(self):' % mname, file=fd) - print_(' t = _lasso.%s_%s_get(self._cptr)' % ( + print(' def get_%s(self):' % mname, file=fd) + print(' t = _lasso.%s_%s_get(self._cptr)' % ( klassname, mname), file=fd) if is_int(m, self.binding_data) or is_xml_node(m) or is_cstring(m) or is_boolean(m): pass elif is_object(m): - print_(' t = cptrToPy(t)', file=fd) + print(' t = cptrToPy(t)', file=fd) elif is_glist(m): el_type = element_type(m) if is_cstring(el_type): @@ -407,54 +406,54 @@ elif is_xml_node(el_type): pass elif is_object(el_type): - print_(' if not t: return t', file=fd) - print_(' t = tuple([cptrToPy(x) for x in t])', file=fd) + print(' if not t: return t', file=fd) + print(' t = tuple([cptrToPy(x) for x in t])', file=fd) else: raise Exception('Unsupported python getter %s.%s' % (clss, m)) elif is_hashtable(m): el_type = element_type(m) - print_(' if not t: return t', file=fd) + print(' if not t: return t', file=fd) if is_object(el_type): - print_(' d2 = {}', file=fd) - print_(' for k, v in t.items():', file=fd) - print_(' d2[k] = cptrToPy(v)', file=fd) - print_(' t = frozendict(d2)', file=fd) + print(' d2 = {}', file=fd) + print(' for k, v in t.items():', file=fd) + print(' d2[k] = cptrToPy(v)', file=fd) + print(' t = frozendict(d2)', file=fd) else: - print_(' t = frozendict(t)', file=fd) + print(' t = frozendict(t)', file=fd) elif is_boolean(m) or is_int(m, self.binding_data) or is_xml_node(m) or is_cstring(m): pass else: raise Exception('Unsupported python getter %s.%s' % (clss, m)) - print_(' return t;', file=fd) + print(' return t;', file=fd) # setter - print_(' def set_%s(self, value):' % mname, file=fd) + print(' def set_%s(self, value):' % mname, file=fd) if is_int(m, self.binding_data) or is_xml_node(m) or is_boolean(m): pass elif is_cstring(m): - print_(' value = str2lasso(value)', file=fd) + print(' value = str2lasso(value)', file=fd) elif is_object(m): - print_(' if value is not None:', file=fd) - print_(' value = value and value._cptr', file=fd) + print(' if value is not None:', file=fd) + print(' value = value and value._cptr', file=fd) elif is_glist(m): el_type = element_type(m) if is_cstring(el_type) or is_xml_node(el_type): pass elif is_object(el_type): - print_(' if value is not None:', file=fd) - print_(' value = tuple([x._cptr for x in value])', file=fd) + print(' if value is not None:', file=fd) + print(' value = tuple([x._cptr for x in value])', file=fd) else: raise Exception('Unsupported python setter %s.%s' % (clss, m)) elif is_hashtable(m): - print_('W: unsupported setter for hashtable %s' % (m,), file=sys.stderr) + print('W: unsupported setter for hashtable %s' % (m,), file=sys.stderr) else: - print_('W: unsupported setter for %s' % (m,), file=sys.stderr) - print_(' _lasso.%s_%s_set(self._cptr, value)' % ( + print('W: unsupported setter for %s' % (m,), file=sys.stderr) + print(' _lasso.%s_%s_set(self._cptr, value)' % ( klassname, mname), file=fd) - print_(' %s = property(get_%s, set_%s)' % (mname, mname, mname), file=fd) + print(' %s = property(get_%s, set_%s)' % (mname, mname, mname), file=fd) old_mname = old_format_as_camelcase(m[1]) if mname != old_mname: - print_(' %s = %s' % (old_mname, mname), file=fd) - print_('', file=fd) + print(' %s = %s' % (old_mname, mname), file=fd) + print('', file=fd) # first pass on methods, getting accessors # second pass on methods, real methods @@ -464,7 +463,7 @@ m.name.endswith('_new_full'): continue if not m.name.startswith(method_prefix): - print_('W:', m.name, 'vs', method_prefix, file=sys.stderr) + print('W:', m.name, 'vs', method_prefix, file=sys.stderr) continue if m.rename: @@ -501,7 +500,7 @@ if '=' in x: opt = True elif opt: - print_('W: non-optional follow optional,', m, file=sys.stderr) + print('W: non-optional follow optional,', m, file=sys.stderr) if py_args: py_args = ', ' + ', '.join(py_args) @@ -512,51 +511,51 @@ else: c_args = '' - print_(' def %s(self%s):' % ( + print(' def %s(self%s):' % ( format_underscore_as_camelcase(mname), py_args), file=fd) if m.docstring: - print_(" '''", file=fd) - print_(self.format_docstring(m, mname, 8), file=fd) - print_(" '''", file=fd) + print(" '''", file=fd) + print(self.format_docstring(m, mname, 8), file=fd) + print(" '''", file=fd) if outarg: - print_(" %s = list((None,))" % outvar, file=fd) + print(" %s = list((None,))" % outvar, file=fd) return_type = m.return_type return_type_qualifier = m.return_type_qualifier assert is_int(make_arg(return_type),self.binding_data) or not outarg if return_type in (None, 'void'): - print_(' _lasso.%s(self._cptr%s)' % ( + print(' _lasso.%s(self._cptr%s)' % ( function_name, c_args), file=fd) elif is_rc(m.return_arg): - print_(' rc = _lasso.%s(self._cptr%s)' % ( + print(' rc = _lasso.%s(self._cptr%s)' % ( function_name, c_args), file=fd) - print_(' Error.raise_on_rc(rc)', file=fd) + print(' Error.raise_on_rc(rc)', file=fd) elif (is_int(m.return_arg, self.binding_data) or is_xml_node(m.return_arg) or is_cstring(m.return_arg) or is_boolean(m.return_arg) or is_hashtable(m.return_arg)): - print_(' return _lasso.%s(self._cptr%s)' % ( + print(' return _lasso.%s(self._cptr%s)' % ( function_name, c_args), file=fd) elif is_glist(m.return_arg): el_type = element_type(m.return_arg) if is_object(el_type): - print_(' value = _lasso.%s(self._cptr%s)' % ( + print(' value = _lasso.%s(self._cptr%s)' % ( function_name, c_args), file=fd) - print_(' if value is not None:', file=fd) - print_(' value = tuple([cptrToPy(x) for x in value])', file=fd) - print_(' return value', file=fd) + print(' if value is not None:', file=fd) + print(' value = tuple([cptrToPy(x) for x in value])', file=fd) + print(' return value', file=fd) elif is_cstring(el_type) or is_xml_node(el_type): - print_(' return _lasso.%s(self._cptr%s)' % ( + print(' return _lasso.%s(self._cptr%s)' % ( function_name, c_args), file=fd) else: raise Exception('Return Type GList<%s> is not supported' % el_type) elif is_object(m.return_arg): - print_(' return cptrToPy(_lasso.%s(self._cptr%s))' % ( + print(' return cptrToPy(_lasso.%s(self._cptr%s))' % ( function_name, c_args), file=fd) else: raise Exception('Return type %s is unsupported' % (m.return_arg,)) if outarg: - print_(' return %s[0]' % outvar, file=fd) - print_('', file=fd) + print(' return %s[0]' % outvar, file=fd) + print('', file=fd) # transform methods to properties for m in methods: if len(m.args) > 1: @@ -564,7 +563,7 @@ name = m.rename or m.name suffix = name[len(method_prefix)+len('get_'):] if clss.getMember(suffix): - print_('W: method %s and member %s clashes' % (m.name, arg_name(clss.getMember(suffix))), file=sys.stderr) + print('W: method %s and member %s clashes' % (m.name, arg_name(clss.getMember(suffix))), file=sys.stderr) continue if not name.startswith(method_prefix) or not name[len(method_prefix):].startswith('get_'): continue @@ -576,13 +575,13 @@ pname = format_as_camelcase(name[len(method_prefix)+len('get_'):]) fname = format_as_camelcase(name[len(method_prefix):]) if not setter: - print_(' %s = property(%s)' % (pname, fname), file=fd) + print(' %s = property(%s)' % (pname, fname), file=fd) else: f2name = format_as_camelcase(setter.name[len(method_prefix):]) - print_(' %s = property(%s, %s)' % (pname, fname, f2name), file=fd) + print(' %s = property(%s, %s)' % (pname, fname, f2name), file=fd) if empty: - print_(' pass', file=fd) - print_('', file=fd) + print(' pass', file=fd) + print('', file=fd) def format_docstring(self, func, method_name, indent): if func.args: @@ -601,7 +600,7 @@ return 'True' if var == 'FALSE': return 'False' - print_('W: unknown docstring thingie: %s' % s.group(1), file=sys.stderr) + print('W: unknown docstring thingie: %s' % s.group(1), file=sys.stderr) elif type == '@': if var == first_arg_name: var = 'self' @@ -686,14 +685,14 @@ else: name = m.name[6:] pname = format_as_camelcase(name) - print_('%s = _lasso.%s' % (pname, name), file=fd) + print('%s = _lasso.%s' % (pname, name), file=fd) def generate_wrapper(self, fd): - print_(open(os.path.join(self.src_dir,'wrapper_top.c')).read(), file=fd) + print(open(os.path.join(self.src_dir,'wrapper_top.c')).read(), file=fd) for h in self.binding_data.headers: - print_('#include <%s>' % h, file=fd) - print_('', file=fd) + print('#include <%s>' % h, file=fd) + print('', file=fd) self.generate_constants_wrapper(fd) @@ -705,33 +704,33 @@ for m in c.methods: self.generate_function_wrapper(m, fd) self.generate_wrapper_list(fd) - print_(open(os.path.join(self.src_dir,'wrapper_bottom.c')).read(), file=fd) + print(open(os.path.join(self.src_dir,'wrapper_bottom.c')).read(), file=fd) def generate_constants_wrapper(self, fd): - print_('''static void + print('''static void register_constants(PyObject *d) { PyObject *obj; ''', file=fd) for c in self.binding_data.constants: if c[0] == 'i': - print_(' obj = PyInt_FromLong(%s);' % c[1], file=fd) + print(' obj = PyInt_FromLong(%s);' % c[1], file=fd) elif c[0] == 's': - print_(' obj = PyString_FromString((char*)%s);' % c[1], file=fd) + print(' obj = PyString_FromString((char*)%s);' % c[1], file=fd) elif c[0] == 'b': - print_('''\ + print('''\ #ifdef %s obj = Py_True; #else obj = Py_False; #endif''' % c[1], file=fd) else: - print_('E: unknown constant type: %r' % c[0], file=sys.stderr) - print_(' PyDict_SetItemString(d, "%s", obj);' % c[1][6:], file=fd) + print('E: unknown constant type: %r' % c[0], file=sys.stderr) + print(' PyDict_SetItemString(d, "%s", obj);' % c[1][6:], file=fd) if c[0] != 'b': # refcount of Py_True/False should not be changed - print_(' Py_DECREF(obj);', file=fd) - print_('}', file=fd) - print_('', file=fd) + print(' Py_DECREF(obj);', file=fd) + print('}', file=fd) + print('', file=fd) def generate_member_wrapper(self, c, fd): @@ -740,7 +739,7 @@ name = arg_name(m) mname = format_as_camelcase(arg_name(m)) # getter - print_('''static PyObject* + print('''static PyObject* %s_%s_get(G_GNUC_UNUSED PyObject *self, PyObject *args) {''' % (klassname[5:], mname), file=fd) self.wrapper_list.append('%s_%s_get' % (klassname[5:], mname)) @@ -748,140 +747,140 @@ ftype = arg_type(m) if is_cstring(m): ftype = 'char*' - print_(' %s return_value;' % ftype, file=fd) - print_(' PyObject* return_pyvalue;', file=fd) - print_(' PyGObjectPtr* cvt_this;', file=fd) - print_(' %s* this;' % klassname, file=fd) - print_('', file=fd) - print_(' if (! PyArg_ParseTuple(args, "O", &cvt_this)) return NULL;', file=fd) - print_(' this = (%s*)cvt_this->obj;' % klassname, file=fd) - print_(' return_value = this->%s;' % arg_name(m), file=fd) + print(' %s return_value;' % ftype, file=fd) + print(' PyObject* return_pyvalue;', file=fd) + print(' PyGObjectPtr* cvt_this;', file=fd) + print(' %s* this;' % klassname, file=fd) + print('', file=fd) + print(' if (! PyArg_ParseTuple(args, "O", &cvt_this)) return NULL;', file=fd) + print(' this = (%s*)cvt_this->obj;' % klassname, file=fd) + print(' return_value = this->%s;' % arg_name(m), file=fd) try: self.return_value(fd, m) except: - print_('W: cannot make an assignment for', c, m, file=sys.stderr) + print('W: cannot make an assignment for', c, m, file=sys.stderr) raise - print_(' return return_pyvalue;', file=fd) - print_('}', file=fd) - print_('', file=fd) + print(' return return_pyvalue;', file=fd) + print('}', file=fd) + print('', file=fd) # setter - print_('''static PyObject* + print('''static PyObject* %s_%s_set(G_GNUC_UNUSED PyObject *self, PyObject *args) {''' % (klassname[5:], mname), file=fd) self.wrapper_list.append('%s_%s_set' % (klassname[5:], mname)) - print_(' PyGObjectPtr* cvt_this;', file=fd) - print_(' %s* this;' % klassname, file=fd) + print(' PyGObjectPtr* cvt_this;', file=fd) + print(' %s* this;' % klassname, file=fd) type = m[0] # Determine type class if is_cstring(m): type = type.replace('const ', '') parse_format = 'z' parse_arg = '&value' - print_(' %s value;' % type, file=fd) + print(' %s value;' % type, file=fd) elif is_int(m, self.binding_data): parse_format = 'l' parse_arg = '&value' - print_(' long value;', file=fd) + print(' long value;', file=fd) elif is_glist(m) or is_hashtable(m) or is_xml_node(m) or is_boolean(m): parse_format = 'O' - print_(' PyObject *cvt_value;', file=fd) + print(' PyObject *cvt_value;', file=fd) parse_arg = '&cvt_value' elif is_object(m): parse_format = 'O' - print_(' PyGObjectPtr *cvt_value;', file=fd) + print(' PyGObjectPtr *cvt_value;', file=fd) parse_arg = '&cvt_value' else: raise Exception('Unsupported field: %s' % (m,)) # Get GObject - print_(' if (! PyArg_ParseTuple(args, "O%s", &cvt_this, %s)) return NULL;' % ( + print(' if (! PyArg_ParseTuple(args, "O%s", &cvt_this, %s)) return NULL;' % ( parse_format, parse_arg), file=fd) - print_(' this = (%s*)cvt_this->obj;' % klassname, file=fd) + print(' this = (%s*)cvt_this->obj;' % klassname, file=fd) # Change value if is_int(m, self.binding_data): - print_(' this->%s = value;' % name, file=fd) + print(' this->%s = value;' % name, file=fd) elif is_boolean(m): - print_(' this->%s = PyInt_AS_LONG(cvt_value) ? TRUE : FALSE;' % name, file=fd) + print(' this->%s = PyInt_AS_LONG(cvt_value) ? TRUE : FALSE;' % name, file=fd) elif is_cstring(m): - print_(' lasso_assign_string(this->%s, value);' % name, file=fd) + print(' lasso_assign_string(this->%s, value);' % name, file=fd) elif is_xml_node(m): - print_(' if (this->%s) xmlFreeNode(this->%s);' % (name, name), file=fd) - print_(' this->%s = get_xml_node_from_pystring(cvt_value);' % name, file=fd) + print(' if (this->%s) xmlFreeNode(this->%s);' % (name, name), file=fd) + print(' this->%s = get_xml_node_from_pystring(cvt_value);' % name, file=fd) elif is_glist(m): el_type = element_type(m) if is_cstring(el_type): - print_(' RETURN_IF_FAIL(set_list_of_strings(&this->%s, cvt_value));' % name, file=fd) + print(' RETURN_IF_FAIL(set_list_of_strings(&this->%s, cvt_value));' % name, file=fd) elif is_xml_node(el_type): - print_(' RETURN_IF_FAIL(set_list_of_xml_nodes(&this->%s, cvt_value));' % name, file=fd) + print(' RETURN_IF_FAIL(set_list_of_xml_nodes(&this->%s, cvt_value));' % name, file=fd) elif is_object(el_type): - print_(' RETURN_IF_FAIL(set_list_of_pygobject(&this->%s, cvt_value));' % name, file=fd) + print(' RETURN_IF_FAIL(set_list_of_pygobject(&this->%s, cvt_value));' % name, file=fd) else: raise Exception('Unsupported setter for %s' % (m,)) elif is_hashtable(m): el_type = element_type(m) if is_object(el_type): - print_(' RETURN_IF_FAIL(set_hashtable_of_pygobject(this->%s, cvt_value));' % name, file=fd) + print(' RETURN_IF_FAIL(set_hashtable_of_pygobject(this->%s, cvt_value));' % name, file=fd) else: - print_(' RETURN_IF_FAIL(set_hashtable_of_strings(this->%s, cvt_value));' % name, file=fd) + print(' RETURN_IF_FAIL(set_hashtable_of_strings(this->%s, cvt_value));' % name, file=fd) elif is_object(m): - print_(' set_object_field((GObject**)&this->%s, cvt_value);' % name, file=fd) + print(' set_object_field((GObject**)&this->%s, cvt_value);' % name, file=fd) else: raise Exception('Unsupported member %s.%s' % (klassname, m)) - print_(' return noneRef();', file=fd) - print_('}', file=fd) - print_('', file=fd) + print(' return noneRef();', file=fd) + print('}', file=fd) + print('', file=fd) def return_value(self, fd, arg, return_var_name = 'return_value', return_pyvar_name = 'return_pyvalue'): if is_boolean(arg): - print_(' if (%s) {' % return_var_name, file=fd) - print_(' Py_INCREF(Py_True);', file=fd) - print_(' %s = Py_True;' % return_pyvar_name, file=fd) - print_(' } else {', file=fd) - print_(' Py_INCREF(Py_False);', file=fd) - print_(' %s = Py_False;' % return_pyvar_name, file=fd) - print_(' }', file=fd) + print(' if (%s) {' % return_var_name, file=fd) + print(' Py_INCREF(Py_True);', file=fd) + print(' %s = Py_True;' % return_pyvar_name, file=fd) + print(' } else {', file=fd) + print(' Py_INCREF(Py_False);', file=fd) + print(' %s = Py_False;' % return_pyvar_name, file=fd) + print(' }', file=fd) elif is_int(arg, self.binding_data): - print_(' %s = PyInt_FromLong(%s);' % (return_pyvar_name, return_var_name), file=fd) + print(' %s = PyInt_FromLong(%s);' % (return_pyvar_name, return_var_name), file=fd) elif is_cstring(arg) and is_transfer_full(arg): - print_(' if (%s) {' % return_var_name, file=fd) - print_(' %s = PyString_FromString(%s);' % (return_pyvar_name, return_var_name), file=fd) - print_(' } else {', file=fd) - print_(' %s = noneRef();' % return_pyvar_name, file=fd) - print_(' }', file=fd) + print(' if (%s) {' % return_var_name, file=fd) + print(' %s = PyString_FromString(%s);' % (return_pyvar_name, return_var_name), file=fd) + print(' } else {', file=fd) + print(' %s = noneRef();' % return_pyvar_name, file=fd) + print(' }', file=fd) elif is_cstring(arg): - print_(' if (%s) {' % return_var_name, file=fd) - print_(' %s = PyString_FromString(%s);' % (return_pyvar_name, return_var_name), file=fd) - print_(' } else {', file=fd) - print_(' %s = noneRef();' % return_pyvar_name, file=fd) - print_(' }', file=fd) + print(' if (%s) {' % return_var_name, file=fd) + print(' %s = PyString_FromString(%s);' % (return_pyvar_name, return_var_name), file=fd) + print(' } else {', file=fd) + print(' %s = noneRef();' % return_pyvar_name, file=fd) + print(' }', file=fd) elif is_glist(arg): el_type = element_type(arg) if is_object(el_type): - print_(' %s = get_list_of_pygobject(%s);' % (return_pyvar_name, return_var_name), file=fd) + print(' %s = get_list_of_pygobject(%s);' % (return_pyvar_name, return_var_name), file=fd) elif is_cstring(el_type): - print_(' %s = get_list_of_strings(%s);' % (return_pyvar_name, return_var_name), file=fd) + print(' %s = get_list_of_strings(%s);' % (return_pyvar_name, return_var_name), file=fd) elif is_xml_node(el_type): - print_(' %s = get_list_of_xml_nodes(%s);' % (return_pyvar_name, return_var_name), file=fd) + print(' %s = get_list_of_xml_nodes(%s);' % (return_pyvar_name, return_var_name), file=fd) else: raise Exception('failed to make an assignment for %s' % (arg,)) elif is_hashtable(arg): el_type = element_type(arg) if is_object(el_type): - print_(' %s = get_dict_from_hashtable_of_objects(%s);' % (return_pyvar_name, return_var_name), file=fd) + print(' %s = get_dict_from_hashtable_of_objects(%s);' % (return_pyvar_name, return_var_name), file=fd) else: - print_(' %s = get_dict_from_hashtable_of_strings(%s);' % (return_pyvar_name, return_var_name), file=fd) + print(' %s = get_dict_from_hashtable_of_strings(%s);' % (return_pyvar_name, return_var_name), file=fd) elif is_xml_node(arg): # convert xmlNode* to strings - print_(' if (%s) {' % return_var_name, file=fd) - print_(' %s = get_pystring_from_xml_node(%s);' % (return_pyvar_name, return_var_name), file=fd) - print_(' } else {', file=fd) - print_(' %s = noneRef();' % return_pyvar_name, file=fd) - print_(' }', file=fd) + print(' if (%s) {' % return_var_name, file=fd) + print(' %s = get_pystring_from_xml_node(%s);' % (return_pyvar_name, return_var_name), file=fd) + print(' } else {', file=fd) + print(' %s = noneRef();' % return_pyvar_name, file=fd) + print(' }', file=fd) elif is_object(arg): # return a PyGObjectPtr (wrapper around GObject) - print_('''\ + print('''\ if (%s) { %s = PyGObjectPtr_New(G_OBJECT(%s)); } else { @@ -899,7 +898,7 @@ else: name = m.name[6:] self.wrapper_list.append(name) - print_('''static PyObject* + print('''static PyObject* %s(G_GNUC_UNUSED PyObject *self, PyObject *args) { int ok = 1;''' % name, file=fd) @@ -951,21 +950,21 @@ parse_tuple_args.pop() parse_tuple_args.append('&cvt_%s_out' % aname) python_cvt_def = ' PyObject *cvt_%s_out = NULL;' % aname - print_(' PyObject *out_pyvalue = NULL;', file=fd) - print_(arg_def, file=fd) + print(' PyObject *out_pyvalue = NULL;', file=fd) + print(arg_def, file=fd) if python_cvt_def: - print_(python_cvt_def, file=fd) + print(python_cvt_def, file=fd) if m.return_type: - print_(' %s return_value;' % m.return_type, file=fd) - print_(' PyObject* return_pyvalue = NULL;', file=fd) - print_('', file=fd) + print(' %s return_value;' % m.return_type, file=fd) + print(' PyObject* return_pyvalue = NULL;', file=fd) + print('', file=fd) parse_tuple_args = ', '.join(parse_tuple_args) if parse_tuple_args: parse_tuple_args = ', ' + parse_tuple_args - print_(' if (! PyArg_ParseTuple(args, "%s"%s)) return NULL;' % ( + print(' if (! PyArg_ParseTuple(args, "%s"%s)) return NULL;' % ( ''.join(parse_tuple_format), parse_tuple_args), file=fd) for f, arg in zip([ x for x in parse_tuple_format if x != '|'], m.args): @@ -974,48 +973,48 @@ if is_list(arg): qualifier = element_type(arg) if is_cstring(qualifier): - print_(' EXIT_IF_FAIL(set_list_of_strings(&%s, cvt_%s));' % (arg[1], arg[1]), file=fd) + print(' EXIT_IF_FAIL(set_list_of_strings(&%s, cvt_%s));' % (arg[1], arg[1]), file=fd) elif is_xml_node(qualifier): - print_(' EXIT_IF_FAIL(set_list_of_xml_nodes(&%s, cvt_%s));' % (arg[1], arg[1]), file=fd) + print(' EXIT_IF_FAIL(set_list_of_xml_nodes(&%s, cvt_%s));' % (arg[1], arg[1]), file=fd) elif isinstance(qualifier, str) and qualifier.startswith('Lasso'): - print_(' EXIT_IF_FAIL(set_list_of_pygobject(&%s, cvt_%s));' % (arg[1], arg[1]), file=fd) + print(' EXIT_IF_FAIL(set_list_of_pygobject(&%s, cvt_%s));' % (arg[1], arg[1]), file=fd) else: - print_('E: unqualified GList argument in', name, qualifier, arg, file=sys.stderr) + print('E: unqualified GList argument in', name, qualifier, arg, file=sys.stderr) elif is_xml_node(arg): - print_(' %s = get_xml_node_from_pystring(cvt_%s);' % (arg[1], arg[1]), file=fd) + print(' %s = get_xml_node_from_pystring(cvt_%s);' % (arg[1], arg[1]), file=fd) elif is_time_t_pointer(arg): - print_(' %s = get_time_t(cvt_%s);' % (arg[1], arg[1]), file=fd) + print(' %s = get_time_t(cvt_%s);' % (arg[1], arg[1]), file=fd) elif is_hashtable(arg): el_type = element_type(arg) k_type = key_type(arg) v_type = value_type(arg) if is_cstring(el_type) or (is_cstring(k_type) and is_cstring(v_type)): - print_(' %s = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);' % arg[1], file=fd) - print_(' EXIT_IF_FAIL(set_hashtable_of_strings(%s, cvt_%s));' % (arg[1], arg[1]), file=fd) + print(' %s = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);' % arg[1], file=fd) + print(' EXIT_IF_FAIL(set_hashtable_of_strings(%s, cvt_%s));' % (arg[1], arg[1]), file=fd) elif f == 'O': if is_optional(arg): - print_(' if (PyObject_TypeCheck((PyObject*)cvt_%s, &PyGObjectPtrType)) {' % arg[1], file=fd) - print_(' %s = (%s)cvt_%s->obj;' % (arg[1], arg[0], arg[1]), file=fd) - print_(' } else {', file=fd) - print_(' %s = NULL;' % arg[1], file=fd) - print_(' }', file=fd) + print(' if (PyObject_TypeCheck((PyObject*)cvt_%s, &PyGObjectPtrType)) {' % arg[1], file=fd) + print(' %s = (%s)cvt_%s->obj;' % (arg[1], arg[0], arg[1]), file=fd) + print(' } else {', file=fd) + print(' %s = NULL;' % arg[1], file=fd) + print(' }', file=fd) else: - print_(' if (PyObject_TypeCheck((PyObject*)cvt_%s, &PyGObjectPtrType)) {' % arg[1], file=fd) - print_(' %s = (%s)cvt_%s->obj;' % (arg[1], arg[0], arg[1]), file=fd) - print_(' } else {', file=fd) - print_(' PyErr_SetString(PyExc_TypeError, "value should be a PyGObject");', file=fd) - print_(' return NULL;', file=fd) - print_(' }', file=fd) + print(' if (PyObject_TypeCheck((PyObject*)cvt_%s, &PyGObjectPtrType)) {' % arg[1], file=fd) + print(' %s = (%s)cvt_%s->obj;' % (arg[1], arg[0], arg[1]), file=fd) + print(' } else {', file=fd) + print(' PyErr_SetString(PyExc_TypeError, "value should be a PyGObject");', file=fd) + print(' return NULL;', file=fd) + print(' }', file=fd) if m.return_type: - print_(' return_value = ', file=fd, end='') + print(' return_value = ', file=fd, end='') if 'new' in m.name: - print_('(%s)' % m.return_type, file=fd) + print('(%s)' % m.return_type, file=fd) else: - print_(' ', file=fd, end='') - print_('%s(%s);' % (m.name, ', '.join([ref_name(x) for x in m.args])), file=fd) + print(' ', file=fd, end='') + print('%s(%s);' % (m.name, ', '.join([ref_name(x) for x in m.args])), file=fd) if m.return_type: # Constructor so decrease refcount (it was incremented by PyGObjectPtr_New called @@ -1023,7 +1022,7 @@ try: self.return_value(fd, m.return_arg) except: - print_('W: cannot assign return value of', m, file=sys.stderr) + print('W: cannot assign return value of', m, file=sys.stderr) raise if is_transfer_full(m.return_arg, default=True): @@ -1033,48 +1032,48 @@ if is_out(arg): self.return_value(fd, arg, return_var_name = arg[1], return_pyvar_name = 'out_pyvalue') - print_(' EXIT_IF_FAIL(%s);' % arg[1], file=fd) - print_(' if (PyList_SetItem(cvt_%s_out, 0, out_pyvalue) == -1) {' % arg[1], file=fd) - print_(' ok = 0;', file=fd) - print_(' Py_XDECREF(out_pyvalue);', file=fd) - print_(' }', file=fd) + print(' EXIT_IF_FAIL(%s);' % arg[1], file=fd) + print(' if (PyList_SetItem(cvt_%s_out, 0, out_pyvalue) == -1) {' % arg[1], file=fd) + print(' ok = 0;', file=fd) + print(' Py_XDECREF(out_pyvalue);', file=fd) + print(' }', file=fd) elif arg[0] == 'GList*': qualifier = arg[2].get('element-type') if is_cstring(qualifier): - print_(' free_list(&%s, (GFunc)g_free);' % arg[1], file=fd) + print(' free_list(&%s, (GFunc)g_free);' % arg[1], file=fd) elif is_xml_node(qualifier): - print_(' free_list(&%s, (GFunc)xmlFreeNode);' % arg[1], file=fd) + print(' free_list(&%s, (GFunc)xmlFreeNode);' % arg[1], file=fd) elif is_object(qualifier): - print_(' free_list(&%s, (GFunc)g_object_unref);' % arg[1], file=fd) + print(' free_list(&%s, (GFunc)g_object_unref);' % arg[1], file=fd) elif is_time_t_pointer(arg): - print_(' if (%s) free(%s);' % (arg[1], arg[1]), file=fd) + print(' if (%s) free(%s);' % (arg[1], arg[1]), file=fd) elif not is_transfer_full(arg) and is_hashtable(arg): self.free_value(fd, arg) elif not is_transfer_full(arg) and is_xml_node(arg): self.free_value(fd, arg) - print_('failure:', file=fd) + print('failure:', file=fd) if not m.return_type: - print_(' if (ok) {', file=fd) - print_(' return noneRef();', file=fd) + print(' if (ok) {', file=fd) + print(' return noneRef();', file=fd) else: - print_(' if (ok && return_pyvalue) {', file=fd) - print_(' return return_pyvalue;', file=fd) - print_(' } else {', file=fd) + print(' if (ok && return_pyvalue) {', file=fd) + print(' return return_pyvalue;', file=fd) + print(' } else {', file=fd) if m.return_type: - print_(' Py_XDECREF(return_pyvalue);', file=fd) - print_(' return NULL;', file=fd) - print_(' }', file=fd) - print_('}', file=fd) - print_('', file=fd) + print(' Py_XDECREF(return_pyvalue);', file=fd) + print(' return NULL;', file=fd) + print(' }', file=fd) + print('}', file=fd) + print('', file=fd) def generate_wrapper_list(self, fd): - print_(''' + print(''' static PyMethodDef lasso_methods[] = {''', file=fd) for m in self.wrapper_list: - print_(' {"%s", %s, METH_VARARGS, NULL},' % (m, m), file=fd) - print_(' {NULL, NULL, 0, NULL}', file=fd) - print_('};', file=fd) - print_('', file=fd) + print(' {"%s", %s, METH_VARARGS, NULL},' % (m, m), file=fd) + print(' {NULL, NULL, 0, NULL}', file=fd) + print('};', file=fd) + print('', file=fd) Only in lasso-2.8.2/bindings/python: Makefile.in diff '--exclude=ChangeLog' -ur lasso-2.8.2/bindings/python/tests/binding_tests.py lasso/bindings/python/tests/binding_tests.py --- lasso-2.8.2/bindings/python/tests/binding_tests.py 2021-09-04 04:12:54.062799700 +0800 +++ lasso/bindings/python/tests/binding_tests.py 2024-10-26 11:06:24.489063600 +0800 @@ -353,7 +353,7 @@ with self.assertRaises(TypeError, msg='value should be a tuple of PyGobject'): node.attributeValue = value -bindingSuite = unittest.makeSuite(BindingTestCase, 'test') +bindingSuite = unittest.defaultTestLoader.loadTestsFromTestCase(BindingTestCase) allTests = unittest.TestSuite((bindingSuite, )) Only in lasso/bindings/python/tests: idwsf1_tests.py Only in lasso-2.8.2/bindings/python/tests: Makefile.in diff '--exclude=ChangeLog' -ur lasso-2.8.2/bindings/python/tests/profiles_tests.py lasso/bindings/python/tests/profiles_tests.py --- lasso-2.8.2/bindings/python/tests/profiles_tests.py 2021-09-12 01:20:25.848637900 +0800 +++ lasso/bindings/python/tests/profiles_tests.py 2024-10-26 11:06:24.491130900 +0800 @@ -543,12 +543,12 @@ assert aq.response.assertion[0].attributeStatement[0].attribute[0] assert aq.response.assertion[0].attributeStatement[0].attribute[0].attributeValue[0] -serverSuite = unittest.makeSuite(ServerTestCase, 'test') -loginSuite = unittest.makeSuite(LoginTestCase, 'test') -logoutSuite = unittest.makeSuite(LogoutTestCase, 'test') -defederationSuite = unittest.makeSuite(DefederationTestCase, 'test') -identitySuite = unittest.makeSuite(IdentityTestCase, 'test') -attributeSuite = unittest.makeSuite(AttributeAuthorityTestCase, 'test') +serverSuite = unittest.defaultTestLoader.loadTestsFromTestCase(ServerTestCase) +loginSuite = unittest.defaultTestLoader.loadTestsFromTestCase(LoginTestCase) +logoutSuite = unittest.defaultTestLoader.loadTestsFromTestCase(LogoutTestCase) +defederationSuite = unittest.defaultTestLoader.loadTestsFromTestCase(DefederationTestCase) +identitySuite = unittest.defaultTestLoader.loadTestsFromTestCase(IdentityTestCase) +attributeSuite = unittest.defaultTestLoader.loadTestsFromTestCase(AttributeAuthorityTestCase) allTests = unittest.TestSuite((serverSuite, loginSuite, logoutSuite, defederationSuite, identitySuite, attributeSuite)) diff '--exclude=ChangeLog' -ur lasso-2.8.2/bindings/python/tests/tests.py lasso/bindings/python/tests/tests.py --- lasso-2.8.2/bindings/python/tests/tests.py 2021-09-12 01:20:25.848637900 +0800 +++ lasso/bindings/python/tests/tests.py 2024-10-26 11:06:24.491634400 +0800 @@ -1,5 +1,4 @@ #! /usr/bin/env python -# -*- coding: utf-8 -*- # # $Id: tests.py 3425 2007-10-10 09:31:03Z dlaniel $ # @@ -31,7 +30,6 @@ import sys import time import unittest -from six import print_ from XmlTestRunner import XmlTestRunner @@ -61,10 +59,10 @@ __builtin__.__dict__['dataDir'] = os.path.join(options.srcDir, '../../../tests/data') if options.xmlMode: - print_('') - print_('') - print_(' Python Bindings') - print_(' %s' % time.strftime('%Y-%m-%d %H:%M:%S', time.localtime())) + print('') + print('') + print(' Python Bindings') + print(' %s' % time.strftime('%Y-%m-%d %H:%M:%S', time.localtime())) success = True for testSuite in testSuites: @@ -75,7 +73,7 @@ if fp: fp.close() if not module: - print_('Unable to load test suite:', testSuite, file=sys.stderr) + print('Unable to load test suite:', testSuite, file=sys.stderr) continue if module.__doc__: @@ -88,13 +86,13 @@ else: runner = unittest.TextTestRunner(verbosity=2) print - print_('-' * len(doc)) - print_(doc) - print_('-' * len(doc)) + print('-' * len(doc)) + print(doc) + print('-' * len(doc)) result = runner.run(module.allTests) success = success and result.wasSuccessful() if options.xmlMode: - print_('') + print('') sys.exit(not success) diff '--exclude=ChangeLog' -ur lasso-2.8.2/bindings/python/tests/XmlTestRunner.py lasso/bindings/python/tests/XmlTestRunner.py --- lasso-2.8.2/bindings/python/tests/XmlTestRunner.py 2021-05-18 04:00:09.051310300 +0800 +++ lasso/bindings/python/tests/XmlTestRunner.py 2024-10-26 11:06:24.489063600 +0800 @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # $Id: XmlTestRunner.py 3254 2007-06-05 21:23:57Z fpeters $ # @@ -25,7 +24,6 @@ import unittest import time import sys -from six import print_ def xml(text): if not text: @@ -34,14 +32,14 @@ class XmlTestResult(unittest.TestResult): def addSuccess(self, test): - print_(""" + print(""" %s %s """ % (test.id(), xml(test.shortDescription()))) def addError(self, test, err): unittest.TestResult.addError(self, test, err) - print_(""" + print(""" %s %s """ % (test.id(), xml(test.shortDescription()))) @@ -49,7 +47,7 @@ def addFailure(self, test, err): unittest.TestResult.addFailure(self, test, err) - print_(""" + print(""" %s %s """ % (test.id(), xml(test.shortDescription()))) @@ -61,14 +59,14 @@ return XmlTestResult() def run(self, test): - print_("") + print("") result = self._makeResult() startTime = time.time() test(result) stopTime = time.time() timeTaken = float(stopTime - startTime) - print_(" %s" % timeTaken) - print_("") + print(" %s" % timeTaken) + print("") return result Only in lasso-2.8.2: compile Only in lasso-2.8.2: config.guess Only in lasso-2.8.2: config.h.in Only in lasso-2.8.2: config.sub Only in lasso-2.8.2: configure diff '--exclude=ChangeLog' -ur lasso-2.8.2/configure.ac lasso/configure.ac --- lasso-2.8.2/configure.ac 2023-03-06 19:05:02.761160500 +0800 +++ lasso/configure.ac 2024-10-26 11:06:24.495054600 +0800 @@ -90,6 +90,7 @@ dnl dnl Check for programs dnl +CFLAGS="$CFLAGS -Werror=undef -Werror=implicit-function-declaration" AC_PROG_CC AM_CFLAGS="" AC_HEADER_STDC @@ -133,7 +134,7 @@ AC_CHECK_PROGS(PHP5_CONFIG, php-config5 php-config) AC_CHECK_PROGS(PHP7, php7.4 php7.3 php7.2 php7.1 php7.0 php7 php) AC_CHECK_PROGS(PHP7_CONFIG, php-config7.4 php-config7.3 php-config7.2 php-config7.1 php-config7.0 php-config7 php-config) -AC_CHECK_PROGS(PYTHON, python3 python python2) +AC_CHECK_PROGS(PYTHON, python3 python) AC_CHECK_PROGS(SWIG, swig) dnl Make sure we have an ANSI compiler Only in lasso: debian Only in lasso-2.8.2: depcomp Only in lasso/docs/lasso-book: check-functions.py Only in lasso/docs/lasso-book: defederation.process Only in lasso-2.8.2/docs/lasso-book/figures: Makefile.in Only in lasso/docs/lasso-book/figures: single-logout.png Only in lasso/docs/lasso-book/figures: single-logout.svg Only in lasso/docs/lasso-book/figures: single-sign-on.png Only in lasso/docs/lasso-book/figures: single-sign-on.svg Only in lasso-2.8.2/docs/lasso-book/figures: slo-sp-soap.png Only in lasso-2.8.2/docs/lasso-book/figures: slo-sp-soap-1.png Only in lasso-2.8.2/docs/lasso-book/figures: slo-sp-soap-1.svg Only in lasso-2.8.2/docs/lasso-book/figures: slo-sp-soap-2.png Only in lasso-2.8.2/docs/lasso-book/figures: slo-sp-soap-2.svg Only in lasso-2.8.2/docs/lasso-book/figures: slo-sp-soap-3.png Only in lasso-2.8.2/docs/lasso-book/figures: slo-sp-soap-3.svg Only in lasso-2.8.2/docs/lasso-book/figures: slo-sp-soap-4.png Only in lasso-2.8.2/docs/lasso-book/figures: slo-sp-soap-4.svg Only in lasso-2.8.2/docs/lasso-book/figures: slo-sp-soap-5.png Only in lasso-2.8.2/docs/lasso-book/figures: slo-sp-soap-5.svg Only in lasso-2.8.2/docs/lasso-book/figures: slo-sp-soap-6.png Only in lasso-2.8.2/docs/lasso-book/figures: slo-sp-soap-6.svg Only in lasso-2.8.2/docs/lasso-book/figures: sso-brws-art.png Only in lasso-2.8.2/docs/lasso-book/figures: sso-brws-art-1.png Only in lasso-2.8.2/docs/lasso-book/figures: sso-brws-art-1.svg Only in lasso-2.8.2/docs/lasso-book/figures: sso-brws-art-2.png Only in lasso-2.8.2/docs/lasso-book/figures: sso-brws-art-2.svg Only in lasso-2.8.2/docs/lasso-book/figures: sso-brws-art-3.png Only in lasso-2.8.2/docs/lasso-book/figures: sso-brws-art-3.svg Only in lasso-2.8.2/docs/lasso-book/figures: sso-brws-art-4.png Only in lasso-2.8.2/docs/lasso-book/figures: sso-brws-art-4.svg Only in lasso-2.8.2/docs/lasso-book/figures: sso-brws-art-5.png Only in lasso-2.8.2/docs/lasso-book/figures: sso-brws-art-5.svg Only in lasso-2.8.2/docs/lasso-book/figures: sso-brws-post.png Only in lasso-2.8.2/docs/lasso-book/figures: sso-brws-post-1.png Only in lasso-2.8.2/docs/lasso-book/figures: sso-brws-post-1.svg Only in lasso-2.8.2/docs/lasso-book/figures: sso-brws-post-2.png Only in lasso-2.8.2/docs/lasso-book/figures: sso-brws-post-2.svg Only in lasso-2.8.2/docs/lasso-book/figures: sso-brws-post-3.png Only in lasso-2.8.2/docs/lasso-book/figures: sso-brws-post-3.svg Only in lasso-2.8.2/docs/lasso-book/figures: sso-brws-post-4.png Only in lasso-2.8.2/docs/lasso-book/figures: sso-brws-post-4.svg Only in lasso-2.8.2/docs/lasso-book: Makefile.in Only in lasso/docs/lasso-book: name-registration.process Only in lasso/docs/lasso-book: single-logout.process Only in lasso/docs/lasso-book: single-sign-on.process Only in lasso-2.8.2/docs: Makefile.in Only in lasso-2.8.2/docs/reference/lasso: html Only in lasso-2.8.2/docs/reference/lasso: Makefile.in Only in lasso-2.8.2/docs/reference: Makefile.in Only in lasso: examples Only in lasso: FAQ.rst Only in lasso: fedora Only in lasso-2.8.2: gtk-doc.make diff '--exclude=ChangeLog' -ur lasso-2.8.2/INSTALL lasso/INSTALL --- lasso-2.8.2/INSTALL 2020-12-17 17:22:08.718894900 +0800 +++ lasso/INSTALL 2024-10-26 11:06:24.446681200 +0800 @@ -26,9 +26,6 @@ aptitude install libxml2-dev libxslt1-dev libxmlsec1-dev libxmlsec1-openssl \ libglib2.0-dev python-all-dev fastjar php5-dev php5-cli python-lxml -Python bindings require the "six" library: - - pip install six Basic Installation ================== Only in lasso-2.8.2: install-sh Only in lasso: jenkins.sh Only in lasso: Jenkinsfile diff '--exclude=ChangeLog' -ur lasso-2.8.2/lasso/build_strerror.py lasso/lasso/build_strerror.py --- lasso-2.8.2/lasso/build_strerror.py 2021-05-18 04:00:09.083309900 +0800 +++ lasso/lasso/build_strerror.py 2024-10-26 11:06:24.535015200 +0800 @@ -4,14 +4,14 @@ import re import sys import os -from six import print_, StringIO +from io import StringIO srcdir = sys.argv[1] messages = dict() description = '' -with open('%s/errors.h' % srcdir,'r') as f: +with open('%s/errors.h' % srcdir) as f: for line in f: m = re.match(r'^ \* LASSO.*ERROR', line) if m: @@ -30,13 +30,13 @@ if m: messages[m.group(1)] = m.group(1) -with open('%s/errors.c.in' % srcdir,'r') as f: +with open('%s/errors.c.in' % srcdir) as f: for line in f: if '@ERROR_CASES@' in line: keys = sorted(messages.keys()) for k in keys: - print_(' case %s:\n' + print(' case %s:\n' ' return "%s";' % (k,messages[k].rstrip('\n'))) else: - print_(line, end="") + print(line, end="") Only in lasso-2.8.2/lasso: errors.c diff '--exclude=ChangeLog' -ur lasso-2.8.2/lasso/extract_sections.py lasso/lasso/extract_sections.py --- lasso-2.8.2/lasso/extract_sections.py 2021-09-12 01:20:25.848637900 +0800 +++ lasso/lasso/extract_sections.py 2024-10-26 11:06:24.538495400 +0800 @@ -5,7 +5,6 @@ import sys import os import os.path -from six import print_ if len(sys.argv) == 2: srcdir = sys.argv[1] @@ -19,21 +18,21 @@ prefixes.append(os.path.splitext(file)[0]) for prefix in prefixes: try: - header = io.open(os.path.join(root, prefix + '.h'), encoding='utf-8').read() - implementation = io.open(os.path.join(root, prefix + '.c'), encoding='utf-8').read() - exported_functions = re.findall('LASSO_EXPORT.*(lasso_\w*)', header) + header = open(os.path.join(root, prefix + '.h'), encoding='utf-8').read() + implementation = open(os.path.join(root, prefix + '.c'), encoding='utf-8').read() + exported_functions = re.findall(r'LASSO_EXPORT.*(lasso_\w*)', header) normal_functions = sorted ([ x for x in exported_functions if not x.endswith('get_type') ]) get_type = [ x for x in exported_functions if x.endswith('get_type') ][0] file_name = re.findall('lasso_(.*)_get_type', get_type)[0] try: - macro_type = re.findall('LASSO_(\w*)_CLASS\(', header)[0] + macro_type = re.findall(r'LASSO_(\w*)_CLASS\(', header)[0] except: macro_type = None try: type = re.findall(r'^struct _(Lasso\w*)', header, re.MULTILINE)[0] except: type = None - types = re.findall('^} (Lasso\w*);', header) + types = re.findall(r'^} (Lasso\w*);', header) def convert(x): if '%s' in x: return x % macro_type @@ -41,17 +40,17 @@ return x if type and macro_type: standard_decl = [ convert(x) for x in [ 'LASSO_%s', 'LASSO_IS_%s', 'LASSO_TYPE_%s', get_type, 'LASSO_%s_CLASS', 'LASSO_IS_%s_CLASS', 'LASSO_%s_GET_CLASS' ] ] - print_('') - print_('
') - print_('%s' % file_name) - print_('%s' % type) - print_(type) + print('') + print('
') + print('%s' % file_name) + print('%s' % type) + print(type) for x in types + normal_functions: - print_(x) - print_('') + print(x) + print('') for x in standard_decl: - print_(x) - print_('
') + print(x) + print('
') except: continue diff '--exclude=ChangeLog' -ur lasso-2.8.2/lasso/extract_symbols.py lasso/lasso/extract_symbols.py --- lasso-2.8.2/lasso/extract_symbols.py 2021-09-12 01:20:25.848637900 +0800 +++ lasso/lasso/extract_symbols.py 2024-10-26 11:06:24.539750000 +0800 @@ -4,7 +4,6 @@ import glob import re import sys -import six if len(sys.argv) == 2: srcdir = sys.argv[1] @@ -17,8 +16,8 @@ for header_file in glob.glob('%s/*/*.h' % srcdir) + glob.glob('%s/*.h' % srcdir) + \ glob.glob('%s/*/*/*.h' % srcdir): assert not ('/id-wsf/' in header_file or '/id-wsf-2.0' in header_file) - symbols.extend(regex.findall(io.open(header_file, encoding='utf-8').read().replace('\\\n', ''))) + symbols.extend(regex.findall(open(header_file, encoding='utf-8').read().replace('\\\n', ''))) for s in symbols: - six.print_(s) + print(s) diff '--exclude=ChangeLog' -ur lasso-2.8.2/lasso/extract_types.py lasso/lasso/extract_types.py --- lasso-2.8.2/lasso/extract_types.py 2021-09-12 01:20:25.848637900 +0800 +++ lasso/lasso/extract_types.py 2024-10-26 11:06:24.539750000 +0800 @@ -4,7 +4,6 @@ import glob import re import sys -import six if len(sys.argv) == 2: srcdir = sys.argv[1] @@ -14,30 +13,30 @@ fd = io.StringIO() -six.print_(u"/* This file has been autogenerated; changes will be lost */", file=fd) -six.print_(u"", file=fd) -six.print_(u"typedef GType (*type_function) ();", file=fd) -six.print_(u"", file=fd) +print("/* This file has been autogenerated; changes will be lost */", file=fd) +print("", file=fd) +print("typedef GType (*type_function) ();", file=fd) +print("", file=fd) header_files = [] for header_file in sorted(glob.glob('%s/*/*.h' % srcdir) + glob.glob('%s/*/*/*.h' % srcdir)): assert not ('/id-wsf/' in header_file or '/id-wsf-2.0' in header_file) header_files.append(header_file) try: - type = re.findall('lasso_.*get_type', io.open(header_file, encoding='utf-8').read())[0] + type = re.findall('lasso_.*get_type', open(header_file, encoding='utf-8').read())[0] except IndexError: continue - six.print_("extern GType %s();" % type, file=fd) + print("extern GType %s();" % type, file=fd) -six.print_(u"", file=fd) -six.print_(u"type_function functions[] = {", file=fd) +print("", file=fd) +print("type_function functions[] = {", file=fd) for header_file in header_files: try: - type = re.findall('lasso_.*get_type', io.open(header_file, encoding='utf-8').read())[0] + type = re.findall('lasso_.*get_type', open(header_file, encoding='utf-8').read())[0] except IndexError: continue - six.print_(u"\t%s," % type, file=fd) -six.print_(u"\tNULL", file=fd) -six.print_(u"};", file=fd) + print("\t%s," % type, file=fd) +print("\tNULL", file=fd) +print("};", file=fd) -io.open('types.c', 'w', encoding='utf-8').write(fd.getvalue()) +open('types.c', 'w', encoding='utf-8').write(fd.getvalue()) Only in lasso-2.8.2/lasso/id-ff: Makefile.in diff '--exclude=ChangeLog' -ur lasso-2.8.2/lasso/id-ff/provider.h lasso/lasso/id-ff/provider.h --- lasso-2.8.2/lasso/id-ff/provider.h 2021-09-12 01:20:25.852638000 +0800 +++ lasso/lasso/id-ff/provider.h 2024-10-26 11:06:24.553984800 +0800 @@ -278,6 +278,8 @@ LASSO_EXPORT lasso_error_t lasso_provider_add_key(LassoProvider *provider, LassoKey *key, gboolean after); +LASSO_EXPORT int lasso_provider_verify_saml_signature(LassoProvider *provider, xmlNode *signed_node, xmlDoc *doc); + LASSO_EXPORT int lasso_provider_verify_signature(LassoProvider *provider, const char *message, const char *id_attr_name, LassoMessageFormat format); diff '--exclude=ChangeLog' -ur lasso-2.8.2/lasso/id-ff/providerprivate.h lasso/lasso/id-ff/providerprivate.h --- lasso-2.8.2/lasso/id-ff/providerprivate.h 2021-09-12 01:20:25.852638000 +0800 +++ lasso/lasso/id-ff/providerprivate.h 2024-10-26 11:06:24.553984800 +0800 @@ -93,7 +93,6 @@ xmlSecKey* lasso_provider_get_encryption_public_key(const LassoProvider *provider); LassoEncryptionSymKeyType lasso_provider_get_encryption_sym_key_type(const LassoProvider* provider); LassoKeyEncryptionMethod lasso_provider_get_key_encryption_method(const LassoProvider* provider); -int lasso_provider_verify_saml_signature(LassoProvider *provider, xmlNode *signed_node, xmlDoc *doc); int lasso_provider_verify_query_signature(LassoProvider *provider, const char *message); void _lasso_provider_load_key_descriptor(LassoProvider *provider, xmlNode *key_descriptor); void _lasso_provider_add_metadata_value_for_role(LassoProvider *provider, diff '--exclude=ChangeLog' -ur lasso-2.8.2/lasso/id-ff/server.h lasso/lasso/id-ff/server.h --- lasso-2.8.2/lasso/id-ff/server.h 2021-09-04 04:12:54.070799800 +0800 +++ lasso/lasso/id-ff/server.h 2024-10-26 11:06:24.555252900 +0800 @@ -133,9 +133,6 @@ LASSO_EXPORT GList *lasso_server_get_filtered_provider_list(const LassoServer *server, LassoProviderRole role, LassoMdProtocolType protocol_type, LassoHttpMethod http_method); -LASSO_EXPORT LassoSignatureMethod lasso_get_default_signature_method(); -void lasso_set_default_signature_method(LassoSignatureMethod meth); - #ifdef __cplusplus } #endif /* __cplusplus */ diff '--exclude=ChangeLog' -ur lasso-2.8.2/lasso/lasso.c lasso/lasso/lasso.c --- lasso-2.8.2/lasso/lasso.c 2023-01-26 01:10:30.746769100 +0800 +++ lasso/lasso/lasso.c 2024-10-26 11:06:24.560249600 +0800 @@ -138,7 +138,13 @@ #include "types.c" static void -lasso_xml_structured_error_func(G_GNUC_UNUSED void *user_data, xmlErrorPtr error) +lasso_xml_structured_error_func(G_GNUC_UNUSED void *user_data, +#if LIBXML_VERSION >= 21200 + const xmlError *error +#else + xmlErrorPtr error +#endif + ) { g_log("libxml2", G_LOG_LEVEL_DEBUG, "libxml2: %s", error->message); } @@ -148,7 +154,7 @@ const char *errorObject G_GNUC_UNUSED, const char *errorSubject G_GNUC_UNUSED, int reason G_GNUC_UNUSED, const char *msg) { - g_log("libxmlsec", G_LOG_LEVEL_DEBUG, "libxmlsec: %s:%d:%s:%s:%s:%s:%s", file, line, func, errorObject, errorSubject, xmlSecErrorsGetMsg(reason), msg); + g_log("libxmlsec", G_LOG_LEVEL_INFO, "libxmlsec: %s:%d:%s:%s:%s:%s:%s", file, line, func, errorObject, errorSubject, xmlSecErrorsGetMsg(reason), msg); } static int @@ -270,7 +276,7 @@ * xmlsec-crypto library. */ #ifdef XMLSEC_CRYPTO_DYNAMIC_LOADING - if (xmlSecCryptoDLLoadLibrary(BAD_CAST XMLSEC_CRYPTO) < 0) { + if (xmlSecCryptoDLLoadLibrary(BAD_CAST xmlSecGetDefaultCrypto()) < 0) { message(G_LOG_LEVEL_CRITICAL, "Unable to load default xmlsec-crypto library. Make sure" "that you have it installed and check shared libraries path" Only in lasso-2.8.2/lasso: lasso_config.h Only in lasso-2.8.2/lasso: Makefile.in Only in lasso-2.8.2/lasso/saml-2.0: Makefile.in Only in lasso-2.8.2/lasso/xml/dsig: Makefile.in Only in lasso-2.8.2/lasso/xml/ecp: Makefile.in Only in lasso-2.8.2/lasso/xml: Makefile.in diff '--exclude=ChangeLog' -ur lasso-2.8.2/lasso/xml/private.h lasso/lasso/xml/private.h --- lasso-2.8.2/lasso/xml/private.h 2023-01-26 01:10:30.758769100 +0800 +++ lasso/lasso/xml/private.h 2024-10-26 11:06:24.612432900 +0800 @@ -354,6 +354,10 @@ xmlTextReader *lasso_xmltextreader_from_message(const char *message, char **to_free); +void lasso_set_default_signature_method(LassoSignatureMethod meth); +void lasso_set_min_signature_method(LassoSignatureMethod meth); + + #ifdef __cplusplus } #endif /* __cplusplus */ Only in lasso-2.8.2/lasso/xml/saml-2.0: Makefile.in diff '--exclude=ChangeLog' -ur lasso-2.8.2/lasso/xml/saml-2.0/samlp2_logout_request.c lasso/lasso/xml/saml-2.0/samlp2_logout_request.c --- lasso-2.8.2/lasso/xml/saml-2.0/samlp2_logout_request.c 2021-09-03 14:15:49.870437400 +0800 +++ lasso/lasso/xml/saml-2.0/samlp2_logout_request.c 2024-10-26 11:06:24.650071700 +0800 @@ -128,14 +128,10 @@ lasso_foreach(it, other_session_index) { xmlNode *child = xmlSecAddChild(xmlnode, BAD_CAST SESSION_INDEX, BAD_CAST LASSO_SAML2_PROTOCOL_HREF); -#if (XMLSEC_MAJOR > 1) || (XMLSEC_MAJOR == 1 && XMLSEC_MINOR > 2) || (XMLSEC_MAJOR == 1 && XMLSEC_MINOR == 2 && XMLSEC_SUBMINOR > 12) - xmlSecNodeEncodeAndSetContent(child, BAD_CAST it->data); -#else xmlChar *content; content = xmlEncodeSpecialChars(child->doc, BAD_CAST it->data); xmlNodeSetContent(child, content); xmlFree(content); -#endif } ((LassoSamlp2LogoutRequest*)node)->SessionIndex = keep_session_index; lasso_release_list_of_strings(other_session_index); Only in lasso-2.8.2/lasso/xml/soap-1.1: Makefile.in diff '--exclude=ChangeLog' -ur lasso-2.8.2/lasso/xml/tools.c lasso/lasso/xml/tools.c --- lasso-2.8.2/lasso/xml/tools.c 2023-03-06 19:05:02.761160500 +0800 +++ lasso/lasso/xml/tools.c 2024-10-26 11:06:24.697541100 +0800 @@ -47,6 +47,7 @@ #include #include +#include #include #include @@ -63,6 +64,7 @@ #include #include "xml.h" #include "xml_enc.h" +#include "../id-ff/server.h" #include "saml-2.0/saml2_assertion.h" #include #include "../debug.h" @@ -308,8 +310,13 @@ pub_key = lasso_get_public_key_from_pem_cert_file(file); break; case LASSO_PEM_FILE_TYPE_PUB_KEY: +#if LASSO_XMLSEC_VERSION_NUMBER >= 0x010300 + pub_key = xmlSecCryptoAppKeyLoadEx(file, xmlSecKeyDataTypePublic | xmlSecKeyDataTypePrivate, + xmlSecKeyDataFormatPem, NULL, NULL, NULL); +#else pub_key = xmlSecCryptoAppKeyLoad(file, xmlSecKeyDataFormatPem, NULL, NULL, NULL); +#endif break; case LASSO_PEM_FILE_TYPE_PRIVATE_KEY: pub_key = lasso_get_public_key_from_private_key_file(file); @@ -377,8 +384,13 @@ static xmlSecKeyPtr lasso_get_public_key_from_private_key_file(const char *private_key_file) { +#if LASSO_XMLSEC_VERSION_NUMBER >= 0x010300 + return xmlSecCryptoAppKeyLoadEx(private_key_file, xmlSecKeyDataTypePrivate | xmlSecKeyDataTypePublic, + xmlSecKeyDataFormatPem, NULL, NULL, NULL); +#else return xmlSecCryptoAppKeyLoad(private_key_file, xmlSecKeyDataFormatPem, NULL, NULL, NULL); +#endif } /** @@ -1027,12 +1039,12 @@ goto_cleanup_with_rc(LASSO_PROFILE_ERROR_INVALID_QUERY); } - if (! sig_alg) { - goto_cleanup_with_rc(LASSO_DS_ERROR_INVALID_SIGALG); - } if (! b64_signature) { goto_cleanup_with_rc(LASSO_DS_ERROR_SIGNATURE_NOT_FOUND); } + if (! sig_alg) { + goto_cleanup_with_rc(LASSO_DS_ERROR_INVALID_SIGALG); + } /* build the signed query */ if (relaystate) { signed_query = g_strconcat(saml_request_response, "&", relaystate, "&", sig_alg, NULL); @@ -1249,9 +1261,9 @@ if (doc) { xmlRemoveID(doc, id_attr); xmlUnlinkNode(xmlnode); - lasso_release_doc(doc); xmlnode->parent = old_parent; xmlSetTreeDoc(xmlnode, NULL); + lasso_release_doc(doc); } lasso_release_signature_context(dsig_ctx); return rc; @@ -1449,7 +1461,14 @@ } } -static void structuredErrorFunc (void *userData, xmlErrorPtr error) { +static void structuredErrorFunc (void *userData, +#if LIBXML_VERSION >= 21200 + const xmlError *error +#else + xmlErrorPtr error +#endif + ) +{ *(int*)userData = error->code; } @@ -2696,7 +2715,7 @@ xmlSecKeyPtr lasso_xmlsec_load_key_info(xmlNode *key_descriptor) { - xmlSecKeyPtr key, result = NULL; + xmlSecKeyPtr key = NULL, result = NULL; xmlNodePtr key_info = NULL; xmlSecKeyInfoCtx ctx = {0}; xmlSecKeysMngr *keys_mngr = NULL; @@ -2730,6 +2749,17 @@ ctx.keyReq.keyUsage = xmlSecKeyDataUsageAny; ctx.certsVerificationDepth = 0; + if((xmlSecPtrListAdd(&ctx.enabledKeyData, BAD_CAST xmlSecKeyDataX509Id) < 0) || + (xmlSecPtrListAdd(&ctx.enabledKeyData, BAD_CAST xmlSecKeyDataValueId) < 0) || + (xmlSecPtrListAdd(&ctx.enabledKeyData, BAD_CAST xmlSecKeyDataRsaId) < 0) || + (xmlSecPtrListAdd(&ctx.enabledKeyData, BAD_CAST xmlSecKeyDataDsaId) < 0) || + (xmlSecPtrListAdd(&ctx.enabledKeyData, BAD_CAST xmlSecKeyDataHmacId) < 0)) { + message(G_LOG_LEVEL_CRITICAL, "Could not enable needed KeyData"); + goto next; + } + + + key = xmlSecKeyCreate(); if (lasso_flag_pem_public_key) { xmlSecErrorsDefaultCallbackEnableOutput(FALSE); @@ -3126,7 +3156,7 @@ break; case LASSO_SIGNATURE_METHOD_RSA_SHA512: case LASSO_SIGNATURE_METHOD_HMAC_SHA512: - digest_method_id = xmlSecTransformSha384Id; + digest_method_id = xmlSecTransformSha512Id; break; default: g_assert_not_reached(); diff '--exclude=ChangeLog' -ur lasso-2.8.2/lasso/xml/xml.c lasso/lasso/xml/xml.c --- lasso-2.8.2/lasso/xml/xml.c 2023-01-26 01:10:30.770769200 +0800 +++ lasso/lasso/xml/xml.c 2024-10-26 11:06:24.698552500 +0800 @@ -44,6 +44,7 @@ #include #include +#include #include "xml.h" #include "xml_enc.h" #include "saml_name_identifier.h" @@ -620,6 +621,12 @@ goto cleanup; } +#if LASSO_XMLSEC_VERSION_NUMBER >= 0x010300 + enc_ctx->keyInfoWriteCtx.flags |= XMLSEC_KEYINFO_FLAGS_LAX_KEY_SEARCH; + enc_ctx->keyInfoReadCtx.flags |= XMLSEC_KEYINFO_FLAGS_LAX_KEY_SEARCH; + enc_ctx->keyInfoReadCtx.flags |= XMLSEC_KEYINFO_FLAGS_LAX_KEY_SEARCH; +#endif + /* generate a symetric key */ switch (encryption_sym_key_type) { case LASSO_ENCRYPTION_SYM_KEY_TYPE_AES_256: diff '--exclude=ChangeLog' -ur lasso-2.8.2/lasso/xml/xml.h lasso/lasso/xml/xml.h --- lasso-2.8.2/lasso/xml/xml.h 2022-11-16 20:08:45.104675600 +0800 +++ lasso/lasso/xml/xml.h 2024-10-26 11:06:24.699587800 +0800 @@ -117,35 +117,6 @@ LASSO_SIGNATURE_METHOD_LAST } LassoSignatureMethod; -/* signature method and hash strength */ -LassoSignatureMethod lasso_get_default_signature_method(); - -void lasso_set_default_signature_method(LassoSignatureMethod meth); - -LassoSignatureMethod lasso_get_min_signature_method(); - -void lasso_set_min_signature_method(LassoSignatureMethod meth); - -static inline gboolean -lasso_validate_signature_method(LassoSignatureMethod signature_method) -{ - return signature_method > (LassoSignatureMethod)LASSO_SIGNATURE_TYPE_NONE \ - && signature_method < (LassoSignatureMethod)LASSO_SIGNATURE_METHOD_LAST; -} - -static inline gboolean -lasso_allowed_signature_method(LassoSignatureMethod signature_method) -{ - return signature_method >= lasso_get_min_signature_method(); -} - -static inline gboolean -lasso_ok_signature_method(LassoSignatureMethod signature_method) -{ - return lasso_validate_signature_method(signature_method) \ - && lasso_allowed_signature_method(signature_method); -} - typedef struct _LassoNode LassoNode; typedef struct _LassoNodeClass LassoNodeClass; typedef struct _LassoNodeClassData LassoNodeClassData; @@ -242,6 +213,32 @@ LASSO_EXPORT void lasso_set_default_key_encryption_method(LassoKeyEncryptionMethod method); +/* signature method and hash strength */ +LASSO_EXPORT LassoSignatureMethod lasso_get_default_signature_method(); +LASSO_EXPORT LassoSignatureMethod lasso_get_min_signature_method(); + +void lasso_set_min_signature_method(LassoSignatureMethod meth); + +static inline gboolean +lasso_validate_signature_method(LassoSignatureMethod signature_method) +{ + return signature_method > (LassoSignatureMethod)LASSO_SIGNATURE_TYPE_NONE \ + && signature_method < (LassoSignatureMethod)LASSO_SIGNATURE_METHOD_LAST; +} + +static inline gboolean +lasso_allowed_signature_method(LassoSignatureMethod signature_method) +{ + return signature_method >= lasso_get_min_signature_method(); +} + +static inline gboolean +lasso_ok_signature_method(LassoSignatureMethod signature_method) +{ + return lasso_validate_signature_method(signature_method) \ + && lasso_allowed_signature_method(signature_method); +} + #ifdef __cplusplus } #endif /* __cplusplus */ Only in lasso-2.8.2: ltmain.sh Only in lasso/m4: ac_check_java_home.m4 Only in lasso/m4: ac_check_rqrd_class.m4 Only in lasso/m4: ac_java_options.m4 Only in lasso/m4: ac_prog_java_cc.m4 Only in lasso/m4: ac_prog_javadoc.m4 Only in lasso/m4: ac_try_run_javac.m4 Only in lasso/m4: check.m4 Only in lasso/m4: dps_libgcj_jar.m4 Only in lasso-2.8.2/m4: gtk-doc.m4 Only in lasso-2.8.2/m4: libtool.m4 Only in lasso-2.8.2/m4: lt~obsolete.m4 Only in lasso-2.8.2/m4: ltoptions.m4 Only in lasso-2.8.2/m4: ltsugar.m4 Only in lasso-2.8.2/m4: ltversion.m4 Only in lasso-2.8.2: Makefile.in Only in lasso-2.8.2: missing diff '--exclude=ChangeLog' -ur lasso-2.8.2/NEWS lasso/NEWS --- lasso-2.8.2/NEWS 2023-03-15 01:13:10.828058400 +0800 +++ lasso/NEWS 2024-10-26 11:06:24.447680400 +0800 @@ -1,6 +1,17 @@ NEWS ==== +Future +------ + +- Fix symbol deprecation of XMLSEC_CRYPTO macro in libxmlsec 1.3.0 (Patch + provided by Simo Sorce of RedHat) (#78280) +- Annotate lasso_*_signature_method functions with LASSO_EXPORT (#86076) +- Fix implicit function declaration errors, patch provided by Rob Crittenden + from RedHat (#85340) +- Adjust to structured error callback argument change in libxml2 2.12, patch + provided by Florian Wiemer of RedHat (#86080) + 2.8.2 - March 14th 2023 ----------------------- Only in lasso-2.8.2: test-driver Only in lasso/tests/data: lasso.crt Only in lasso/tests/data: lasso.csr Only in lasso/tests/data: lasso.key Only in lasso/tests/data: lasso.pkcs12 Only in lasso-2.8.2/tests/data: Makefile.in Only in lasso/tests: integration diff '--exclude=ChangeLog' -ur lasso-2.8.2/tests/login_tests_saml2.c lasso/tests/login_tests_saml2.c --- lasso-2.8.2/tests/login_tests_saml2.c 2023-01-26 01:10:30.778769300 +0800 +++ lasso/tests/login_tests_saml2.c 2024-10-26 11:06:24.851087300 +0800 @@ -1581,7 +1581,7 @@ } END_TEST -void check_digest_method(G_GNUC_UNUSED LassoLogin *idp_login_context, LassoLogin *sp_login_context) +void check_sha256_digest_method(G_GNUC_UNUSED LassoLogin *idp_login_context, LassoLogin *sp_login_context) { char *dump = lasso_node_debug((LassoNode*)sp_login_context->parent.response, 10); check_true(strstr(dump, "") != NULL); @@ -1604,7 +1604,7 @@ test07_make_context(sp_context, "sp6-saml2", LASSO_PROVIDER_ROLE_IDP, "idp6-saml2", key) block_lasso_logs; - sso_initiated_by_sp(idp_context, sp_context, check_digest_method); + sso_initiated_by_sp(idp_context, sp_context, check_sha256_digest_method); unblock_lasso_logs; /* Cleanup */ @@ -1614,6 +1614,40 @@ } END_TEST +void check_sha512_digest_method(G_GNUC_UNUSED LassoLogin *idp_login_context, LassoLogin *sp_login_context) +{ + char *dump = lasso_node_debug((LassoNode*)sp_login_context->parent.response, 10); + check_true(strstr(dump, "") != NULL); + lasso_release_string(dump) +} + +START_TEST(test14_sso_sp_with_rsa_sha512_signatures) +{ + LassoServer *idp_context = NULL; + LassoServer *sp_context = NULL; + GList *providers; + LassoKey *key = NULL; + + /* Create a key for signature algorithm RSA_SHA256 */ + key = lasso_key_new_for_signature_from_file(TESTSDATADIR "idp6-saml2/private-key.pem", NULL, + LASSO_SIGNATURE_METHOD_RSA_SHA512, NULL); + check_true(LASSO_IS_KEY(key)); + + test07_make_context(idp_context, "idp6-saml2", LASSO_PROVIDER_ROLE_SP, "sp6-saml2", key) + test07_make_context(sp_context, "sp6-saml2", LASSO_PROVIDER_ROLE_IDP, "idp6-saml2", key) + + block_lasso_logs; + sso_initiated_by_sp(idp_context, sp_context, check_sha512_digest_method); + unblock_lasso_logs; + + /* Cleanup */ + lasso_release_gobject(idp_context); + lasso_release_gobject(sp_context); + lasso_release_gobject(key); +} +END_TEST + + Suite* login_saml2_suite() { @@ -1647,6 +1681,7 @@ tcase_add_test(tc_ecp, test11_ecp); tcase_add_test(tc_ecp, test12_ecp); tcase_add_test(tc_spLogin, test13_sso_sp_with_rsa_sha256_signatures); + tcase_add_test(tc_spLogin, test14_sso_sp_with_rsa_sha512_signatures); return s; } Only in lasso-2.8.2/tests: Makefile.in diff '--exclude=ChangeLog' -ur lasso-2.8.2/tests/random_tests.c lasso/tests/random_tests.c --- lasso-2.8.2/tests/random_tests.c 2023-01-26 01:10:30.778769300 +0800 +++ lasso/tests/random_tests.c 2024-10-26 11:06:24.853121100 +0800 @@ -292,6 +292,8 @@ * changed to ; */ const char query2[] = "Signature=Zfz3DE1VMV3thaV4FWpH0fkWsBMzAFJcfvVWAbo0a3cY48Et%2BXUcbr1nvOJUJmhGoie0pQ4%2BcD9ToQlSk7BbJSBCct%2FQQgn2QNkX%2F1lk4v8RU8p5ptJRJ2iPLb8nC6WZhs81HoihQePSuj7Qe5bRUsDKvnWMq6OkD%2Fe6YO77dMXregTcfmnkrXqRb2T6TFfqyOz9i0%2FjmISsmj%2F3kEEfUzVA4LEbeEgiJDj1hec4XW26gQTih53v0sYukq4Eyb4zS2jVd3apUUxUrjn1NUpr7Z7dZ7w5MQlgZ8aw1xFDE8BkxymvIjwf8ciyx6sfTKbCRsoS9E0pQB1vxvh6OMt1Ww%3D%3D;SAMLRequest=fVHJasMwEP0Vo3tqRXY2YRvcOIFAl9CUHnopwpkkAllyNeMuf1%2FZaSG95PrmLfNmMlSNaWXZ0ck%2BwXsHSNFXYyzKYZCzzlvpFGqUVjWAkmq5K%2B%2FvpLjhsvWOXO0Mu5BcVyhE8KSdZdGmytnbNEmTBV%2Bli9ulKMt5KlbVfDkbizWfcVEmUxa9gMfAz1mQBxFiBxuLpCwFiIvxiE9H48mz4FJMZJq8sqgKHbRVNKhORK2MY71vJzFqezSw00f7GPLXztcw9M7ZQRmE3n0bFtQf8IcUWV9JDqm%2B%2BPXCYNUAqb0ilcWXhOx8zIdQe1NtndH1dx%2FTKLp%2BlR7R%2B9FhoMq2b4wEllhUGuM%2Blx4UhZ3Id8Di4pz5%2F2fFDw%3D%3D;RelayState=fake;SigAlg=http%3A%2F%2Fwww.w3.org%2F2001%2F04%2Fxmldsig-more%23rsa-sha256"; const char query3[] = "SAMLRequest=fVHJasMwEP0Vo3tqRXY2YRvcOIFAl9CUHnopwpkkAllyNeMuf1%2FZaSG95PrmLfNmMlSNaWXZ0ck%2BwXsHSNFXYyzKYZCzzlvpFGqUVjWAkmq5K%2B%2FvpLjhsvWOXO0Mu5BcVyhE8KSdZdGmytnbNEmTBV%2Bli9ulKMt5KlbVfDkbizWfcVEmUxa9gMfAz1mQBxFiBxuLpCwFiIvxiE9H48mz4FJMZJq8sqgKHbRVNKhORK2MY71vJzFqezSw00f7GPLXztcw9M7ZQRmE3n0bFtQf8IcUWV9JDqm%2B%2BPXCYNUAqb0ilcWXhOx8zIdQe1NtndH1dx%2FTKLp%2BlR7R%2B9FhoMq2b4wEllhUGuM%2Blx4UhZ3Id8Di4pz5%2F2fFDw%3D%3D&RelayState=fake&SigAlg=http%3A%2F%2Fwww.w3.org%2F2001%2F04%2Fxmldsig-more%23rsa-sha256&Signature=rUJ%2B9wVSvdGSmZWGuGXgudAPV5KBxRfxRKraBWGIslBz2XreyNbQjSA47DhIfi%2Bxf0awIIGkKcieN3Qd5sqVn4wvFU8fsmfqrdtouYi46aKsj4W91N19TxJ%2BCgrP7ygVEGDaGdc%2BrCQC3%2FuoYTELXq0gYP7tHaXA%2FCaZHfx5Z159crpRxS6eabZ6BGf4ImxiKhE1FuYzKHeISEV1iSyvgx5%2FE8ydSO%2FSP6yA5Rck4JxVJWH6ImbswCVQ80qfqR4NoJ%2BxiZqilbDJnQaSKZggx%2FgjNVoX%2FMVW1FqEmgJNcZpSjNUQqy9u4veSllpxPc2aB%2FpiUjzpbq9XzyFDOQfkUQ%3D%3D"; + /* Deleting SigAlg & Signature fields */ + const char query4[] = "SAMLRequest=fVHJasMwEP0Vo3tqRXY2YRvcOIFAl9CUHnopwpkkAllyNeMuf1%2FZaSG95PrmLfNmMlSNaWXZ0ck%2BwXsHSNFXYyzKYZCzzlvpFGqUVjWAkmq5K%2B%2FvpLjhsvWOXO0Mu5BcVyhE8KSdZdGmytnbNEmTBV%2Bli9ulKMt5KlbVfDkbizWfcVEmUxa9gMfAz1mQBxFiBxuLpCwFiIvxiE9H48mz4FJMZJq8sqgKHbRVNKhORK2MY71vJzFqezSw00f7GPLXztcw9M7ZQRmE3n0bFtQf8IcUWV9JDqm%2B%2BPXCYNUAqb0ilcWXhOx8zIdQe1NtndH1dx%2FTKLp%2BlR7R%2B9FhoMq2b4wEllhUGuM%2Blx4UhZ3Id8Di4pz5%2F2fFDw%3D%3D&RelayState=fake"; /* sp5-saml2 key */ const char pkey[] = "-----BEGIN CERTIFICATE-----\n\ MIIDnjCCAoagAwIBAgIBATANBgkqhkiG9w0BAQUFADBUMQswCQYDVQQGEwJGUjEP\n\ @@ -324,6 +326,11 @@ /* test reordering and semi-colon separator support */ ck_assert_msg(lasso_saml2_query_verify_signature(query2, key) == 0, "Disordered signature was not validated"); ck_assert_msg(lasso_saml2_query_verify_signature(query3, key) != 0, "Altered signature was validated"); + /* test missing signature error code */ + ck_assert_msg(lasso_saml2_query_verify_signature(query3, key) == LASSO_DS_ERROR_INVALID_SIGNATURE, + "Altered signature do not lead to invalid signature"); + ck_assert_msg(lasso_saml2_query_verify_signature(query4, key) == LASSO_DS_ERROR_SIGNATURE_NOT_FOUND, + "Bad error code when missing signature"); xmlSecKeyDestroy(key); } END_TEST diff '--exclude=ChangeLog' -ur lasso-2.8.2/tools/api.py lasso/tools/api.py --- lasso-2.8.2/tools/api.py 2021-09-12 01:20:25.856638000 +0800 +++ lasso/tools/api.py 2024-10-26 11:06:24.857307000 +0800 @@ -2,7 +2,6 @@ import os.path sys.path.append(os.path.join(os.path.dirname(__file__),'../bindings')) import bindings -from six import print_ def main(args): @@ -29,16 +28,16 @@ l = sorted(d.keys()) for x in l: if isinstance(d[x], bindings.Function): - print_(d[x].return_type, " ",) - print_(x, end='') - print_('(', ', '.join(map(lambda x: x[0] + ' ' + x[1], d[x].args)), ')') + print(d[x].return_type, " ",) + print(x, end='') + print('(', ', '.join(map(lambda x: x[0] + ' ' + x[1], d[x].args)), ')') elif isinstance(d[x], bindings.Struct): - print_('struct', x, '{ ',) - print_(', '.join(map(lambda x: x[0] + ' ' + x[1], d[x].members)), + print('struct', x, '{ ',) + print(', '.join(map(lambda x: x[0] + ' ' + x[1], d[x].members)), end='') - print_(' }') + print(' }') else: - print_(x) + print(x) if __name__ == "__main__": main(sys.argv) diff '--exclude=ChangeLog' -ur lasso-2.8.2/tools/check-lasso-sections.py lasso/tools/check-lasso-sections.py --- lasso-2.8.2/tools/check-lasso-sections.py 2021-05-18 04:00:09.275307800 +0800 +++ lasso/tools/check-lasso-sections.py 2024-10-26 11:06:24.858311100 +0800 @@ -3,10 +3,9 @@ import sys import os.path import re -from six import print_ if len(sys.argv) < 3: - print_("Usage: check-lasso-sections.py " + print("Usage: check-lasso-sections.py " "lasso docs/referenrece/lasso/lasso-sections.txt", file=sys.stderr) sys.exit(1) @@ -34,13 +33,13 @@ lasso_sections_txt=file(lasso_sections_txt).read() -print_(' = Methods missing from lasso-sections.txt =\n') +print(' = Methods missing from lasso-sections.txt =\n') for method in methods: if not method in lasso_sections_txt: - print_(method) + print(method) -print_(' = Methods in lasso-sections.txt which does not exist anymore = \n') +print(' = Methods in lasso-sections.txt which does not exist anymore = \n') for line in lasso_sections_txt.splitlines(): if line.startswith('lasso_'): if line not in methods: - print_(line) + print(line) diff '--exclude=ChangeLog' -ur lasso-2.8.2/tools/format-suppressions.py lasso/tools/format-suppressions.py --- lasso-2.8.2/tools/format-suppressions.py 2021-05-18 04:00:09.275307800 +0800 +++ lasso/tools/format-suppressions.py 2024-10-26 11:06:24.858311100 +0800 @@ -1,7 +1,6 @@ import re -from six import print_ -valgrind_log = open('log','r').read() +valgrind_log = open('log').read() inblock = False l = 0 @@ -34,11 +33,11 @@ i = 43 for x in keep: block = keep[x] - print_("{") - print_(" suppression", i) + print("{") + print(" suppression", i) for x in block[1:]: - print_(x) + print(x) if re.search(limit_re, x): break - print_('}') + print('}') i += 1 Only in lasso: website