mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 02:42:49 -04:00
Add get_tag_keys / get_python_tag_keys (based on patch by Josh Enes)
This commit is contained in:
parent
6254263a1f
commit
8c83ab08f4
@ -2181,6 +2181,73 @@ get_tag(const string &key) const {
|
|||||||
return node()->get_tag(key);
|
return node()->get_tag(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: NodePath::get_tag_keys
|
||||||
|
// Access: Published
|
||||||
|
// Description: Fills the given vector up with the
|
||||||
|
// list of tags on this PandaNode.
|
||||||
|
//
|
||||||
|
// It is the user's responsibility to ensure that the
|
||||||
|
// keys vector is empty before making this call;
|
||||||
|
// otherwise, the new files will be appended to it.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE void NodePath::
|
||||||
|
get_tag_keys(vector_string &keys) const {
|
||||||
|
nassertv_always(!is_empty());
|
||||||
|
node()->get_tag_keys(keys);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_PYTHON
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: NodePath::get_python_tag_keys
|
||||||
|
// Access: Published
|
||||||
|
// Description: Fills the given vector up with the
|
||||||
|
// list of Python tags on this PandaNode.
|
||||||
|
//
|
||||||
|
// It is the user's responsibility to ensure that the
|
||||||
|
// keys vector is empty before making this call;
|
||||||
|
// otherwise, the new files will be appended to it.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE void NodePath::
|
||||||
|
get_python_tag_keys(vector_string &keys) const {
|
||||||
|
nassertv_always(!is_empty());
|
||||||
|
node()->get_python_tag_keys(keys);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: Filename::get_tag_keys
|
||||||
|
// Access: Published
|
||||||
|
// Description: This variant on get_tag_keys returns a Python list
|
||||||
|
// of strings. Returns None if the NodePath is empty.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE PyObject *NodePath::
|
||||||
|
get_tag_keys() const {
|
||||||
|
// An empty NodePath returns None
|
||||||
|
if (is_empty()) {
|
||||||
|
Py_INCREF(Py_None);
|
||||||
|
return Py_None;
|
||||||
|
}
|
||||||
|
return node()->get_tag_keys();
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: Filename::get_python_tag_keys
|
||||||
|
// Access: Published
|
||||||
|
// Description: This variant on get_python_tag_keys returns a
|
||||||
|
// Python list of strings.
|
||||||
|
// Returns None if the NodePath is empty.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE PyObject *NodePath::
|
||||||
|
get_python_tag_keys() const {
|
||||||
|
// An empty NodePath returns None
|
||||||
|
if (is_empty()) {
|
||||||
|
Py_INCREF(Py_None);
|
||||||
|
return Py_None;
|
||||||
|
}
|
||||||
|
return node()->get_python_tag_keys();
|
||||||
|
}
|
||||||
|
#endif // HAVE_PYTHON
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: NodePath::has_tag
|
// Function: NodePath::has_tag
|
||||||
// Access: Published
|
// Access: Published
|
||||||
|
@ -891,6 +891,7 @@ PUBLISHED:
|
|||||||
|
|
||||||
INLINE void set_tag(const string &key, const string &value);
|
INLINE void set_tag(const string &key, const string &value);
|
||||||
INLINE string get_tag(const string &key) const;
|
INLINE string get_tag(const string &key) const;
|
||||||
|
INLINE void get_tag_keys(vector_string &keys) const;
|
||||||
INLINE bool has_tag(const string &key) const;
|
INLINE bool has_tag(const string &key) const;
|
||||||
INLINE void clear_tag(const string &key);
|
INLINE void clear_tag(const string &key);
|
||||||
INLINE string get_net_tag(const string &key) const;
|
INLINE string get_net_tag(const string &key) const;
|
||||||
@ -898,8 +899,11 @@ PUBLISHED:
|
|||||||
NodePath find_net_tag(const string &key) const;
|
NodePath find_net_tag(const string &key) const;
|
||||||
|
|
||||||
#ifdef HAVE_PYTHON
|
#ifdef HAVE_PYTHON
|
||||||
|
INLINE PyObject *get_tag_keys() const;
|
||||||
INLINE void set_python_tag(const string &key, PyObject *value);
|
INLINE void set_python_tag(const string &key, PyObject *value);
|
||||||
INLINE PyObject *get_python_tag(const string &key) const;
|
INLINE PyObject *get_python_tag(const string &key) const;
|
||||||
|
INLINE void get_python_tag_keys(vector_string &keys) const;
|
||||||
|
INLINE PyObject *get_python_tag_keys() const;
|
||||||
INLINE bool has_python_tag(const string &key) const;
|
INLINE bool has_python_tag(const string &key) const;
|
||||||
INLINE void clear_python_tag(const string &key);
|
INLINE void clear_python_tag(const string &key);
|
||||||
INLINE PyObject *get_net_python_tag(const string &key) const;
|
INLINE PyObject *get_net_python_tag(const string &key) const;
|
||||||
|
@ -1721,6 +1721,94 @@ list_tags(ostream &out, const string &separator) const {
|
|||||||
#endif // HAVE_PYTHON
|
#endif // HAVE_PYTHON
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: Filename::get_tag_keys
|
||||||
|
// Access: Published
|
||||||
|
// Description: Fills the given vector up with the
|
||||||
|
// list of tags on this PandaNode.
|
||||||
|
//
|
||||||
|
// It is the user's responsibility to ensure that the
|
||||||
|
// keys vector is empty before making this call;
|
||||||
|
// otherwise, the new keys will be appended to it.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void PandaNode::
|
||||||
|
get_tag_keys(vector_string &keys) const {
|
||||||
|
CDReader cdata(_cycler);
|
||||||
|
if (!cdata->_tag_data.empty()) {
|
||||||
|
TagData::const_iterator ti = cdata->_tag_data.begin();
|
||||||
|
while (ti != cdata->_tag_data.end()) {
|
||||||
|
keys.push_back((*ti).first);
|
||||||
|
++ti;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_PYTHON
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: Filename::get_python_tag_keys
|
||||||
|
// Access: Published
|
||||||
|
// Description: Fills the given vector up with the
|
||||||
|
// list of Python tags on this PandaNode.
|
||||||
|
//
|
||||||
|
// It is the user's responsibility to ensure that the
|
||||||
|
// keys vector is empty before making this call;
|
||||||
|
// otherwise, the new files will be appended to it.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void PandaNode::
|
||||||
|
get_python_tag_keys(vector_string &keys) const {
|
||||||
|
CDReader cdata(_cycler);
|
||||||
|
if (!cdata->_python_tag_data.empty()) {
|
||||||
|
PythonTagData::const_iterator ti = cdata->_python_tag_data.begin();
|
||||||
|
while (ti != cdata->_python_tag_data.end()) {
|
||||||
|
keys.push_back((*ti).first);
|
||||||
|
++ti;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: Filename::get_tag_keys
|
||||||
|
// Access: Published
|
||||||
|
// Description: This variant on get_tag_keys returns
|
||||||
|
// a Python list of strings.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
PyObject *PandaNode::
|
||||||
|
get_tag_keys() const {
|
||||||
|
vector_string keys;
|
||||||
|
get_tag_keys(keys);
|
||||||
|
|
||||||
|
PyObject *result = PyList_New(keys.size());
|
||||||
|
for (size_t i = 0; i < keys.size(); ++i) {
|
||||||
|
const string &tag_name = keys[i];
|
||||||
|
PyObject *str = PyString_FromStringAndSize(tag_name.data(), tag_name.size());
|
||||||
|
PyList_SET_ITEM(result, i, str);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: Filename::get_python_tag_keys
|
||||||
|
// Access: Published
|
||||||
|
// Description: This variant on get_python_tag_keys returns
|
||||||
|
// a Python list of strings.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
PyObject *PandaNode::
|
||||||
|
get_python_tag_keys() const {
|
||||||
|
vector_string keys;
|
||||||
|
get_python_tag_keys(keys);
|
||||||
|
|
||||||
|
PyObject *result = PyList_New(keys.size());
|
||||||
|
for (size_t i = 0; i < keys.size(); ++i) {
|
||||||
|
const string &tag_name = keys[i];
|
||||||
|
PyObject *str = PyString_FromStringAndSize(tag_name.data(), tag_name.size());
|
||||||
|
PyList_SET_ITEM(result, i, str);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
#endif // HAVE_PYTHON
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: PandaNode::compare_tags
|
// Function: PandaNode::compare_tags
|
||||||
// Access: Published
|
// Access: Published
|
||||||
|
@ -201,12 +201,16 @@ PUBLISHED:
|
|||||||
Thread *current_thread = Thread::get_current_thread()) const;
|
Thread *current_thread = Thread::get_current_thread()) const;
|
||||||
void clear_tag(const string &key,
|
void clear_tag(const string &key,
|
||||||
Thread *current_thread = Thread::get_current_thread());
|
Thread *current_thread = Thread::get_current_thread());
|
||||||
|
void get_tag_keys(vector_string &keys) const;
|
||||||
#ifdef HAVE_PYTHON
|
#ifdef HAVE_PYTHON
|
||||||
|
PyObject *get_tag_keys() const;
|
||||||
|
|
||||||
void set_python_tag(const string &key, PyObject *value);
|
void set_python_tag(const string &key, PyObject *value);
|
||||||
PyObject *get_python_tag(const string &key) const;
|
PyObject *get_python_tag(const string &key) const;
|
||||||
bool has_python_tag(const string &key) const;
|
bool has_python_tag(const string &key) const;
|
||||||
void clear_python_tag(const string &key);
|
void clear_python_tag(const string &key);
|
||||||
|
void get_python_tag_keys(vector_string &keys) const;
|
||||||
|
PyObject *get_python_tag_keys() const;
|
||||||
#endif // HAVE_PYTHON
|
#endif // HAVE_PYTHON
|
||||||
|
|
||||||
INLINE bool has_tags() const;
|
INLINE bool has_tags() const;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user