Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modernize to c++14 for gcc/clang like compilers #1074

Merged
merged 74 commits into from
Dec 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
c4d5252
compile with cxx14 std
marscher May 29, 2022
64d4a30
clean unused imports
marscher May 29, 2022
460e6e9
removed unused virtual (override already used).
marscher May 29, 2022
f45fe98
use explicit ctor
marscher May 29, 2022
d10a8ff
prefer using x = y; instead of typedef
marscher May 29, 2022
383bde1
f
marscher May 29, 2022
73f5b01
removed unused header
marscher May 29, 2022
58553d5
follow up-use-using (union)
marscher May 29, 2022
e4ea8ba
use auto
marscher May 29, 2022
826b3cf
use nullptr
marscher May 29, 2022
c07c307
typos
marscher May 29, 2022
ad7807b
JPPrimitiveType explicit ctor (std:string& name)
marscher May 29, 2022
55ec01f
jpype.h remove duplicated included headers. Use nullptr in JP_RAISE
marscher May 29, 2022
390efa6
use initializer to avoid code duplication
marscher May 29, 2022
e143934
do not polute jpype.h with stringstream, iostream etc.
marscher May 29, 2022
93618e1
do not polute jpype.h with stringstream, iostream etc.
marscher May 29, 2022
13b8a65
f
marscher May 29, 2022
3764856
explicit ctors
marscher May 29, 2022
391457d
f
marscher May 29, 2022
c42d6f3
JPypeException derives from std::exception (is this ok?)
marscher May 29, 2022
c6c5ebc
explicit ctors
marscher May 29, 2022
95239d5
cstr conversion not needed
marscher May 29, 2022
bf0296c
const
marscher May 29, 2022
f4fe48d
no type repetition
marscher May 29, 2022
c70d9f7
no shadow
marscher May 29, 2022
36dd3b5
use range operator, default dtor
marscher May 29, 2022
002500f
minor
marscher May 29, 2022
88c71d5
fix explicit conversion for JPValue
marscher May 29, 2022
ee95979
initializer
marscher May 29, 2022
79dbb7b
modernize: use = default for empty bodied ctors
marscher May 29, 2022
b35a9b9
match return type
marscher May 29, 2022
528a69c
emplace back, where involved types would be copied.
marscher May 29, 2022
347de60
use move
marscher May 29, 2022
c2f0dcc
added fixme about build_ext.parallel
marscher May 29, 2022
4c9d5ce
use common c++ std in Platform()
marscher May 29, 2022
4577ef1
removed unused code
marscher May 29, 2022
ee03db8
mark unimplemented private special functions with "delete"
marscher May 29, 2022
55328c2
disallow copying (delete copy ctors, made public).
marscher May 29, 2022
eec272f
follow up: explicit ctor (updated comment)
marscher May 29, 2022
bee2ab8
refactor jpypeexception to be a std::runtime_error
marscher May 29, 2022
78819bb
removed getMessage
marscher May 29, 2022
7f10e50
jpypeexception: reordering, simplification
marscher May 29, 2022
0df72fe
jpypeexception: initialize mesg
marscher May 29, 2022
6a92aa9
method move arguments, default ctor impl, delete copy construction
marscher May 29, 2022
0bf7044
jpypeexcetion: copy ctor
marscher May 29, 2022
e434a88
removed fixme (parallel only works for multiple extensions, not sourc…
marscher May 29, 2022
5579dbc
added assertion about Jpypeexception to be nothrow copy constructable
marscher May 29, 2022
c4d0881
use dynamic_cast
marscher May 29, 2022
acb6665
no const cast needed here
marscher May 29, 2022
ff73c4e
jpbuffer: const, initialize fields
marscher May 29, 2022
f4e9b80
jparray: initialize all fields
marscher May 29, 2022
4854827
no const cast
marscher May 29, 2022
f53e98f
jpexception cpy ctor
marscher May 30, 2022
6741b2f
jpexception: use enum
marscher Jun 1, 2022
fded35e
added info
marscher Jun 1, 2022
3877296
jp_encoding: minor change
marscher Jun 1, 2022
32021d6
jp_pythontypes: use actual type (PyThreadState) and avoid casting to …
marscher Jun 1, 2022
dd83cc3
jp_pythontypes: use Py_ssize_t
marscher Jun 1, 2022
172dc47
[core] fix bug in jedi autocomplete allowed descriptors
marscher Jun 1, 2022
e9958ed
fix uninitialized members variables. use generators
marscher Jun 1, 2022
41a62c7
Revert "fix uninitialized members variables. use generators"
marscher Jun 1, 2022
43854b9
replace auto i = 0; with decltype to be explicit
marscher Jun 1, 2022
3e9d4eb
use c++11 for clang/gcc like compilers, c++14 on msvc (like for versi…
marscher Jun 1, 2022
c0fa927
jpexception: reorder init
marscher Jun 1, 2022
5d093bb
pass string by const-ref
marscher Jun 1, 2022
24b23a4
jp_array use nullptr, removed unused include
marscher Jun 2, 2022
e8a5e86
fix array size
marscher Jun 3, 2022
ca265ee
Merge branch 'master' into tidyup_virtual_override_mess
marscher Nov 9, 2022
5bc12ce
merged jp_exception (broken)
marscher Nov 9, 2022
6bf4871
fix
marscher Nov 9, 2022
5ac5a1a
Merge branch 'master' into tidyup_virtual_override_mess
marscher Apr 29, 2023
df7d2e4
use proper workaround
marscher Apr 29, 2023
5647a3a
use proper workaround PyJPValue_alloc from current master
marscher Apr 29, 2023
f06042f
Merge branch 'master' into tidyup_virtual_override_mess
Thrameos Dec 10, 2023
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
11 changes: 7 additions & 4 deletions jpype/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,14 @@ class JVMNotRunning(RuntimeError):

# Activate jedi tab completion
try:
import jedi as _jedi
_jedi.evaluate.compiled.access.ALLOWED_DESCRIPTOR_ACCESS += \
(_jpype._JMethod, _jpype._JField)
except Exception:
from jedi import __version__ as _jedi_version
import jedi.access as _jedi_access
_jedi_access.ALLOWED_DESCRIPTOR_ACCESS += _jpype._JMethod, _jpype._JField
except ModuleNotFoundError:
Dismissed Show dismissed Hide dismissed
pass
except AttributeError:
import warnings as _w
_w.warn(f"provided Jedi seems out of date. Version is {_jedi_version}.")


if typing.TYPE_CHECKING:
Expand Down
20 changes: 10 additions & 10 deletions native/common/include/jp_array.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,21 @@ class JPArray;
class JPArrayView
{
public:
JPArrayView(JPArray* array);
explicit JPArrayView(JPArray* array);
JPArrayView(JPArray* array, jobject collection);
~JPArrayView();
void reference();
bool unreference();
JPContext *getContext();
JPContext *getContext() const;
public:
JPArray *m_Array;
void *m_Memory;
Py_buffer m_Buffer;
void *m_Memory{};
Py_buffer m_Buffer{};
int m_RefCount;
Py_ssize_t m_Shape[5];
Py_ssize_t m_Strides[5];
jboolean m_IsCopy;
jboolean m_Owned;
Py_ssize_t m_Shape[5]{};
Py_ssize_t m_Strides[5]{};
jboolean m_IsCopy{};
jboolean m_Owned{};
} ;

/**
Expand All @@ -47,7 +47,7 @@ class JPArray
{
friend class JPArrayView;
public:
JPArray(const JPValue& array);
explicit JPArray(const JPValue& array);
JPArray(JPArray* cls, jsize start, jsize stop, jsize step);
virtual~ JPArray();

Expand All @@ -56,7 +56,7 @@ class JPArray
return m_Class;
}

jsize getLength();
jsize getLength() const;
void setRange(jsize start, jsize length, jsize step, PyObject* val);
JPPyObject getItem(jsize ndx);
void setItem(jsize ndx, PyObject*);
Expand Down
10 changes: 5 additions & 5 deletions native/common/include/jp_arrayclass.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ class JPArrayClass : public JPClass
JPClass* superClass,
JPClass* componentType,
jint modifiers);
virtual~ JPArrayClass();
~ JPArrayClass() override;

virtual JPPyObject convertToPythonObject(JPJavaFrame& frame, jvalue val, bool cast) override;
virtual JPMatch::Type findJavaConversion(JPMatch &match) override;
virtual void getConversionInfo(JPConversionInfo &info) override;
JPPyObject convertToPythonObject(JPJavaFrame& frame, jvalue val, bool cast) override;
JPMatch::Type findJavaConversion(JPMatch &match) override;
void getConversionInfo(JPConversionInfo &info) override;

JPValue newArray(JPJavaFrame& frame, int length);

Expand All @@ -54,7 +54,7 @@ class JPArrayClass : public JPClass
return m_ComponentType;
}

virtual bool isArray() const override
bool isArray() const override
{
return true;
}
Expand Down
54 changes: 27 additions & 27 deletions native/common/include/jp_booleantype.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ class JPBooleanType : public JPPrimitiveType
public:

JPBooleanType();
virtual ~JPBooleanType();
~JPBooleanType() override;

typedef jboolean type_t;
typedef jbooleanArray array_t;
using type_t = jboolean;
using array_t = jbooleanArray;

static inline jboolean& field(jvalue& v)
{
Expand All @@ -36,32 +36,32 @@ class JPBooleanType : public JPPrimitiveType
return v.z;
}

virtual JPClass* getBoxedClass(JPContext *context) const override
JPClass* getBoxedClass(JPContext *context) const override
{
return context->_java_lang_Boolean;
}

virtual JPMatch::Type findJavaConversion(JPMatch& match) override;
virtual void getConversionInfo(JPConversionInfo &info) override;
virtual JPPyObject convertToPythonObject(JPJavaFrame& frame, jvalue val, bool cast) override;
virtual JPValue getValueFromObject(const JPValue& obj) override;
JPMatch::Type findJavaConversion(JPMatch& match) override;
void getConversionInfo(JPConversionInfo &info) override;
JPPyObject convertToPythonObject(JPJavaFrame& frame, jvalue val, bool cast) override;
JPValue getValueFromObject(const JPValue& obj) override;

virtual JPPyObject invokeStatic(JPJavaFrame& frame, jclass, jmethodID, jvalue*) override;
virtual JPPyObject invoke(JPJavaFrame& frame, jobject, jclass, jmethodID, jvalue*) override;
JPPyObject invokeStatic(JPJavaFrame& frame, jclass, jmethodID, jvalue*) override;
JPPyObject invoke(JPJavaFrame& frame, jobject, jclass, jmethodID, jvalue*) override;

virtual JPPyObject getStaticField(JPJavaFrame& frame, jclass c, jfieldID fid) override;
virtual void setStaticField(JPJavaFrame& frame, jclass c, jfieldID fid, PyObject* val) override;
virtual JPPyObject getField(JPJavaFrame& frame, jobject c, jfieldID fid) override;
virtual void setField(JPJavaFrame& frame, jobject c, jfieldID fid, PyObject* val) override;
JPPyObject getStaticField(JPJavaFrame& frame, jclass c, jfieldID fid) override;
void setStaticField(JPJavaFrame& frame, jclass c, jfieldID fid, PyObject* val) override;
JPPyObject getField(JPJavaFrame& frame, jobject c, jfieldID fid) override;
void setField(JPJavaFrame& frame, jobject c, jfieldID fid, PyObject* val) override;

virtual jarray newArrayOf(JPJavaFrame& frame, jsize size) override;
virtual void setArrayRange(JPJavaFrame& frame, jarray,
jarray newArrayOf(JPJavaFrame& frame, jsize size) override;
void setArrayRange(JPJavaFrame& frame, jarray,
jsize start, jsize length, jsize step,
PyObject *sequence) override;
virtual JPPyObject getArrayItem(JPJavaFrame& frame, jarray, jsize ndx) override;
virtual void setArrayItem(JPJavaFrame& frame, jarray, jsize ndx, PyObject* val) override;
JPPyObject getArrayItem(JPJavaFrame& frame, jarray, jsize ndx) override;
void setArrayItem(JPJavaFrame& frame, jarray, jsize ndx, PyObject* val) override;

virtual char getTypeCode() override
char getTypeCode() override
{
return 'Z';
}
Expand All @@ -70,26 +70,26 @@ class JPBooleanType : public JPPrimitiveType
// These methods are required by primitive but are not used for a non
// number type

virtual jlong getAsLong(jvalue v) override
jlong getAsLong(jvalue v) override
{
return field(v);
}

virtual jdouble getAsDouble(jvalue v) override
jdouble getAsDouble(jvalue v) override
{
return field(v);
}
// GCOVR_EXCL_STOP

virtual void getView(JPArrayView& view) override;
virtual void releaseView(JPArrayView& view) override;
virtual const char* getBufferFormat() override;
virtual Py_ssize_t getItemSize() override;
virtual void copyElements(JPJavaFrame &frame,
void getView(JPArrayView& view) override;
void releaseView(JPArrayView& view) override;
const char* getBufferFormat() override;
Py_ssize_t getItemSize() override;
void copyElements(JPJavaFrame &frame,
jarray a, jsize start, jsize len,
void* memory, int offset) override;

virtual PyObject *newMultiArray(JPJavaFrame &frame,
PyObject *newMultiArray(JPJavaFrame &frame,
JPPyBuffer &buffer, int subs, int base, jobject dims) override;

} ;
Expand Down
8 changes: 4 additions & 4 deletions native/common/include/jp_boxedtype.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,18 @@ class JPBoxedType : public JPClass
JPClassList& interfaces,
jint modifiers,
JPPrimitiveType* primitiveType);
virtual ~JPBoxedType();
~JPBoxedType() override;

virtual JPMatch::Type findJavaConversion(JPMatch &match) override;
virtual void getConversionInfo(JPConversionInfo &info) override;
JPMatch::Type findJavaConversion(JPMatch &match) override;
void getConversionInfo(JPConversionInfo &info) override;

JPPrimitiveType* getPrimitive()
{
return m_PrimitiveType;
}

jobject box(JPJavaFrame &frame, jvalue v);
virtual JPPyObject convertToPythonObject(JPJavaFrame& frame, jvalue val, bool cast) override;
JPPyObject convertToPythonObject(JPJavaFrame& frame, jvalue val, bool cast) override;

protected:
JPPrimitiveType* m_PrimitiveType;
Expand Down
10 changes: 5 additions & 5 deletions native/common/include/jp_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class JPBufferType;
class JPBuffer
{
public:
JPBuffer(const JPValue& array);
explicit JPBuffer(const JPValue& array);
virtual~ JPBuffer();

JPBufferType* getClass()
Expand All @@ -39,19 +39,19 @@ class JPBuffer
return m_Object.get();
}

bool isReadOnly();
bool isReadOnly() const;

Py_buffer& getView();

bool isValid();
bool isValid() const;

private:
JPBufferType* m_Class;
JPObjectRef m_Object;
void *m_Address;
Py_ssize_t m_Capacity;
Py_buffer m_Buffer;
char m_Format[3];
Py_buffer m_Buffer{};
char m_Format[3]{};
} ;

#endif // _JPBUFFER_H_
8 changes: 4 additions & 4 deletions native/common/include/jp_buffertype.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ class JPBufferType : public JPClass
{
public:
JPBufferType(JPJavaFrame& frame, jclass cls, const string& name, JPClass* superClass, const JPClassList& interfaces, jint modifiers);
virtual~ JPBufferType();
~ JPBufferType() override;

char* getType()
const char* getType()
{
return const_cast<char*> (m_Type);
return m_Type;
}

int getSize()
int getSize() const
{
return m_Size;
}
Expand Down
54 changes: 27 additions & 27 deletions native/common/include/jp_bytetype.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ class JPByteType : public JPPrimitiveType
public:

JPByteType();
virtual ~JPByteType() override;
~JPByteType() override;

public:
typedef jbyte type_t;
typedef jbyteArray array_t;
using type_t = jbyte;
using array_t = jbyteArray;

static inline jbyte& field(jvalue& v)
{
Expand All @@ -37,30 +37,30 @@ class JPByteType : public JPPrimitiveType
return v.b;
}

virtual JPClass* getBoxedClass(JPContext *context) const override
JPClass* getBoxedClass(JPContext *context) const override
{
return context->_java_lang_Byte;
}

virtual JPMatch::Type findJavaConversion(JPMatch &match) override;
virtual void getConversionInfo(JPConversionInfo &info) override;
virtual JPPyObject convertToPythonObject(JPJavaFrame &frame, jvalue val, bool cast) override;
virtual JPValue getValueFromObject(const JPValue& obj) override;
JPMatch::Type findJavaConversion(JPMatch &match) override;
void getConversionInfo(JPConversionInfo &info) override;
JPPyObject convertToPythonObject(JPJavaFrame &frame, jvalue val, bool cast) override;
JPValue getValueFromObject(const JPValue& obj) override;

virtual JPPyObject invokeStatic(JPJavaFrame& frame, jclass, jmethodID, jvalue*) override;
virtual JPPyObject invoke(JPJavaFrame& frame, jobject, jclass, jmethodID, jvalue*) override;
JPPyObject invokeStatic(JPJavaFrame& frame, jclass, jmethodID, jvalue*) override;
JPPyObject invoke(JPJavaFrame& frame, jobject, jclass, jmethodID, jvalue*) override;

virtual JPPyObject getStaticField(JPJavaFrame& frame, jclass c, jfieldID fid) override;
virtual void setStaticField(JPJavaFrame& frame, jclass c, jfieldID fid, PyObject* val) override;
virtual JPPyObject getField(JPJavaFrame& frame, jobject c, jfieldID fid) override;
virtual void setField(JPJavaFrame& frame, jobject c, jfieldID fid, PyObject* val) override;
JPPyObject getStaticField(JPJavaFrame& frame, jclass c, jfieldID fid) override;
void setStaticField(JPJavaFrame& frame, jclass c, jfieldID fid, PyObject* val) override;
JPPyObject getField(JPJavaFrame& frame, jobject c, jfieldID fid) override;
void setField(JPJavaFrame& frame, jobject c, jfieldID fid, PyObject* val) override;

virtual jarray newArrayOf(JPJavaFrame& frame, jsize size) override;
virtual void setArrayRange(JPJavaFrame& frame, jarray, jsize start, jsize length, jsize step, PyObject*) override;
virtual JPPyObject getArrayItem(JPJavaFrame& frame, jarray, jsize ndx) override;
virtual void setArrayItem(JPJavaFrame& frame, jarray, jsize ndx, PyObject* val) override;
jarray newArrayOf(JPJavaFrame& frame, jsize size) override;
void setArrayRange(JPJavaFrame& frame, jarray, jsize start, jsize length, jsize step, PyObject*) override;
JPPyObject getArrayItem(JPJavaFrame& frame, jarray, jsize ndx) override;
void setArrayItem(JPJavaFrame& frame, jarray, jsize ndx, PyObject* val) override;

virtual char getTypeCode() override
char getTypeCode() override
{
return 'B';
}
Expand All @@ -74,25 +74,25 @@ class JPByteType : public JPPrimitiveType
return l;
}

virtual jlong getAsLong(jvalue v) override
jlong getAsLong(jvalue v) override
{
return field(v);
}

virtual jdouble getAsDouble(jvalue v) override
jdouble getAsDouble(jvalue v) override
{
return field(v);
}

virtual void getView(JPArrayView& view) override;
virtual void releaseView(JPArrayView& view) override;
virtual const char* getBufferFormat() override;
virtual Py_ssize_t getItemSize() override;
virtual void copyElements(JPJavaFrame &frame,
void getView(JPArrayView& view) override;
void releaseView(JPArrayView& view) override;
const char* getBufferFormat() override;
Py_ssize_t getItemSize() override;
void copyElements(JPJavaFrame &frame,
jarray a, jsize start, jsize len,
void* memory, int offset) override;

virtual PyObject *newMultiArray(JPJavaFrame &frame,
PyObject *newMultiArray(JPJavaFrame &frame,
JPPyBuffer &buffer, int subs, int base, jobject dims) override;

private:
Expand Down
Loading
Loading