Skip to content

lightuserdata ffi.cast #248

@Lightnet

Description

@Lightnet

Just testing the windows 64 bit.

-- test_ffi.lua
local ffi = require "ffi"
ffi.cdef [[
    typedef struct { float x, y; } Pos;
]]
local p = ffi.new("Pos")
local cp_new = ffi.new("void*", p)
local cp_cast = ffi.cast("void*", p)
print("Type of p:", type(p))
print("Type of cp_new:", type(cp_new))
print("Type of cp_cast:", type(cp_cast))
Type of p:      cdata
Type of cp_new: cdata
Type of cp_cast:        cdata

I wonder if this is correct?

I wonder how to create lightuserdata lua script to c to check lightuserdata ?

One reason is I having problem what type it is. lua_type it return 10 which outside the LUA_ that I current found.

LUA_TNONE -1
LUA_TNIL 0
LUA_TBOOLEAN 1
LUA_TNUMBER 3
LUA_TSTRING 4
LUA_TTABLE 5
LUA_TFUNCTION 6
LUA_TUSERDATA 7
LUA_TTHREAD 8

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions