Skip to content

Commit 1cae927

Browse files
authored
Merge pull request #68 from rust-lang/feature/new_array_type_u64
Add Context::new_array_type_u64
2 parents 17bf030 + 88f6195 commit 1cae927

4 files changed

Lines changed: 32 additions & 3 deletions

File tree

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "gccjit"
3-
version = "3.2.0"
3+
version = "3.3.0"
44
authors = ["Sean Gillespie <sean.william.g@gmail.com>", "Antoni Boucher <bouanto@zoho.com>"]
55
description = "Higher-level Rust bindings for libgccjit."
66
keywords = ["compiler", "jit", "gcc"]
@@ -14,7 +14,7 @@ master = ["gccjit_sys/master"]
1414
dlopen = ["gccjit_sys/dlopen"]
1515

1616
[dependencies]
17-
gccjit_sys = { version = "1.2.0", path = "gccjit_sys" }
17+
gccjit_sys = { version = "1.3.0", path = "gccjit_sys" }
1818

1919
[package.metadata.docs.rs]
2020
features = ["master"]

gccjit_sys/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "gccjit_sys"
3-
version = "1.2.0"
3+
version = "1.3.0"
44
authors = ["Sean Gillespie <sean.william.g@gmail.com>", "Antoni Boucher <bouanto@zoho.com>"]
55
#links = "gccjit"
66
description = "Raw bindings to libgccjit. Companion to the gccjit crate."

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)