00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef BxCAAMInterpretorData
00022 #define BxCAAMInterpretorData
00023
00024 #if defined(__BORLANDC__) && !defined(_NO_VCL)
00025 #include <vcl.h>
00026 #endif
00027
00028 #include <exception>
00029
00031
00032
00033
00034
00035
00036
00037 typedef int *PBxInteger;
00038 typedef short *PBxSmallInt;
00039 typedef unsigned int *PBxCardinal;
00040 typedef unsigned short *PBxWord;
00041 typedef bool *PBxBoolean;
00042 typedef char *PBxChar;
00043 #if defined(__BORLANDC__) && !defined(_NO_VCL)
00044 typedef AnsiString *PBxString;
00045 #endif
00046 typedef float *PBxSingle;
00047 typedef double *PBxDouble;
00048 typedef long double *PBxExtended;
00049 typedef void *PBxPointer;
00050
00051
00052
00053
00054
00055 typedef PBxDouble *PPBxDouble;
00056 typedef PPBxDouble TBxDoubleArray;
00057 struct TOptics
00058 {
00059 TBxDoubleArray Amplitude;
00060 TBxDoubleArray Phase;
00061 double sizeX;
00062 double sizeY;
00063 int width;
00064 int height;
00065 };
00066 typedef TOptics* POptics;
00067
00068 typedef
00069
00070 struct TModes
00071 {
00072 int count;
00073 PBxInteger m, n;
00074 PBxDouble alpha, w;
00075 PBxDouble A, phi;
00076 } TModes;
00077 typedef TModes *PModes;
00078
00079 typedef
00080
00081 struct TComplex1D
00082 {
00083 int size;
00084 PBxDouble imag;
00085 PBxDouble real;
00086 double beginX;
00087 double endX;
00088 } TComplex1D;
00089 typedef TComplex1D *PComplex1D;
00090
00091 #if defined(__BORLANDC__) && !defined(_NO_VCL)
00092 typedef DynamicArray<double> TDoubles;
00093 typedef DynamicArray<int> TInts;
00094 typedef
00095
00096 struct TBxSchedule
00097 {
00098 TDoubles Argument;
00099 TDoubles Abscissa;
00100 TInts Orders;
00101 } TBxSchedule;
00102 typedef TBxSchedule *PBxSchedule;
00103 #endif
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119 struct IInterpreterCAAMExternalInterface;
00120 typedef IInterpreterCAAMExternalInterface * PInterpreterCAAMExternalInterface;
00121 typedef int (__stdcall *setProgressPositionInvoker)(PInterpreterCAAMExternalInterface , double );
00122 typedef bool (__stdcall *isExitInvoker)(PInterpreterCAAMExternalInterface);
00123 struct IInterpreterCAAMExternalInterface
00124 {
00126 setProgressPositionInvoker setProgressPosition;
00127 int (__stdcall *setProgressText)(PInterpreterCAAMExternalInterface, const char*);
00128 const char* (__stdcall *getProjectPath)(PInterpreterCAAMExternalInterface);
00130 isExitInvoker isExit;
00131 void (__stdcall *exitWithError)(PInterpreterCAAMExternalInterface, const char*);
00132 void * self;
00133 int processId;
00134 unsigned int LanguageId;
00135 };
00136 #if defined(__BORLANDC__) && !defined(_NO_VCL)
00137 class EExit : public Exception {
00138 public :
00139 EExit(void) : Exception("Exit"){
00140
00141 }
00142 };
00143 #else
00144 class EExit : public std::exception {
00145 public :
00146 EExit(void) : std::exception(){
00147
00148 }
00149 };
00150 #endif
00151
00152
00153 inline void Progress(
00154 PInterpreterCAAMExternalInterface pExternalInterface, double position)
00155 {
00156 if (pExternalInterface->isExit(pExternalInterface))
00157 throw EExit();
00158 pExternalInterface->setProgressPosition(pExternalInterface, position);
00159 }
00160
00161 #if defined(__BORLANDC__) && !defined(_NO_VCL)
00162 inline void Except(PInterpreterCAAMExternalInterface pExternalInterface,
00163 const Exception * e)
00164 {
00165 if ((dynamic_cast<const EExit *>(e)) == 0)
00166 pExternalInterface->exitWithError(pExternalInterface, e->Message.c_str());
00167 }
00168
00169 #else
00170
00171 inline void Except(PInterpreterCAAMExternalInterface pExternalInterface,
00172 const std::exception * e)
00173 {
00174 if ((dynamic_cast<const EExit *>(e)) == 0 && pExternalInterface)
00175 pExternalInterface->exitWithError(pExternalInterface, e->what());
00176 }
00177 #endif
00178
00179
00180
00192 #define BX_CAAM_BEGIN_FUNCTION(pExternalInterface)\
00193 try\
00194 {
00195
00196 #if defined(__BORLANDC__) && !defined(_NO_VCL)
00197
00204 #define BX_CAAM_END_FUNCTION(pExternalInterface)\
00205 }\
00206 catch (const Exception * exception)\
00207 {\
00208 Except(pExternalInterface, exception);\
00209 }
00210
00211 #else
00212
00213 #define BX_CAAM_END_FUNCTION(pExternalInterface)\
00214 }\
00215 catch (const std::exception &e)\
00216 {\
00217 Except(pExternalInterface, &e);\
00218 }\
00219 catch (const std::exception *e)\
00220 {\
00221 Except(pExternalInterface, e);\
00222 }
00223
00224 #endif
00225
00226 #if defined(__BORLANDC__)
00227
00228 #define BX_CAAM_EXPORT_FUNCTION(TYPE)\
00229 extern "C" __declspec(dllexport) TYPE _stdcall
00230
00231 #else
00232
00233 #define BX_CAAM_EXPORT_FUNCTION(TYPE)\
00234 extern "C" __declspec(dllexport) TYPE
00235
00236 #endif
00237
00238
00239 #endif //BxCAAMInterpretorData