openresty / openresty/luajit2

lightuserdata ffi.cast

Open
#248 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
1.4k
Forks
252
Avg merge
7d 11h
Merged PRs (30d)
3

Description

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the test_ffi.lua snippet on the Windows 64-bit target and inspect the reported lua_type value against LuaJIT's FFI behavior. Determine whether the cdata results and lightuserdata question indicate a bug or need documentation, then define the expected type and a reproducible test before making a change.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, lua
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.