Skip to content

Commit

Permalink
Merge pull request #95 from TheBlueMatt/main
Browse files Browse the repository at this point in the history
Convert primitives before passing to host language
  • Loading branch information
TheBlueMatt authored Apr 15, 2022
2 parents 9aa1eeb + 294c0da commit 53fabb3
Show file tree
Hide file tree
Showing 6 changed files with 5,642 additions and 5,390 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -331,14 +331,14 @@ jobs:
run: rustup target install aarch64-apple-darwin
- name: Fetch upstream LLVM/clang snapshot
run: |
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
if [ "$(shasum -a 256 clang+llvm-14.0.0-x86_64-apple-darwin.tar.xz | awk '{ print $1 }')" != "cf5af0f32d78dcf4413ef6966abbfd5b1445fe80bba57f2ff8a08f77e672b9b3" ]; then
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
if [ "$(shasum -a 256 clang+llvm-14.0.1-x86_64-apple-darwin.tar.xz | awk '{ print $1 }')" != "43149390e95b1cdbf1d4ef2e9d214bbb6d35858ceb2df27245868e06bc4fc44c" ]; then
echo "Bad hash"
exit 1
fi
- name: Unpack upstream LLVM+clang and use it by default
run: |
tar xvvf clang+llvm-14.0.0-x86_64-apple-darwin.tar.xz
tar xvvf clang+llvm-14.0.1-x86_64-apple-darwin.tar.xz
- name: Checkout source code
uses: actions/checkout@v2
with:
Expand All @@ -360,7 +360,7 @@ jobs:
- name: Rebuild C bindings with upstream clang, and check the sample app builds + links
run: |
cd ldk-c-bindings
export PATH=`pwd`/clang+llvm-14.0.0-x86_64-apple-darwin/bin:$PATH
export PATH=`pwd`/clang+llvm-14.0.1-x86_64-apple-darwin/bin:$PATH
CC=clang ./genbindings.sh ../rust-lightning true
cd ..
- name: Fetch OpenJDK 16
Expand Down Expand Up @@ -390,7 +390,7 @@ jobs:
export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)"
export JAVA_HOME=`pwd`/jdk-16.0.1.jdk/Contents/Home
export PATH=$JAVA_HOME/bin:$PATH
export PATH=`pwd`/clang+llvm-14.0.0-x86_64-apple-darwin/bin:$PATH
export PATH=`pwd`/clang+llvm-14.0.1-x86_64-apple-darwin/bin:$PATH
./genbindings.sh ./ldk-c-bindings/ "-I$JAVA_HOME/include/ -I$JAVA_HOME/include/darwin -isysroot$(xcrun --show-sdk-path)" false false
if [ "${{ matrix.platform }}" = "macos-11" ]; then
export CC="clang --target=aarch64-apple-darwin"
Expand Down
14 changes: 11 additions & 3 deletions gen_type_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,11 +260,19 @@ def _do_map_type_with_info(self, ty_info, print_void, ret_arr_len, is_free, hold
return ConvInfo(ty_info = ty_info, arg_name = ty_info.var_name,
arg_conv = None, arg_conv_name = "arg", arg_conv_cleanup = None,
ret_conv = None, ret_conv_name = None, to_hu_conv = "TODO 8", to_hu_conv_name = None, from_hu_conv = None)
elif ty_info.is_native_primitive:
elif ty_info.is_native_primitive and ty_info.c_ty != "void":
assert not is_nullable
return ConvInfo(ty_info = ty_info, arg_name = ty_info.var_name,
arg_conv = None, arg_conv_name = ty_info.var_name, arg_conv_cleanup = None,
ret_conv = None, ret_conv_name = None, to_hu_conv = None, to_hu_conv_name = None, from_hu_conv = None)
arg_conv = None, arg_conv_name = ty_info.var_name, arg_conv_cleanup = None,
ret_conv = (ty_info.c_ty + " " + ty_info.var_name + "_conv = ", ";"), ret_conv_name = ty_info.var_name + "_conv",
to_hu_conv = None, to_hu_conv_name = None, from_hu_conv = None)
elif ty_info.c_ty == "void":
assert ty_info.is_native_primitive
assert not is_nullable
return ConvInfo(ty_info = ty_info, arg_name = ty_info.var_name,
arg_conv = None, arg_conv_name = ty_info.var_name, arg_conv_cleanup = None,
ret_conv = None, ret_conv_name = ty_info.var_name,
to_hu_conv = None, to_hu_conv_name = None, from_hu_conv = None)
else:
if ty_info.var_name == "":
ty_info.var_name = "ret"
Expand Down
Loading

0 comments on commit 53fabb3

Please sign in to comment.