changeset 19: |
fd19fdc77a20 |
parent: |
a1137af05c8d
|
author: |
ellis <ellis@rwest.io> |
date: |
Mon, 29 May 2023 21:55:22 -0400 |
permissions: |
-rw-r--r-- |
description: |
readme update, removed scripts dir |
1 //! demo/lib.rs --- generated by DEMO:RS-MACROEXPAND 4 use libc::{c_char, size_t}; 5 use obj::{CustomService, Objective, Service}; 6 use std::ffi::{CStr, CString}; 9 pub unsafe extern "C" fn free_service(ptr: *mut Service) { 13 let _ = Box::from_raw(ptr); 16 pub unsafe extern "C" fn service_from_string(ptr: *const c_char) -> *mut Service { 17 assert!(!ptr.is_null()); 18 let p = CStr::from_ptr(ptr).to_str().unwrap(); 19 Box::into_raw(Box::new(p.into())) 22 pub unsafe extern "C" fn service_from_json_string(ptr: *const c_char) -> *mut Service { 23 assert!(!ptr.is_null()); 24 let s = CStr::from_ptr(ptr); 25 Box::into_raw(Box::new( 26 Service::from_json_str(&s.to_str().unwrap()).unwrap(), 30 pub unsafe extern "C" fn service_to_json_string(ptr: *const Service) -> *mut c_char { 32 let x = p.to_json_string().unwrap(); 33 CString::new(x.as_str().as_bytes()).unwrap().into_raw() 36 pub unsafe extern "C" fn service_from_ron_string(ptr: *const c_char) -> *mut Service { 37 assert!(!ptr.is_null()); 38 let s = CStr::from_ptr(ptr); 39 Box::into_raw(Box::new( 40 Service::from_ron_str(&s.to_str().unwrap()).unwrap(), 44 pub unsafe extern "C" fn service_to_ron_string(ptr: *const Service) -> *mut c_char { 46 let x = p.to_ron_string().unwrap(); 47 CString::new(x.as_str().as_bytes()).unwrap().into_raw() 50 pub unsafe extern "C" fn service_decode(ptr: *const u8, len: size_t) -> *mut Service { 51 Box::into_raw(Box::new( 52 Service::decode(slice::from_raw_parts(ptr, len)).unwrap(), 56 pub unsafe extern "C" fn service_encode(ptr: *const Service) -> *mut u8 { 58 let mut x = p.encode().unwrap(); 59 let r = x.as_mut_ptr(); 64 pub unsafe extern "C" fn free_custom_service(ptr: *mut CustomService) { 68 let _ = Box::from_raw(ptr); 71 pub unsafe extern "C" fn custom_service_from_string(ptr: *const c_char) -> *mut CustomService { 72 assert!(!ptr.is_null()); 73 let p = CStr::from_ptr(ptr).to_str().unwrap(); 74 Box::into_raw(Box::new(p.into())) 77 pub unsafe extern "C" fn custom_service_from_json_string(ptr: *const c_char) -> *mut CustomService { 78 assert!(!ptr.is_null()); 79 let s = CStr::from_ptr(ptr); 80 Box::into_raw(Box::new( 81 CustomService::from_json_str(&s.to_str().unwrap()).unwrap(), 85 pub unsafe extern "C" fn custom_service_to_json_string(ptr: *const CustomService) -> *mut c_char { 87 let x = p.to_json_string().unwrap(); 88 CString::new(x.as_str().as_bytes()).unwrap().into_raw() 91 pub unsafe extern "C" fn custom_service_from_ron_string(ptr: *const c_char) -> *mut CustomService { 92 assert!(!ptr.is_null()); 93 let s = CStr::from_ptr(ptr); 94 Box::into_raw(Box::new( 95 CustomService::from_ron_str(&s.to_str().unwrap()).unwrap(), 99 pub unsafe extern "C" fn custom_service_to_ron_string(ptr: *const CustomService) -> *mut c_char { 101 let x = p.to_ron_string().unwrap(); 102 CString::new(x.as_str().as_bytes()).unwrap().into_raw() 105 pub unsafe extern "C" fn custom_service_decode(ptr: *const u8, len: size_t) -> *mut CustomService { 106 Box::into_raw(Box::new( 107 CustomService::decode(slice::from_raw_parts(ptr, len)).unwrap(), 111 pub unsafe extern "C" fn custom_service_encode(ptr: *const CustomService) -> *mut u8 { 113 let mut x = p.encode().unwrap(); 114 let r = x.as_mut_ptr();