Skip to content

Commit 691198f

Browse files
committed
Merge remote-tracking branch 'origin/master' into devel
2 parents 37cdadd + f19f558 commit 691198f

File tree

7 files changed

+31
-8
lines changed

7 files changed

+31
-8
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
strategy:
1212
fail-fast: false
1313
matrix:
14-
version: [29, 30, 31, 32, 33, 34, 35, 36, 37]
14+
version: [29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]
1515
runs-on: ubuntu-latest
1616
name: Binder_on_Fedora${{ matrix.version }}
1717
container:

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ if (Clang_FOUND AND LLVM_FOUND AND NOT LLVMCONFIG )
4646
${LLVM_LIBRARY_DIR}/../../lib/clang/${LLVM_VERSION}/include
4747
${LLVM_LIBRARY_DIR}/../../lib64/clang/${LLVM_VERSION}/include
4848
${CLANG_INCLUDE_DIRS}/clang/${LLVM_VERSION}/include
49+
${LLVM_LIBRARY_DIR}/clang/${LLVM_VERSION_MAJOR}/include
50+
${LLVM_LIBRARY_DIR}/../clang/${LLVM_VERSION_MAJOR}/include
51+
${LLVM_LIBRARY_DIR}/../../lib/clang/${LLVM_VERSION_MAJOR}/include
52+
${LLVM_LIBRARY_DIR}/../../lib64/clang/${LLVM_VERSION_MAJOR}/include
53+
${CLANG_INCLUDE_DIRS}/clang/${LLVM_VERSION_MAJOR}/include
4954
${LLVM_LIBRARY_DIR}/clang/${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}/include
5055
${LLVM_LIBRARY_DIR}/../clang/${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}/include
5156
${LLVM_LIBRARY_DIR}/../../lib/clang/${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}/include

build.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
from __future__ import print_function
1616

17-
import os, sys, argparse, platform, subprocess, imp, shutil, distutils.dir_util, json
17+
import os, sys, argparse, platform, subprocess, shutil, json
1818

1919
from collections import OrderedDict
2020

source/class.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,11 @@ bool is_callback_structure_needed(CXXRecordDecl const *C)
616616
// check if all pure-virtual methods could be overridden in Python
617617
if( C->isAbstract() ) {
618618
for( auto m = C->method_begin(); m != C->method_end(); ++m ) {
619+
#if( LLVM_VERSION_MAJOR >= 18 )
620+
if( m->isPureVirtual() and is_const_overload(*m) ) return false; // it is not clear how to deal with this case since we can't overrdie const versions in Python, - so disabling for now
621+
#else
619622
if( m->isPure() and is_const_overload(*m) ) return false; // it is not clear how to deal with this case since we can't overrdie const versions in Python, - so disabling for now
623+
#endif
620624
}
621625
}
622626

@@ -644,7 +648,11 @@ bool is_callback_structure_constructible(CXXRecordDecl const *C)
644648
{
645649
if( C->isAbstract() ) {
646650
for( auto m = C->method_begin(); m != C->method_end(); ++m ) {
651+
#if( LLVM_VERSION_MAJOR >= 18 )
652+
if( m->isPureVirtual() and !isa<CXXConstructorDecl>(*m) and (m->getAccess() == AS_private or !is_bindable(*m) or is_skipping_requested(*m, Config::get())) ) return false;
653+
#else
647654
if( m->isPure() and !isa<CXXConstructorDecl>(*m) and (m->getAccess() == AS_private or !is_bindable(*m) or is_skipping_requested(*m, Config::get())) ) return false;
655+
#endif
648656
}
649657

650658
for( auto b = C->bases_begin(); b != C->bases_end(); ++b ) {
@@ -692,7 +700,7 @@ if (overload) {{
692700
static pybind11::detail::override_caster_t<{3}> caster;
693701
return pybind11::detail::cast_ref<{3}>(std::move(o), caster);
694702
}}
695-
else return pybind11::detail::cast_safe<{3}>(std::move(o));
703+
return pybind11::detail::cast_safe<{3}>(std::move(o));
696704
}}
697705
)_";
698706

@@ -744,6 +752,7 @@ string bind_member_functions_for_call_back(CXXRecordDecl const *C, string const
744752
if( return_type.find(',') != std::string::npos ) {
745753
string return_type_alias = "_binder_ret_" + std::to_string(ret_id);
746754
++ret_id;
755+
if (begins_with(return_type,"class ")) return_type = return_type.substr(6);
747756
c += "\tusing {} = {};\n"_format(return_type_alias, return_type);
748757
return_type = std::move(return_type_alias);
749758
}
@@ -766,7 +775,11 @@ string bind_member_functions_for_call_back(CXXRecordDecl const *C, string const
766775
string custom_function_info = Config::get().is_custom_trampoline_function_requested(member_function_name);
767776
if( custom_function_info == "" ) {
768777
c += indent(fmt::format(call_back_function_body_template, class_name, /*class_qualified_name(C), */ python_name, std::get<1>(args), return_type), "\t\t");
778+
#if( LLVM_VERSION_MAJOR >= 18 )
779+
if( m->isPureVirtual() ) c += "\t\tpybind11::pybind11_fail(\"Tried to call pure virtual function \\\"{}::{}\\\"\");\n"_format(C->getNameAsString(), python_name);
780+
#else
769781
if( m->isPure() ) c += "\t\tpybind11::pybind11_fail(\"Tried to call pure virtual function \\\"{}::{}\\\"\");\n"_format(C->getNameAsString(), python_name);
782+
#endif
770783
else c += "\t\treturn {}::{}({});\n"_format(C->getNameAsString(), m->getNameAsString(), std::get<1>(args));
771784
}
772785
else {

source/context.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ const char *main_module_header = R"_(#include <map>
8989
9090
{0}
9191
92-
typedef std::function< pybind11::module & (std::string const &) > ModuleGetter;
92+
using ModuleGetter = std::function< pybind11::module & (std::string const &) >;
9393
9494
{1}
9595
@@ -110,13 +110,13 @@ PYBIND11_MODULE({2}, root_module) {{
110110
auto mangle_namespace_name(
111111
[](std::string const &ns) -> std::string {{
112112
if ( std::find(reserved_python_words.begin(), reserved_python_words.end(), ns) == reserved_python_words.end() ) return ns;
113-
else return ns+'_';
113+
return ns+'_';
114114
}}
115115
);
116116
117117
std::vector< std::pair<std::string, std::string> > sub_modules {{
118118
{3} }};
119-
for(auto &p : sub_modules ) modules[p.first.size() ? p.first+"::"+p.second : p.second] = modules[p.first].def_submodule( mangle_namespace_name(p.second).c_str(), ("Bindings for " + p.first + "::" + p.second + " namespace").c_str() );
119+
for(auto &p : sub_modules ) modules[ p.first.empty() ? p.second : p.first+"::"+p.second ] = modules[p.first].def_submodule( mangle_namespace_name(p.second).c_str(), ("Bindings for " + p.first + "::" + p.second + " namespace").c_str() );
120120
121121
//pybind11::class_<std::shared_ptr<void>>(M(""), "_encapsulated_data_");
122122
@@ -132,7 +132,7 @@ const char *module_header = R"_(
132132
#ifndef BINDER_PYBIND11_TYPE_CASTER
133133
#define BINDER_PYBIND11_TYPE_CASTER
134134
{2}
135-
PYBIND11_DECLARE_HOLDER_TYPE(T, T*)
135+
PYBIND11_DECLARE_HOLDER_TYPE(T, T*, false)
136136
{3}
137137
#endif
138138
@@ -437,7 +437,7 @@ void Context::generate(Config const &config)
437437

438438
string const holder_type = Config::get().holder_type();
439439

440-
string shared_declare = "PYBIND11_DECLARE_HOLDER_TYPE(T, "+holder_type+"<T>)";
440+
string shared_declare = "PYBIND11_DECLARE_HOLDER_TYPE(T, "+holder_type+"<T>, false)";
441441
string shared_make_opaque = "PYBIND11_MAKE_OPAQUE("+holder_type+"<void>)";
442442

443443
string const pybind11_include = "#include <" + Config::get().pybind11_include_file() + ">";

source/function.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#define _INCLUDED_function_hpp_
1515

1616
#include <binder.hpp>
17+
#include <config.hpp>
1718

1819
#include <clang/AST/Decl.h>
1920
#include <clang/AST/DeclCXX.h>

test/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,10 @@ if (pybind11_VERSION VERSION_LESS 2.5.99)
150150
list(REMOVE_ITEM binder_tests T11.override)
151151
list(REMOVE_ITEM binder_tests T15.inner_class)
152152
endif()
153+
if (LLVM_VERSION_MAJOR VERSION_GREATER 15)
154+
list(REMOVE_ITEM binder_tests T15.inner_class)
155+
list(REMOVE_ITEM binder_tests T17.anonymous)
156+
endif()
153157
if( CMAKE_HOST_SYSTEM_NAME MATCHES "Darwin" )
154158
list(REMOVE_ITEM binder_tests T42.stl.names.multimap)
155159
list(REMOVE_ITEM binder_tests T42.stl.names.multiset)

0 commit comments

Comments
 (0)