Skip to content

Commit 53fabb3

Browse files
authored
Merge pull request #95 from TheBlueMatt/main
Convert primitives before passing to host language
2 parents 9aa1eeb + 294c0da commit 53fabb3

File tree

6 files changed

+5642
-5390
lines changed

6 files changed

+5642
-5390
lines changed

.github/workflows/build.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -331,14 +331,14 @@ jobs:
331331
run: rustup target install aarch64-apple-darwin
332332
- name: Fetch upstream LLVM/clang snapshot
333333
run: |
334-
wget -O clang+llvm-14.0.0-x86_64-apple-darwin.tar.xz https://github.com/llvm/llvm-project/releases/download/llvmorg-14.0.0/clang+llvm-14.0.0-x86_64-apple-darwin.tar.xz
335-
if [ "$(shasum -a 256 clang+llvm-14.0.0-x86_64-apple-darwin.tar.xz | awk '{ print $1 }')" != "cf5af0f32d78dcf4413ef6966abbfd5b1445fe80bba57f2ff8a08f77e672b9b3" ]; then
334+
wget -O clang+llvm-14.0.1-x86_64-apple-darwin.tar.xz https://github.com/llvm/llvm-project/releases/download/llvmorg-14.0.1/clang+llvm-14.0.1-x86_64-apple-darwin.tar.xz
335+
if [ "$(shasum -a 256 clang+llvm-14.0.1-x86_64-apple-darwin.tar.xz | awk '{ print $1 }')" != "43149390e95b1cdbf1d4ef2e9d214bbb6d35858ceb2df27245868e06bc4fc44c" ]; then
336336
echo "Bad hash"
337337
exit 1
338338
fi
339339
- name: Unpack upstream LLVM+clang and use it by default
340340
run: |
341-
tar xvvf clang+llvm-14.0.0-x86_64-apple-darwin.tar.xz
341+
tar xvvf clang+llvm-14.0.1-x86_64-apple-darwin.tar.xz
342342
- name: Checkout source code
343343
uses: actions/checkout@v2
344344
with:
@@ -360,7 +360,7 @@ jobs:
360360
- name: Rebuild C bindings with upstream clang, and check the sample app builds + links
361361
run: |
362362
cd ldk-c-bindings
363-
export PATH=`pwd`/clang+llvm-14.0.0-x86_64-apple-darwin/bin:$PATH
363+
export PATH=`pwd`/clang+llvm-14.0.1-x86_64-apple-darwin/bin:$PATH
364364
CC=clang ./genbindings.sh ../rust-lightning true
365365
cd ..
366366
- name: Fetch OpenJDK 16
@@ -390,7 +390,7 @@ jobs:
390390
export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)"
391391
export JAVA_HOME=`pwd`/jdk-16.0.1.jdk/Contents/Home
392392
export PATH=$JAVA_HOME/bin:$PATH
393-
export PATH=`pwd`/clang+llvm-14.0.0-x86_64-apple-darwin/bin:$PATH
393+
export PATH=`pwd`/clang+llvm-14.0.1-x86_64-apple-darwin/bin:$PATH
394394
./genbindings.sh ./ldk-c-bindings/ "-I$JAVA_HOME/include/ -I$JAVA_HOME/include/darwin -isysroot$(xcrun --show-sdk-path)" false false
395395
if [ "${{ matrix.platform }}" = "macos-11" ]; then
396396
export CC="clang --target=aarch64-apple-darwin"

gen_type_mapping.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,11 +260,19 @@ def _do_map_type_with_info(self, ty_info, print_void, ret_arr_len, is_free, hold
260260
return ConvInfo(ty_info = ty_info, arg_name = ty_info.var_name,
261261
arg_conv = None, arg_conv_name = "arg", arg_conv_cleanup = None,
262262
ret_conv = None, ret_conv_name = None, to_hu_conv = "TODO 8", to_hu_conv_name = None, from_hu_conv = None)
263-
elif ty_info.is_native_primitive:
263+
elif ty_info.is_native_primitive and ty_info.c_ty != "void":
264264
assert not is_nullable
265265
return ConvInfo(ty_info = ty_info, arg_name = ty_info.var_name,
266-
arg_conv = None, arg_conv_name = ty_info.var_name, arg_conv_cleanup = None,
267-
ret_conv = None, ret_conv_name = None, to_hu_conv = None, to_hu_conv_name = None, from_hu_conv = None)
266+
arg_conv = None, arg_conv_name = ty_info.var_name, arg_conv_cleanup = None,
267+
ret_conv = (ty_info.c_ty + " " + ty_info.var_name + "_conv = ", ";"), ret_conv_name = ty_info.var_name + "_conv",
268+
to_hu_conv = None, to_hu_conv_name = None, from_hu_conv = None)
269+
elif ty_info.c_ty == "void":
270+
assert ty_info.is_native_primitive
271+
assert not is_nullable
272+
return ConvInfo(ty_info = ty_info, arg_name = ty_info.var_name,
273+
arg_conv = None, arg_conv_name = ty_info.var_name, arg_conv_cleanup = None,
274+
ret_conv = None, ret_conv_name = ty_info.var_name,
275+
to_hu_conv = None, to_hu_conv_name = None, from_hu_conv = None)
268276
else:
269277
if ty_info.var_name == "":
270278
ty_info.var_name = "ret"

0 commit comments

Comments
 (0)