@@ -6,7 +6,7 @@ use std::{
66 convert:: identity,
77 ffi:: { c_void, CStr } ,
88 mem,
9- os:: raw:: { c_char, c_int} ,
9+ os:: raw:: { c_char, c_float , c_int, c_long , c_short } ,
1010 panic:: { catch_unwind, UnwindSafe } ,
1111 ptr,
1212} ;
@@ -195,6 +195,31 @@ pub unsafe extern "C" fn spring_row_close(row: *mut SpringRow) -> SpringErrno {
195195 }
196196}
197197
198+ /// See: springql_core::api::spring_column_i16
199+ ///
200+ /// # Returns
201+ ///
202+ /// - `0`: if there are no recent errors.
203+ /// - `< 0`: SpringErrno
204+ ///
205+ /// # Safety
206+ ///
207+ /// This function is unsafe because it uses raw pointer.
208+ #[ no_mangle]
209+ pub unsafe extern "C" fn spring_column_short (
210+ row : * const SpringRow ,
211+ i_col : u16 ,
212+ out : * mut c_short ,
213+ ) -> SpringErrno {
214+ let row = & * ( ( * row) . 0 as * const springql_core:: SpringRow ) ;
215+ let i_col = i_col as usize ;
216+
217+ with_catch ( || springql_core:: spring_column_i16 ( row, i_col) ) . map_or_else ( identity, |r| {
218+ * out = r;
219+ SpringErrno :: Ok
220+ } )
221+ }
222+
198223/// See: springql_core::api::spring_column_i32
199224///
200225/// # Returns
@@ -220,6 +245,31 @@ pub unsafe extern "C" fn spring_column_int(
220245 } )
221246}
222247
248+ /// See: springql_core::api::spring_column_i64
249+ ///
250+ /// # Returns
251+ ///
252+ /// - `0`: if there are no recent errors.
253+ /// - `< 0`: SpringErrno
254+ ///
255+ /// # Safety
256+ ///
257+ /// This function is unsafe because it uses raw pointer.
258+ #[ no_mangle]
259+ pub unsafe extern "C" fn spring_column_long (
260+ row : * const SpringRow ,
261+ i_col : u16 ,
262+ out : * mut c_long ,
263+ ) -> SpringErrno {
264+ let row = & * ( ( * row) . 0 as * const springql_core:: SpringRow ) ;
265+ let i_col = i_col as usize ;
266+
267+ with_catch ( || springql_core:: spring_column_i64 ( row, i_col) ) . map_or_else ( identity, |r| {
268+ * out = r;
269+ SpringErrno :: Ok
270+ } )
271+ }
272+
223273/// See: springql_core::api::spring_column_text
224274///
225275/// This returns UTF-8 string into `out`.
@@ -247,6 +297,56 @@ pub unsafe extern "C" fn spring_column_text(
247297 . map_or_else ( |errno| errno as c_int , |text| strcpy ( & text, out, out_len) )
248298}
249299
300+ /// See: springql_core::api::spring_column_bool
301+ ///
302+ /// # Returns
303+ ///
304+ /// - `0`: if there are no recent errors.
305+ /// - `< 0`: SpringErrno
306+ ///
307+ /// # Safety
308+ ///
309+ /// This function is unsafe because it uses raw pointer.
310+ #[ no_mangle]
311+ pub unsafe extern "C" fn spring_column_bool (
312+ row : * const SpringRow ,
313+ i_col : u16 ,
314+ out : * mut bool ,
315+ ) -> SpringErrno {
316+ let row = & * ( ( * row) . 0 as * const springql_core:: SpringRow ) ;
317+ let i_col = i_col as usize ;
318+
319+ with_catch ( || springql_core:: spring_column_bool ( row, i_col) ) . map_or_else ( identity, |r| {
320+ * out = r;
321+ SpringErrno :: Ok
322+ } )
323+ }
324+
325+ /// See: springql_core::api::spring_column_f32
326+ ///
327+ /// # Returns
328+ ///
329+ /// - `0`: if there are no recent errors.
330+ /// - `< 0`: SpringErrno
331+ ///
332+ /// # Safety
333+ ///
334+ /// This function is unsafe because it uses raw pointer.
335+ #[ no_mangle]
336+ pub unsafe extern "C" fn spring_column_float (
337+ row : * const SpringRow ,
338+ i_col : u16 ,
339+ out : * mut c_float ,
340+ ) -> SpringErrno {
341+ let row = & * ( ( * row) . 0 as * const springql_core:: SpringRow ) ;
342+ let i_col = i_col as usize ;
343+
344+ with_catch ( || springql_core:: spring_column_f32 ( row, i_col) ) . map_or_else ( identity, |r| {
345+ * out = r;
346+ SpringErrno :: Ok
347+ } )
348+ }
349+
250350fn with_catch < F , R > ( f : F ) -> Result < R , SpringErrno >
251351where
252352 F : FnOnce ( ) -> Result < R , SpringError > + UnwindSafe ,
0 commit comments