PageRenderTime 21ms CodeModel.GetById 9ms app.highlight 8ms RepoModel.GetById 2ms app.codeStats 0ms

/xbmc/visualizations/Vortex/angelscript/add_on/scriptarray/scriptarray.h

http://github.com/xbmc/xbmc
C++ Header | 65 lines | 43 code | 18 blank | 4 comment | 0 complexity | 1af4050f81a56f08e8a0520d48be7483 MD5 | raw file
 1#ifndef SCRIPTARRAY_H
 2#define SCRIPTARRAY_H
 3
 4#include <angelscript.h>
 5
 6BEGIN_AS_NAMESPACE
 7
 8struct SArrayBuffer;
 9
10class CScriptArray
11{
12public:
13	CScriptArray(asUINT length, asIObjectType *ot);
14	virtual ~CScriptArray();
15
16	void AddRef();
17	void Release();
18
19	// Type information
20	asIObjectType *GetArrayObjectType() const;
21	int            GetArrayTypeId() const;
22	int            GetElementTypeId() const;
23
24	void   Resize(asUINT numElements);
25	asUINT GetSize();
26
27	// Get a pointer to an element. Returns 0 if out of bounds
28	void  *At(asUINT index);
29
30	CScriptArray &operator=(const CScriptArray&);
31
32	// TODO: Add methods Sort, Reverse, Find, PopLast, PushLast, InsertAt, RemoveAt, etc
33
34	// GC methods
35	int  GetRefCount();
36	void SetFlag();
37	bool GetFlag();
38	void EnumReferences(asIScriptEngine *engine);
39	void ReleaseAllHandles(asIScriptEngine *engine);
40
41protected:
42	int            refCount;
43	bool           gcFlag;
44	asIObjectType *objType;
45	SArrayBuffer  *buffer;
46	bool           isArrayOfHandles;
47	int            elementSize;
48
49	bool CheckMaxSize(asUINT numElements);
50
51	void CreateBuffer(SArrayBuffer **buf, asUINT numElements);
52	void DeleteBuffer(SArrayBuffer *buf);
53	void CopyBuffer(SArrayBuffer *dst, SArrayBuffer *src);
54
55	void Construct(SArrayBuffer *buf, asUINT start, asUINT end);
56	void Destruct(SArrayBuffer *buf, asUINT start, asUINT end);
57};
58
59void RegisterScriptArray(asIScriptEngine *engine);
60void RegisterScriptArray_Native(asIScriptEngine *engine);
61void RegisterScriptArray_Generic(asIScriptEngine *engine);
62
63END_AS_NAMESPACE
64
65#endif