Commit Graph

25 Commits

Author SHA1 Message Date
baldurk e305029ddd Update copyright years to 2018 2018-01-01 17:55:29 +00:00
baldurk 21d5943d82 Remove dependency on Qt in qrenderdoc python module
* The main addition here apart from some extra stubs is a new rdc type
  for date time objects.
* Although the module doesn't do anything and is only used for docs
  reflection it is desirable to not have to link against Qt as this
  can cause problems when linking the module without unresolved symbols.
2017-12-27 16:05:15 +00:00
baldurk 6937756618 Add new structured data, that will be used to expose serialised values
* We have some special handling to allow SWIG wrapping of these types:
  SDFile owns the chunks and buffers within, and each object owns its
  children. Copying is disallowed except from SWIG where we assume the
  wrapper is handling lifetime management for its objects externally.
2017-11-03 16:19:45 +00:00
baldurk 9db71b803a Change python wrapping of arrays to be more pythonic, by reference
* Previously we would convert from python to C++ arrays immediately by
  copying, and vice-versa convert TO python immediately by creating a
  new python list by copying.
* This however behaves rather poorly in common situations, e.g.:
  > foo.bar.append(5)
  Would not append 5 to foo.bar, but copy foo.bar to a temporary, append
  5 to it, then destroy it leaving foo.bar untouched.
* Instead we leave the C++ array type as a pointer for as long as we can
  and instead implement the python sequence API as extensions/slots that
  work in-place on the original array.
2017-11-03 16:19:41 +00:00
baldurk e6c5c03896 Remove rdctype namespace. Rename rdctype::str -> rdcstr, rdcarray, etc
* Since these types are more prevalent than originally designed, it
  makes more sense to remove the namespace for ease of typing/naming.
* Also add a specialised type 'bytebuf' for an array of bytes.
* This makes mapping easier to SWIG since there's no special casing for
  namespaced arrays. Especially so for nested cases like
  rdctype::array<rdctype::str> -> rdcarray<rdcstr>
2017-11-03 16:04:59 +00:00
baldurk 5e59616a8c Update rdctype::array to have a more stl-like mutable interface
* For the most part the interface is stl-compatible, but we have a few
  little changes of our own for convenience.
* This class is still needed after deleting the C# UI, because we don't
  want to pass C++ stl structs over module boundaries and possibly run
  into hard to diagnose incompatibilities.
2017-11-03 16:01:58 +00:00
baldurk 3d11c502f5 Don't use SWIG_BUILTIN_INIT for passing SWIG ptrs, use SWIG_POINTER_OWN
* The former is only needed inside tp_init of a new object. Instead when
  we want to pass in and own a pointer, we use SWIG_POINTER_OWN.
* This also removes the need to pass 'self' all the way down in
  ConvertToPy which tidies up a lot of code.
2017-09-29 12:11:15 +01:00
baldurk 90aedf58e6 Don't error if calling ConvertToPyInPlace on bytes object 2017-09-29 12:11:15 +01:00
baldurk 6759d975b0 Add conversion typemaps for fixed-size arrays in python 2017-09-29 12:11:14 +01:00
baldurk fbd1c40654 Add python typemap handling for rdctype::pair 2017-08-31 18:34:19 +01:00
baldurk 87ef595cce For a block invoke to another thread, safe and restore
* In future we could handle async exceptions by storing the exception
  information in a std::function derived object (instead of the separate
  ExceptionHandling that lives on the stack) and query it out in a new
  WaitForInvoke function maybe. Right now we just print the exception
  to the output log and abort the callback.
2017-08-03 17:57:23 +01:00
baldurk 21836c240d Don't crash on NULL pointers being dealloc'd
* The error handling code will be OK if a NULL parameter was passed in
  but during cleanup it will go through tempdealloc, so we need to check
  that the pointer is actually valid.
2017-06-09 16:57:33 +01:00
baldurk 055acb05e1 Fix an unused variable warning with python parameterless callbacks 2017-06-08 21:31:21 +01:00
baldurk 1d1b7d8c55 Fix off-by-one error converting strings
* The length returned by PyBytes_AsStringAndSize isn't the byte size
  including null terminator, but the number of bytes in the string.
2017-04-19 18:03:19 +01:00
baldurk 4c0fc8ce1d Add a specialisation for bytes objects 2017-04-18 14:57:46 +01:00
baldurk d746b9278c Define HandleCallbackFailure inline so we don't have it in renderdoc.i 2017-04-18 14:57:44 +01:00
baldurk 694d7b6c7b Split apart renderdoc.i for better organisation 2017-04-18 14:57:43 +01:00
baldurk 7a5bf26325 Add conversions for certain Qt types to/from python native types 2017-04-18 14:57:43 +01:00
baldurk 6969b5b677 Fix refcounting and lifetime management around async python callbacks
* We need to keep a PythonContext (and its globals Dict) around while
  we still have some pending callbacks happening. So now the external
  code creates a PythonContext and then releases it when it's done, but
  the context will hang around until the global redirector object is
  destructed, which is responsible for deleting the context.
* The global redirector is deleted when a refcounting cycle is detected
  and the dict is unreachable, which only happens after the context is
  released.
* Any time a callback is passed to something and converted to a
  std::function we add a reference on the global redirector to keep it
  alive. When the callback has finished executing we remove the ref.
* This way, any pending callbacks that have been called but not finished
  or converted (queued) and not called yet asynchronously will keep the
  context object alive to be able to output, handle exceptions, etc.
* Additionally we need to detect when we're being called asynchronously
  and handle exceptions separately instead of trying to propagate up the
  call chain, because there might not be any more python code up the
  chain (e.g. the render manager calling a python callback).
2017-04-18 14:57:42 +01:00
baldurk 3e1275ed50 Pass PyObject *self along with conversion functions
* We need this object to properly convert any object/pointer to a new
  python owned instance of that type.
2017-04-18 14:57:42 +01:00
baldurk dc1ee62730 Generalise function ConvertList to ConvertInPlace
* We'll use the same function for maps and we want to be able to reuse
  the typemaps and things there.
2017-04-18 14:57:42 +01:00
baldurk ab6a868057 Don't rely on TypeName just for error messages calling python callbacks 2017-04-18 14:57:42 +01:00
baldurk 6e1ebf2978 Convert strings directly without using SWIG_AsCharPtrAndSize
* This function is optionally compiled into bindings files so it might
  not be present, there's no need to depend upon it.
2017-04-18 14:57:42 +01:00
baldurk 66353de7fb Add support for SWIG wrapping python callbacks as std::functions 2017-04-18 14:57:41 +01:00
baldurk 940d3662eb Add SWIG file to generate python bindings for internal replay API
* SWIG outputs two files - renderdoc_python.cpp with the main actual
  wrapping code, and renderdoc.py a small module that does some
  bootstrapping on python side.
* We use a custom version of SWIG that generates strong/typed enums in
  python based on enum classes, so in cmake we add this custom swig
  fork as an external project and compile it before generating the
  wrappers. On windows there's a committed version of the SWIG binary
  that gets run directly from the .pro or .vcxproj.
* The renderdoc.py gets embedded as a resource on windows or as a C
  generated unsigned char array via include-bin on other platforms, so
  that we can insert it into the python context without needing it to
  sit around on disk somewhere in sys.path
2017-04-18 14:57:40 +01:00