summaryrefslogtreecommitdiffstats
path: root/tests/samplebinding
diff options
context:
space:
mode:
authorLuciano Wolf <luciano.wolf@openbossa.org>2010-09-13 16:16:40 -0300
committerLuciano Wolf <luciano.wolf@openbossa.org>2010-09-13 19:34:30 -0300
commit58692e4b27957b587a9b8bd5075fbcb0daad7998 (patch)
tree3b1d954e67482c468ca64e7a642759309330fa3b /tests/samplebinding
parentc3059779d7628fdbb140ed02cdc0cc7ca80e7ad8 (diff)
downloadshiboken-58692e4b27957b587a9b8bd5075fbcb0daad7998.tar.gz
shiboken-58692e4b27957b587a9b8bd5075fbcb0daad7998.tar.xz
shiboken-58692e4b27957b587a9b8bd5075fbcb0daad7998.zip
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 14ec6693..3536ce39 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 f7933536..2e06bce5 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 00000000..80612bd8
--- /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 7b02a4d3..de262c9e 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" />