forked from sbird/GadgetReader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgadgetreader.i
67 lines (60 loc) · 1.77 KB
/
gadgetreader.i
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
60
61
62
63
64
65
66
67
/* SWIG interface file for GadgetReader:
* module gadgetreader*/
%module gadgetreader
%{
#include "../gadgetreader.hpp"
%}
/* Numpy integration:
* This works somewhat poorly and isn't in my numpy install*/
/*%{
#define SWIG_FILE_WITH_INIT
%}
%include "numpy.i"
%init %{
import_array();
%}*/
/*STL declarations. */
/*Gives us access to std::string as native types*/
%include "std_string.i"
/*Swig doesn't support this in Perl yet*/
#if !defined(SWIGPERL)
/*We want to wrap std::set<std::string>*/
%include "std_set.i"
namespace std{
%template(StrSet) set<string>;
}
#endif
/*We want to wrap std::vector<std::string>*/
%include "std_vector.i"
namespace std{
%template(StrVector) vector<string>;
/* %template(IntVector) vector<int>;*/
%template(IntVector) vector<long long>;
%template(FloatVector) vector<float>;
}
%include "stdint.i"
/* Let us use arrays: this may be needed in future to
* allow access to the npart and mass arrays of gadgetheader*/
/*%include "carrays.i"
%array_class(int,IntArr);
%array_class(double,DoubArr);*/
%feature("autodoc","1");
%include "gadgetreader.hpp"
%include "gadgetheader.h"
/* Methods to access the arrays in gadget_header, which SWIG can't wrap properly*/
%extend gadget_header{
uint32_t GetNpart(int i){
if(i >= N_TYPE || i<0)
return 0;
else
return $self->npart[i];
}
double GetMass(int i){
if(i >= N_TYPE || i<0)
return 0;
else
return $self->mass[i];
}
};
/* int64_t GetBlock(std::string BlockName, float *block, int64_t npart_toread, int64_t start_part, int skip_type){*/
/*%apply (float* IN_ARRAY1, int DIMS1) {(float *block, int64_t npart_toread,)};*/