diff options
author | Matthew Woehlke <matthew.woehlke@kitware.com> | 2013-07-26 12:16:45 -0400 |
---|---|---|
committer | John Ehresman <jpe@wingware.com> | 2013-07-30 17:26:24 +0200 |
commit | 46db89a2a500c5b760c6f2b35ecde38d7e5ebfb6 (patch) | |
tree | 1feb857d0b8a1a8e34496b57e72300703e8f78ed /tests/libsample | |
parent | ae2a80453b95775364e93ed1a4647429b2fd7bad (diff) |
Fix '%#' substitution for # > 9
Change '%#' substitution to use a regular expression for the 'old' text
to enforce a word boundary after '#', such that we don't perform e.g.
'%1' replacement on inputs like '%10'. This fixes problems trying to
modify functions with more than nine arguments, such as the example from
the previous commit (which now compiles and passes). Also add a test
case for this.
Change-Id: I9956804b3c65bddf7e36838866641b24ceb87c57
Reviewed-by: John Ehresman <jpe@wingware.com>
Diffstat (limited to 'tests/libsample')
-rw-r--r-- | tests/libsample/CMakeLists.txt | 1 | ||||
-rw-r--r-- | tests/libsample/transform.cpp | 54 | ||||
-rw-r--r-- | tests/libsample/transform.h | 40 |
3 files changed, 95 insertions, 0 deletions
diff --git a/tests/libsample/CMakeLists.txt b/tests/libsample/CMakeLists.txt index 074de61fc..30205ed0c 100644 --- a/tests/libsample/CMakeLists.txt +++ b/tests/libsample/CMakeLists.txt @@ -43,6 +43,7 @@ size.cpp sometime.cpp str.cpp strlist.cpp +transform.cpp virtualmethods.cpp expression.cpp filter.cpp diff --git a/tests/libsample/transform.cpp b/tests/libsample/transform.cpp new file mode 100644 index 000000000..2984ed391 --- /dev/null +++ b/tests/libsample/transform.cpp @@ -0,0 +1,54 @@ +/* + * Copyright 2013 Kitware, Inc. + * + * This file is part of the Shiboken Python Binding Generator project. + * + * Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). + * + * Contact: PySide team <contact@pyside.org> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "transform.h" + +#include <cmath> + +using namespace std; + +Point applyHomogeneousTransform( + const Point& in, + double m11, double m12, double m13, + double m21, double m22, double m23, + double m31, double m32, double m33, + bool* okay) +{ + double x = m11 * in.x() + m12 * in.y() + m13; + double y = m21 * in.x() + m22 * in.y() + m23; + double w = m31 * in.x() + m32 * in.y() + m33; + + if (isfinite(w) && fabs(w) > 1e-10) + { + if (okay) + *okay = true; + return Point(x / w, y / w); + } + else + { + if (okay) + *okay = false; + return Point(); + } +} diff --git a/tests/libsample/transform.h b/tests/libsample/transform.h new file mode 100644 index 000000000..d21232889 --- /dev/null +++ b/tests/libsample/transform.h @@ -0,0 +1,40 @@ +/* + * Copyright 2013 Kitware, Inc. + * + * This file is part of the Shiboken Python Binding Generator project. + * + * Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). + * + * Contact: PySide team <contact@pyside.org> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef TRANSFORM_H +#define TRANSFORM_H + +#include "point.h" + +#include "libsamplemacros.h" + +LIBSAMPLE_API Point +applyHomogeneousTransform( + const Point& in, + double m11, double m12, double m13, + double m21, double m22, double m23, + double m31, double m32, double m33, + bool* okay); + +#endif // TRANSFORM_H |