add null_void
parent
b8e624fecd
commit
1a3145b5b6
|
@ -9,15 +9,29 @@ macro_rules! c_str {
|
|||
($s:expr) => {concat!($s, "\0").as_ptr() as $crate::durandal::ffi::NT};
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub const fn null_void() -> *const c_void
|
||||
{
|
||||
null()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub const fn null_mut_void() -> *mut c_void
|
||||
{
|
||||
null_mut()
|
||||
}
|
||||
|
||||
impl CStringVec
|
||||
{
|
||||
/// Creates a new empty CStringVec.
|
||||
#[inline]
|
||||
pub fn new() -> Self
|
||||
{
|
||||
Self{sv: Vec::new(), cv: vec![null()]}
|
||||
}
|
||||
|
||||
/// Creates a new `CStringVec` from an iterator.
|
||||
#[inline]
|
||||
pub fn new_from_iter<'a, I: Iterator<Item = &'a str>>(it: I)
|
||||
-> ResultS<Self>
|
||||
{
|
||||
|
@ -31,6 +45,7 @@ impl CStringVec
|
|||
}
|
||||
|
||||
/// Pushes a new `CString`.
|
||||
#[inline]
|
||||
pub fn push(&mut self, st: CString)
|
||||
{
|
||||
self.cv.insert(self.cv.len() - 1, st.as_ptr());
|
||||
|
@ -38,12 +53,14 @@ impl CStringVec
|
|||
}
|
||||
|
||||
/// Returns the FFI pointer.
|
||||
#[inline]
|
||||
pub fn as_ptr(&self) -> *const NT
|
||||
{
|
||||
self.cv.as_ptr()
|
||||
}
|
||||
|
||||
/// Returns the FFI pointer mutably.
|
||||
#[inline]
|
||||
pub fn as_mut_ptr(&mut self) -> *mut NT
|
||||
{
|
||||
self.cv.as_mut_ptr()
|
||||
|
@ -52,6 +69,7 @@ impl CStringVec
|
|||
|
||||
impl Default for CStringVec
|
||||
{
|
||||
#[inline]
|
||||
fn default() -> Self {Self::new()}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use maraiah::{durandal::{err::*, file::*, image::*, sound::*},
|
||||
marathon::{machdr, ppm, shp, snd, tga, wad, wav}};
|
||||
use std::{fs, io};
|
||||
use std::{fs, io, slice::from_ref};
|
||||
|
||||
fn make_tga(_opt: &Options, fname: &str, im: &impl Image) -> ResultS<()>
|
||||
{
|
||||
|
@ -140,7 +140,7 @@ fn main() -> ResultS<()>
|
|||
|
||||
macro_rules! arg {
|
||||
($name:expr, $ref:expr, $type:expr, $desc:expr) => {
|
||||
ap.refer(&mut $ref).add_option(&[$name], $type, $desc);
|
||||
ap.refer(&mut $ref).add_option(from_ref(&$name), $type, $desc);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue