default_value fails, incorrect parameter order

Asked by John Stowers

Gustavo,

You must be getting sick of me. The default value stuff does not yet work for CppClass.

When adding parameter annotations

    "smlTransportSend": {'link' : {'transfer_ownership':'False',
                                                         'default_value':'NULL' }

I get the following

Traceback (most recent call last):
  File "./pysyncml.py", line 200, in <module>
    main()
  File "./pysyncml.py", line 197, in main
    root_module.generate(out)
  File "../pybindgen/module.py", line 784, in generate
  File "../pybindgen/module.py", line 676, in do_generate
  File "../pybindgen/cppclass.py", line 1438, in generate
  File "../pybindgen/cppclass.py", line 1544, in _generate_methods
  File "../pybindgen/utils.py", line 118, in call_with_error_handling
  File "../pybindgen/overloading.py", line 165, in generate
  File "../pybindgen/utils.py", line 118, in call_with_error_handling
  File "../pybindgen/function.py", line 133, in generate
  File "../pybindgen/typehandlers/base.py", line 848, in generate_body
  File "../pybindgen/typehandlers/base.py", line 309, in get_parameters
ValueError: Error: optional parameter followed by a non-optional one (debug: self._parse_tuple_parameters=[('O!', ['&PySmlLink_Type', '&link2'], 'link', True), ('O!', ['&PySmlTransportData_Type', '&data2'], 'data', False)])
make: *** [build/syncmlmodule.c] Error 1

Adding 'null_ok'='True' instead seems to work fine.

Question information

Language:
English Edit question
Status:
Answered
For:
PyBindGen Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Gustavo Carneiro (gjc) said :
#1

But, this error is normal. I think it is pretty clear when it says "optional parameter followed by a non-optional one". This is a Python language restriction, not a bug.

Revision history for this message
Gustavo Carneiro (gjc) said :
#2

To clarify, you have a link parameter optional, and then a data parameter not optional. It's like having this in Python:

def foo(link=None, data):
   ...

You would get a syntax error with the above, and so PyBindGen does not allow it.

Revision history for this message
Gustavo Carneiro (gjc) said :
#3

Explained.

Can you help with this problem?

Provide an answer of your own, or ask John Stowers for more information if necessary.

To post a message you must log in.