All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Public Attributes | List of all members
uscript::Value Struct Reference

#include <value.h>

Public Member Functions

void Print () const
 
void PrintObj () const
 
bool operator! () const
 

Public Attributes

ValueType val
 
union {
   bool   boolean
 
   double   number
 
   int   integer
 
   ObjString   string
 
   ObjTInstance   tinst
 
as
 

Detailed Description

Definition at line 29 of file value.h.

Member Function Documentation

bool uscript::Value::operator! ( ) const

Definition at line 16 of file value.cc.

16  {
17  return IS_NIL(*this) || (IS_INTEGER(*this) && AS_INTEGER(*this) == 0) || (IS_BOOL(*this) && !AS_BOOL(*this));
18 }
#define IS_INTEGER(value)
Definition: value.h:62
#define AS_BOOL(value)
Definition: value.h:52
#define IS_BOOL(value)
Definition: value.h:60
#define IS_NIL(value)
Definition: value.h:59
#define AS_INTEGER(value)
Definition: value.h:54
void uscript::Value::Print ( ) const

Definition at line 5 of file value.cc.

5  {
6  switch (val) {
7  case uscript::VAL_BOOL: std::cout << (AS_BOOL(*this) ? "true" : "false"); break;
8  case uscript::VAL_NIL: std::cout << "nil"; break;
9  case uscript::VAL_NUMBER: std::cout << AS_NUMBER(*this); break;
10  case uscript::VAL_INTEGER: std::cout << AS_INTEGER(*this); break;
11  case uscript::VAL_OBJ_STRING: std::cout << AS_CSTRING(*this); break;
12  case uscript::VAL_OBJ_TINSTANCE: std::cout << "TInstance"; break;
13  }
14 }
#define AS_BOOL(value)
Definition: value.h:52
#define AS_NUMBER(value)
Definition: value.h:53
#define AS_CSTRING(value)
Definition: value.h:56
ValueType val
Definition: value.h:30
#define AS_INTEGER(value)
Definition: value.h:54
BEGIN_PROLOG could also be cout
void uscript::Value::PrintObj ( ) const

Member Data Documentation

union { ... } uscript::Value::as
bool uscript::Value::boolean

Definition at line 32 of file value.h.

int uscript::Value::integer

Definition at line 34 of file value.h.

double uscript::Value::number

Definition at line 33 of file value.h.

ObjString uscript::Value::string

Definition at line 35 of file value.h.

ObjTInstance uscript::Value::tinst

Definition at line 36 of file value.h.

ValueType uscript::Value::val

Definition at line 30 of file value.h.


The documentation for this struct was generated from the following files: