Skip to content

Commit e1e07b8

Browse files
committed
Fix compiler warnings on missing return value.
Non-void functions in ReflectionProfileWrap should return something. Also fix warning about unused variable.
1 parent a075d4c commit e1e07b8

File tree

2 files changed

+38
-13
lines changed

2 files changed

+38
-13
lines changed

extensions/powderpatternbackground_ext.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ void _SetInterpPoints(PowderPatternBackground& b,
3636
PyObject* tth, PyObject* backgd)
3737
{
3838
// cout << "_SetInterpPoints:" << tth << ", " << backgd << endl;
39-
const unsigned long ndim = PyArray_NDIM((PyObject*)tth);
40-
// cout << "dimensions = " << ndim << endl;
39+
// cout << "dimensions = " << PyArray_NDIM(tth) << endl;
4140
const unsigned long nb = *(PyArray_DIMS((PyObject*)tth));
4241
// cout << "nbPoints = " << nb << endl;
4342
CrystVector_REAL tth2(nb), backgd2(nb);

extensions/reflectionprofile_ext.cpp

Lines changed: 37 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
*****************************************************************************/
1919

2020
#include <boost/python/class.hpp>
21+
#include <boost/python/manage_new_object.hpp>
22+
#include <boost/python/pure_virtual.hpp>
2123

2224
#include <iostream>
2325

@@ -32,22 +34,42 @@ namespace {
3234
class ReflectionProfileWrap :
3335
public ReflectionProfile, public wrapper<ReflectionProfile>
3436
{
35-
//:TODO: :KLUDGE: Dummy override of pure virtual functions
3637
public:
37-
ReflectionProfileWrap() : ReflectionProfile() {}
38-
virtual ReflectionProfile* CreateCopy() const {}
39-
virtual CrystVector_REAL GetProfile(
38+
39+
// Pure virtual functions
40+
41+
ReflectionProfile* CreateCopy() const
42+
{
43+
return this->get_override("CreateCopy")();
44+
}
45+
46+
CrystVector_REAL GetProfile(
4047
const CrystVector_REAL& x, const REAL xcenter,
4148
const REAL h, const REAL k, const REAL l) const
42-
{}
43-
virtual REAL GetFullProfileWidth(
49+
{
50+
bp::override f = this->get_override("GetProfile");
51+
return f(x, xcenter, h, k, l);
52+
}
53+
54+
REAL GetFullProfileWidth(
4455
const REAL relativeIntensity, const REAL xcenter,
4556
const REAL h, const REAL k, const REAL l)
46-
{}
47-
virtual void XMLOutput(ostream& os, int indent) const
48-
{}
49-
virtual void XMLInput(istream& is, const XMLCrystTag& tag)
50-
{}
57+
{
58+
bp::override f = this->get_override("GetFullProfileWidth");
59+
return f(relativeIntensity, xcenter, h, k, l);
60+
}
61+
62+
void XMLOutput(ostream& os, int indent) const
63+
{
64+
bp::override f = this->get_override("XMLOutput");
65+
f(os, indent);
66+
}
67+
68+
void XMLInput(istream& is, const XMLCrystTag& tag)
69+
{
70+
bp::override f = this->get_override("GetProfile");
71+
f(is, tag);
72+
}
5173
};
5274

5375
} // namespace
@@ -57,5 +79,9 @@ void wrap_reflectionprofile()
5779
{
5880
class_<ReflectionProfileWrap, bases<RefinableObj>, boost::noncopyable>(
5981
"ReflectionProfile")
82+
// TODO add pure_virtual bindings to the remaining public methods
83+
.def("CreateCopy",
84+
pure_virtual(&ReflectionProfile::CreateCopy),
85+
return_value_policy<manage_new_object>())
6086
;
6187
}

0 commit comments

Comments
 (0)