Add a missing const_cast if the parameter is const.
This commit is contained in:
1 parent
9644fb7db5
commit
236e26ce7f
2 files changed
+7
-2
No files matched your search
@@ -139,7 +139,8 @@ def my_module_gen(out_file):
|
||||
|
||||
SomeObject.add_method(CppMethod(
|
||||
ReturnValue.new('std::string'), 'get_prefix_with_foo_ref',
|
||||
[Parameter.new('Foo&', 'foo', is_const=True)],
|
||||
[Parameter.new('Foo&', 'foo', is_const=True,
|
||||
direction=Parameter.DIRECTION_INOUT)],
|
||||
is_virtual=True, is_const=True))
|
||||
|
||||
#SomeObject.add_method(CppMethod(
|
||||
|
||||
@@ -915,8 +915,12 @@ class CppClassRefParameter(CppClassParameterBase):
|
||||
## the ->obj pointer after the python call; this is so
|
||||
## that the python code directly manipulates the object
|
||||
## received as parameter, instead of a copy.
|
||||
if self.is_const:
|
||||
value = "const_cast<%s*>(&(%s))" % (self.cpp_class.full_name, self.value)
|
||||
else:
|
||||
value = "&(%s)" % self.value
|
||||
wrapper.before_call.write_code(
|
||||
"%s->obj = &(%s);" % (self.py_name, self.value))
|
||||
"%s->obj = %s;" % (self.py_name, value))
|
||||
wrapper.build_params.add_parameter("O", [self.py_name])
|
||||
wrapper.before_call.add_cleanup_code("Py_DECREF(%s);" % self.py_name)
|
||||
|
||||
|
||||
Reference in new issue
Block a user