mirror of
https://github.com/id-Software/DOOM-3-BFG.git
synced 2025-05-31 08:50:54 +00:00
Formatted code using Artistic Style for better readability.
This commit is contained in:
parent
d40e661b3e
commit
f55a763ca4
701 changed files with 206183 additions and 142961 deletions
|
@ -2,9 +2,9 @@
|
|||
===========================================================================
|
||||
|
||||
Doom 3 BFG Edition GPL Source Code
|
||||
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
|
||||
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
|
||||
|
||||
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
|
||||
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
|
||||
|
||||
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
@ -35,11 +35,15 @@ class idSWFSpriteInstance;
|
|||
This is the base class for script variables which are implemented in code
|
||||
========================
|
||||
*/
|
||||
class idSWFScriptNativeVariable {
|
||||
class idSWFScriptNativeVariable
|
||||
{
|
||||
public:
|
||||
virtual bool IsReadOnly() { return false; }
|
||||
virtual void Set( class idSWFScriptObject * object, const idSWFScriptVar & value ) = 0;
|
||||
virtual idSWFScriptVar Get( class idSWFScriptObject * object ) = 0;
|
||||
virtual bool IsReadOnly()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
virtual void Set( class idSWFScriptObject* object, const idSWFScriptVar& value ) = 0;
|
||||
virtual idSWFScriptVar Get( class idSWFScriptObject* object ) = 0;
|
||||
};
|
||||
|
||||
#define SWF_NATIVE_VAR_DECLARE( x ) \
|
||||
|
@ -63,14 +67,19 @@ This is a helper class for quickly setting up native variables which need access
|
|||
========================
|
||||
*/
|
||||
template< typename T >
|
||||
class idSWFScriptNativeVariable_Nested : public idSWFScriptNativeVariable {
|
||||
class idSWFScriptNativeVariable_Nested : public idSWFScriptNativeVariable
|
||||
{
|
||||
public:
|
||||
idSWFScriptNativeVariable_Nested() : pThis( NULL ) { }
|
||||
idSWFScriptNativeVariable_Nested * Bind( T * p ) { pThis = p; return this; }
|
||||
virtual void Set( class idSWFScriptObject * object, const idSWFScriptVar & value ) = 0;
|
||||
virtual idSWFScriptVar Get( class idSWFScriptObject * object ) = 0;
|
||||
idSWFScriptNativeVariable_Nested* Bind( T* p )
|
||||
{
|
||||
pThis = p;
|
||||
return this;
|
||||
}
|
||||
virtual void Set( class idSWFScriptObject* object, const idSWFScriptVar& value ) = 0;
|
||||
virtual idSWFScriptVar Get( class idSWFScriptObject* object ) = 0;
|
||||
protected:
|
||||
T * pThis;
|
||||
T* pThis;
|
||||
};
|
||||
|
||||
#define SWF_NATIVE_VAR_DECLARE_NESTED( x, y ) \
|
||||
|
@ -93,97 +102,133 @@ protected:
|
|||
An object in an action script is a collection of variables. functions are also variables.
|
||||
========================
|
||||
*/
|
||||
class idSWFScriptObject {
|
||||
class idSWFScriptObject
|
||||
{
|
||||
public:
|
||||
idSWFScriptObject();
|
||||
idSWFScriptObject();
|
||||
virtual ~idSWFScriptObject();
|
||||
|
||||
static idSWFScriptObject * Alloc();
|
||||
|
||||
static idSWFScriptObject* Alloc();
|
||||
void AddRef();
|
||||
void Release();
|
||||
void SetNoAutoDelete( bool b ) { noAutoDelete = b; }
|
||||
|
||||
void Clear();
|
||||
|
||||
void MakeArray();
|
||||
|
||||
void SetSprite( idSWFSpriteInstance * s ) { objectType = SWF_OBJECT_SPRITE; data.sprite = s; }
|
||||
idSWFSpriteInstance * GetSprite() { return ( objectType == SWF_OBJECT_SPRITE ) ? data.sprite : NULL; }
|
||||
|
||||
void SetText( idSWFTextInstance * t ) { objectType = SWF_OBJECT_TEXT; data.text = t; }
|
||||
idSWFTextInstance * GetText() { return ( objectType == SWF_OBJECT_TEXT ) ? data.text : NULL; }
|
||||
|
||||
// Also accessible via __proto__ property
|
||||
idSWFScriptObject * GetPrototype() { return prototype; }
|
||||
void SetPrototype( idSWFScriptObject *_prototype ) { assert( prototype == NULL ); prototype = _prototype; prototype->AddRef(); }
|
||||
idSWFScriptVar Get( int index );
|
||||
idSWFScriptVar Get( const char * name );
|
||||
idSWFSpriteInstance * GetSprite( int index );
|
||||
idSWFSpriteInstance * GetSprite( const char * name );
|
||||
idSWFScriptObject * GetObject( int index );
|
||||
idSWFScriptObject * GetObject( const char * name );
|
||||
idSWFTextInstance * GetText( int index );
|
||||
idSWFTextInstance * GetText( const char * name );
|
||||
void Set( int index, const idSWFScriptVar & value );
|
||||
void Set( const char * name, const idSWFScriptVar & value );
|
||||
void SetNative( const char * name, idSWFScriptNativeVariable * native );
|
||||
bool HasProperty( const char * name );
|
||||
bool HasValidProperty( const char * name );
|
||||
idSWFScriptVar DefaultValue( bool stringHint );
|
||||
|
||||
// This is to implement for-in (fixme: respect DONTENUM flag)
|
||||
int NumVariables() { return variables.Num(); }
|
||||
const char * EnumVariable( int i ) { return variables[i].name; }
|
||||
void SetNoAutoDelete( bool b )
|
||||
{
|
||||
noAutoDelete = b;
|
||||
}
|
||||
|
||||
void Clear();
|
||||
|
||||
void MakeArray();
|
||||
|
||||
void SetSprite( idSWFSpriteInstance* s )
|
||||
{
|
||||
objectType = SWF_OBJECT_SPRITE;
|
||||
data.sprite = s;
|
||||
}
|
||||
idSWFSpriteInstance* GetSprite()
|
||||
{
|
||||
return ( objectType == SWF_OBJECT_SPRITE ) ? data.sprite : NULL;
|
||||
}
|
||||
|
||||
void SetText( idSWFTextInstance* t )
|
||||
{
|
||||
objectType = SWF_OBJECT_TEXT;
|
||||
data.text = t;
|
||||
}
|
||||
idSWFTextInstance* GetText()
|
||||
{
|
||||
return ( objectType == SWF_OBJECT_TEXT ) ? data.text : NULL;
|
||||
}
|
||||
|
||||
// Also accessible via __proto__ property
|
||||
idSWFScriptObject* GetPrototype()
|
||||
{
|
||||
return prototype;
|
||||
}
|
||||
void SetPrototype( idSWFScriptObject* _prototype )
|
||||
{
|
||||
assert( prototype == NULL );
|
||||
prototype = _prototype;
|
||||
prototype->AddRef();
|
||||
}
|
||||
idSWFScriptVar Get( int index );
|
||||
idSWFScriptVar Get( const char* name );
|
||||
idSWFSpriteInstance* GetSprite( int index );
|
||||
idSWFSpriteInstance* GetSprite( const char* name );
|
||||
idSWFScriptObject* GetObject( int index );
|
||||
idSWFScriptObject* GetObject( const char* name );
|
||||
idSWFTextInstance* GetText( int index );
|
||||
idSWFTextInstance* GetText( const char* name );
|
||||
void Set( int index, const idSWFScriptVar& value );
|
||||
void Set( const char* name, const idSWFScriptVar& value );
|
||||
void SetNative( const char* name, idSWFScriptNativeVariable* native );
|
||||
bool HasProperty( const char* name );
|
||||
bool HasValidProperty( const char* name );
|
||||
idSWFScriptVar DefaultValue( bool stringHint );
|
||||
|
||||
// This is to implement for-in (fixme: respect DONTENUM flag)
|
||||
int NumVariables()
|
||||
{
|
||||
return variables.Num();
|
||||
}
|
||||
const char* EnumVariable( int i )
|
||||
{
|
||||
return variables[i].name;
|
||||
}
|
||||
|
||||
idSWFScriptVar GetNestedVar( const char* arg1, const char* arg2 = NULL, const char* arg3 = NULL, const char* arg4 = NULL, const char* arg5 = NULL, const char* arg6 = NULL );
|
||||
idSWFScriptObject* GetNestedObj( const char* arg1, const char* arg2 = NULL, const char* arg3 = NULL, const char* arg4 = NULL, const char* arg5 = NULL, const char* arg6 = NULL );
|
||||
idSWFSpriteInstance* GetNestedSprite( const char* arg1, const char* arg2 = NULL, const char* arg3 = NULL, const char* arg4 = NULL, const char* arg5 = NULL, const char* arg6 = NULL );
|
||||
idSWFTextInstance* GetNestedText( const char* arg1, const char* arg2 = NULL, const char* arg3 = NULL, const char* arg4 = NULL, const char* arg5 = NULL, const char* arg6 = NULL );
|
||||
|
||||
idSWFScriptVar GetNestedVar( const char * arg1, const char * arg2 = NULL, const char * arg3 = NULL, const char * arg4 = NULL, const char * arg5 = NULL, const char * arg6 = NULL );
|
||||
idSWFScriptObject * GetNestedObj( const char * arg1, const char * arg2 = NULL, const char * arg3 = NULL, const char * arg4 = NULL, const char * arg5 = NULL, const char * arg6 = NULL );
|
||||
idSWFSpriteInstance * GetNestedSprite( const char * arg1, const char * arg2 = NULL, const char * arg3 = NULL, const char * arg4 = NULL, const char * arg5 = NULL, const char * arg6 = NULL );
|
||||
idSWFTextInstance * GetNestedText( const char * arg1, const char * arg2 = NULL, const char * arg3 = NULL, const char * arg4 = NULL, const char * arg5 = NULL, const char * arg6 = NULL );
|
||||
|
||||
void PrintToConsole() const;
|
||||
|
||||
|
||||
private:
|
||||
int refCount;
|
||||
bool noAutoDelete;
|
||||
|
||||
enum swfNamedVarFlags_t {
|
||||
|
||||
enum swfNamedVarFlags_t
|
||||
{
|
||||
SWF_VAR_FLAG_NONE = 0,
|
||||
SWF_VAR_FLAG_READONLY = BIT(1),
|
||||
SWF_VAR_FLAG_DONTENUM = BIT(2)
|
||||
SWF_VAR_FLAG_READONLY = BIT( 1 ),
|
||||
SWF_VAR_FLAG_DONTENUM = BIT( 2 )
|
||||
};
|
||||
struct swfNamedVar_t {
|
||||
swfNamedVar_t() : native( NULL ) { }
|
||||
~swfNamedVar_t();
|
||||
swfNamedVar_t & operator=( const swfNamedVar_t & other );
|
||||
|
||||
struct swfNamedVar_t
|
||||
{
|
||||
swfNamedVar_t() : native( NULL ) { }
|
||||
~swfNamedVar_t();
|
||||
swfNamedVar_t& operator=( const swfNamedVar_t& other );
|
||||
|
||||
int index;
|
||||
int hashNext;
|
||||
idStr name;
|
||||
idSWFScriptVar value;
|
||||
idSWFScriptNativeVariable * native;
|
||||
idSWFScriptNativeVariable* native;
|
||||
int flags;
|
||||
};
|
||||
idList< swfNamedVar_t, TAG_SWF > variables;
|
||||
|
||||
|
||||
static const int VARIABLE_HASH_BUCKETS = 16;
|
||||
int variablesHash[VARIABLE_HASH_BUCKETS];
|
||||
|
||||
idSWFScriptObject * prototype;
|
||||
|
||||
enum swfObjectType_t {
|
||||
|
||||
idSWFScriptObject* prototype;
|
||||
|
||||
enum swfObjectType_t
|
||||
{
|
||||
SWF_OBJECT_OBJECT,
|
||||
SWF_OBJECT_ARRAY,
|
||||
SWF_OBJECT_SPRITE,
|
||||
SWF_OBJECT_TEXT
|
||||
} objectType;
|
||||
|
||||
union swfObjectData_t {
|
||||
idSWFSpriteInstance * sprite; // only valid if objectType == SWF_OBJECT_SPRITE
|
||||
idSWFTextInstance * text; // only valid if objectType == SWF_OBJECT_TEXT
|
||||
|
||||
union swfObjectData_t
|
||||
{
|
||||
idSWFSpriteInstance* sprite; // only valid if objectType == SWF_OBJECT_SPRITE
|
||||
idSWFTextInstance* text; // only valid if objectType == SWF_OBJECT_TEXT
|
||||
} data;
|
||||
|
||||
swfNamedVar_t * GetVariable( int index, bool create );
|
||||
swfNamedVar_t * GetVariable( const char * name, bool create );
|
||||
|
||||
swfNamedVar_t* GetVariable( int index, bool create );
|
||||
swfNamedVar_t* GetVariable( const char* name, bool create );
|
||||
};
|
||||
|
||||
#endif // !__SWF_SCRIPTOBJECT_H__
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue