Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 7 additions & 16 deletions .github/workflows/test-linux-mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@ jobs:
fail-fast: false
matrix:
version:
- "1.6"
- "1.11"
- "1.10"
- "1"
- "nightly"
os:
- ubuntu-latest
- macos-13
- macos-15-intel
arch:
- x64
include:
- os: macos-14
- os: macos-latest
arch: aarch64
version: "1.11"
- os: macos-14
version: "1.10"
- os: macos-latest
arch: aarch64
version: "nightly"
steps:
Expand All @@ -38,12 +38,6 @@ jobs:
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- name: Set up GCC 10 on Ubuntu and Julia 1.6
if: matrix.os == 'ubuntu-latest' && matrix.version == '1.6'
run: |
sudo apt-get install -y gcc-10 g++-10
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 10
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-10 10
- name: Build and test
env:
body: ${{ github.event.pull_request.body }}
Expand All @@ -52,14 +46,11 @@ jobs:
if [[ ! "${package}" =~ ^https:// ]]; then
package="https://github.com/JuliaInterop/CxxWrap.jl.git"
fi
if [[ "$OSTYPE" != "darwin"* ]]; then
rm -f /opt/hostedtoolcache/julia/1.6*/x64/lib/julia/libstdc++.so.6
fi
mkdir build && cd build
CXXFLAGS=-ftemplate-backtrace-limit=0 cmake -DCMAKE_INSTALL_PREFIX=$HOME/install -DAPPEND_OVERRIDES_TOML=ON -DCMAKE_BUILD_TYPE=Debug ..
VERBOSE=ON cmake --build . --config Debug --target install
wget https://github.com/JuliaRegistries/General/raw/refs/heads/master/jll/L/libcxxwrap_julia_jll/Versions.toml
jllversion=0.14.2 #$(grep '\["' Versions.toml | tail -n 1 | sed -E 's/\["([0-9]+\.[0-9]+\.[0-9]+)\+[^"]*"\]/\1/g')
jllversion=$(grep '\["' Versions.toml | tail -n 1 | sed -E 's/\["([0-9]+\.[0-9]+\.[0-9]+)\+[^"]*"\]/\1/g')
cd lib
if [ ! -f libcxxwrap_julia.${jllversion}.dylib ]; then
ln -s libcxxwrap_julia.*.*.*.* libcxxwrap_julia.${jllversion}.dylib
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-win.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ jobs:
fail-fast: false
matrix:
version:
- "1.7"
- "1.11"
- "1.10"
- "1"
- "nightly"
os:
- windows-latest
Expand Down
36 changes: 36 additions & 0 deletions examples/inheritance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,25 @@ namespace virtualsolver
};
}

struct Parent {
virtual std::string name() const { return "Parent"; }
virtual ~Parent() = default;
};

struct DerivedA : public Parent {
std::string name() const override { return "DerivedA"; }
};

struct DerivedB : public Parent {
std::string name() const override { return "DerivedB"; }
};


Parent* make_a() { return new DerivedA(); }
Parent* make_b() { return new DerivedB(); }
const Parent* make_const_a() { return new const DerivedA(); }
const Parent* make_const_b() { return new const DerivedB(); }

namespace jlcxx
{
// Needed for upcasting
Expand All @@ -196,6 +215,9 @@ namespace jlcxx
template<> struct IsMirroredType<StaticBase> : std::false_type { };
template<> struct IsMirroredType<StaticDerived> : std::false_type { };
template<> struct SuperType<StaticDerived> { typedef StaticBase type; };

template<> struct SuperType<DerivedA> { typedef Parent type; };
template<> struct SuperType<DerivedB> { typedef Parent type; };
}

JLCXX_MODULE define_types_module(jlcxx::Module& types)
Expand Down Expand Up @@ -230,6 +252,20 @@ JLCXX_MODULE define_types_module(jlcxx::Module& types)
.constructor<int, double>()
.method("getData", &VirtualCfunctionExtended::getData)
.method("set_callback", &VirtualCfunctionExtended::set_callback);

types.add_type<Parent>("Parent")
.method("name", &Parent::name);

types.add_type<DerivedA>("DerivedA", jlcxx::julia_base_type<Parent>())
.method("name", &DerivedA::name);

types.add_type<DerivedB>("DerivedB", jlcxx::julia_base_type<Parent>())
.method("name", &DerivedB::name);

types.method("make_a", &make_a);
types.method("make_b", &make_b);
types.method("make_const_a", &make_const_a);
types.method("make_const_b", &make_const_b);
}

JLCXX_MODULE define_vsolver_module(jlcxx::Module& vsolver_mod)
Expand Down
2 changes: 1 addition & 1 deletion include/jlcxx/jlcxx_config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#define JLCXX_VERSION_MAJOR 0
#define JLCXX_VERSION_MINOR 14
#define JLCXX_VERSION_PATCH 5
#define JLCXX_VERSION_PATCH 6

// From https://stackoverflow.com/questions/5459868/concatenate-int-to-string-using-c-preprocessor
#define __JLCXX_STR_HELPER(x) #x
Expand Down
Loading