mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-08-28 17:36:36 +00:00
Returning const arrays forces a copy
* This doesn't cover all cases but helps with 'pythonic' cases where a list returned from a function should be expected to be mutable. Modifying direct 'members' can still modify through const.
This commit is contained in:
@@ -155,8 +155,8 @@ public:
|
||||
ResultDetails GetFatalError() override { return m_Replay.GetFatalError(); }
|
||||
rdcstr GetCaptureFilename() override { return m_CaptureFile; }
|
||||
CaptureModifications GetCaptureModifications() override { return m_CaptureMods; }
|
||||
const FrameDescription &FrameInfo() override { return m_FrameInfo; }
|
||||
const APIProperties &APIProps() override { return m_APIProps; }
|
||||
FrameDescription FrameInfo() override { return m_FrameInfo; }
|
||||
APIProperties APIProps() override { return m_APIProps; }
|
||||
rdcarray<ShaderEncoding> CustomShaderEncodings() override { return m_CustomEncodings; }
|
||||
rdcarray<ShaderSourcePrefix> CustomShaderSourcePrefixes() override { return m_CustomPrefixes; }
|
||||
rdcarray<ShaderEncoding> TargetShaderEncodings() override { return m_TargetEncodings; }
|
||||
|
||||
@@ -2166,14 +2166,14 @@ the UI which aren't reflected in the capture file on disk.
|
||||
:return: The frame information.
|
||||
:rtype: renderdoc.FrameDescription
|
||||
)");
|
||||
virtual const FrameDescription &FrameInfo() = 0;
|
||||
virtual FrameDescription FrameInfo() = 0;
|
||||
|
||||
DOCUMENT(R"(Retrieve the :class:`~renderdoc.APIProperties` for the currently loaded capture.
|
||||
|
||||
:return: The API properties.
|
||||
:rtype: renderdoc.APIProperties
|
||||
)");
|
||||
virtual const APIProperties &APIProps() = 0;
|
||||
virtual APIProperties APIProps() = 0;
|
||||
|
||||
DOCUMENT(R"(Retrieve the list of :class:`~renderdoc.ShaderEncoding` that are available for
|
||||
building target shaders for the currently loaded capture. See
|
||||
|
||||
@@ -328,6 +328,10 @@ void ARRAY_INSTANTIATION_CHECK_NAME(typeName)(typeName<innerType> *);
|
||||
%typemap(ret) typeName & { ARRAY_INSTANTIATION_CHECK_NAME(typeName)($1); }
|
||||
%typemap(ret) typeName { ARRAY_INSTANTIATION_CHECK_NAME(typeName)(&$1); }
|
||||
|
||||
%typemap(out) typeName const & {
|
||||
$result = ConvertToPy(indirect($1));
|
||||
}
|
||||
|
||||
%enddef
|
||||
|
||||
%define NON_TEMPLATE_ARRAY_INSTANTIATE(typeName)
|
||||
|
||||
@@ -98,6 +98,13 @@ VA_IGNORE_REST_OF_FILE
|
||||
PyDateTime_IMPORT;
|
||||
%}
|
||||
|
||||
%typemap(out) const SWIGTYPE & {
|
||||
static_assert(false, "Const ref types must be explicitly allowed, to ensure proper copy semantics. " \
|
||||
"Consider returning by copy if reasonable, or explicitly set up copy typemap.");
|
||||
//$ltype owned = new std::remove_pointer<$ltype>::type(indirect($1));
|
||||
//$result = SWIG_NewPointerObj(SWIG_as_voidptr(owned), $descriptor, SWIG_POINTER_OWN | 0 );
|
||||
}
|
||||
|
||||
%include "pyconversion.i"
|
||||
|
||||
// typemaps for windowing data
|
||||
@@ -232,6 +239,17 @@ VA_IGNORE_REST_OF_FILE
|
||||
$1.assign(*$input);
|
||||
}
|
||||
|
||||
// this is fine to return directly as it offers no mutable members
|
||||
%typemap(out) const PipeState & {
|
||||
$result = SWIG_NewPointerObj(SWIG_as_voidptr($1), $descriptor, 0 );
|
||||
}
|
||||
|
||||
// this is returned directly due to the size of the data contained in the type.
|
||||
// it's mostly "pythonic" to have an object returned that is considered mutable
|
||||
%typemap(out) const SDFile & {
|
||||
$result = SWIG_NewPointerObj(SWIG_as_voidptr($1), $descriptor, 0 );
|
||||
}
|
||||
|
||||
%typemap(ret) const ActionDescription * {
|
||||
// for ActionDescription pointers don't apply parent tracking, since these are preserved
|
||||
// in other ways and the linked-list nature of walking them can produce absurdly long
|
||||
|
||||
Reference in New Issue
Block a user