mirror of
https://github.com/rizinorg/rz-bindgen.git
synced 2026-11-07 23:02:04 -10:00
Compare commits
8
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
968f931b95 | ||
|
|
b8eba9a251 | ||
|
|
63e4acd999 | ||
|
|
bc98be658d | ||
|
|
efe87d6d1b | ||
|
|
9f0fea8837 | ||
|
|
7172f6e9ba | ||
|
|
66dd4bf9e9 |
No files matched your search
+12
-99
@@ -1,133 +1,46 @@
|
||||
name: build
|
||||
name: run-rz-bindgen
|
||||
on:
|
||||
push:
|
||||
workflow_dispatch:
|
||||
workflow_call:
|
||||
inputs:
|
||||
external_call:
|
||||
description: 'To distinguish workflow_call from regular push'
|
||||
type: boolean
|
||||
required: false
|
||||
default: true
|
||||
rizin_ref:
|
||||
required: false
|
||||
type: string
|
||||
default: 'dev'
|
||||
|
||||
jobs:
|
||||
pypa-wheels:
|
||||
run-bindgen:
|
||||
name: Run bindgen
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-24.04, windows-2019, macos-14]
|
||||
os: [ubuntu-latest, windows-2019, macos-latest]
|
||||
|
||||
steps:
|
||||
- name: Install SWIG with Homebrew
|
||||
if: matrix.os == 'macos-14' && matrix.enabled
|
||||
run: brew install swig
|
||||
|
||||
- name: Checkout rz-bindgen
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v3
|
||||
|
||||
# runned only from workflow_call
|
||||
- name: Checkout rizin
|
||||
if: ${{ inputs.external_call }}
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
repository: rizinorg/rizin
|
||||
path: rizin
|
||||
ref: ${{ inputs.rizin_ref }}
|
||||
|
||||
- name: Checkout rizin (stable)
|
||||
if: ${{ !inputs.external_call && ((github.ref_name == 'stable') || (github.base_ref == 'stable')) }}
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: rizinorg/rizin
|
||||
path: rizin
|
||||
ref: stable
|
||||
|
||||
- name: Checkout rizin (dev)
|
||||
if: ${{ !inputs.external_call && ((github.ref_name != 'stable') && (github.base_ref != 'stable')) }}
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: rizinorg/rizin
|
||||
path: rizin
|
||||
ref: dev
|
||||
|
||||
- name: Build rz-bindgen
|
||||
uses: pypa/[email protected]
|
||||
- name: Run rz-bindgen
|
||||
uses: pypa/[email protected]
|
||||
|
||||
- name: Upload sdist
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: sdist-${{ matrix.os }}
|
||||
name: sdist
|
||||
path: dist/*.tar.gz
|
||||
|
||||
- name: Upload wheels
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: wheels-${{ matrix.os }}
|
||||
name: wheels
|
||||
path: wheelhouse/*.whl
|
||||
|
||||
ubuntu-default-llvm:
|
||||
runs-on: ubuntu-24.04
|
||||
|
||||
steps:
|
||||
- name: Checkout rz-bindgen
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
path: rz-bindgen
|
||||
|
||||
# runned only from workflow_call
|
||||
- name: Checkout rizin
|
||||
if: ${{ inputs.external_call }}
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: rizinorg/rizin
|
||||
path: rizin
|
||||
ref: ${{ inputs.rizin_ref }}
|
||||
|
||||
- name: Checkout rizin (stable)
|
||||
if: ${{ !inputs.external_call && ((github.ref_name == 'stable') || (github.base_ref == 'stable')) }}
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: rizinorg/rizin
|
||||
path: rizin
|
||||
ref: stable
|
||||
|
||||
- name: Checkout rizin (dev)
|
||||
if: ${{ !inputs.external_call && ((github.ref_name != 'stable') && (github.base_ref != 'stable')) }}
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: rizinorg/rizin
|
||||
path: rizin
|
||||
ref: dev
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
sudo apt update
|
||||
sudo apt-get --assume-yes install cmake swig pkg-config clang libclang-dev llvm wget unzip python3-wheel python3-setuptools build-essential python3-pip
|
||||
sudo pip3 install meson ninja
|
||||
|
||||
- name: Install rizin
|
||||
run: |
|
||||
export PATH=$PATH:/usr/local/bin
|
||||
meson setup --prefix=/usr --buildtype=release build && ninja -C build && sudo ninja -C build install
|
||||
working-directory: rizin
|
||||
|
||||
- name: Build rz-bindgen
|
||||
run: |
|
||||
meson setup --prefix=/usr -Dplugin=enabled build
|
||||
meson compile -C build
|
||||
sudo meson install -C build
|
||||
working-directory: rz-bindgen
|
||||
|
||||
- name: Test python lang plugin
|
||||
run: rizin -qc "Ll" | grep "Python SWIG"
|
||||
|
||||
- name: Test rizin.py
|
||||
run: |
|
||||
echo "import rizin" > testimport.py
|
||||
python3 testimport.py
|
||||
@@ -1,8 +1,8 @@
|
||||
name: lint
|
||||
name: linting
|
||||
on: push
|
||||
jobs:
|
||||
licenses:
|
||||
runs-on: ubuntu-24.04
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout rz-bindgen
|
||||
uses: actions/checkout@v3
|
||||
@@ -10,7 +10,7 @@ jobs:
|
||||
uses: fsfe/reuse-action@v1
|
||||
|
||||
python:
|
||||
runs-on: ubuntu-24.04
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout rz-bindgen
|
||||
uses: actions/checkout@v3
|
||||
@@ -19,7 +19,7 @@ jobs:
|
||||
pip install mypy pyflakes pylint black
|
||||
- name: Run mypy
|
||||
run: |
|
||||
mypy --disable-error-code misc src/main.py
|
||||
mypy src/main.py
|
||||
if: ${{ always() }}
|
||||
- name: Run pyflakes
|
||||
run: |
|
||||
@@ -35,7 +35,7 @@ jobs:
|
||||
if: ${{ always() }}
|
||||
|
||||
codeql:
|
||||
runs-on: ubuntu-24.04
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
security-events: write
|
||||
steps:
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
name: release
|
||||
name: release-rz-bindgen
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
@@ -7,22 +7,23 @@ on:
|
||||
|
||||
jobs:
|
||||
extract-rizin-version:
|
||||
runs-on: ubuntu-24.04
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
rizin_version: ${{ steps.extract_version.outputs.result }}
|
||||
steps:
|
||||
- id: extract_version
|
||||
run: echo "result=$(echo ${{ github.ref }} | cut -d'_' -f1 | cut -d'-' -f2-)" >> "$GITHUB_OUTPUT"
|
||||
|
||||
build:
|
||||
run-bindgen:
|
||||
uses: ./.github/workflows/ci.yml
|
||||
needs: [extract-rizin-version]
|
||||
with:
|
||||
rizin_ref: ${{ needs.extract-rizin-version.outputs.rizin_version }}
|
||||
|
||||
publish-pypi:
|
||||
runs-on: ubuntu-24.04
|
||||
needs: [build]
|
||||
name: Publish PyPi
|
||||
runs-on: ubuntu-latest
|
||||
needs: [run-bindgen]
|
||||
steps:
|
||||
- name: Download artifacts
|
||||
uses: actions/download-artifact@v3
|
||||
|
||||
@@ -9,9 +9,9 @@ For usage information, see [the documentation](doc/README.md).
|
||||
## Building python plugin
|
||||
Requirements:
|
||||
- rizin > 0.4.1 (needs commit [59b38e6](https://github.com/rizinorg/rizin/commit/59b38e6efaf00b9b9869e0ec5baba4f1b9605f37))
|
||||
- meson >= 1.1.0
|
||||
- meson
|
||||
- ninja
|
||||
- python >= 3.10
|
||||
- python >= 3.7
|
||||
- libclang
|
||||
- SWIG
|
||||
|
||||
|
||||
+8
-22
@@ -4,48 +4,34 @@
|
||||
set -ex
|
||||
|
||||
# Install deps
|
||||
pygt311=$(python3 -c 'import sys; print(0) if sys.version_info.minor > 11 else print(1)' 2>&1)
|
||||
if [[ $pygt311 == '0' ]]; then
|
||||
pip3 install --break-system-packages meson ninja meson-python build
|
||||
else
|
||||
pip3 install meson ninja meson-python build
|
||||
fi
|
||||
pip3 install meson ninja meson-python build
|
||||
|
||||
if command -v brew; then
|
||||
brew install --require-sha swig
|
||||
elif command -v apt; then
|
||||
if command -v apt; then
|
||||
set +e
|
||||
grep VERSION_CODENAME=stretch /etc/os-release >/dev/null 2>/dev/null
|
||||
if [[ $? == 0 ]] ; then
|
||||
# Required because manylinux_2_24 uses Debian Stretch and the repos are not available anymore
|
||||
# Required because manylinux_2_24 uses Debian Stretch and the repos are not available anymore
|
||||
echo "deb http://archive.debian.org/debian stretch main" > /etc/apt/sources.list
|
||||
echo "deb http://archive.debian.org/debian-security stretch/updates main" >> /etc/apt/sources.list
|
||||
echo "Acquire::Check-Valid-Until no;" > /etc/apt/apt.conf.d/99no-check-valid-until
|
||||
fi
|
||||
set -e
|
||||
apt update && apt install --assume-yes libclang-7-dev clang-7 llvm-7 sudo
|
||||
apt update && apt install --assume-yes libclang-7-dev clang-7 llvm-7
|
||||
elif command -v apk; then
|
||||
apk update && apk add clang-dev sudo
|
||||
elif command -v yum; then
|
||||
yum -y install llvm-toolset-7.0 llvm-toolset-7.0-llvm-devel sudo
|
||||
# (CentOS 7) Uncomment following lines to see required paths in build log:
|
||||
# yum -y install centos-release-scl
|
||||
# source scl_source enable llvm-toolset-7.0 || true
|
||||
apk update && apk add clang-dev
|
||||
elif command -v brew; then
|
||||
brew install pkg-config
|
||||
fi
|
||||
|
||||
pushd rizin
|
||||
|
||||
if [[ "$OSTYPE" =~ msys* ]]; then
|
||||
meson setup --buildtype=release --prefix='c:/rizin' --vsenv build
|
||||
meson install -C build
|
||||
else
|
||||
if [[ "$OSTYPE" =~ linux* ]]; then
|
||||
export CFLAGS="-include linux/limits.h"
|
||||
fi
|
||||
meson setup --buildtype=release --libdir=lib build
|
||||
sudo meson install -C build
|
||||
fi
|
||||
|
||||
meson install -C build
|
||||
popd
|
||||
|
||||
if command -v apt; then
|
||||
|
||||
+9
-12
@@ -1,7 +1,7 @@
|
||||
project('rz-bindgen', 'c', 'cpp',
|
||||
version: '0.6.0',
|
||||
license: 'LGPL3',
|
||||
meson_version: '>=0.62.2',
|
||||
meson_version: '>=0.53.0',
|
||||
default_options: ['python.install_env=auto'])
|
||||
|
||||
pymod = import('python')
|
||||
@@ -19,9 +19,9 @@ target_sphinx = targets.contains('sphinx')
|
||||
doxygen_path = get_option('doxygen_path')
|
||||
|
||||
if clang_path == ''
|
||||
llvm_config = find_program('llvm-config', 'llvm-config-7', required: false)
|
||||
if llvm_config.found()
|
||||
clang_path = run_command(llvm_config, '--libdir', check: true).stdout().strip()
|
||||
llvm = dependency('llvm', required: false)
|
||||
if llvm.found()
|
||||
clang_path = llvm.get_variable(cmake: 'LLVM_LIBRARY_DIRS', configtool: 'libdir', default_value: 'none')
|
||||
elif build_machine.system() == 'darwin'
|
||||
clang_path = '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/'
|
||||
elif build_machine.system() == 'windows'
|
||||
@@ -49,7 +49,7 @@ if clang_args == ''
|
||||
clang = find_program('clang', 'clang-7', required: false)
|
||||
if clang.found()
|
||||
clang_args += ' -resource-dir='
|
||||
clang_args += '"' + run_command(clang, '-print-resource-dir', check: true).stdout().strip() + '"'
|
||||
clang_args += run_command(clang, '-print-resource-dir', check: true).stdout().strip()
|
||||
endif
|
||||
if build_machine.system() == 'darwin'
|
||||
clang_args += ' -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk'
|
||||
@@ -108,7 +108,6 @@ if target_swig or target_sphinx
|
||||
endif
|
||||
|
||||
if target_swig
|
||||
wheel = get_option('wheel')
|
||||
swig_output = custom_target(
|
||||
'swig_output',
|
||||
input: bindgen_outputs[swig_source_idx],
|
||||
@@ -118,7 +117,7 @@ if target_swig
|
||||
'-python', '-c++',
|
||||
'-outdir', '@OUTDIR@', '@INPUT@'
|
||||
],
|
||||
install: wheel or host_machine.system() == 'windows',
|
||||
install: true,
|
||||
install_dir: [py.get_install_dir(), false]
|
||||
)
|
||||
swig_py = swig_output[0]
|
||||
@@ -128,18 +127,15 @@ if target_swig
|
||||
rz_core = dependency('rz_core')
|
||||
endif
|
||||
|
||||
ext_mod = py.extension_module(
|
||||
py.extension_module(
|
||||
'_rizin',
|
||||
swig_wrap,
|
||||
dependencies: [
|
||||
py.dependency(),
|
||||
rz_core,
|
||||
],
|
||||
install: wheel or host_machine.system() == 'windows',
|
||||
install: true,
|
||||
)
|
||||
if host_machine.system() != 'windows'
|
||||
meson.add_install_script('py_install.py', swig_py.full_path(), ext_mod.full_path())
|
||||
endif
|
||||
endif
|
||||
|
||||
if target_sphinx
|
||||
@@ -159,3 +155,4 @@ endif
|
||||
if get_option('plugin').enabled()
|
||||
subdir('plugin')
|
||||
endif
|
||||
|
||||
@@ -4,6 +4,5 @@ option('rizin_include_path', type: 'string', value: '')
|
||||
option('targets', type: 'array', choices: ['SWIG', 'sphinx'], value: ['SWIG'])
|
||||
|
||||
option('plugin', type: 'feature', value: 'disabled')
|
||||
option('wheel', type: 'boolean', value: false, description: 'Set up for pypa wheel build')
|
||||
|
||||
option('doxygen_path', type: 'string', value: '')
|
||||
@@ -2,13 +2,6 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-only
|
||||
|
||||
#include <Python.h>
|
||||
/**
|
||||
* Some defines in rz_userconf.h are conflicting with the ones in python.h
|
||||
**/
|
||||
#undef HAVE_EXPLICIT_BZERO
|
||||
#undef HAVE_SIGACTION
|
||||
#undef HAVE_REALPATH
|
||||
|
||||
#include <rz_core.h>
|
||||
#include <rz_util/rz_file.h>
|
||||
#include <swig_runtime.h>
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
SPDX-FileCopyrightText: 2024 kazarmy <[email protected]>
|
||||
SPDX-License-Identifier: LGPL-3.0-only
|
||||
"""
|
||||
|
||||
import os
|
||||
import shutil
|
||||
import sys
|
||||
import sysconfig
|
||||
|
||||
def install_files(scheme):
|
||||
for file in sys.argv[1:]:
|
||||
if file.endswith(".py"):
|
||||
dest_type = 'purelib'
|
||||
elif file.endswith(".so"):
|
||||
dest_type = 'platlib'
|
||||
install_dir = sysconfig.get_path(dest_type, scheme)
|
||||
shutil.copy(file, install_dir)
|
||||
print(f"Installing {os.path.basename(file)} to {install_dir}")
|
||||
|
||||
try:
|
||||
install_files(sysconfig.get_default_scheme())
|
||||
except PermissionError:
|
||||
print("Installing to user site-packages since normal site-packages is not writeable")
|
||||
install_files(f"{os.name}_user")
|
||||
@@ -1,9 +1,8 @@
|
||||
[MESSAGES CONTROL]
|
||||
disable=too-many-instance-attributes,
|
||||
too-few-public-methods,
|
||||
too-few-public-methods,
|
||||
too-many-branches,
|
||||
too-many-return-statements,
|
||||
too-many-locals,
|
||||
too-many-arguments,
|
||||
broad-exception-raised,
|
||||
fixme
|
||||
+16
-11
@@ -5,30 +5,35 @@ requires = [
|
||||
]
|
||||
build-backend = "mesonpy"
|
||||
|
||||
[tool.meson-python.args]
|
||||
setup = ['-Dwheel=true']
|
||||
|
||||
[tool.cibuildwheel]
|
||||
build-verbosity = 3
|
||||
before-all = "bash {project}/cibw_before_all.sh"
|
||||
manylinux-x86_64-image = "manylinux2014"
|
||||
manylinux-x86_64-image = "manylinux_2_24"
|
||||
manylinux-i686-image = "manylinux_2_24"
|
||||
manylinux-aarch64-image = "manylinux_2_24"
|
||||
manylinux-ppc64le-image = "manylinux_2_24"
|
||||
manylinux-s390x-image = "manylinux_2_24"
|
||||
manylinux-pypy_x86_64-image = "manylinux_2_24"
|
||||
manylinux-pypy_i686-image = "manylinux_2_24"
|
||||
manylinux-pypy_aarch64-image = "manylinux_2_24"
|
||||
skip = "pp*"
|
||||
|
||||
[tool.cibuildwheel.linux]
|
||||
environment = { PATH="/opt/rh/llvm-toolset-7.0/root/usr/bin:/opt/rh/llvm-toolset-7.0/root/usr/sbin:$PATH", LD_LIBRARY_PATH="/opt/rh/llvm-toolset-7.0/root/usr/lib64:$LD_LIBRARY_PATH" }
|
||||
archs = ["x86_64"]
|
||||
|
||||
[tool.cibuildwheel.windows]
|
||||
environment = { CMAKE_PREFIX_PATH="C:/rizin" }
|
||||
environment = { CMAKE_PREFIX_PATH="C:\\rizin" }
|
||||
archs = ["AMD64"]
|
||||
|
||||
[tool.cibuildwheel.linux]
|
||||
#archs = ["x86_64", "aarch64", "ppc64le", "s390x"]
|
||||
archs = ["x86_64", "aarch64"]
|
||||
|
||||
[tool.cibuildwheel.macos]
|
||||
environment = { PATH="/opt/homebrew/bin:$PATH", MACOSX_DEPLOYMENT_TARGET="14.0" }
|
||||
#archs = ["x86_64", "arm64", "universal2"]
|
||||
archs = ["x86_64"]
|
||||
|
||||
[project]
|
||||
name = "rz-bindings"
|
||||
dynamic = [
|
||||
'version',
|
||||
]
|
||||
requires-python = ">=3.9"
|
||||
requires-python = ">=3.8"
|
||||
readme = "README.md"
|
||||
@@ -54,7 +54,8 @@ class Class:
|
||||
typedef: str,
|
||||
ignore_fields: Optional[Set[str]] = ...,
|
||||
rename_fields: Optional[Dict[str, str]] = ...,
|
||||
): ...
|
||||
):
|
||||
...
|
||||
|
||||
@overload
|
||||
def __init__(
|
||||
@@ -65,7 +66,8 @@ class Class:
|
||||
struct: str,
|
||||
ignore_fields: Optional[Set[str]] = ...,
|
||||
rename_fields: Optional[Dict[str, str]] = ...,
|
||||
): ...
|
||||
):
|
||||
...
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
|
||||
+4
-2
@@ -46,10 +46,12 @@ class MacroEnum:
|
||||
defines: OrderedDict[str, str]
|
||||
|
||||
@overload
|
||||
def __init__(self, header: Header, *defines: str): ...
|
||||
def __init__(self, header: Header, *defines: str):
|
||||
...
|
||||
|
||||
@overload
|
||||
def __init__(self, header: Header, *, prefix: str): ...
|
||||
def __init__(self, header: Header, *, prefix: str):
|
||||
...
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
|
||||
+4
-2
@@ -28,7 +28,8 @@ class Func:
|
||||
*,
|
||||
default_args: Optional[Dict[str, str]] = ...,
|
||||
typemaps: Optional[List[Typemap]] = ...,
|
||||
): ...
|
||||
):
|
||||
...
|
||||
|
||||
@overload
|
||||
def __init__(
|
||||
@@ -38,7 +39,8 @@ class Func:
|
||||
cfunc: "CFunc",
|
||||
default_args: Optional[Dict[str, str]] = ...,
|
||||
typemaps: Optional[List[Typemap]] = ...,
|
||||
): ...
|
||||
):
|
||||
...
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
SPDX-FileCopyrightText: 2022 wingdeans <[email protected]>
|
||||
SPDX-License-Identifier: LGPL-3.0-only
|
||||
"""
|
||||
|
||||
from typing import List, Dict, TYPE_CHECKING
|
||||
|
||||
from clang.cindex import Cursor, CursorKind
|
||||
|
||||
+16
-53
@@ -147,11 +147,13 @@ def bind_analysis(analysis_h: Header) -> None:
|
||||
"""
|
||||
RzAnalysis
|
||||
"""
|
||||
analysis_h.ignore("rz_analysis_version")
|
||||
|
||||
rz_analysis = Class(
|
||||
analysis_h,
|
||||
typedef="RzAnalysis",
|
||||
ignore_fields={"leaddrs"},
|
||||
rename_fields={},
|
||||
rename_fields={"type_links": "_type_links"},
|
||||
)
|
||||
|
||||
rz_analysis_function = Class(analysis_h, typedef="RzAnalysisFunction")
|
||||
@@ -164,7 +166,6 @@ def bind_analysis(analysis_h: Header) -> None:
|
||||
|
||||
Class(analysis_h, typedef="RzAnalysisBlock")
|
||||
Class(analysis_h, typedef="RzAnalysisEsil")
|
||||
Class(analysis_h, typedef="RzAnalysisEsilInterState")
|
||||
Class(analysis_h, typedef="RzAnalysisPlugin")
|
||||
|
||||
Class(
|
||||
@@ -258,6 +259,7 @@ def bind_cons(cons_h: Header) -> None:
|
||||
typedef="RzCons",
|
||||
ignore_fields={"term_raw", "term_buf"}, # struct termios
|
||||
rename_fields={
|
||||
"lastline": "_lastline",
|
||||
"echo": "_echo",
|
||||
"highlight": "_highlight",
|
||||
"newline": "_newline",
|
||||
@@ -327,29 +329,6 @@ def bind_core(core_h: Header) -> None:
|
||||
|
||||
Class(core_h, typedef="RzCoreFile")
|
||||
|
||||
@threaded_header("rz_util/rz_annotated_code.h")
|
||||
def bind_annotated_code(annotated_code_h: Header) -> None:
|
||||
"""
|
||||
RzAnnotatedCode
|
||||
"""
|
||||
rz_code_annotation = Class(
|
||||
annotated_code_h,
|
||||
typedef="RzCodeAnnotation",
|
||||
struct="rz_code_annotation_t",
|
||||
)
|
||||
rz_code_annotation.add_prefixed_methods("rz_annotation_")
|
||||
rz_code_annotation.add_prefixed_funcs("rz_annotation_")
|
||||
|
||||
rz_annotated_code = Class(
|
||||
annotated_code_h,
|
||||
typedef="RzAnnotatedCode",
|
||||
struct="rz_annotated_code_t",
|
||||
)
|
||||
rz_annotated_code.add_constructor("rz_annotated_code_new")
|
||||
rz_annotated_code.add_destructor("rz_annotated_code_free")
|
||||
|
||||
rz_annotated_code.add_prefixed_methods("rz_annotated_code_")
|
||||
rz_annotated_code.add_prefixed_funcs("rz_annotated_code_")
|
||||
|
||||
@threaded_header("rz_flag.h")
|
||||
def bind_flag(flag_h: Header) -> None:
|
||||
@@ -438,7 +417,15 @@ def bind_sdb(sdb_h: Header) -> None:
|
||||
Class(sdb_h, typedef="Sdb", ignore_fields={"db", "m"})
|
||||
|
||||
|
||||
@threaded_header("rz_util/ht_pp.h")
|
||||
@threaded_header("sdb/ls.h")
|
||||
def bind_ls(ls_h: Header) -> None:
|
||||
"""
|
||||
ls
|
||||
"""
|
||||
Class(ls_h, typedef="SdbList")
|
||||
|
||||
|
||||
@threaded_header("sdb/ht_pp.h")
|
||||
def bind_ht_pp(ht_pp_h: Header) -> None:
|
||||
"""
|
||||
ht_pp
|
||||
@@ -446,7 +433,7 @@ def bind_ht_pp(ht_pp_h: Header) -> None:
|
||||
Class(ht_pp_h, typedef="HtPP")
|
||||
|
||||
|
||||
@threaded_header("rz_util/ht_pu.h")
|
||||
@threaded_header("sdb/ht_pu.h")
|
||||
def bind_ht_pu(ht_pu_h: Header) -> None:
|
||||
"""
|
||||
ht_pu
|
||||
@@ -454,7 +441,7 @@ def bind_ht_pu(ht_pu_h: Header) -> None:
|
||||
Class(ht_pu_h, typedef="HtPU")
|
||||
|
||||
|
||||
@threaded_header("rz_util/ht_up.h")
|
||||
@threaded_header("sdb/ht_up.h")
|
||||
def bind_ht_up(ht_up_h: Header) -> None:
|
||||
"""
|
||||
ht_up
|
||||
@@ -462,33 +449,9 @@ def bind_ht_up(ht_up_h: Header) -> None:
|
||||
Class(ht_up_h, typedef="HtUP")
|
||||
|
||||
|
||||
@threaded_header("rz_util/ht_uu.h")
|
||||
@threaded_header("sdb/ht_uu.h")
|
||||
def bind_ht_uu(ht_uu_h: Header) -> None:
|
||||
"""
|
||||
ht_uu
|
||||
"""
|
||||
Class(ht_uu_h, typedef="HtUU")
|
||||
|
||||
|
||||
@threaded_header("rz_util/ht_sp.h")
|
||||
def bind_ht_sp(ht_sp_h: Header) -> None:
|
||||
"""
|
||||
ht_sp
|
||||
"""
|
||||
Class(ht_sp_h, typedef="HtSP")
|
||||
|
||||
|
||||
@threaded_header("rz_util/ht_ss.h")
|
||||
def bind_ht_ss(ht_ss_h: Header) -> None:
|
||||
"""
|
||||
ht_ss
|
||||
"""
|
||||
Class(ht_ss_h, typedef="HtSS")
|
||||
|
||||
|
||||
@threaded_header("rz_util/ht_su.h")
|
||||
def bind_ht_su(ht_su_h: Header) -> None:
|
||||
"""
|
||||
ht_su
|
||||
"""
|
||||
Class(ht_su_h, typedef="HtSU")
|
||||
+2
-2
@@ -2224,7 +2224,7 @@ class Type(Structure):
|
||||
|
||||
return result
|
||||
|
||||
assert self.kind in (TypeKind.FUNCTIONPROTO, TypeKind.FUNCTIONNOPROTO)
|
||||
assert self.kind == TypeKind.FUNCTIONPROTO
|
||||
return ArgumentsIterator(self)
|
||||
|
||||
@property
|
||||
@@ -2320,7 +2320,7 @@ class Type(Structure):
|
||||
|
||||
def is_function_variadic(self):
|
||||
"""Determine whether this function Type is a variadic function type."""
|
||||
assert self.kind in (TypeKind.FUNCTIONPROTO, TypeKind.FUNCTIONNOPROTO)
|
||||
assert self.kind == TypeKind.FUNCTIONPROTO
|
||||
|
||||
return conf.lib.clang_isFunctionTypeVariadic(self)
|
||||
|
||||
|
||||
@@ -38,7 +38,6 @@ class TypeKind(Enum):
|
||||
POINTER: TypeKind
|
||||
CONSTANTARRAY: TypeKind
|
||||
FUNCTIONPROTO: TypeKind
|
||||
FUNCTIONNOPROTO: TypeKind
|
||||
INCOMPLETEARRAY: TypeKind
|
||||
|
||||
RECORD: TypeKind
|
||||
@@ -87,7 +86,6 @@ class Type:
|
||||
class SourceLocation:
|
||||
class File:
|
||||
name: str
|
||||
|
||||
file: File
|
||||
line: int
|
||||
column: int
|
||||
|
||||
+9
-13
@@ -98,20 +98,18 @@ class HeaderBuilder:
|
||||
|
||||
assert rizin_include_path
|
||||
filename = os.path.abspath(os.path.join(rizin_include_path, *name_segments))
|
||||
assert os.path.exists(filename), f"File {filename} does not exist"
|
||||
|
||||
# Fix sdb path if using source librz/include
|
||||
if name_segments[0] == "sdb" and not os.path.exists(filename):
|
||||
name_segments = ["..", "util", "sdb", "src"] + name_segments[1:]
|
||||
filename = os.path.abspath(os.path.join(rizin_include_path, *name_segments))
|
||||
|
||||
assert os.path.exists(filename)
|
||||
self.filename = filename
|
||||
|
||||
# Parse ht_inc.h if importing SDB hashtable header
|
||||
self.extra_filename = None
|
||||
if name_segments[-1] in [
|
||||
"ht_pp.h",
|
||||
"ht_pu.h",
|
||||
"ht_up.h",
|
||||
"ht_uu.h",
|
||||
"ht_sp.h",
|
||||
"ht_ss.h",
|
||||
"ht_su.h",
|
||||
]:
|
||||
if name_segments[-1] in ["ht_pp.h", "ht_pu.h", "ht_up.h", "ht_uu.h"]:
|
||||
self.extra_filename = "ht_inc.h"
|
||||
|
||||
def translation_unit(self) -> TranslationUnit:
|
||||
@@ -181,9 +179,7 @@ class Header:
|
||||
continue
|
||||
|
||||
# Check for redefinitions
|
||||
if (
|
||||
name in self.cursor_kinds and cursor.kind == self.cursor_kinds[name]
|
||||
): # Redefinition
|
||||
if name in self.cursor_kinds: # Redefinition
|
||||
prev = self.cursors[cursor.kind][name]
|
||||
if cursor.kind == CursorKind.STRUCT_DECL:
|
||||
assert prev.kind == CursorKind.STRUCT_DECL
|
||||
|
||||
@@ -100,32 +100,29 @@ def wrap_type(type_: Type) -> CType:
|
||||
"""
|
||||
Wrap a type
|
||||
"""
|
||||
orig_type = type_
|
||||
while type_.kind == TypeKind.ELABORATED:
|
||||
type_ = type_.get_named_type()
|
||||
|
||||
# Complex types
|
||||
if type_.kind == TypeKind.POINTER:
|
||||
return CPointerType(orig_type, pointee=wrap_type(type_.get_pointee()))
|
||||
return CPointerType(type_, pointee=wrap_type(type_.get_pointee()))
|
||||
|
||||
if type_.kind in [TypeKind.CONSTANTARRAY, TypeKind.INCOMPLETEARRAY]:
|
||||
array_t = CArrayType(
|
||||
orig_type, element=wrap_type(type_.get_array_element_type())
|
||||
)
|
||||
array_t = CArrayType(type_, element=wrap_type(type_.get_array_element_type()))
|
||||
if type_.kind == TypeKind.CONSTANTARRAY:
|
||||
array_t.element_count = type_.element_count
|
||||
return array_t
|
||||
|
||||
if type_.kind == TypeKind.TYPEDEF:
|
||||
return CTypedefType(
|
||||
orig_type,
|
||||
type_,
|
||||
canonical=wrap_type(type_.get_canonical()),
|
||||
cursor=type_.get_declaration(),
|
||||
)
|
||||
|
||||
if type_.kind in (TypeKind.FUNCTIONPROTO, TypeKind.FUNCTIONNOPROTO):
|
||||
if type_.kind == TypeKind.FUNCTIONPROTO:
|
||||
return CFunctionType(
|
||||
orig_type,
|
||||
type_,
|
||||
result=wrap_type(type_.get_result()),
|
||||
args=[wrap_type(arg) for arg in type_.argument_types()],
|
||||
)
|
||||
@@ -135,7 +132,7 @@ def wrap_type(type_: Type) -> CType:
|
||||
if decl_spelling.startswith("const "):
|
||||
decl_spelling = decl_spelling[len("const ") :]
|
||||
|
||||
return CRecordType(orig_type, decl_spelling=decl_spelling)
|
||||
return CRecordType(type_, decl_spelling=decl_spelling)
|
||||
|
||||
# Primitive types
|
||||
if type_.kind in [
|
||||
|
||||
@@ -265,11 +265,6 @@ def write_func(writer: Writer, func: Func, name: str, kind: FuncKind) -> None:
|
||||
if arg_name == "self":
|
||||
arg_name = "_self"
|
||||
|
||||
# if function arg is the same as the function name
|
||||
# we rename the argument
|
||||
if arg_name == name:
|
||||
arg_name += "_arg"
|
||||
|
||||
arg_decl = stringify_decl(
|
||||
arg_name,
|
||||
arg.ctype,
|
||||
|
||||
+1
-12
@@ -23,7 +23,6 @@ and definitions. It also does this for Rizin annotations, such as RZ_OWN. This w
|
||||
by defining the RZ_BINDINGS preprocessor flag, which sets the annotations to expand to
|
||||
__attribute__((annotate)), which can be picked up by libclang.
|
||||
"""
|
||||
|
||||
from typing import List, Dict, Set, TypedDict, Optional, cast
|
||||
|
||||
import os
|
||||
@@ -164,17 +163,7 @@ def cursor_get_comment(cursor: Cursor, *, packed: bool = False) -> Optional[str]
|
||||
warn(
|
||||
f"Type comment at {stringify_location(cursor.location)} should not have pointer"
|
||||
)
|
||||
elif typeref_spelling in {
|
||||
"HtPP",
|
||||
"HtUP",
|
||||
"HtUU",
|
||||
"HtPU",
|
||||
"HtSP",
|
||||
"HtSS",
|
||||
"HtSU",
|
||||
"RBTree",
|
||||
"SdbList",
|
||||
}:
|
||||
elif typeref_spelling in {"HtPP", "HtUP", "HtUU", "RBTree", "SdbList"}:
|
||||
pass
|
||||
else:
|
||||
warn(
|
||||
|
||||
@@ -13,7 +13,7 @@ void register_swig_command(const char *str, CmdDirector *director,
|
||||
} else {
|
||||
char *dup = strdup(str);
|
||||
dup[len - 1] = '\0';
|
||||
parent = (RzCmdDesc *)ht_sp_find($self->ht_cmds, dup, NULL);
|
||||
parent = (RzCmdDesc *)ht_pp_find($self->ht_cmds, dup, NULL);
|
||||
free(dup);
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ void register_swig_command(const char *str, CmdDirector *director,
|
||||
throw "Could not get parent RzCmdDesc";
|
||||
}
|
||||
|
||||
RzCmdDesc *prev = (RzCmdDesc *)ht_sp_find($self->ht_cmds, str, NULL);
|
||||
RzCmdDesc *prev = (RzCmdDesc *)ht_pp_find($self->ht_cmds, str, NULL);
|
||||
std::string cmd(str);
|
||||
if (prev) { // Update existing RzCmdDesc
|
||||
auto it = SWIGCmds.find(cmd);
|
||||
|
||||
Reference in new issue
Block a user