Git Product home page Git Product logo

Comments (5)

kunitoki avatar kunitoki commented on June 29, 2024

What do you want to do with the void* in lua land ? Is it an opaque pointer ? I suggest you wrap it in a cfunction compatible lambda and push a lightuserdata in lua land instead

from luabridge3.

venjin avatar venjin commented on June 29, 2024

It is a database library, the void* is used by blob data type.
such as:

Database db;
db.open()
db.select("xxxx");
while(db.next())
{
  Variant v = db.value(0);
  //now v is a blob type, so we get the data like:
  const void* blobPointer = v.blobValue();
  size_t blobSize = v.blobSize();
}

Now i use a function to do so which is near to what you said. It is work fine, but it looks like not pretty.

from luabridge3.

kunitoki avatar kunitoki commented on June 29, 2024

What i mean is how do you expect it to work on lua side ? if you assign this pointer to lua it needs to be marshalled over a structured type so luabridge can know what it is and how set and retrieve it from the stack. For sure you won't be accessing the blob binary bytes in lua. So create a Blob class that hides the void* and use that to transfer the pointer to lua, by using reference counting you could even safely share ownership (if you can ensure the lifetime of it somehow in c++). Or convert it to a std::vector of std::byte.

If you don't like adding a method, you could use an inline lambda instead of a function to perform the conversion.

from luabridge3.

kunitoki avatar kunitoki commented on June 29, 2024

I added support in #138 for void* and const void* as lightuserdata, it's up to you to make good use of it.

from luabridge3.

venjin avatar venjin commented on June 29, 2024

I added support in #138 for void* and const void* as lightuserdata, it's up to you to make good use of it.

ok, thanks a lot!!!

from luabridge3.

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.