00001 using System; 00002 using System.Collections.Generic; 00003 using System.Text; 00004 using System.Runtime.InteropServices; 00005 00006 namespace EmbeddedCh 00007 { 00008 [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] 00009 public struct ChOptions_t 00010 { 00011 public int shelltype; 00012 /* int chrc; */ 00013 /* deprecated, use default value */ 00014 /* char *chrcname; */ 00015 /* deprecated, use default value */ 00016 public String chhome; 00018 /* char *chmtdir; */ 00019 /* directory for dynamically loaded libs chmt1.dl, chmt2.dl etc. 00020 deprecated, use default value*/ 00021 }; 00022 00023 /* return type for Ch_FuncType() */ 00024 public enum ChFuncType_t 00025 { 00026 CH_NOTFUNCTYPE, /* not function */ 00027 CH_FUNCTYPE, /* regular function */ 00028 CH_FUNCPROTOTYPE, /* function prototype without function definition */ 00029 CH_FUNCPTRTYPE, /* pointer to function */ 00030 CH_FUNCMEMBERTYPE,/* member function of a class */ 00031 CH_FUNCCONSTYPE, /* constructor of a class */ 00032 CH_FUNCDESTTYPE /* destructor of a class */ 00033 }; 00034 00035 /* return type for Ch_VarType () */ 00036 public enum ChVarType_t 00037 { 00038 CH_NOTVARTYPE, /* undefined, tag in struct tag{}; enum tag{}; typedef int tag;*/ 00039 CH_GLOBALVARTYPE, /* global variables including functions with function definition */ 00040 CH_LOCALVARTYPE /* local variables including functions with function definition */ 00041 /* CH_FUNCPROTOTYPE obsolete */ /* function prototype without function definition */ 00042 } ; 00043 00044 /* the information for a block in Ch */ 00045 [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] 00046 public struct ChBlock_t { 00047 int event_; /* event for callback */ 00048 int count; /* every 'count' instructions for callback mask CH_MASKCOUNT */ 00049 int level; /* int level2() {level1();} int leve1(){level0();} int leve0() {current func}. 00050 Level 0 is the current running function, whereas level n+1 00051 is the function that has called level n. */ 00052 int linecurrent; /* the current line num where the given function is executing. */ 00053 int linefuncbegin; /* the line number where the definition of the function begins. */ 00054 int linefuncend; /* the line number where the definition of the function ends. */ 00055 String source; /* the file name if the source is a file, otherwise, it is a string. 00056 It contains the first 70 characters beginning with "@string: " */ 00057 String funcname; /* function name if the block is a function, otherwise NULL */ 00058 String classname; /* class name if it is a member function, otherwise NULL */ 00059 int isconstructor; /* true if it is a constructor of class, otherwise false */ 00060 int isdestructor; /* true if it is a destructor of class, otherwise false */ 00061 }; 00062 00063 /* the information for a user defined tag of class/struct/union in Ch */ 00064 public struct ChUserDefinedInfo_t { 00065 ChType_t dtype; /* user defined data type: CH_STRUCTTYPE, CH_CLASSTYPE, CH_UNIONTYPE, or CH_UNDEFINETYPE */ 00066 String tagname; /* tag name */ 00067 int size; /* size of class/struct/union */ 00068 int totnum; /* total number of members in class/struct/union */ 00069 }; 00070 00071 /* the information for a member of class/struct/union in Ch */ 00072 public struct ChMemInfo_t { 00073 int index; /* index number of the member */ 00074 String memname; /* member name */ 00075 int offset; /* offset of the member from the starting memory for the class/struct */ 00076 ChType_t dtype; /* data type of the member */ 00077 int ispublic; /* 1: public; 0: private */ 00078 int isfunc; /* 1: function type; 0: not function type */ 00079 int ismemberfunc; /* 1: member funct; 0: not member funct */ 00080 int isconstructor; /* 1: constructor; 0: not constructor */ 00081 int isdestructor; /* 1: destructor; 0: not destructor */ 00082 int isvararg; /* 1: function with variable number arguments; 0: not */ 00083 int arraytype; /* one of array type defined in ch.h, similar to Ch_ArrayType() */ 00084 int dim; /* array dim */ 00085 [MarshalAs(UnmanagedType.ByValArray, SizeConst = 7)] 00086 int[] extent; /* extent for each dimension, up to 7 */ 00087 int isbitfield; /* 1: bit field; 0: not bit field */ 00088 int fieldsize; /* struct tag{int i:3, j:10}; fieldsize of j is 10 */ 00089 int fieldoffset; /* struct tag{int i:3, j:10}; fieldoffset of j is 3 */ 00090 //^^ TBD 00091 //ChUserDefinedTag_t udtag; /* tag for member of struct/class/union */ 00092 IntPtr udtag; /* tag for member of struct/class/union */ 00093 }; 00094 00095 //^^ TBD 00096 //typedef int ChFile_t; /* file descriptor for portable file stream redirection */ 00097 //typedef void *ChFuncdl_t; /* pointer to wrappter _chdl function for Ch_DeclareFunc(ChInterp_t, char *, ChFuncdl_t); */ 00098 //typedef void *ChPointer_t; /* a generic Ch pointer */ 00099 /* call back function prototype for Ch_AddCallback() */ 00100 //typedef void (*ChCallback_t)(ChInterp_t interp, ChBlock_t *calldata, ChPointer_t clientdata); 00101 //typedef void *ChValueNode_t; /* pointer to a value node inside Ch for 00102 // ChValueNode_t Ch_ExprValue(ChInterp_t interp, const char *expr, void *result); 00103 // int Ch_DeleteExprValue(ChInterp_t interp, ChValueNode_t vn);*/ 00104 00110 public enum ChShellType 00111 { 00112 CH_REGULARCH = 0, 00113 CH_SAFECH = 1, 00114 } 00115 00116 /* Standard file descriptors used in 2nd arg in Ch_Reopen() */ 00117 public enum ChFileDescriptor 00118 { 00119 STDIN_FILENO = 0, /* Standard input. */ 00120 STDOUT_FILENO = 1, /* Standard output. */ 00121 STDERR_FILENO = 2, /* Standard error output. */ 00122 }; 00123 00124 /* The mast for callback setup by Ch_AddCallback() () */ 00125 [Flags] 00126 public enum ChCallbackMask 00127 { 00128 CH_MASKNONE = 0X0000, 00129 CH_MASKCALL = 0X0001, 00130 CH_MASKRET = 0X0002, 00131 CH_MASKBLOCK = 0X0004, 00132 CH_MASKEND = 0X0008, 00133 CH_MASKLINE = 0X0010, 00134 CH_MASKCOUNT = 0X0020, 00135 CH_MASKABORT = 0X0040, 00136 } 00137 00138 //^^ TBD 00139 /* one of possible return values of Ch_ChangeStack() */ 00140 //#define CH_INVALIDLEVEL 2 00141 00142 00143 }