changeset 9: |
b9720ba9c4a0 |
parent: |
bebb76da449c
|
child: |
a1137af05c8d |
author: |
ellis <ellis@rwest.io> |
date: |
Mon, 08 May 2023 21:11:03 -0400 |
permissions: |
-rw-r--r-- |
description: |
readme, removed redundant script |
1 //! demo/lib.rs --- generated by DEMO:RS-MACROEXPAND 5 use libc::{c_char, size_t}; 6 use obj::{CustomService, Objective, Service}; 7 use std::ffi::{CStr, CString}; 10 pub unsafe extern "C" fn free_service(ptr: *mut Service) { 14 let _ = Box::from_raw(ptr); 17 pub unsafe extern "C" fn service_from_string(ptr: *const c_char) -> *mut Service { 18 assert!(!ptr.is_null()); 19 let p = CStr::from_ptr(ptr).to_str().unwrap(); 20 Box::into_raw(Box::new(p.into())) 23 pub unsafe extern "C" fn service_from_json_string(ptr: *const c_char) -> *mut Service { 24 assert!(!ptr.is_null()); 25 let s = CStr::from_ptr(ptr); 26 Box::into_raw(Box::new( 27 Service::from_json_str(&s.to_str().unwrap()).unwrap(), 31 pub unsafe extern "C" fn service_to_json_string(ptr: *const Service) -> *mut c_char { 33 let x = p.to_json_string().unwrap(); 34 CString::new(x.as_str().as_bytes()).unwrap().into_raw() 37 pub unsafe extern "C" fn service_from_ron_string(ptr: *const c_char) -> *mut Service { 38 assert!(!ptr.is_null()); 39 let s = CStr::from_ptr(ptr); 40 Box::into_raw(Box::new( 41 Service::from_ron_str(&s.to_str().unwrap()).unwrap(), 45 pub unsafe extern "C" fn service_to_ron_string(ptr: *const Service) -> *mut c_char { 47 let x = p.to_ron_string().unwrap(); 48 CString::new(x.as_str().as_bytes()).unwrap().into_raw() 51 pub unsafe extern "C" fn service_decode(ptr: *const u8, len: size_t) -> *mut Service { 52 Box::into_raw(Box::new( 53 Service::decode(slice::from_raw_parts(ptr, len)).unwrap(), 57 pub unsafe extern "C" fn service_encode(ptr: *const Service) -> *mut u8 { 59 let mut x = p.encode().unwrap(); 60 let r = x.as_mut_ptr(); 65 pub unsafe extern "C" fn free_custom_service(ptr: *mut CustomService) { 69 let _ = Box::from_raw(ptr); 72 pub unsafe extern "C" fn custom_service_from_string(ptr: *const c_char) -> *mut CustomService { 73 assert!(!ptr.is_null()); 74 let p = CStr::from_ptr(ptr).to_str().unwrap(); 75 Box::into_raw(Box::new(p.into())) 78 pub unsafe extern "C" fn custom_service_from_json_string(ptr: *const c_char) -> *mut CustomService { 79 assert!(!ptr.is_null()); 80 let s = CStr::from_ptr(ptr); 81 Box::into_raw(Box::new( 82 CustomService::from_json_str(&s.to_str().unwrap()).unwrap(), 86 pub unsafe extern "C" fn custom_service_to_json_string(ptr: *const CustomService) -> *mut c_char { 88 let x = p.to_json_string().unwrap(); 89 CString::new(x.as_str().as_bytes()).unwrap().into_raw() 92 pub unsafe extern "C" fn custom_service_from_ron_string(ptr: *const c_char) -> *mut CustomService { 93 assert!(!ptr.is_null()); 94 let s = CStr::from_ptr(ptr); 95 Box::into_raw(Box::new( 96 CustomService::from_ron_str(&s.to_str().unwrap()).unwrap(), 100 pub unsafe extern "C" fn custom_service_to_ron_string(ptr: *const CustomService) -> *mut c_char { 102 let x = p.to_ron_string().unwrap(); 103 CString::new(x.as_str().as_bytes()).unwrap().into_raw() 106 pub unsafe extern "C" fn custom_service_decode(ptr: *const u8, len: size_t) -> *mut CustomService { 107 Box::into_raw(Box::new( 108 CustomService::decode(slice::from_raw_parts(ptr, len)).unwrap(), 112 pub unsafe extern "C" fn custom_service_encode(ptr: *const CustomService) -> *mut u8 { 114 let mut x = p.encode().unwrap(); 115 let r = x.as_mut_ptr();