home *** CD-ROM | disk | FTP | other *** search
/ Computer Shopper 275 / DPCS0111DVD.ISO / Toolkit / Audio-Visual / VirtualDub / Source / VirtualDub-1.9.10-src.7z / src / h / vd2 / plugin / vdvideofilt.h < prev    next >
Encoding:
C/C++ Source or Header  |  2009-09-14  |  18.6 KB  |  517 lines

  1. //    VirtualDub - Video processing and capture application
  2. //    Copyright (C) 1998-2001 Avery Lee
  3. //
  4. //    This program is free software; you can redistribute it and/or modify
  5. //    it under the terms of the GNU General Public License as published by
  6. //    the Free Software Foundation; either version 2 of the License, or
  7. //    (at your option) any later version.
  8. //
  9. //    This program is distributed in the hope that it will be useful,
  10. //    but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12. //    GNU General Public License for more details.
  13. //
  14. //    You should have received a copy of the GNU General Public License
  15. //    along with this program; if not, write to the Free Software
  16. //    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17.  
  18. #ifndef f_VD2_PLUGIN_VDVIDEOFILT_H
  19. #define f_VD2_PLUGIN_VDVIDEOFILT_H
  20.  
  21. #ifdef _MSC_VER
  22.     #pragma once
  23. #endif
  24.  
  25. #include <stddef.h>
  26.  
  27. #include "vdplugin.h"
  28.  
  29. typedef struct VDXHINSTANCEStruct *VDXHINSTANCE;
  30. typedef struct VDXHDCStruct *VDXHDC;
  31. typedef struct VDXHWNDStruct *VDXHWND;
  32.  
  33. //////////////////
  34.  
  35. struct VDXScriptObject;
  36. struct VDXFilterVTbls;
  37.  
  38. //////////////////
  39.  
  40. enum {
  41.     /// Request distinct source and destination buffers. Otherwise, the source and destination buffers
  42.     /// alias (in-place mode).
  43.     FILTERPARAM_SWAP_BUFFERS        = 0x00000001L,
  44.  
  45.     /// Request an extra buffer for the previous source frame.
  46.     FILTERPARAM_NEEDS_LAST            = 0x00000002L,
  47.  
  48.     /// Filter supports image formats other than RGB32. Filters that support format negotiation must
  49.     /// set this flag for all calls to paramProc.
  50.     FILTERPARAM_SUPPORTS_ALTFORMATS    = 0x00000004L,
  51.  
  52.     /// Filter requests 16 byte alignment for source and destination buffers. This guarantees that:
  53.     ///
  54.     ///        - data and pitch fields are multiples of 16 bytes (aligned)
  55.     ///        - an integral number of 16 byte vectors may be read, even if the last vector includes
  56.     ///          some bytes beyond the end of the scanline (their values are undefined)
  57.     ///        - an integral number of 16 byte vectors may be written, even if the last vector includes
  58.     ///          some bytes beyong the end of the scanline (their values are ignored)
  59.     ///
  60.     FILTERPARAM_ALIGN_SCANLINES        = 0x00000008L,
  61.  
  62.     /// Filter's output is purely a function of configuration parameters and source image data, and not
  63.     /// source or output frame numbers. In other words, two output frames produced by a filter instance
  64.     /// can be assumed to be identical images if:
  65.     ///
  66.     ///        - the same number of source frames are prefetched
  67.     ///        - the same type of prefetches are performed (direct vs. non-direct)
  68.     ///        - the frame numbers for the two prefetch lists, taken in order, correspond to identical
  69.     ///          source frames
  70.     ///        - the prefetch cookies match
  71.     ///
  72.     /// Enabling this flag improves the ability of the host to identify identical frames and drop them
  73.     /// in preview or in the output file.
  74.     ///
  75.     FILTERPARAM_PURE_TRANSFORM        = 0x00000010L,
  76.  
  77.     /// Filter cannot support the requested source format. Note that this sets all bits, so the meaning
  78.     /// of other bits is ignored. The one exception is that FILTERPARAM_SUPPORTS_ALTFORMATS is assumed
  79.     /// to be implicitly set.
  80.     FILTERPARAM_NOT_SUPPORTED        = (long)0xFFFFFFFF
  81. };
  82.  
  83. /// The filter has a delay from source to output. For instance, a lag of 3 indicates that the
  84. /// filter internally buffers three frames, so when it is fed frames in sequence, frame 0 emerges
  85. /// after frame 3 has been processed. The host attempts to correct timestamps in order to compensate.
  86. ///
  87. /// VirtualDub 1.9.1 or later: Setting this flag can have a performance penalty, as it causes the host
  88. /// to request additional frames to try to produce the correct requested output frames.
  89. ///
  90. #define FILTERPARAM_HAS_LAG(frames) ((int)(frames) << 16)
  91.  
  92. ///////////////////
  93.  
  94. class VDXFBitmap;
  95. class VDXFilterActivation;
  96. struct VDXFilterFunctions;
  97. struct VDXFilterModule;
  98. class IVDXVideoPrefetcher;
  99. class IVDXAContext;
  100.  
  101. enum {
  102.     kVDXVFEvent_None                = 0,
  103.     kVDXVFEvent_InvalidateCaches    = 1
  104. };
  105.  
  106. typedef int  (__cdecl *VDXFilterInitProc     )(VDXFilterActivation *fa, const VDXFilterFunctions *ff);
  107. typedef void (__cdecl *VDXFilterDeinitProc   )(VDXFilterActivation *fa, const VDXFilterFunctions *ff);
  108. typedef int  (__cdecl *VDXFilterRunProc      )(const VDXFilterActivation *fa, const VDXFilterFunctions *ff);
  109. typedef long (__cdecl *VDXFilterParamProc    )(VDXFilterActivation *fa, const VDXFilterFunctions *ff);
  110. typedef int  (__cdecl *VDXFilterConfigProc   )(VDXFilterActivation *fa, const VDXFilterFunctions *ff, VDXHWND hWnd);
  111. typedef void (__cdecl *VDXFilterStringProc   )(const VDXFilterActivation *fa, const VDXFilterFunctions *ff, char *buf);
  112. typedef int  (__cdecl *VDXFilterStartProc    )(VDXFilterActivation *fa, const VDXFilterFunctions *ff);
  113. typedef int  (__cdecl *VDXFilterEndProc      )(VDXFilterActivation *fa, const VDXFilterFunctions *ff);
  114. typedef bool (__cdecl *VDXFilterScriptStrProc)(VDXFilterActivation *fa, const VDXFilterFunctions *, char *, int);
  115. typedef void (__cdecl *VDXFilterStringProc2  )(const VDXFilterActivation *fa, const VDXFilterFunctions *ff, char *buf, int maxlen);
  116. typedef int  (__cdecl *VDXFilterSerialize    )(VDXFilterActivation *fa, const VDXFilterFunctions *ff, char *buf, int maxbuf);
  117. typedef void (__cdecl *VDXFilterDeserialize  )(VDXFilterActivation *fa, const VDXFilterFunctions *ff, const char *buf, int maxbuf);
  118. typedef void (__cdecl *VDXFilterCopy         )(VDXFilterActivation *fa, const VDXFilterFunctions *ff, void *dst);
  119. typedef sint64 (__cdecl *VDXFilterPrefetch   )(const VDXFilterActivation *fa, const VDXFilterFunctions *ff, sint64 frame);
  120. typedef void (__cdecl *VDXFilterCopy2Proc    )(VDXFilterActivation *fa, const VDXFilterFunctions *ff, void *dst, VDXFilterActivation *fa2, const VDXFilterFunctions *ff2);
  121. typedef bool (__cdecl *VDXFilterPrefetch2Proc)(const VDXFilterActivation *fa, const VDXFilterFunctions *ff, sint64 frame, IVDXVideoPrefetcher *prefetcher);
  122. typedef bool (__cdecl *VDXFilterEventProc     )(const VDXFilterActivation *fa, const VDXFilterFunctions *ff, uint32 event, const void *eventData);
  123. typedef void (__cdecl *VDXFilterAccelRunProc )(const VDXFilterActivation *fa, const VDXFilterFunctions *ff);
  124.  
  125. typedef int (__cdecl *VDXFilterModuleInitProc)(VDXFilterModule *fm, const VDXFilterFunctions *ff, int& vdfd_ver, int& vdfd_compat);
  126. typedef void (__cdecl *VDXFilterModuleDeinitProc)(VDXFilterModule *fm, const VDXFilterFunctions *ff);
  127.  
  128. //////////
  129.  
  130. typedef void (__cdecl *VDXFilterPreviewButtonCallback)(bool fNewState, void *pData);
  131. typedef void (__cdecl *VDXFilterPreviewSampleCallback)(VDXFBitmap *, long lFrame, long lCount, void *pData);
  132.  
  133. class IVDXFilterPreview {
  134. public:
  135.     virtual void SetButtonCallback(VDXFilterPreviewButtonCallback, void *)=0;
  136.     virtual void SetSampleCallback(VDXFilterPreviewSampleCallback, void *)=0;
  137.  
  138.     virtual bool isPreviewEnabled()=0;
  139.     virtual void Toggle(VDXHWND)=0;
  140.     virtual void Display(VDXHWND, bool)=0;
  141.     virtual void RedoFrame()=0;
  142.     virtual void RedoSystem()=0;
  143.     virtual void UndoSystem()=0;
  144.     virtual void InitButton(VDXHWND)=0;
  145.     virtual void Close()=0;
  146.     virtual bool SampleCurrentFrame()=0;
  147.     virtual long SampleFrames()=0;
  148. };
  149.  
  150. class IVDXFilterPreview2 : public IVDXFilterPreview {
  151. public:
  152.     virtual bool IsPreviewDisplayed() = 0;
  153. };
  154.  
  155. class IVDXVideoPrefetcher : public IVDXUnknown {
  156. public:
  157.     enum { kIID = VDXMAKEFOURCC('X', 'v', 'p', 'f') };
  158.  
  159.     /// Request a video frame fetch from an upstream source.
  160.     virtual void VDXAPIENTRY PrefetchFrame(sint32 srcIndex, sint64 frame, uint64 cookie) = 0;
  161.  
  162.     /// Request a video frame fetch from an upstream source in direct mode.
  163.     /// This specifies that the output frame is the same as the input frame.
  164.     /// There cannot be more than one direct fetch and there must be no standard
  165.     /// fetches at the same time. There can, however, be symbolic fetches.
  166.     virtual void VDXAPIENTRY PrefetchFrameDirect(sint32 srcIndex, sint64 frame) = 0;
  167.  
  168.     /// Request a symbolic fetch from a source. This does not actually fetch
  169.     /// any frames, but marks an association from source to output. This is
  170.     /// useful for indicating the approximate center of where an output derives
  171.     /// in a source, even if those frames aren't fetched (perhaps due to caching).
  172.     /// There may be either zero or one symbolic fetch per source.
  173.     ///
  174.     /// If no symbolic fetches are performed, the symbolic frame is assumed to
  175.     /// be the rounded mean of the fetched source frames.
  176.     virtual void VDXAPIENTRY PrefetchFrameSymbolic(sint32 srcIndex, sint64 frame) = 0;
  177. };
  178.  
  179. //////////
  180.  
  181. enum {
  182.     // This is the highest API version supported by this header file.
  183.     VIRTUALDUB_FILTERDEF_VERSION        = 15,
  184.  
  185.     // This is the absolute lowest API version supported by this header file.
  186.     // Note that V4 is rather old, corresponding to VirtualDub 1.2.
  187.     // Chances are you will need to declare a higher version.
  188.     VIRTUALDUB_FILTERDEF_COMPATIBLE        = 4,
  189.  
  190.     // API V9 is a slightly saner baseline, since it is the first API
  191.     // version that has copy constructor support. You may still need to
  192.     // declare a higher vdfd_compat version in your module init if you
  193.     // need features beyond V9 (VirtualDub 1.4.12).
  194.     VIRTUALDUB_FILTERDEF_COMPATIBLE_COPYCTOR = 9
  195.  
  196. };
  197.  
  198. // v3: added lCurrentSourceFrame to FrameStateInfo
  199. // v4 (1.2): lots of additions (VirtualDub 1.2)
  200. // v5 (1.3d): lots of bugfixes - stretchblt bilinear, and non-zero startproc
  201. // v6 (1.4): added error handling functions
  202. // v7 (1.4d): added frame lag, exception handling
  203. // v8 (1.4.11): added string2 proc
  204. // v9 (1.4.12): added (working) copy constructor
  205. // v10 (1.5.10): added preview flag
  206. // v11 (1.7.0): guaranteed src structure setup before configProc; added IVDFilterPreview2
  207. // v12 (1.7.4): support for frame alteration
  208. // v13 (1.8.2): added mOutputFrame field to VDXFilterStateInfo
  209. // v14 (1.9.1): added copyProc2, prefetchProc2, input/output frame arrays
  210. // v15 (1.9.3): added VDXA support
  211.  
  212. struct VDXFilterDefinition {
  213.     void *_next;        // deprecated - set to NULL
  214.     void *_prev;        // deprecated - set to NULL
  215.     void *_module;        // deprecated - set to NULL
  216.  
  217.     const char *        name;
  218.     const char *        desc;
  219.     const char *        maker;
  220.     void *                private_data;
  221.     int                    inst_data_size;
  222.  
  223.     VDXFilterInitProc        initProc;
  224.     VDXFilterDeinitProc        deinitProc;
  225.     VDXFilterRunProc        runProc;
  226.     VDXFilterParamProc        paramProc;
  227.     VDXFilterConfigProc        configProc;
  228.     VDXFilterStringProc        stringProc;
  229.     VDXFilterStartProc        startProc;
  230.     VDXFilterEndProc        endProc;
  231.  
  232.     VDXScriptObject            *script_obj;
  233.  
  234.     VDXFilterScriptStrProc    fssProc;
  235.  
  236.     // NEW - 1.4.11
  237.     VDXFilterStringProc2    stringProc2;
  238.     VDXFilterSerialize        serializeProc;
  239.     VDXFilterDeserialize    deserializeProc;
  240.     VDXFilterCopy            copyProc;
  241.  
  242.     VDXFilterPrefetch        prefetchProc;        // (V12/V1.7.4+)
  243.  
  244.     // NEW - V14 / 1.9.1
  245.     VDXFilterCopy2Proc        copyProc2;
  246.     VDXFilterPrefetch2Proc    prefetchProc2;
  247.     VDXFilterEventProc        eventProc;
  248.  
  249.     // NEW - V15 / 1.9.3
  250.     VDXFilterAccelRunProc    accelRunProc;
  251. };
  252.  
  253. //////////
  254.  
  255. // FilterStateInfo: contains dynamic info about file being processed
  256.  
  257. class VDXFilterStateInfo {
  258. public:
  259.     sint32    lCurrentFrame;                // current sequence frame (previously called output frame)
  260.     sint32    lMicrosecsPerFrame;            // microseconds per sequence frame
  261.     sint32    lCurrentSourceFrame;        // current source frame
  262.     sint32    lMicrosecsPerSrcFrame;        // microseconds per source frame
  263.     sint32    lSourceFrameMS;                // source frame timestamp
  264.     sint32    lDestFrameMS;                // output frame timestamp
  265.  
  266.     enum {
  267.         kStateNone        = 0x00000000,
  268.         kStatePreview    = 0x00000001,    // (V1.5.10+) Job output is not being saved to disk.
  269.         kStateRealTime    = 0x00000002,    // (V1.5.10+) Operation is running in real-time (capture, playback).
  270.         kStateMax        = 0xFFFFFFFF
  271.     };
  272.  
  273.     uint32    flags;
  274.  
  275.     sint32    mOutputFrame;                // (V13/V1.8.2+) current output frame
  276. };
  277.  
  278. // VDXFBitmap: VBitmap extended to hold filter-specific information
  279.  
  280. class VDXBitmap {
  281. public:
  282.     void *            _vtable;    // Reserved - do not use.
  283.     uint32 *        data;        // Pointer to start of _bottom-most_ scanline of plane 0.
  284.     uint32 *        palette;    // Pointer to palette (reserved - set to NULL).
  285.     sint32            depth;        // Bit depth, in bits. Set to zero if mpPixmap/mpPixmapLayout are active.
  286.     sint32            w;            // Width of bitmap, in pixels.
  287.     sint32            h;            // Height of bitmap, in pixels.
  288.     ptrdiff_t        pitch;        // Distance, in bytes, from the start of one scanline in plane 0 to the next.
  289.     ptrdiff_t        modulo;        // Distance, in bytes, from the end of one scanline in plane 0 to the start of the next.
  290.     ptrdiff_t        size;        // Size of plane 0, including padding.
  291.     ptrdiff_t        offset;        // Offset from beginning of buffer to beginning of plane 0.
  292.  
  293.     uint32 *Address32(int x, int y) const {
  294.         return Address32i(x, h-y-1);
  295.     }
  296.  
  297.     uint32 *Address32i(int x, int y) const {
  298.         return (uint32 *)((char *)data + y*pitch + x*4);
  299.     }
  300.  
  301.     void AlignTo4() {
  302.         pitch = w << 2;
  303.     }
  304.  
  305.     void AlignTo8() {
  306.         pitch = ((w+1)&~1) << 2;
  307.     }
  308. };
  309.  
  310. class VDXFBitmap : public VDXBitmap {
  311. public:
  312.     enum {
  313.         /// Set in paramProc if the filter requires a Win32 GDI display context
  314.         /// for a bitmap. (Deprecated as of API V12 - do not use)
  315.         NEEDS_HDC        = 0x00000001L,
  316.     };
  317.  
  318.     uint32        dwFlags;
  319.     VDXHDC        hdc;
  320.  
  321.     uint32    mFrameRateHi;        // Frame rate numerator (V1.7.4+)
  322.     uint32    mFrameRateLo;        // Frame rate denominator (V1.7.4+)
  323.     sint64    mFrameCount;        // Frame count; -1 if unlimited or indeterminate (V1.7.4+)
  324.  
  325.     VDXPixmapLayout    *mpPixmapLayout;
  326.     const VDXPixmap    *mpPixmap;
  327.  
  328.     uint32    mAspectRatioHi;                ///< Pixel aspect ratio fraction (numerator).    0/0 = unknown
  329.     uint32    mAspectRatioLo;                ///< Pixel aspect ratio fraction (denominator).
  330.  
  331.     sint64    mFrameNumber;                ///< Current frame number (zero based).
  332.     sint64    mFrameTimestampStart;        ///< Starting timestamp of frame, in 100ns units.
  333.     sint64    mFrameTimestampEnd;            ///< Ending timestamp of frame, in 100ns units.
  334.     sint64    mCookie;                    ///< Cookie supplied when frame was requested.
  335.  
  336.     uint32    mVDXAHandle;                ///< Acceleration handle to be used with VDXA routines.
  337.     uint32    mBorderWidth;
  338.     uint32    mBorderHeight;
  339. };
  340.  
  341. // VDXFilterActivation: This is what is actually passed to filters at runtime.
  342.  
  343. class VDXFilterActivation {
  344. public:
  345.     const VDXFilterDefinition *filter;        // 
  346.     void *filter_data;
  347.     VDXFBitmap&    dst;
  348.     VDXFBitmap&    src;
  349.     VDXFBitmap    *_reserved0;
  350.     VDXFBitmap    *const last;
  351.     uint32        x1;
  352.     uint32        y1;
  353.     uint32        x2;
  354.     uint32        y2;
  355.  
  356.     VDXFilterStateInfo    *pfsi;
  357.     IVDXFilterPreview    *ifp;
  358.     IVDXFilterPreview2    *ifp2;            // (V11+)
  359.  
  360.     uint32        mSourceFrameCount;        // (V14+)
  361.     VDXFBitmap *const *mpSourceFrames;    // (V14+)
  362.     VDXFBitmap *const *mpOutputFrames;    // (V14+)
  363.  
  364.     IVDXAContext    *mpVDXA;            // (V15+)
  365. };
  366.  
  367. // These flags must match those in cpuaccel.h!
  368.  
  369. #ifndef f_VIRTUALDUB_CPUACCEL_H
  370. #define CPUF_SUPPORTS_CPUID            (0x00000001L)
  371. #define CPUF_SUPPORTS_FPU            (0x00000002L)
  372. #define CPUF_SUPPORTS_MMX            (0x00000004L)
  373. #define CPUF_SUPPORTS_INTEGER_SSE    (0x00000008L)
  374. #define CPUF_SUPPORTS_SSE            (0x00000010L)
  375. #define CPUF_SUPPORTS_SSE2            (0x00000020L)
  376. #define CPUF_SUPPORTS_3DNOW            (0x00000040L)
  377. #define CPUF_SUPPORTS_3DNOW_EXT        (0x00000080L)
  378. #endif
  379.  
  380. struct VDXFilterFunctions {
  381.     VDXFilterDefinition *(__cdecl *addFilter)(VDXFilterModule *, VDXFilterDefinition *, int fd_len);
  382.     void (__cdecl *removeFilter)(VDXFilterDefinition *);
  383.     bool (__cdecl *isFPUEnabled)();
  384.     bool (__cdecl *isMMXEnabled)();
  385.     void (__cdecl *InitVTables)(VDXFilterVTbls *);
  386.  
  387.     // These functions permit you to throw MyError exceptions from a filter.
  388.     // YOU MUST ONLY CALL THESE IN runProc, initProc, and startProc.
  389.  
  390.     void (__cdecl *ExceptOutOfMemory)();                        // ADDED: V6 (VirtualDub 1.4)
  391.     void (__cdecl *Except)(const char *format, ...);            // ADDED: V6 (VirtualDub 1.4)
  392.  
  393.     // These functions are callable at any time.
  394.  
  395.     long (__cdecl *getCPUFlags)();                                // ADDED: V6 (VirtualDub 1.4)
  396.     long (__cdecl *getHostVersionInfo)(char *buffer, int len);    // ADDED: V7 (VirtualDub 1.4d)
  397. };
  398.  
  399.  
  400.  
  401.  
  402.  
  403. ///////////////////////////////////////////////////////////////////////////
  404.  
  405. class VDXScriptValue;
  406. class VDXScriptError;
  407. struct VDXScriptObject;
  408.  
  409. class VDXScriptError {
  410. public:
  411.     enum {
  412.         PARSE_ERROR=1,
  413.         SEMICOLON_EXPECTED,
  414.         IDENTIFIER_EXPECTED,
  415.  
  416.         TYPE_INT_REQUIRED,
  417.         TYPE_ARRAY_REQUIRED,
  418.         TYPE_FUNCTION_REQUIRED,
  419.         TYPE_OBJECT_REQUIRED,
  420.  
  421.         OBJECT_MEMBER_NAME_REQUIRED,
  422.         FUNCCALLEND_EXPECTED,
  423.         TOO_MANY_PARAMS,
  424.         DIVIDE_BY_ZERO,
  425.         VAR_NOT_FOUND,
  426.         MEMBER_NOT_FOUND,
  427.         OVERLOADED_FUNCTION_NOT_FOUND,
  428.         IDENT_TOO_LONG,
  429.         OPERATOR_EXPECTED,
  430.         CLOSEPARENS_EXPECTED,
  431.         CLOSEBRACKET_EXPECTED,
  432.  
  433.         VAR_UNDEFINED,
  434.  
  435.         OUT_OF_STRING_SPACE,
  436.         OUT_OF_MEMORY,
  437.         INTERNAL_ERROR,
  438.         EXTERNAL_ERROR,
  439.  
  440.         FCALL_OUT_OF_RANGE,
  441.         FCALL_INVALID_PTYPE,
  442.         FCALL_UNKNOWN_STR,
  443.  
  444.         ARRAY_INDEX_OUT_OF_BOUNDS,
  445.  
  446.         NUMERIC_OVERFLOW,
  447.         STRING_NOT_AN_INTEGER_VALUE,
  448.         STRING_NOT_A_REAL_VALUE,
  449.  
  450.         ASSERTION_FAILED,
  451.         AMBIGUOUS_CALL,
  452.         CANNOT_CAST
  453.     };
  454. };
  455.  
  456. class IVDXScriptInterpreter {
  457. public:
  458.     virtual    void _placeholder1() {}
  459.     virtual void _placeholder2(void *, void *) {}
  460.     virtual void _placeholder3(char *s) {}
  461.  
  462.     virtual void ScriptError(int e)=0;
  463.     virtual void _placeholder4(VDXScriptError& cse) {}
  464.     virtual char** AllocTempString(long l)=0;
  465.  
  466.     virtual void _placeholder5() {}
  467. };
  468.  
  469. #define EXT_SCRIPT_ERROR(x)    (isi->ScriptError((VDXScriptError::x)))
  470.  
  471. typedef VDXScriptValue (*VDXScriptFunctionPtr)(IVDXScriptInterpreter *, void *, const VDXScriptValue *, int);
  472. typedef void (*VDXScriptVoidFunctionPtr)(IVDXScriptInterpreter *, void *, const VDXScriptValue *, int);
  473. typedef int (*VDXScriptIntFunctionPtr)(IVDXScriptInterpreter *, void *, const VDXScriptValue *, int);
  474.  
  475. struct VDXScriptFunctionDef {
  476.     VDXScriptFunctionPtr func_ptr;
  477.     char *name;
  478.     char *arg_list;
  479. };
  480.  
  481. struct VDXScriptObject {
  482.     void *_lookup;                            // reserved - set to NULL
  483.     VDXScriptFunctionDef    *func_list;
  484.     void *_obj_list;                        // reserved - set to NULL
  485. };
  486.  
  487. class VDXScriptValue {
  488. public:
  489.     enum { T_VOID, T_INT, T_PINT, T_STR, T_ARRAY, T_OBJECT, T_FNAME, T_FUNCTION, T_VARLV, T_LONG, T_DOUBLE } type;
  490.     VDXScriptObject *thisPtr;
  491.     union {
  492.         int i;
  493.         char **s;
  494.         sint64 l;
  495.         double d;
  496.     } u;
  497.  
  498.     VDXScriptValue()                    { type = T_VOID; }
  499.     VDXScriptValue(int i)                { type = T_INT;            u.i = i; }
  500.     VDXScriptValue(sint64 l)            { type = T_LONG;        u.l = l; }
  501.     VDXScriptValue(double d)            { type = T_DOUBLE;        u.d = d; }
  502.     VDXScriptValue(char **s)            { type = T_STR;            u.s = s; }
  503.  
  504.     bool isVoid() const                    { return type == T_VOID; }
  505.     bool isInt() const                    { return type == T_INT; }
  506.     bool isString() const                { return type == T_STR; }
  507.     bool isLong() const                    { return type == T_LONG; }
  508.     bool isDouble() const                { return type == T_DOUBLE; }
  509.  
  510.     int        asInt() const                { return u.i; }
  511.     sint64    asLong() const                { return u.l; }
  512.     double    asDouble() const            { return u.d; }
  513.     char **    asString() const             { return u.s; }
  514. };
  515.  
  516. #endif
  517.