File: hamlib.swg

package info (click to toggle)
hamlib 4.6.4-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 17,804 kB
  • sloc: ansic: 262,998; sh: 5,400; cpp: 1,578; perl: 876; makefile: 849; python: 148; awk: 58; xml: 26
file content (255 lines) | stat: -rw-r--r-- 5,484 bytes parent folder | download | duplicates (2)
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255

#ifndef SWIGLUA
%module Hamlib
#else
%module Hamliblua
#endif

%{
/*
 *  Hamlib bindings - swig interface file
 *  Copyright (c) 2001-2008 by Stephane Fillod
 *
 *
 *   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 <hamlib/rig.h>
#include <hamlib/rotator.h>
#include <hamlib/amplifier.h>
//mdblack98 -- Commented this out -- is anybody using the functions in misc.h?
//If so, then those functions should be moved to rig.h
//#include "misc.h"

#include <limits.h>

%}

/*
 * symbols that won't be wrapped
 */
%include "ignore.swg"

%include typemaps.i
%include stdint.i
%include exception.i
#ifndef SWIGLUA
#ifndef SWIGJAVA
%include cstring.i
#endif
#endif
#ifdef SWIGPYTHON
%include python/file.i

%typemap(out) int [ANY] {
  int len,i;
  len = $1_dim0;
  $result = PyList_New(len);
  for (i = 0; i < len; i++) {
    PyList_SetItem($result,i,PyInt_FromLong((long)$1[i]));
  }
}

%typemap(varout) int [ANY] {
  int len,i;
  len = $1_dim0;
  $result = PyList_New(len);
  for (i = 0; i < len; i++) {
    PyList_SetItem($result,i,PyInt_FromLong((long)$1[i]));
  }
}

#endif

#ifdef SWIGPERL

%typemap(out) int [ANY] {
    AV * av = newAV();
    int i = 0,len = 0;
    len = $1_dim0;

    for (i = 0; i < len ; i++) {
        SV* perlval = newSV(0);
        sv_setiv(perlval, (IV)$1[i]);
        av_push(av, perlval);
    }
    $result = newRV_noinc((SV *)av);
    sv_2mortal( $result );
    argvi++;
}

%typemap(argout) int [ANY] {
    AV * av = newAV();
    int i = 0,len = 0;
    len = $1_dim0;

    for (i = 0; i < len ; i++) {
        SV* perlval = newSV(0);
        sv_setiv(perlval, (IV)$1[i]);
        av_push(av, perlval);
    }
    $result = newRV_noinc((SV *)av);
    sv_2mortal( $result );
    argvi++;
}

#endif

#ifdef SWIGTCL

%typemap(out) int [ANY] {
    int i, len, l;
    len = $1_dim0;

    Tcl_Obj * list = Tcl_NewListObj(len, NULL);
    for(i=0; i < len; i++) {
        Tcl_ListObjAppendElement(interp, list, Tcl_NewIntObj($1[i]));
    }
    Tcl_SetObjResult(interp, list);
}

%typemap(varout) int [ANY] {
    int i, len, l;
    len = $1_dim0;

    Tcl_Obj * list = Tcl_NewListObj(len, NULL);
    for(i=0; i < len; i++) {
        Tcl_ListObjAppendElement(interp, list, Tcl_NewIntObj($1[i]));
    }

    $result = list;
}


#endif

#ifdef SWIGLUA

%typemap(out) int [ANY] {
  int len,i;
  len = $1_dim0;
  lua_createtable (L, len, 0);
  for(i=0; i<len; i++) {
    lua_pushinteger(L, (i+1)); // Lua starts list index with 1
    lua_pushinteger(L, (lua_Integer)$1[i]);
    lua_rawset(L, -3);
  }
  SWIG_arg++;
}

%typemap(varout) int [ANY] {
  int len,i;
  len = $1_dim0;
  lua_createtable (L, len, 0);
  for(i=0; i<len; i++) {
    lua_pushinteger(L, (i+1)); // Lua starts list index with 1
    lua_pushinteger(L, (lua_Integer)$1[i]);
    lua_rawset(L, -3);
  }
  SWIG_arg++;
}

%typemap(in,numinputs=0) char * OUTPUT (char *returnstr) {
    char returnstr[1024];
    $1 = returnstr;
}

%typemap(argout) char * OUTPUT {
    lua_pushstring(L,(char *)$1); SWIG_arg++;
}


#endif

%apply double *OUTPUT { double *distance, double *azimuth };
%apply int *OUTPUT { int *degrees, int *minutes, double *seconds, int *sw };
%apply int *OUTPUT { int *degrees, double *minutes, int *sw };
%apply double *OUTPUT { double *longitude, double *latitude };

#ifndef SWIGJAVA
// If SWIGJAVA ever maps char * we can enable these
%apply char *OUTPUT { char *locator_res };
%apply char *OUTPUT { char *hamlib_version2 };
%apply char *OUTPUT { char *hamlib_copyright2 };
%apply char *OUTPUT { char *returnstr };
#endif

#ifndef SWIGLUA
#ifndef SWIG_CSTRING_UNIMPL
#ifndef SWIGJAVA
/* longlat2locator */
%cstring_bounded_output(char *locator_res, 13)
%cstring_bounded_output(char *hamlib_version2, 4)
%cstring_bounded_output(char *hamlib_copyright2, 4)
#endif
#endif
#endif

%immutable confparams::name;
%immutable confparams::label;
%immutable confparams::tooltip;
%immutable confparams::dflt;
%immutable cs;
%immutable rig_caps::model_name;
%immutable rig_caps::mfg_name;
%immutable rig_caps::version;
%immutable rig_caps::copyright;
%immutable hamlib_version2;
%immutable hamlib_copyright2;

%immutable clone_combo_set;
%immutable clone_combo_get;

%immutable rot_caps::model_name;
%immutable rot_caps::mfg_name;
%immutable rot_caps::version;
%immutable rot_caps::copyright;

%include <hamlib/rig_dll.h>

%include <hamlib/riglist.h>
%include <hamlib/rig.h>

%include <hamlib/rotlist.h>
%include <hamlib/rotator.h>

%inline {
typedef const char * const_char_string;
}

/*
 * The Rig "class"
 */
%include "rig.swg"

/*
 * The Rot "class"
 */
%include "rotator.swg"

/*
 * The Amp "class"
 */
%include "amplifier.swg"

/*
 * Put binding specific code in separate files
 *
  %include "perl.i"
  %include "tcl.i"
  %include "python.i"
  %include "whatever.i"
 */