diff --git a/qrenderdoc/Code/CaptureContext.h b/qrenderdoc/Code/CaptureContext.h index e0294098f..b17a36a77 100644 --- a/qrenderdoc/Code/CaptureContext.h +++ b/qrenderdoc/Code/CaptureContext.h @@ -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 CustomShaderEncodings() override { return m_CustomEncodings; } rdcarray CustomShaderSourcePrefixes() override { return m_CustomPrefixes; } rdcarray TargetShaderEncodings() override { return m_TargetEncodings; } diff --git a/qrenderdoc/Code/Interface/QRDInterface.h b/qrenderdoc/Code/Interface/QRDInterface.h index 9a4455087..0fd664b32 100644 --- a/qrenderdoc/Code/Interface/QRDInterface.h +++ b/qrenderdoc/Code/Interface/QRDInterface.h @@ -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 diff --git a/qrenderdoc/Code/pyrenderdoc/container_handling.i b/qrenderdoc/Code/pyrenderdoc/container_handling.i index 6940b428c..a690abcac 100644 --- a/qrenderdoc/Code/pyrenderdoc/container_handling.i +++ b/qrenderdoc/Code/pyrenderdoc/container_handling.i @@ -328,6 +328,10 @@ void ARRAY_INSTANTIATION_CHECK_NAME(typeName)(typeName *); %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) diff --git a/qrenderdoc/Code/pyrenderdoc/renderdoc.i b/qrenderdoc/Code/pyrenderdoc/renderdoc.i index 14e8c549e..ed5f67b18 100644 --- a/qrenderdoc/Code/pyrenderdoc/renderdoc.i +++ b/qrenderdoc/Code/pyrenderdoc/renderdoc.i @@ -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 diff --git a/qrenderdoc/Windows/PythonShell.cpp b/qrenderdoc/Windows/PythonShell.cpp index 07ef5b7f1..f07ba48f0 100644 --- a/qrenderdoc/Windows/PythonShell.cpp +++ b/qrenderdoc/Windows/PythonShell.cpp @@ -484,8 +484,8 @@ struct CaptureContextInvoker : ObjectForwarder { return m_Obj.GetCaptureModifications(); } - virtual const FrameDescription &FrameInfo() override { return m_Obj.FrameInfo(); } - virtual const APIProperties &APIProps() override { return m_Obj.APIProps(); } + virtual FrameDescription FrameInfo() override { return m_Obj.FrameInfo(); } + virtual APIProperties APIProps() override { return m_Obj.APIProps(); } virtual rdcarray TargetShaderEncodings() override { return m_Obj.TargetShaderEncodings();