comparison @pyobject/pyobject.m @ 374:d362cdd1ddeb

pyobject: add conversion methods for single, intX, and uintX types * oct-py-types.cc, oct-py-types.h (pytave::extract_py_uint64): New function. * __py_struct_from_dict__.cc (F__py_uint64_scalar_value__): New function. (F__py_int64_scalar_value__): Simplify and clean up style. Add %!tests. * @pyobject/pyobject.m (pyobject.single, pyobject.int8, pyobject.int16, pyobject.int32, pyobject.uint8, pyobject.uint16, pyobject.uint32, pyobject.uint64): New conversion methods.
author Mike Miller <mtmiller@octave.org>
date Fri, 26 Aug 2016 18:51:42 -0700
parents 0e4097c66788
children 6c316b5f30f7
comparison
equal deleted inserted replaced
373:0e4097c66788 374:d362cdd1ddeb
107 else 107 else
108 y = pycall ("float", x); 108 y = pycall ("float", x);
109 endif 109 endif
110 endfunction 110 endfunction
111 111
112 function y = single (x)
113 y = single (double (x));
114 endfunction
115
116 function y = int8 (x)
117 y = int8 (__py_int64_scalar_value__ (x));
118 endfunction
119
120 function y = int16 (x)
121 y = int16 (__py_int64_scalar_value__ (x));
122 endfunction
123
124 function y = int32 (x)
125 y = int32 (__py_int64_scalar_value__ (x));
126 endfunction
127
112 function y = int64 (x) 128 function y = int64 (x)
113 y = __py_int64_scalar_value__ (x); 129 y = __py_int64_scalar_value__ (x);
130 endfunction
131
132 function y = uint8 (x)
133 y = uint8 (__py_uint64_scalar_value__ (x));
134 endfunction
135
136 function y = uint16 (x)
137 y = uint16 (__py_uint64_scalar_value__ (x));
138 endfunction
139
140 function y = uint32 (x)
141 y = uint32 (__py_uint64_scalar_value__ (x));
142 endfunction
143
144 function y = uint64 (x)
145 y = __py_uint64_scalar_value__ (x);
114 endfunction 146 endfunction
115 147
116 function y = isa (x, typestr) 148 function y = isa (x, typestr)
117 assert (nargin == 2); 149 assert (nargin == 2);
118 assert (ischar (typestr) || iscellstr (typestr)); 150 assert (ischar (typestr) || iscellstr (typestr));