OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4Value.cpp File Reference
#include "C4Include.h"
#include "script/C4Value.h"
#include "script/C4AulExec.h"
#include "object/C4Def.h"
#include "object/C4DefList.h"
#include "script/C4StringTable.h"
#include "script/C4ValueArray.h"
#include "game/C4Game.h"
#include "game/C4GameScript.h"
#include "object/C4GameObjects.h"
#include "object/C4Object.h"
#include "lib/C4Log.h"
#include "script/C4Effect.h"
Include dependency graph for C4Value.cpp:

Go to the source code of this file.

Functions

const char * GetC4VName (const C4V_Type Type)
 
C4Value C4VObj (C4Object *pObj)
 
bool ComparisonImpl (const C4Value &Value1, const C4Value &Value2)
 

Variables

const C4Value C4VNull
 

Function Documentation

C4Value C4VObj ( C4Object pObj)

Definition at line 90 of file C4Value.cpp.

Referenced by C4Object::AddObjectAndContentsToArray(), C4Game::CastObjects(), C4Landscape::P::DigMaterial2Objects(), C4ScriptGuiWindowAction::ExecuteCommand(), C4Command::Fail(), C4FindObject::FindMany(), C4EditCursor::PerformDuplication(), C4EditCursor::PerformDuplicationLegacy(), and C4EditCursor::SetHighlightedObject().

90 { return C4Value(static_cast<C4PropList*>(pObj)); }

Here is the caller graph for this function:

bool ComparisonImpl ( const C4Value Value1,
const C4Value Value2 
)
inline

Definition at line 542 of file C4Value.cpp.

References C4V_Data::Array, C4V_Array, C4V_Bool, C4V_Function, C4V_Int, C4V_Nil, C4V_PropList, C4V_String, C4V_Data::Fn, C4Value::GetData(), C4Value::GetType(), C4V_Data::Int, C4V_Data::PropList, and C4V_Data::Str.

Referenced by C4Value::operator==().

543 {
544  C4V_Type Type1 = Value1.GetType();
545  C4V_Data Data1 = Value1.GetData();
546  C4V_Type Type2 = Value2.GetType();
547  C4V_Data Data2 = Value2.GetData();
548  switch (Type1)
549  {
550  case C4V_Nil:
551  assert(!Data1);
552  return Type1 == Type2;
553  case C4V_Int:
554  case C4V_Bool:
555  return (Type2 == C4V_Int || Type2 == C4V_Bool) &&
556  Data1.Int == Data2.Int;
557  case C4V_PropList:
558  return Type1 == Type2 && *Data1.PropList == *Data2.PropList;
559  case C4V_String:
560  return Type1 == Type2 && Data1.Str == Data2.Str;
561  case C4V_Array:
562  return Type1 == Type2 &&
563  (Data1.Array == Data2.Array || *(Data1.Array) == *(Data2.Array));
564  case C4V_Function:
565  return Type1 == Type2 && Data1.Fn == Data2.Fn;
566  default:
567  assert(!"Unexpected C4Value type (denumeration missing?)");
568  return Data1 == Data2;
569  }
570 }
C4V_Type
Definition: C4Value.h:23
C4AulFunc * Fn
Definition: C4Value.h:57
C4String * Str
Definition: C4Value.h:55
C4V_Type GetType() const
Definition: C4Value.h:161
intptr_t Int
Definition: C4Value.h:52
C4ValueArray * Array
Definition: C4Value.h:56
C4V_Data GetData() const
Definition: C4Value.h:160
C4PropList * PropList
Definition: C4Value.h:54

Here is the call graph for this function:

Here is the caller graph for this function:

const char* GetC4VName ( const C4V_Type  Type)

Definition at line 34 of file C4Value.cpp.

References C4V_Any, C4V_Array, C4V_Bool, C4V_Def, C4V_Effect, C4V_Function, C4V_Int, C4V_Nil, C4V_Object, C4V_PropList, and C4V_String.

Referenced by C4AulFunc::CheckParTypes(), C4Value::GetTypeName(), and C4AulCompiler::CodegenAstVisitor::visit().

35 {
36  switch (Type)
37  {
38  case C4V_Nil:
39  return "nil";
40  case C4V_Int:
41  return "int";
42  case C4V_Bool:
43  return "bool";
44  case C4V_String:
45  return "string";
46  case C4V_Array:
47  return "array";
48  case C4V_PropList:
49  return "proplist";
50  case C4V_Any:
51  return "any";
52  case C4V_Object:
53  return "object";
54  case C4V_Def:
55  return "def";
56  case C4V_Effect:
57  return "effect";
58  case C4V_Function:
59  return "function";
60  default:
61  return "!Fehler!";
62  }
63 }

Here is the caller graph for this function:

Variable Documentation