Skip to content

Commit 9ab06ba

Browse files
committed
Add Context::new_array_type_u64
1 parent 17bf030 commit 9ab06ba

2 files changed

Lines changed: 29 additions & 0 deletions

File tree

gccjit_sys/src/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -780,4 +780,10 @@ extern_maybe_dlopen! {
780780

781781
#[cfg(feature="master")]
782782
fn gcc_jit_context_set_filename(ctx: *mut gcc_jit_context, filename: *const c_char);
783+
784+
#[cfg(feature="master")]
785+
fn gcc_jit_context_new_array_type_u64(ctx: *mut gcc_jit_context,
786+
loc: *mut gcc_jit_location,
787+
ty: *mut gcc_jit_type,
788+
num_elements: u64) -> *mut gcc_jit_type;
783789
}

src/context.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,29 @@ impl<'ctx> Context<'ctx> {
478478
})
479479
}
480480

481+
/// Constructs a new array type with a given base element type and a
482+
/// size.
483+
#[cfg(feature="master")]
484+
pub fn new_array_type_u64<'a>(&'a self,
485+
loc: Option<Location<'a>>,
486+
ty: types::Type<'a>,
487+
num_elements: u64) -> types::Type<'a> {
488+
let loc_ptr = match loc {
489+
Some(loc) => unsafe { location::get_ptr(&loc) },
490+
None => ptr::null_mut()
491+
};
492+
with_lib(|lib| {
493+
unsafe {
494+
let ptr = lib.gcc_jit_context_new_array_type_u64(self.ptr, loc_ptr, types::get_ptr(&ty), num_elements);
495+
#[cfg(debug_assertions)]
496+
if let Ok(Some(error)) = self.get_last_error() {
497+
panic!("{}", error);
498+
}
499+
types::from_ptr(ptr)
500+
}
501+
})
502+
}
503+
481504
pub fn new_vector_type<'a>(&'a self, ty: types::Type<'a>, num_units: u64) -> types::Type<'a> {
482505
with_lib(|lib| {
483506
unsafe {

0 commit comments

Comments
 (0)