blender/source/gameengine/Expressions/ListValue.h
Campbell Barton 6b9f3b5f5c BGE Python API
Remove the last of the odd C++/python wrapper code from http://www.python.org/doc/PyCPP.html (~1998)

* Use python subclasses rather then having fake subclassing through get/set attributes calling parent types.
* PyObject getset arrays are created while initializing the types, converted from our own attribute arrays. This way python deals with subclasses and we dont have to define getattro or setattro functions for each type.
* GameObjects and Scenes no longer have attribute access to properties. only dictionary style access - ob['prop']
* remove each class's get/set/dir functions.
* remove isA() methods, can use PyObject_TypeCheck() in C and issubclass() in python.
* remove Parents[] array for each C++ class, was only used for isA() and wasnt correct in quite a few cases.
* remove PyTypeObject that was being passed as the last argument to each class (the parent classes too).

TODO -
* Light and VertexProxy need to be converted to using attributes.
* memory for getset arrays is never freed, not that bad since its will only allocates once.
2009-06-28 11:22:26 +00:00

89 lines
2.4 KiB
C++

/*
* ListValue.h: interface for the CListValue class.
* $Id$
* Copyright (c) 1996-2000 Erwin Coumans <coockie@acm.org>
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Erwin Coumans makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*
*/
#if !defined _LISTVALUE_H
#define _LISTVALUE_H
#include "Value.h"
class CListValue : public CPropValue
{
Py_Header;
//PLUGIN_DECLARE_SERIAL (CListValue,CValue)
public:
CListValue();
virtual ~CListValue();
void AddConfigurationData(CValue* menuvalue);
void Configure(CValue* menuvalue);
void Add(CValue* value);
/** @attention not implemented yet :( */
virtual CValue* Calc(VALUE_OPERATOR op,CValue *val);
virtual CValue* CalcFinal(VALUE_DATA_TYPE dtype,
VALUE_OPERATOR op,
CValue* val);
virtual double GetNumber();
virtual CValue* GetReplica();
public:
void MergeList(CListValue* otherlist);
bool RemoveValue(CValue* val);
void SetReleaseOnDestruct(bool bReleaseContents);
bool SearchValue(CValue* val);
CValue* FindValue(const STR_String & name);
CValue* FindValue(const char *name);
void ReleaseAndRemoveAll();
virtual void SetModified(bool bModified);
virtual inline bool IsModified();
void Remove(int i);
void Resize(int num);
void SetValue(int i,CValue* val);
CValue* GetValue(int i){ assertd(i < m_pValueArray.size()); return m_pValueArray[i];}
int GetCount() { return m_pValueArray.size();};
virtual const STR_String & GetText();
bool CheckEqual(CValue* first,CValue* second);
virtual PyObject* py_repr(void) {
PyObject *py_proxy= this->GetProxy();
PyObject *py_list= PySequence_List(py_proxy);
PyObject *py_string= PyObject_Repr(py_list);
Py_DECREF(py_list);
Py_DECREF(py_proxy);
return py_string;
}
KX_PYMETHOD_O(CListValue,append);
KX_PYMETHOD_NOARGS(CListValue,reverse);
KX_PYMETHOD_O(CListValue,index);
KX_PYMETHOD_O(CListValue,count);
KX_PYMETHOD_VARARGS(CListValue,get);
KX_PYMETHOD_O(CListValue,has_key);
KX_PYMETHOD_O(CListValue,from_id);
private:
std::vector<CValue*> m_pValueArray;
bool m_bReleaseContents;
};
#endif // !defined _LISTVALUE_H