Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / v8plus / share / swig / 1.3.26 / ruby / rubyswigtype.swg
CommitLineData
920dae64
AT
1/* --- Input typemaps --- */
2
3%typemap(in) SWIGTYPE *,
4 SWIGTYPE []
5 "SWIG_ConvertPtr($input, (void **) &$1, $1_descriptor, $disown);"
6
7%typemap(in) SWIGTYPE *DISOWN
8 "SWIG_ConvertPtr($input, (void **) &$1, $1_descriptor, SWIG_POINTER_DISOWN);"
9
10/* Additional check for null references */
11%typemap(in) SWIGTYPE &
12 "SWIG_ConvertPtr($input, (void **) &$1, $1_descriptor, $disown); if ($1 == NULL) rb_raise(rb_eTypeError, \"null reference\");"
13
14/* Object passed by value. Convert to a pointer */
15%typemap(in) SWIGTYPE {
16 $&1_ltype ptr;
17 SWIG_ConvertPtr($input, (void **) &ptr, $&1_descriptor, $disown);
18 if (ptr) $1 = *ptr;
19}
20
21/* Pointer to a class member */
22%typemap(in) SWIGTYPE (CLASS::*) "SWIG_ConvertPacked($input, (void *) &$1, sizeof($1_type), $1_descriptor, $disown);";
23
24/* --- Output typemaps --- */
25
26/* Pointers, references, and arrays */
27%typemap(out) SWIGTYPE*, SWIGTYPE &, SWIGTYPE []
28 "$result = SWIG_NewPointerObj((void *) $1, $1_descriptor,$owner);";
29
30/* Dynamic casts */
31
32%typemap(out) SWIGTYPE *DYNAMIC, SWIGTYPE &DYNAMIC {
33 swig_type_info *ty = SWIG_TypeDynamicCast($1_descriptor, (void **) &$1);
34 $result = SWIG_NewPointerObj((void *) $1, ty,$owner);
35}
36
37/* Member pointer */
38%typemap(out) SWIGTYPE (CLASS::*) "$result = SWIG_NewPackedObj((void *) &$1, sizeof($1_type), $1_descriptor);";
39
40/* Primitive types--return by value */
41%typemap(out) SWIGTYPE
42#ifdef __cplusplus
43{
44 $&1_ltype resultptr;
45 resultptr = new $1_ltype(($1_ltype &)$1);
46 $result = SWIG_NewPointerObj((void *) resultptr, $&1_descriptor, 1);
47}
48#else
49{
50 $&1_ltype resultptr;
51 resultptr = ($&1_ltype) malloc(sizeof($1_type));
52 memmove(resultptr, &$1, sizeof($1_type));
53 $result = SWIG_NewPointerObj((void *) resultptr, $&1_descriptor, 1);
54}
55#endif
56
57/* --- Variable Input --- */
58
59%typemap(varin) SWIGTYPE [ANY] {
60 void *temp;
61 int ii;
62 $1_basetype *b = 0;
63 if ((SWIG_ConvertPtr($input,(void **) &temp, $1_descriptor, 0)) == -1) {
64 rb_raise(rb_eTypeError, "C variable '$name ($1_ltype)'");
65 }
66 b = ($1_basetype *) $1;
67 for (ii = 0; ii < $1_size; ii++) b[ii] = *(($1_basetype *) temp + ii);
68}
69
70%typemap(varin,warning="462: Unable to set dimensionless array variable") SWIGTYPE [] {
71 rb_raise(rb_eTypeError, "C/C++ variable '$name' is readonly");
72}
73
74/* Typemaps for pointers. Note: the SWIG run-time type checker works
75 even if a pointer happens to be mapped to a Ruby class */
76
77%typemap(varin) SWIGTYPE *
78 "SWIG_ConvertPtr($input, (void **) &$1, $1_descriptor, 1);"
79
80%typemap(varin) SWIGTYPE & {
81 void *temp;
82 SWIG_ConvertPtr($input, (void **) &temp, $1_descriptor, 1);
83 $1 = *($1_ltype) temp;
84}
85
86%typemap(varin) SWIGTYPE {
87 $&1_ltype ptr;
88 SWIG_ConvertPtr($input, (void **) &ptr, $&1_descriptor, 1);
89 if (ptr) $1 = *ptr;
90}
91
92%typemap(varin) SWIGTYPE (CLASS::*) {
93 char temp[sizeof($1_type)];
94 SWIG_ConvertPacked($input, (void *) temp, sizeof($1_type), $1_descriptor, 1);
95 memmove((void *) &$1, temp, sizeof($1_type));
96}
97
98/* --- Output typemaps --- */
99
100/* Pointers, references, and arrays */
101%typemap(varout) SWIGTYPE*, SWIGTYPE []
102 "$result = SWIG_NewPointerObj((void *) $1, $1_descriptor,0);";
103
104%typemap(varout) SWIGTYPE &
105 "$result = SWIG_NewPointerObj((void *) &$1, $1_descriptor,0);";
106
107/* Copy by value */
108%typemap(varout) SWIGTYPE "$result = SWIG_NewPointerObj((void *) &$1, $&1_descriptor, 0);";
109
110/* Member pointer */
111%typemap(varout) SWIGTYPE (CLASS::*) "$result = SWIG_NewPackedObj((void *) &$1, sizeof($1_type), $1_descriptor);";
112
113/* --- Constants --- */
114
115%typemap(constant) SWIGTYPE*, SWIGTYPE &, SWIGTYPE []
116 "rb_define_const($module,\"$symname\", SWIG_NewPointerObj((void *) $1, $1_descriptor,0));";
117
118%typemap(constant) SWIGTYPE "rb_define_const($module,\"$symname\", SWIG_NewPointerObj((void *) &$1, $&1_descriptor, 0));";
119
120%typemap(constant) SWIGTYPE (CLASS::*) "rb_define_const($module, \"$symname\", SWIG_NewPackedObj((void *) &$1, sizeof($type), $1_descriptor));";
121
122/* --- directorin typemaps --- */
123
124%typemap(directorin) SWIGTYPE*
125 "$input = SWIG_NewPointerObj((void *) $1, $1_descriptor,0);";
126
127%typemap(directorin) SWIGTYPE
128 "$input = SWIG_NewPointerObj((void *) &$1, $1_descriptor,0);";
129
130%typemap(directorin) SWIGTYPE&
131 "$input = SWIG_NewPointerObj((void *) &$1, $1_descriptor,0);";
132
133
134/* --- directorout typemaps --- */
135%typemap(directorout) SWIGTYPE *,
136 SWIGTYPE &,
137 SWIGTYPE []
138 "if ((SWIG_ConvertPtr($input,(void **) &$result, $descriptor,SWIG_POINTER_EXCEPTION | $disown )) == -1) throw Swig::DirectorTypeMismatchException(\"Pointer conversion failed.\");";
139
140/* ------------------------------------------------------------
141 * Typechecking rules
142 * ------------------------------------------------------------ */
143
144%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE {
145 void *ptr;
146 $1 = (NIL_P($input) || (TYPE($input) == T_DATA && SWIG_ConvertPtr($input, &ptr, $&1_descriptor, 0) != -1)) ? 1 : 0;
147}
148
149%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] {
150 void *ptr;
151 $1 = (NIL_P($input) || (TYPE($input) == T_DATA && SWIG_ConvertPtr($input, &ptr, $1_descriptor, 0) != -1)) ? 1 : 0;
152}
153
154/* ------------------------------------------------------------
155 * Exception handling.
156 * Note that in Ruby, we can only raise an exception class and
157 * not some arbitrary object as in Python.
158 * ------------------------------------------------------------ */
159
160%typemap(throws) SWIGTYPE, SWIGTYPE *, SWIGTYPE [ANY], SWIGTYPE &
161 "(void)$1; rb_raise(rb_eRuntimeError, \"$1_type\");";
162