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
4 changes: 2 additions & 2 deletions bindings/pyroot/cppyy/CPyCppyy/src/CPPClassMethod.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ PyObject* CPyCppyy::CPPClassMethod::Call(CPPInstance*&
int nargs = (int)CPyCppyy_PyArgs_GET_SIZE(args, nargsf);
if ((!self || (PyObject*)self == Py_None) && nargs) {
PyObject* arg0 = CPyCppyy_PyArgs_GET_ITEM(args, 0);
if ((CPPInstance_Check(arg0) && ((CPPInstance*)arg0)->ObjectIsA() == GetScope()) && \
(fArgsRequired <= nargs-1)) {
if (CPPInstance_Check(arg0) && fArgsRequired <= nargs - 1 &&
Cppyy::IsSubtype(reinterpret_cast<CPPInstance *>(arg0)->ObjectIsA(), GetScope())) {
args += 1; // drops first argument
nargsf -= 1;
}
Expand Down
28 changes: 28 additions & 0 deletions bindings/pyroot/cppyy/cppyy/test/test_overloads.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import py, pytest, os

Check failure on line 1 in bindings/pyroot/cppyy/cppyy/test/test_overloads.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (F401)

bindings/pyroot/cppyy/cppyy/test/test_overloads.py:1:8: F401 `py` imported but unused

Check failure on line 1 in bindings/pyroot/cppyy/cppyy/test/test_overloads.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (E401)

bindings/pyroot/cppyy/cppyy/test/test_overloads.py:1:1: E401 Multiple imports on one line
from pytest import raises, skip, mark
from support import setup_make, ispypy, IS_WINDOWS, IS_MAC_ARM

Check failure on line 3 in bindings/pyroot/cppyy/cppyy/test/test_overloads.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (F401)

bindings/pyroot/cppyy/cppyy/test/test_overloads.py:3:21: F401 `support.setup_make` imported but unused

Check failure on line 3 in bindings/pyroot/cppyy/cppyy/test/test_overloads.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (I001)

bindings/pyroot/cppyy/cppyy/test/test_overloads.py:1:1: I001 Import block is un-sorted or un-formatted

Expand Down Expand Up @@ -73,7 +73,7 @@
import cppyy
more_overloads = cppyy.gbl.more_overloads
aa_ol = cppyy.gbl.aa_ol
bb_ol = cppyy.gbl.bb_ol

Check failure on line 76 in bindings/pyroot/cppyy/cppyy/test/test_overloads.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (F841)

bindings/pyroot/cppyy/cppyy/test/test_overloads.py:76:9: F841 Local variable `bb_ol` is assigned to but never used
cc_ol = cppyy.gbl.cc_ol
dd_ol = cppyy.gbl.dd_ol

Expand Down Expand Up @@ -130,13 +130,13 @@
def test07_mean_overloads(self):
"""Adapted test for array overloading"""

import cppyy, array

Check failure on line 133 in bindings/pyroot/cppyy/cppyy/test/test_overloads.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (I001)

bindings/pyroot/cppyy/cppyy/test/test_overloads.py:133:9: I001 Import block is un-sorted or un-formatted

Check failure on line 133 in bindings/pyroot/cppyy/cppyy/test/test_overloads.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (E401)

bindings/pyroot/cppyy/cppyy/test/test_overloads.py:133:9: E401 Multiple imports on one line
cmean = cppyy.gbl.calc_mean

numbers = [8, 2, 4, 2, 4, 2, 4, 4, 1, 5, 6, 3, 7]
mean, median = 4.0, 4.0

Check failure on line 137 in bindings/pyroot/cppyy/cppyy/test/test_overloads.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (F841)

bindings/pyroot/cppyy/cppyy/test/test_overloads.py:137:15: F841 Local variable `median` is assigned to but never used

for l in ['f', 'd', 'i', 'h', 'l']:

Check failure on line 139 in bindings/pyroot/cppyy/cppyy/test/test_overloads.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (E741)

bindings/pyroot/cppyy/cppyy/test/test_overloads.py:139:13: E741 Ambiguous variable name: `l`
a = array.array(l, numbers)
assert round(cmean(len(a), a) - mean, 8) == 0

Expand All @@ -158,7 +158,7 @@
assert m.slice(0) == 'non-const'
assert m,slice(0, 0) == 'non-const'
assert m.slice_const(0) == 'const'
assert m,slice_const(0, 0) == 'const'

Check failure on line 161 in bindings/pyroot/cppyy/cppyy/test/test_overloads.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (F821)

bindings/pyroot/cppyy/cppyy/test/test_overloads.py:161:18: F821 Undefined name `slice_const`

def test09_bool_int_overloads(self):
"""Check bool/int overloaded calls"""
Expand Down Expand Up @@ -377,5 +377,33 @@
assert cppyy.gbl.test12_foo(1) == cppyy.gbl.call_test12_foo()
assert cppyy.gbl.test12_bar(1) == cppyy.gbl.call_test12_bar()


def test13_static_call_from_derived_instance(self):
"""Test calling a static member function via a derived instance."""

import cppyy

cppyy.cppdef("""
class Base {
public:
static int StaticMethod() {
return 42;
}
};

class Derived : public Base {
};
""")

d = cppyy.gbl.Derived()

# Call static method through base class directly
result_direct = cppyy.gbl.Base.StaticMethod()

# Call static method through instance
result_instance = d.StaticMethod()

assert result_instance == result_direct

if __name__ == "__main__":
exit(pytest.main(args=['-sv', '-ra', __file__]))
Loading