maxscript/foundation/numbers.h File Reference
 
 
 
maxscript/foundation/numbers.h File Reference
#include "../kernel/value.h"
#include "mxstime.h"
#include "../macros/define_implementations.h"
#include "..\protocols\math.inl"

Classes

class   Double
class   Integer
class   Integer64
class   IntegerPtr

Defines

#define  FLOAT_CACHE_SIZE   1024
#define  DOUBLE_CACHE_SIZE   512
#define  INT_CACHE_SIZE   512
#define  INT64_CACHE_SIZE   128
#define  LOW_INT_RANGE   100
#define  is_integer_number(v)   ((DbgVerify(!is_sourcepositionwrapper(v)), (v))->tag == class_tag(Integer) || (v)->tag == class_tag(Integer64) || (v)->tag == class_tag(IntegerPtr))
#define  is_float_number(v)   ((DbgVerify(!is_sourcepositionwrapper(v)), (v))->tag == class_tag(Float) || (v)->tag == class_tag(Double))
#define  is_number(o)   (is_integer_number(o) || is_float_number(o))
#define  is_double(v)   ((DbgVerify(!is_sourcepositionwrapper(v)), (v))->tag == class_tag(Double))
#define  is_integer(v)   ((DbgVerify(!is_sourcepositionwrapper(v)), (v))->tag == class_tag(Integer))
#define  is_integer64(v)   ((DbgVerify(!is_sourcepositionwrapper(v)), (v))->tag == class_tag(Integer64))
#define  is_integerptr(v)   ((DbgVerify(!is_sourcepositionwrapper(v)), (v))->tag == class_tag(IntegerPtr))
#define  is_float(v)   ((DbgVerify(!is_sourcepositionwrapper(v)), (v))->tag == class_tag(Float))
#define  is_double(v)   ((DbgVerify(!is_sourcepositionwrapper(v)), (v))->tag == class_tag(Double))
#define  is_int(v)   ((DbgVerify(!is_sourcepositionwrapper(v)), (v))->tag == class_tag(Integer))
#define  is_int64(v)   ((DbgVerify(!is_sourcepositionwrapper(v)), (v))->tag == class_tag(Integer64))
#define  is_intptr(v)   ((DbgVerify(!is_sourcepositionwrapper(v)), (v))->tag == class_tag(IntegerPtr))

Functions

  visible_class_debug_ok (Number) class Number
  applyable_class_debug_ok (Float) applyable_class_debug_ok(Double) applyable_class_debug_ok(Integer) applyable_class_debug_ok(Integer64) applyable_class_debug_ok(IntegerPtr) class Float

Variables

Float *  float_cache []
Double double_cache []
Integer int_cache []
Integer64 int64_cache []

Define Documentation

#define FLOAT_CACHE_SIZE   1024
#define DOUBLE_CACHE_SIZE   512
#define INT_CACHE_SIZE   512
#define INT64_CACHE_SIZE   128
#define LOW_INT_RANGE   100
#define is_integer_number (   v )    ((DbgVerify(!is_sourcepositionwrapper(v)), (v))->tag == class_tag(Integer) || (v)->tag == class_tag(Integer64) || (v)->tag == class_tag(IntegerPtr))
#define is_float_number (   v )    ((DbgVerify(!is_sourcepositionwrapper(v)), (v))->tag == class_tag(Float) || (v)->tag == class_tag(Double))
#define is_number (   o )    (is_integer_number(o) || is_float_number(o))
#define is_double (   v )    ((DbgVerify(!is_sourcepositionwrapper(v)), (v))->tag == class_tag(Double))
#define is_integer (   v )    ((DbgVerify(!is_sourcepositionwrapper(v)), (v))->tag == class_tag(Integer))
#define is_integer64 (   v )    ((DbgVerify(!is_sourcepositionwrapper(v)), (v))->tag == class_tag(Integer64))
#define is_integerptr (   v )    ((DbgVerify(!is_sourcepositionwrapper(v)), (v))->tag == class_tag(IntegerPtr))
#define is_float (   v )    ((DbgVerify(!is_sourcepositionwrapper(v)), (v))->tag == class_tag(Float))
#define is_double (   v )    ((DbgVerify(!is_sourcepositionwrapper(v)), (v))->tag == class_tag(Double))
#define is_int (   v )    ((DbgVerify(!is_sourcepositionwrapper(v)), (v))->tag == class_tag(Integer))
#define is_int64 (   v )    ((DbgVerify(!is_sourcepositionwrapper(v)), (v))->tag == class_tag(Integer64))
#define is_intptr (   v )    ((DbgVerify(!is_sourcepositionwrapper(v)), (v))->tag == class_tag(IntegerPtr))

Function Documentation

visible_class_debug_ok ( Number  )

Define an equal operator (i.e. '==') for maxscript visible values.

Define a NOT equal operator (i.e. '!=') for maxscript visible values.

             : public Value
{
public:
#  define  is_integer_number(v) ((DbgVerify(!is_sourcepositionwrapper(v)), (v))->tag == class_tag(Integer) || (v)->tag == class_tag(Integer64) || (v)->tag == class_tag(IntegerPtr))
#  define  is_float_number(v) ((DbgVerify(!is_sourcepositionwrapper(v)), (v))->tag == class_tag(Float) || (v)->tag == class_tag(Double))
#  define  is_number(o) (is_integer_number(o) || is_float_number(o))
        classof_methods (Number, Value);

        static   Value* read(const MCHAR* str, bool heapAlloc = false);
        static   void setup();

#include "../macros/define_implementations.h"
        def_generic( coerce, "coerce");
        def_generic( copy,   "copy");
};
applyable_class_debug_ok ( Float  )

Define an equal operator (i.e. '==') for maxscript visible values.

Define a NOT equal operator (i.e. '!=') for maxscript visible values.

            : public Number
{
public:
        float value;
#pragma push_macro("new")
#undef new
        ENABLE_STACK_ALLOCATE(Float);
#pragma pop_macro("new")
        Float() { }
        ScripterExport Float(float init_val);

        static ScripterExport Value* intern(float init_val);
        static ScripterExport Value* heap_intern(float init_val);

        classof_methods (Float, Number);
#  define  is_float(v) ((DbgVerify(!is_sourcepositionwrapper(v)), (v))->tag == class_tag(Float))
        void  collect();
        ScripterExport void  sprin1(CharStream* s);

        /* include all the protocol declarations */

#include "../macros/define_implementations.h"
#  include "..\protocols\math.inl"

        float    to_float() { return value; }
        double   to_double() { return static_cast<double>(value); }
        int      to_int();
        INT64    to_int64() { return static_cast<INT64>(value); }
        INT_PTR  to_intptr()
        {
#ifndef _WIN64
                return to_int();
#else
                return to_int64();
#endif
        }
        TimeValue to_timevalue() { return (TimeValue)(value * GetTicksPerFrame()); }  // numbers used as times are in frames
        void  to_fpvalue(FPValue& v) { v.f = to_float(); v.type = (ParamType2)TYPE_FLOAT; }

        Value*   widen_to(Value* arg, Value** arg_list);
        BOOL  comparable(Value* arg) { return (is_number(arg) || is_time(arg)); }

        // scene I/O 
        IOResult Save(ISave* isave);
        static Value* Load(ILoad* iload, USHORT chunkID, ValueLoader* vload);
};

Variable Documentation