aboutsummaryrefslogtreecommitdiffstats
path: root/tests/samplebinding
diff options
context:
space:
mode:
authorLuciano Wolf <luciano.wolf@openbossa.org>2010-09-13 16:16:40 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-08 16:05:58 -0300
commit939185f77f4cb107231094300c03ec2c35f64c38 (patch)
tree62354a40ec86e5d2a311fa7dd5265ed33caf2d75 /tests/samplebinding
parent76a9acb72693e670b141b2eb57f14cad1d1a1cef (diff)
Fix code generation for modified constructors.
Reviewers: Renato Araújo <renato.filho@openbossa.org> Hugo Parente Lima <hugo.pl@gmail.com>
Diffstat (limited to 'tests/samplebinding')
-rw-r--r--tests/samplebinding/CMakeLists.txt1
-rw-r--r--tests/samplebinding/global.h1
-rw-r--r--tests/samplebinding/modified_constructor_test.py44
-rw-r--r--tests/samplebinding/typesystem_sample.xml11
4 files changed, 57 insertions, 0 deletions
diff --git a/tests/samplebinding/CMakeLists.txt b/tests/samplebinding/CMakeLists.txt
index 14ec66939..3536ce39b 100644
--- a/tests/samplebinding/CMakeLists.txt
+++ b/tests/samplebinding/CMakeLists.txt
@@ -35,6 +35,7 @@ ${CMAKE_CURRENT_BINARY_DIR}/sample/mderived3_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/sample/mderived4_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/sample/mderived5_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/sample/modifications_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/modifiedconstructor_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/sample/noimplicitconversion_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/sample/nondefaultctor_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/sample/objecttype_wrapper.cpp
diff --git a/tests/samplebinding/global.h b/tests/samplebinding/global.h
index f7933536d..2e06bce5b 100644
--- a/tests/samplebinding/global.h
+++ b/tests/samplebinding/global.h
@@ -13,6 +13,7 @@
#include "listuser.h"
#include "mapuser.h"
#include "modifications.h"
+#include "modified_constructor.h"
#include "multiple_derived.h"
#include "noimplicitconversion.h"
#include "nondefaultctor.h"
diff --git a/tests/samplebinding/modified_constructor_test.py b/tests/samplebinding/modified_constructor_test.py
new file mode 100644
index 000000000..80612bd84
--- /dev/null
+++ b/tests/samplebinding/modified_constructor_test.py
@@ -0,0 +1,44 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# This file is part of the Shiboken Python Bindings Generator project.
+#
+# Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+#
+# Contact: PySide team <contact@pyside.org>
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public License
+# version 2.1 as published by the Free Software Foundation. Please
+# review the following information to ensure the GNU Lesser General
+# Public License version 2.1 requirements will be met:
+# http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+# #
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+# 02110-1301 USA
+
+'''Tests cases for ConstructorWithModifiedArgument class.'''
+
+import sys
+import unittest
+
+from sample import *
+
+
+class ConstructorWithModifiedArgumentTest(unittest.TestCase):
+ '''Test cases for ConstructorWithModifiedArgument class.'''
+
+ def testConstructorWithModifiedArgument(self):
+ sampleClass = ModifiedConstructor("10")
+ self.assertTrue(sampleClass.retrieveValue(), 10)
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/tests/samplebinding/typesystem_sample.xml b/tests/samplebinding/typesystem_sample.xml
index 7b02a4d3e..de262c9ee 100644
--- a/tests/samplebinding/typesystem_sample.xml
+++ b/tests/samplebinding/typesystem_sample.xml
@@ -123,6 +123,17 @@
<object-type name="Derived" polymorphic-id-expression="%1->type() == Derived::TpDerived" />
<value-type name="Derived::SomeInnerClass" />
+ <object-type name="ModifiedConstructor">
+ <modify-function signature="ModifiedConstructor(int)">
+ <modify-argument index="1">
+ <replace-type modified-type="PyString"/>
+ </modify-argument>
+ <inject-code class='target' position='beginning'>
+ %0 = new %FUNCTION_NAME(atoi(%CONVERTTOCPP[const char *](%PYARG_1)));
+ </inject-code>
+ </modify-function>
+ </object-type>
+
<object-type name="ObjectType" hash-function="objectTypeHash">
<!-- rename function to avoid Python signature conflit -->
<modify-function signature="setObject(const Null&amp;)" rename="setNullObject" />