Add type hints to python for class constructors

* We enforce default and copy constructors where possible, this isn't very
  pythonic but we can't use copy.deepcopy on our types.
* The structs that have specialised constructors e.g. FloatVector or Subresource
  also have those documented though we have no way to enforce it.
This commit is contained in:
baldurk
2026-08-13 17:46:47 +01:00
parent 950568fb8f
commit 5e462c5ebe
20 changed files with 1336 additions and 225 deletions
+6 -1
View File
@@ -279,7 +279,12 @@ BITMASK_OPERATORS(DialogButton);
DISABLE_PYTHON_FLAG_ENUMS;
#endif
DOCUMENT("The metadata for an extension.");
DOCUMENT(R"(
ExtensionMetadata()
ExtensionMetadata(other: ExtensionMetadata)
The metadata for an extension.
)");
struct ExtensionMetadata
{
DOCUMENT("");
+23 -4
View File
@@ -30,7 +30,11 @@
class QMutex;
DOCUMENT(R"(Contains the output from invoking a :class:`ShaderProcessingTool`, including both the
DOCUMENT(R"(
ShaderToolOutput()
ShaderToolOutput(other: ShaderToolOutput)
Contains the output from invoking a :class:`ShaderProcessingTool`, including both the
actual output data desired as well as any stdout/stderr messages.
)");
struct ShaderToolOutput
@@ -48,7 +52,11 @@ struct ShaderToolOutput
bytebuf result;
};
DOCUMENT(R"(Describes an external program that can be used to process shaders, typically either
DOCUMENT(R"(
ShaderProcessingTool()
ShaderProcessingTool(other: ShaderProcessingTool)
Describes an external program that can be used to process shaders, typically either
compiling from a high-level language to a binary format, or decompiling from the binary format to
a high-level language or textual representation.
@@ -58,6 +66,9 @@ struct ShaderProcessingTool
{
DOCUMENT("");
ShaderProcessingTool() = default;
ShaderProcessingTool(const ShaderProcessingTool &) = default;
ShaderProcessingTool &operator=(const ShaderProcessingTool &) = default;
VARIANT_CAST(ShaderProcessingTool);
bool operator==(const ShaderProcessingTool &o) const
{
@@ -159,7 +170,12 @@ DECLARE_REFLECTION_STRUCT(ShaderProcessingTool);
#define BUGREPORT_URL "https://renderdoc.org/bugreporter"
#endif
DOCUMENT("Describes a submitted bug report.");
DOCUMENT(R"(
BugReport()
BugReport(other: BugReport)
Describes a submitted bug report.
)");
struct BugReport
{
DOCUMENT("");
@@ -879,7 +895,10 @@ struct CustomPersistentStorage
};
#endif
DOCUMENT(R"(A persistant config file that is automatically loaded and saved, which contains any
DOCUMENT(R"(
PersistantConfig()
A persistant config file that is automatically loaded and saved, which contains any
settings and information that needs to be preserved from one run to the next.
The config is retrieved by calling :meth:`CaptureContext.Config`.
+27 -4
View File
@@ -95,10 +95,18 @@ struct ICaptureContext;
#include "PersistantConfig.h"
#include "RemoteHost.h"
DOCUMENT("Contains all of the settings that control how to capture an executable.");
DOCUMENT(R"(
CaptureSettings()
CaptureSettings(other: CaptureSettings)
Contains all of the settings that control how to capture an executable.
)");
struct CaptureSettings
{
DOCUMENT("");
CaptureSettings();
CaptureSettings(const CaptureSettings &) = default;
CaptureSettings &operator=(const CaptureSettings &) = default;
VARIANT_CAST(CaptureSettings);
@@ -151,7 +159,11 @@ struct CaptureSettings
DECLARE_REFLECTION_STRUCT(CaptureSettings);
DOCUMENT(R"(The details of a capture that has been made on a connection but may not
DOCUMENT(R"(
ConnectedTempCapture()
ConnectedTempCapture(other: ConnectedTempCapture)
The details of a capture that has been made on a connection but may not
have been saved to disk or local.
)");
struct ConnectedTempCapture
@@ -1804,7 +1816,11 @@ protected:
DECLARE_REFLECTION_STRUCT(IPixelHistoryView);
DOCUMENT("An interface implemented by any object wanting to be notified of capture events.");
DOCUMENT(R"(
CaptureViewer()
An interface implemented by any object wanting to be notified of capture events.
)");
struct ICaptureViewer
{
DOCUMENT("Called whenever a capture is opened.");
@@ -2193,7 +2209,13 @@ enum class CaptureModifications : uint32_t
BITMASK_OPERATORS(CaptureModifications);
DOCUMENT("A description of a bookmark on an event");
DOCUMENT(R"(
EventBookmark()
EventBookmark(other: EventBookmark)
EventBookmark(eventId: int)
A description of a bookmark on an event
)");
struct EventBookmark
{
DOCUMENT(R"(The :data:`eventId <renderdoc.APIEvent.eventId>` at which this bookmark is placed.
@@ -2210,6 +2232,7 @@ struct EventBookmark
DOCUMENT("");
EventBookmark() = default;
EventBookmark(const EventBookmark &) = default;
EventBookmark(uint32_t e) : eventId(e) {}
bool operator==(const EventBookmark &o) const { return eventId == o.eventId; }
bool operator!=(const EventBookmark &o) const { return eventId != o.eventId; }
+7 -1
View File
@@ -38,7 +38,13 @@ struct RemoteHostData;
// are unexpectedly removed (such as disconnecting an auto-populated device) these structs are
// copied around and they have a shared locked data pointer. All accessors then lock and look up the
// data there to fetch or modify
DOCUMENT("A handle for interacting with a remote server on a given host.");
DOCUMENT(R"(
RemoteHost()
RemoteHost(other: RemoteHost)
RemoteHost(hostname: str)
A handle for interacting with a remote server on a given host.
)");
class RemoteHost
{
public:
@@ -87,5 +87,10 @@ fail:
template <>
inline SDFile *MakeFromArgsTuple<SDFile>(PyObject *args)
{
if(!SWIG_Python_UnpackTuple(args, "new_SDFile", 0, 0, 0))
SWIG_fail;
return new SDFile();
fail:
return NULL;
}
+3
View File
@@ -114,6 +114,9 @@ TEMPLATE_FIXEDARRAY_DECLARE(rdcfixedarray);
static int capviewer_init(PyObject *self, PyObject *args) {
PyObject *resultobj = 0;
ICaptureViewer *result = 0;
if(!SWIG_Python_UnpackTuple(args, "new_CaptureViewer", 0, 0, 0))
return -1;
result = new PythonCaptureViewer(self);
resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ICaptureViewer, SWIG_BUILTIN_INIT | 0);