blob: d8cadc6f162040f8c1bb1409d0e4edb4bc37d175 (
plain)
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
|
// Copyright (C) by Josh Blum. See LICENSE.txt for licensing information.
#ifndef INCLUDED_GRAS_SBUFFER_I
#define INCLUDED_GRAS_SBUFFER_I
%{
#include <gras/gras.hpp>
#include <gras/sbuffer.hpp>
%}
////////////////////////////////////////////////////////////////////////
// remove base class warning
////////////////////////////////////////////////////////////////////////
#pragma SWIG nowarn=401
////////////////////////////////////////////////////////////////////////
// Export swig element comprehension
////////////////////////////////////////////////////////////////////////
%include <gras/gras.hpp>
%include <gras/sbuffer.hpp>
////////////////////////////////////////////////////////////////////////
// Replace the get method
////////////////////////////////////////////////////////////////////////
%extend gras::SBuffer
{
%insert("python")
%{
def get(self):
from gras.GRAS_Utils import pointer_to_ndarray
addr = long(self.get_actual_memory())
return pointer_to_ndarray(
addr=addr + self.offset,
nitems=self.length,
)
def __len__(self): return self.length
%}
}
#endif /*INCLUDED_GRAS_SBUFFER_I*/
|