1use super::*;
4use super::c_api::*;
5
6pub fn create_module<S>(name: S) -> Module where S: AsRef<str> {
8 Module {
9 module: Some(
10 unsafe {
11 LLVMModuleCreateWithNameInContext(into_c(name).as_ptr(), context())
12 }
13 )
14 }
15}
16
17pub fn create_builder() -> Builder {
19 Builder {
20 builder: Some(
21 unsafe {
22 LLVMCreateBuilderInContext(context())
23 }
24 )
25 }
26}
27
28pub fn const_struct(elements: Vec<Value>, packed: bool) -> Value {
30 Value {
31 value: unsafe {
32 LLVMConstStructInContext(context(), val_vec(&elements).as_mut_ptr(), elements.len() as u32, packed as i32)
33 }
34 }
35}
36
37pub fn const_string<S>(string: S, null_terminated: bool) -> Value where S: AsRef<str> {
39 Value {
40 value: unsafe {
41 let string = string.as_ref();
42 LLVMConstStringInContext(context(), into_c(string).as_ptr(), string.len() as u32, null_terminated as i32)
43 }
44 }
45}