Skip to content

Commit fe76532

Browse files
Refactoring
1 parent f2aaa52 commit fe76532

File tree

5 files changed

+49
-10
lines changed

5 files changed

+49
-10
lines changed

.github/workflows/release.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
jobs:
9+
release:
10+
runs-on: ubuntu-22.04
11+
12+
steps:
13+
- id: get-version
14+
uses: battila7/get-version-action@v2
15+
16+
- uses: actions/checkout@v3
17+
with:
18+
submodules: true
19+
20+
- id: release-asset
21+
run: |
22+
version=${{ steps.get-version.outputs.version-without-v }}
23+
cd ..
24+
cp -r lua-ffi lua-ffi-$version
25+
rm -rf lua-ffi-$version/.git*
26+
tar zcfv lua-ffi-$version.tar.gz lua-ffi-$version
27+
28+
- uses: marvinpinto/action-automatic-releases@latest
29+
with:
30+
repo_token: ${{ secrets.GITHUB_TOKEN }}
31+
draft: true
32+
prerelease: false
33+
files: ../lua-ffi-*.tar.gz

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ include(FindPkgConfig)
152152

153153
# Version settings
154154
set(LUA_FFI_VERSION_MAJOR 1)
155-
set(LUA_FFI_VERSION_MINOR 0)
155+
set(LUA_FFI_VERSION_MINOR 1)
156156
set(LUA_FFI_VERSION_PATCH 0)
157157

158158
# Define options for selecting Lua versions

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
[4]: https://github.com/zhaojh329/lua-ffi/pulls
77
[5]: https://img.shields.io/badge/Issues-welcome-brightgreen.svg?style=plastic
88
[6]: https://github.com/zhaojh329/lua-ffi/issues/new
9-
[7]: https://img.shields.io/badge/release-1.0.0-blue.svg?style=plastic
9+
[7]: https://img.shields.io/badge/release-1.1.0-blue.svg?style=plastic
1010
[8]: https://github.com/zhaojh329/lua-ffi/releases
1111
[9]: https://github.com/zhaojh329/lua-ffi/workflows/build/badge.svg
1212

ffi.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,7 @@ static struct ctype *ctype_new(lua_State *L, bool keep)
444444
struct ctype *ct = lua_newuserdata(L, sizeof(struct ctype));
445445

446446
ct->type = CTYPE_VOID;
447+
ct->ft = &ffi_type_void;
447448
ct->is_const = false;
448449

449450
luaL_getmetatable(L, CTYPE_MT);
@@ -2497,15 +2498,17 @@ static void createmetatable(lua_State *L, const char *name, const struct luaL_Re
24972498

24982499
static void create_nullptr(lua_State *L)
24992500
{
2500-
#ifndef _MSC_VER
2501-
// Currently segfaults on Win10 with MSVC
2502-
struct ctype *ct = ctype_new(L, false);
2503-
ctype_to_ptr(L, ct);
2501+
struct ctype match = {
2502+
.type = CTYPE_VOID,
2503+
.ft = &ffi_type_void
2504+
};
2505+
struct ctype *ct;
2506+
2507+
ctype_to_ptr(L, &match);
2508+
2509+
ct = ctype_lookup(L, &match, false);
2510+
25042511
cdata_ptr_set(cdata_new(L, ct, NULL), NULL);
2505-
#else
2506-
// Pushing NULL als lightuserdata has the same effect
2507-
lua_pushlightuserdata (L, NULL);
2508-
#endif
25092512
}
25102513

25112514
DLL int luaopen_ffi(lua_State *L)

tests/test.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ ffi.cdef([[
4343
]])
4444

4545
local tests = {
46+
function()
47+
print(ffi.nullptr)
48+
end,
4649
function()
4750
local a = ffi.new('int [10]', {1, 2, 3})
4851
assert(a[0] == 1)

0 commit comments

Comments
 (0)