-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathconverters.i
More file actions
59 lines (48 loc) · 1.3 KB
/
converters.i
File metadata and controls
59 lines (48 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
%module(package="challenge") converters
%{
#include "basics.hpp"
%}
%include "std_string.i"
// Challenge solutions must provide only the following file, made available
// on the Swig include path. It should contain the necessary Swig typmaps to
// convert a Doodad C++ object to Python and back, for all of the functions
// below.
%include "basics_typemaps.i"
%inline %{
std::shared_ptr<basics::Doodad> make_sptr(
std::string const & name, int value
) {
return std::shared_ptr<basics::Doodad>(new basics::Doodad(name, value));
}
std::shared_ptr<basics::Doodad const> make_csptr(
std::string const & name, int value
) {
return std::shared_ptr<basics::Doodad const>(
new basics::Doodad(name, value)
);
}
bool accept_ref(
basics::Doodad & d,
std::string const & name, int value
) {
return d.name == name && d.value == value;
}
bool accept_cref(
basics::Doodad const & d,
std::string const & name, int value
) {
return d.name == name && d.value == value;
}
bool accept_sptr(
std::shared_ptr<basics::Doodad> d,
std::string const & name, int value
) {
return d->name == name && d->value == value;
}
bool accept_csptr(
std::shared_ptr<basics::Doodad const> d,
std::string const & name, int value
) {
return d->name == name && d->value == value;
}
%}