|
| 1 | +// Copyright 2015 Eric Millin |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | + |
1 | 15 | %module GribApiProxy
|
2 | 16 |
|
3 | 17 | %rename("%(strip:[grib])s") "";
|
|
12 | 26 | %rename("%(camelcase)s", %$isenum) "";
|
13 | 27 | %rename("%(camelcase)s", %$isenumitem) "";
|
14 | 28 |
|
| 29 | + |
| 30 | +%typemap(imtype, out="System.IntPtr") FILE*, grib_handle*, grib_context* "System.Runtime.InteropServices.HandleRef" |
| 31 | +%typemap(csin) FILE*, grib_handle*, grib_context* "$csinput.Reference" |
| 32 | +%typemap(cstype) FILE* "GribFile" |
| 33 | +%typemap(csout, out="GribFile", excode=SWIGEXCODE) FILE* %{ |
| 34 | + System.IntPtr pVal = $imcall;$excode |
| 35 | + |
| 36 | + return pVal == System.IntPtr.Zero ? null : new GribFile(pVal); |
| 37 | + %} |
| 38 | + |
| 39 | + %typemap(cstype) grib_context* "GribContext" |
| 40 | + %typemap(cstype) grib_handle* "GribHandle" |
| 41 | + |
| 42 | + %typemap(csvarout, out="GribContext", excode=SWIGEXCODE2) grib_context* %{ |
| 43 | + get { |
| 44 | + System.IntPtr pVal = $imcall;$excode |
| 45 | + |
| 46 | + return pVal == System.IntPtr.Zero ? null : new GribContext(pVal); |
| 47 | + } %} |
| 48 | + %typemap(csout, out="GribContext", excode=SWIGEXCODE) grib_context* %{{ |
| 49 | + System.IntPtr pVal = $imcall;$excode |
| 50 | + |
| 51 | + return pVal == System.IntPtr.Zero ? null : new GribContext(pVal); |
| 52 | + }%} |
| 53 | + |
| 54 | + %typemap(csvarout, out="GribHandle", excode=SWIGEXCODE2) grib_handle* %{ |
| 55 | + get { |
| 56 | + System.IntPtr pVal = $imcall;$excode |
| 57 | + |
| 58 | + return pVal == System.IntPtr.Zero ? null : new GribHandle(pVal); |
| 59 | + } %} |
| 60 | +%typemap(csout, out="GribHandle", excode=SWIGEXCODE) grib_handle* %{{ |
| 61 | + System.IntPtr pVal = $imcall;$excode |
| 62 | + |
| 63 | + return pVal == System.IntPtr.Zero ? null : new GribHandle(pVal); |
| 64 | + }%} |
| 65 | + |
| 66 | + |
15 | 67 | %typemap(imtype, out="System.UIntPtr") off_t, size_t "System.UIntPtr"
|
16 | 68 | %typemap(csin) off_t, size_t "$csinput.Value"
|
17 |
| -%typemap(imtype, out="System.UIntPtr") off_t*, size_t * "ref System.UIntPtr" |
| 69 | +%typemap(cstype) off_t, size_t "SizeT" |
| 70 | +%typemap(imtype, out="System.IntPtr") off_t*, size_t * "ref System.UIntPtr" |
| 71 | +//%typemap(imout, out="System.UIntPtr") off_t*, size_t * "System.UIntPtr" |
18 | 72 | %typemap(csin) off_t*, size_t * "ref $csinput.Value"
|
19 |
| -%typemap(cstype) off_t, size_t, off_t*, size_t * "SizeT" |
20 |
| -%typemap(csvarout, out="SizeT", excode=SWIGEXCODE2) off_t, size_t, off_t*, size_t * %{ |
| 73 | +%typemap(cstype, out="SizeT") off_t*, size_t * "ref SizeT" |
| 74 | +%typemap(csout, out="SizeT", excode=SWIGEXCODE) off_t*, size_t * %{ |
| 75 | + System.IntPtr pVal = $imcall;$excode |
| 76 | + |
| 77 | + // dereference the pointer |
| 78 | + System.UIntPtr val = (System.UIntPtr)System.Runtime.InteropServices.Marshal.PtrToStructure(pVal, typeof(System.UIntPtr)); |
| 79 | + |
| 80 | + return new SizeT(val); |
| 81 | + %} |
| 82 | +%typemap(csvarout, out="SizeT", excode=SWIGEXCODE2) off_t*, size_t * %{ |
| 83 | + get { |
| 84 | + System.IntPtr pVal = $imcall;$excode |
| 85 | + |
| 86 | + // dereference the pointer |
| 87 | + System.UIntPtr val = (System.UIntPtr)System.Runtime.InteropServices.Marshal.PtrToStructure(pVal, typeof(System.UIntPtr)); |
| 88 | + |
| 89 | + return new SizeT(val); |
| 90 | + } %} |
| 91 | +%typemap(csvarout, out="SizeT", excode=SWIGEXCODE2) off_t, size_t %{ |
21 | 92 | get {
|
22 | 93 | System.UIntPtr val = $imcall;$excode
|
| 94 | + |
23 | 95 | return new SizeT(val);
|
24 | 96 | } %}
|
25 | 97 |
|
|
35 | 107 | %typemap(cstype) float * value "out float"
|
36 | 108 | %typemap(csin) float * value "out $csinput"
|
37 | 109 |
|
38 |
| -%typemap(csin) long * vals, long * values, int * indexes "$csinput" |
39 |
| -%typemap(cstype) long * vals, long * values, int * indexes "int[]" |
40 |
| -%typemap(imtype) long * vals, long * values, int * indexes "int[]" |
| 110 | +%typemap(csin) long * vals, long * values, int * indexes, long * pl "$csinput" |
| 111 | +%typemap(cstype) long * vals, long * values, int * indexes, long * pl "int[]" |
| 112 | +%typemap(imtype) long * vals, long * values, int * indexes, long * pl "int[]" |
41 | 113 |
|
42 | 114 | %typemap(csin) double * data_values, double * vals, double * values, double * latitudes, double * longitudes, double * lats, double * lons, double * outlats, double * outlons, double * inlats, double * inlons, double * distances "$csinput"
|
43 | 115 | %typemap(cstype) double * data_values, double * vals, double * values, double * latitudes, double * longitudes, double * lats, double * lons, double * outlats, double * outlons, double * inlats, double * inlons, double * distances "double[]"
|
|
76 | 148 | return $imcall;$excode
|
77 | 149 | }
|
78 | 150 |
|
| 151 | +%typemap(csvarout, out="int[]", excode=SWIGEXCODE2) long * pl %{ |
| 152 | + get |
| 153 | + { |
| 154 | + return $imcall;$excode |
| 155 | + } %} |
| 156 | + |
79 | 157 | %typemap(csvarout, out="double[]", excode=SWIGEXCODE2) double * latitudes,double * longitudes %{
|
80 | 158 | get
|
81 | 159 | {
|
|
0 commit comments