Giter Club home page Giter Club logo

Comments (5)

emilio avatar emilio commented on May 26, 2024

Just a quick update: The vtables before were absolutely wrong anyway (didn't take into account destructors, etc.).

Also, MSVC packs virtual method overrides differently from the rest of the compilers, so this will require target-specific code (which is not a huge deal though, we already do it).

In any case, this is still a major amount of work, though certainly useful. I'll consider implementing it if there's enough need for it, though the logic is surely complex.

from rust-bindgen.

ggris avatar ggris commented on May 26, 2024

I was searching for information regarding this feature in bindgen. As I understand, it still has to be done as of may 2018. Is there any hope it will be considered at some point? Thanks

from rust-bindgen.

emilio avatar emilio commented on May 26, 2024

It's not really trivial, someone needs to go ahead and implement it properly, and add a bunch of tests. I'd be happy to mentor, though I'm not sure if I'd have the time to do it myself.

from rust-bindgen.

emilio avatar emilio commented on May 26, 2024

This is basically a matter of implementing this:

impl<'a> CodeGenerator for Vtable<'a> {
type Extra = Item;
fn codegen<'b>(
&self,
ctx: &BindgenContext,
result: &mut CodegenResult<'b>,
item: &Item,
) {
assert_eq!(item.id(), self.item_id);
debug_assert!(item.is_enabled_for_codegen(ctx));
// For now, generate an empty struct, later we should generate function
// pointers and whatnot.
let name = ctx.rust_ident(&self.canonical_name(ctx));
let void = helpers::ast_ty::c_void(ctx);
result.push(quote! {
#[repr(C)]
pub struct #name ( #void );
});
}
}

Which already has a reference to all methods and base classes. Making this work for simple casses (no base classes, no overloaded methods) should be trivial. From there we can improve.

from rust-bindgen.

pvdrz avatar pvdrz commented on May 26, 2024

Is this fixed via #2145?

from rust-bindgen.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.