search for: as_ptr

Displaying 19 results from an estimated 19 matches for "as_ptr".

Did you mean: a_ptr
2019 Jun 27
0
Re: [PATCH 08/11] Rust bindings: Fix memory management and format the file
...ent += 1; + Some(elem) + } + } +} + +fn arg_string_list(v: &[&str]) -> Result<Vec<ffi::CString>, Error> { let mut w = Vec::new(); for x in v.iter() { let y: &str = x; - let s = ffi::CString::new(y).unwrap(); - w.push(s.as_ptr()); + w.push(ffi::CString::new(y)?); + } + Ok(w) +} + +fn free_string_list(l: *const *const c_char) { + for buf in NullTerminatedIter::new(l) { + unsafe { free(buf as * const c_void) }; } - w.push(ptr::null()); - w + unsafe { free(l as *const c_void) }; } -fn...
2019 Jun 27
0
[PATCH 6/9] Rust bindings: Add generator of function signatures
...0,6 +132,18 @@ impl CreateFlags { } } +fn arg_string_list (v: &Vec<String>) -> Vec<*const i8> { + let length = v.len(); + let mut w = Vec::new(); + for x in v.iter() { + let y: &str = x; + let s = ffi::CString::new(y).unwrap(); + w.push(s.as_ptr()); + } + w.push(ptr::null()); + w +} + impl Handle { pub fn create() -> Result<Handle, &'static str> { let g = unsafe { guestfs_create() }; @@ -151,6 +165,10 @@ impl Handle { } }\ +pub struct Error { + // TODO +} + pub struct UUID { uuid: [...
2019 Jun 27
4
Re: [PATCH 9/9] Rust bindings: Complete bindings
Patch 9 is a kind of dumping ground of all kinds of stuff. It may be better to spend some time with git rebase -i trying to work this into more coherent patches. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-p2v converts physical machines to virtual machines. Boot with a live
2013 Sep 03
1
[LLVMdev] X86_thiscall
...to LLVM, so if this is the wrong place for this question then I appologise, please tell me where to go instead. I am generating code to call a member function of a class compiled with Microsoft Visual C++ using the JIT compiler. The following code is used to register the pointer to the function. as_ptr retrieves the address of a member function pointer. Yes, this is a bit of a hack, but it works (I have tested it in other situations). vector<llvm::Type *> arguments; arguments.push_back(interface_group_ptr); arguments.push_back(any); arguments.push_back(instance_ptr); auto ge...
2019 Jun 27
0
[PATCH 9/9] Rust bindings: Complete bindings
...-> Vec<*const i8> { - let length = v.len(); +fn arg_string_list(v: &[&str]) -> Result<Vec<ffi::CString>, Error> { let mut w = Vec::new(); for x in v.iter() { let y: &str = x; - let s = ffi::CString::new(y).unwrap(); - w.push(s.as_ptr()); + w.push(ffi::CString::new(y)?); + } + Ok(w) +} + +fn free_string_list(l: *const *const c_char) { + for buf in NullTerminatedIter::new(l) { + unsafe { free(buf as * const c_void) }; } - w.push(ptr::null()); - w + unsafe { free(l as *const c_void) }; } -fn...
2019 Jun 27
0
[PATCH 7/9] Rust bindings: Complete actions
...-> + pr " %s: if let Some(v) = optargs._%s {\n" n n; + pr " bitmask |= 1 << %d;\n" index; + pr " let y: &str = &v;\n"; + pr " ffi::CString::new(y).unwrap().as_ptr()\n"; + pr " } else {\n"; + pr " ptr::null()\n"; + pr " },\n"; + | OStringList _ -> + pr " %s: if let Some(v) = optargs._%s {\n" n n; + pr &quo...
2019 Jul 02
16
[PATCH] Add Rust bindings
I fixed the patch I submitted before based on comments, and there are some commits which are merged or divided. So, I will re-send all the patches. Regards, Hiroyuki Katsura
2019 Jun 27
16
[PATCH 1/9] Rust bindings: Add Rust bindings
From: Hiroyuki_Katsura <hiroyuki.katsura.0513@gmail.com> --- Makefile.am | 4 ++++ configure.ac | 3 +++ generator/Makefile.am | 3 +++ generator/bindtests.ml | 3 +++ generator/bindtests.mli | 1 + generator/main.ml | 5 +++++ generator/rust.ml | 34 ++++++++++++++++++++++++++++++++++ generator/rust.mli | 19 +++++++++++++++++++
2019 Jul 20
0
[PATCH] Rust bindings: Add Rust bindings
...|v| Ok::<_, Error>({\n"; + pr " let v = arg_string_list(v)?;\n"; + pr " let mut w = (&v).into_iter()\n"; + pr " .map(|v| v.as_ptr())\n"; + pr " .collect::<Vec<_>>();\n"; + pr " w.push(ptr::null());\n"; + pr " (v, w)\n"; + pr "...
2019 Jul 23
2
Re: [PATCH] Rust bindings: Add Rust bindings
...>({\n"; > + pr " let v = > arg_string_list(v)?;\n"; > + pr " let mut w = > (&v).into_iter()\n"; > + pr " .map(|v| > v.as_ptr())\n"; > + pr " > .collect::<Vec<_>>();\n"; > + pr " w.push(ptr::null());\n"; > + pr " (v, w)\n"; > + pr " })\n&...
2019 Jul 23
0
Re: [PATCH] Rust bindings: Add Rust bindings
...|v| Ok::<_, Error>({\n"; + pr " let v = arg_string_list(v)?;\n"; + pr " let mut w = (&v).into_iter()\n"; + pr " .map(|v| v.as_ptr())\n"; + pr " .collect::<Vec<_>>();\n"; + pr " w.push(ptr::null());\n"; + pr " (v, w)\n"; + pr "...
2019 Jul 20
2
Re: [PATCH] Rust bindings: Add Rust bindings
> Is this just trying if the guestfs can be linked with? Yes. In OCaml bindings, there is the corresponding test( https://github.com/libguestfs/libguestfs/blob/master/ocaml/t/guestfs_010_load.ml). I just mimicked it. If it is not required, I will remove it. divided the generated files and handmade files in rust/src/ directory. I'll send this fixed patch to this mailing list. I'm not
2019 Jul 08
2
Re: [PATCH] Add Rust bindings
On Mon, Jul 08, 2019 at 10:04:57AM +0100, Richard W.M. Jones wrote: >On Mon, Jul 08, 2019 at 10:49:55AM +0200, Martin Kletzander wrote: >> On Mon, Jul 08, 2019 at 10:10:10AM +0200, Pino Toscano wrote: >> >On Saturday, 6 July 2019 13:03:24 CEST Martin Kletzander wrote: >> >>Just one thing, the Cargo.toml includes a version under which the crate would be >>
2019 Jul 29
1
Re: [PATCH] Rust bindings: Add Rust bindings
...|v| Ok::<_, Error>({\n"; + pr " let v = arg_string_list(v)?;\n"; + pr " let mut w = (&v).into_iter()\n"; + pr " .map(|v| v.as_ptr())\n"; + pr " .collect::<Vec<_>>();\n"; + pr " w.push(ptr::null());\n"; + pr " (v, w)\n"; + pr "...
2019 Jul 17
2
[PATCH] Rust bindings: Add Rust bindings
...|v| Ok::<_, Error>({\n"; + pr " let v = arg_string_list(v)?;\n"; + pr " let mut w = (&v).into_iter()\n"; + pr " .map(|v| v.as_ptr())\n"; + pr " .collect::<Vec<_>>();\n"; + pr " w.push(ptr::null());\n"; + pr " (v, w)\n"; + pr "...
2019 Jul 26
4
Re: [PATCH] Rust bindings: Add Rust bindings
Hi Hiroyuki, sorry for the late reply. Most of the work is definitely nice! There are few notes below, although they are not big issues. I will check this patch once more on monday, especially the rust parts. Otherwise, I'd say that we are close to merging this :) On Tuesday, 23 July 2019 10:37:17 CEST Hiroyuki Katsura wrote: > From: Hiroyuki_Katsura
2024 May 30
0
[RFC PATCH 7/8] rust: add firmware abstractions
...t is nonzero. > + unsafe { bindings::get_device(self.as_raw()) }; > + } > + > + unsafe fn dec_ref(obj: ptr::NonNull<Self>) { > + // SAFETY: The safety requirements guarantee that the refcount is nonzero. > + unsafe { bindings::put_device(obj.cast().as_ptr()) } > + } > +} > > The following comments give the impression that Rust abstractions > wrongly interact with the reference count; callers check out the > reference counter. Nobody should do that. No, saying that the caller must ensure that the device "has a non-zero ref...
2019 Aug 31
1
[PATCH libnbd] Add bindings for Rust language
Still not working, but I took the latest patch and: - rebased it against libnbd 1.0 - fixed it so it handles new args and cbargs The generator now runs without warnings. This patch doesn't handle optargs at all. In C these are converted to non-optional parameter. Rust doesn't (AFAIK) have optional or labelled arguments unfortunately. Rich.
2019 Jul 07
2
[libnbd PATCH] RFC: Add bindings for Rust language
..."let ret = ret.to_str().unwrap();"; + ] + | RString -> [ + "let c_str = unsafe { CStr::from_ptr(ret as *const c_char) };"; + "let ret = c_str.to_string_lossy().into_owned();"; + "unsafe { libc::free(c_str.as_ptr() as *mut c_void) }; "; + ] + in + let real_ret = + match ret with + | RBool -> "ret != 0"; + | RErr -> "()" + | RFd + | RInt + | RInt64 + | RConstString + | RString -> "ret" +...