Commit Graph

54 Commits

Author SHA1 Message Date
a7b3047cef Datablock ID Properties
The absence of datablock properties "will certainly be resolved soon as the need for them is becoming obvious" said the [[http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.67/Python_Nodes|Python Nodes release notes]]. So this patch allows Python scripts to create ID Properties which reference datablocks.
This functionality is implemented for `PointerProperty` and now such properties can be created with Python.

In addition to the standard update callback, `PointerProperty` can have a `poll` callback (standard RNA) which is useful for search menus. For details see the test included in this patch.

Original author: @artfunkel

Alexander (Blend4Web Team)

Reviewers: brecht, artfunkel, mont29, campbellbarton

Reviewed By: mont29, campbellbarton

Subscribers: jta, sergey, campbellbarton, wisaac, poseidon4o, mont29, homyachetser, Evgeny_Rodygin, AlexKowel, yurikovelenov, fjuhec, sharlybg, cardboard, duarteframos, blueprintrandom, a.romanov, BYOB, disnel, aditiapratama, bliblubli, dfelinto, lukastoenne

Maniphest Tasks: T37754

Differential Revision: https://developer.blender.org/D113
2017-04-13 12:33:05 +03:00
73a9ff0d2d PyAPI: Fast buffer access to id property arrays
Support Python's buffer protocol for ID-properties.
2017-04-10 21:12:02 +10:00
a96c9def6f PyAPI: minor optimization for dictionary creation
Pass size when its known.
2016-07-31 17:22:04 +10:00
e97ab8347a PyAPI: fix leak in unlikely case converting idprops fail 2016-07-31 16:59:08 +10:00
2dfc954c4a PyAPI: Add PyC_UnicodeAsByteAndSize
Read the string length from Python directly when assigning id-properties
2016-07-31 16:52:44 +10:00
409316434c Docs: add initial idprop.types API docs 2016-07-31 15:40:40 +10:00
cca57bf04c PyAPI: Use module names on initializaton
No need to re-convert from C strings to PyUnicode.
2016-07-14 15:51:56 +10:00
339915a962 Optimize PySequence_Fast usage
Access arrays directly, avoiding type-check every time.
2015-07-29 10:49:35 +10:00
3ce4a58aa9 Cleanup: duplicate includes 2015-06-18 06:32:01 +10:00
9fd569a654 PyAPI: add utilities PyTuple_SET_ITEMS, Py_INCREF_RET
Setting all values of a tuple is such a common operation that it deserves its own macro.
Also added Py_INCREF_RET to avoid confusing use of comma operator.
2015-01-06 19:09:11 +11:00
aab4f2b762 cleanup: redundant casts & const cast correctness 2015-01-01 23:42:28 +11:00
3da1a75b74 correct recent cleanup for id-property types 2014-12-18 02:06:57 +01:00
7b0d6a1e6c SCons: correct include for win, also minor cleanup 2014-11-24 09:56:24 +01:00
6e17fb8fe3 Fix T42593: Rigify crash when I press "Generate" - corrupted IDGroup's listbase of children
Nothing related to rigify actually, recent hack in py handling of IDProp (rB3346ab03)
was breaking integrity of IDGroup's listbase of children IDProps...

Took me hours to nail this down, should have bisected for once. :/
2014-11-14 16:42:49 +01:00
3346ab0348 Fix/workaround T37073: Crash updating custom props visible in the UI 2014-11-10 17:10:58 +01:00
3e41c8ad6f Fix compilation error with debug scons
The issue is that we've got hell with DEBUG and _DEBUG,
theu're defined really inconsistent acros CMake and SCons.

Used more reliable NDEBUG definition for IDP_spit.
2014-08-11 20:58:42 +06:00
4ca67869cc Code cleanup: remove unused includes
Opted to keep includes if they are used indirectly (even if removing is possible).
2014-05-01 04:47:51 +10:00
e73d0f57a3 Code cleanup: use 'const' for arrays (python) 2014-04-27 00:25:15 +10:00
617557b08e Code cleanup: remove TRUE/FALSE & WITH_BOOL_COMPAT define 2014-04-01 15:22:28 +11:00
a5c35fb27f Code cleanup: use booleans where appropriate 2014-01-28 04:00:04 +11:00
85bbef0f4e python api internals: no need to set the stop-iter exception string. 2013-11-17 15:09:57 +11:00
bbade535fb fix for crash when deleting from an id property, with a non-string key. 2013-11-08 08:46:43 +00:00
d3a89fc9b7 add typechecks when assigning id-property arrays from python (overflows and errors weren't detected)
reduce/simplify exceptions more.
2013-10-17 03:18:21 +00:00
a619de52cf simplify & improve error handling for id-property python-api. 2013-10-17 02:57:59 +00:00
f5660a05b1 fix [#37105] Long int IDproperties produces errors at weird spots. 2013-10-17 02:36:33 +00:00
089d0ad8f9 add IDP_FreeFromGroup(), replaces IDP_RemFromGroup(), IDP_FreeProperty(), MEM_freeN(). 2013-10-16 05:29:28 +00:00
4dd7d4110a replace macro PYC_INTERPRETER_ACTIVE for PyC_IsInterpreterActive() function call,
(indirectly referenced Python define of ~30 lines, most were optimized out but still caused some code bloat).
2013-09-18 23:21:24 +00:00
14ab39c5e0 minor improvements
- calc normals only check flag when needed.
- keymap, dont get name unless its needed.
- keymap, avoid property lookup.
- idprop debug print, include pointer, helpful for troubleshooting.
2013-07-09 00:13:17 +00:00
ddddb7bab1 code cleanup: favor braces when blocks have mixed brace use. 2013-03-09 03:46:30 +00:00
12ef1b63e2 fix for building blender as a python module,
changes to internal import behavior of py3.3 broke it.
2013-02-06 13:14:11 +00:00
c80db5878b some fixes for building blender as a python module again (wip, more work needed). 2013-02-06 13:07:45 +00:00
1a7638fa94 add id property clear function (matching the same python function for dicts/lists) 2013-01-02 23:10:14 +00:00
3fd388fb06 py api cleanup, replace use...
- PyLong_FromSsize_t --> PyLong_FromLong
- PyLong_AsSsize_t --> PyLong_AsLong

In all places except for those where python api expects PySsize_t (index lookups mainly).

- use PyBool_FromLong in a few areas of the BGE.
- fix incorrect assumption in the BGE that PySequence_Check() means PySequence_Fast_ functions can be used.
2012-11-21 02:28:36 +00:00
004f8d78ed default to Python3.3 on Linux for SCons and CMake, warn when building with python 3.2x or older.
also remove casts to keep Python3.2 warning quiet.
2012-11-05 13:48:42 +00:00
9b948717b0 code cleanup: float <> double conversion. 2012-11-03 18:23:30 +00:00
25591e958d style cleanup: tabs & whitespace 2012-11-03 15:35:03 +00:00
1bcadda46b fix [#30910] Problems: Add Shortcut(s) for "Ctrl Tab" menu
comparing keymaps was too sloppy or too strict, now sloppy keymap comparison works by setting all the operator
properties to their default values if they are not already set, then compare this with the keymap item (ignoring values missing from either one).

... this way any non default keymap setting wont match with an operator menu item which doesnt set this operator at all (a problem sighted in this bug report).


developer notes:
- IDP_EqualsProperties_ex() function adds an argument to treat missing members of either group to act as if there is a match.
- WM_operator_properties_default() function to reset RNA values to their defaults.
- add IDP_spit(), debug only function to print out ID properties.
2012-10-31 20:29:32 +00:00
c7fbeded4c add IDP_MergeGroup(dst, src, overwrite) function,
like PyDict_Merge()
2012-10-31 19:07:25 +00:00
8437980b81 optimization for PyObject -> ID-property sequence conversion, use PySequence_Fast. 2012-10-12 03:59:50 +00:00
f97dfdf227 quiet clang static checker warning by returning an error for invalid situation getting an IDProp mapping from a PyObject.
also print the path installed to when installing an addon.
2012-10-12 03:24:47 +00:00
32cf7fcdb1 code cleanup: spelling 2012-07-16 23:23:33 +00:00
2d2d36fe3b code cleanup:
- style - multi-line ifs move braces onto new lines.
- iterators - convert some to macros, other split up and move brace.
2012-05-20 19:49:27 +00:00
6520aa97a9 add 'idprop' module so we can document idprop.types.*, currently doc generator has no access to ID Property types. 2012-04-15 14:54:15 +00:00
85908b498b fix [#30906] dict(prop) crashes if prop is a PropertyGroup with nested PropertyGroup
the ID of a python ID property can be NULL.
2012-04-11 08:37:48 +00:00
11d12d945e style cleanup: python api 2012-03-26 06:55:09 +00:00
70d3d1aca6 style cleanup: py/capi 2012-03-16 21:39:56 +00:00
27d43f3fd3 added API function to C and python
* C:  BM_vert_separate(...)
* py: bmesh.utils.vert_separate(vert, edges)

This splits off regions around the vertex, splitting on connected edges passed in a sequence.

also made minor changes
- rename python api functions _rip to _separate
- fixed bmesh iterator being iterable its self (some parts of python expect this)
- fix memory leak in bmesh python api.
2012-03-09 00:01:38 +00:00
3590076193 style cleanup - comment formatting 2012-03-03 20:36:09 +00:00
74e9563b8a * bmesh py api BMEdge.verts was using 2 v1's
* bmesh pu api __repr__ functions for mesh data.
* correct py hash defines.
2012-02-26 17:20:36 +00:00
51bada696f Longer names support for all ID and other object names
This commit extends limit of ID and objects to 64 (it means 63 meaning
characters and 1 for zero-terminator). CustomData layers names are also
extended.
Changed DNA structures and all places where length constants were hardcoded.

All names which are "generating" from ID block should be limited by MAX_ID_NAME-2,
all non-id names now has got own define called MAX_NAME which should be used all
over for non-id names to make further name migration stuff easier.

All name fields in DNA now have comment with constant which corresponds to
hardcoded numeric value which should make it easier to further update this
limits or even switch to non-hardcoded values in DNA.

Special thanks to Campbell who helped figuring out some issues and helped a lot
in finding all cases where hardcoded valued were still used in code.

Both of forwards and backwards compatibility is stored with blender versions newer
than January 5, 2011. Older versions had issue with placing null-terminator to
DNA strings on file load which will lead to some unpredictable behavior or even
crashes.
2012-01-11 08:51:06 +00:00