summaryrefslogtreecommitdiffstats
path: root/scilab/modules/ast/includes/system_env/configvariable.hxx
blob: 0380faf0add29ce23e679859e58eca244d197df5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
/*
*  Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
*  Copyright (C) 2008-2008 - DIGITEO - Antoine ELIAS
*
 * Copyright (C) 2012 - 2016 - Scilab Enterprises
 *
 * This file is hereby licensed under the terms of the GNU GPL v2.0,
 * pursuant to article 5.3.4 of the CeCILL v.2.1.
 * This file was originally licensed under the terms of the CeCILL v2.1,
 * and continues to be available under such terms.
 * For more information, see the COPYING file which you should have received
 * along with this program.
*
*/

#ifndef __CONFIGVARIABLE_HXX__
#define __CONFIGVARIABLE_HXX__

//disable warnings about exports STL items
#ifdef _MSC_VER
#pragma warning (disable : 4251)
#endif

#include <vector>
#include <list>
#include <map>
#include <string>
#include <memory>
#include <atomic>

#include "visitor.hxx"

extern "C"
{
#include "dynamiclibrary.h"
#include "dynlib_ast.h"
}

// Minimal values for iConsoleLines & iConsoleWidth
#define ICONSOLELINES_MIN 0
#define ICONSOLEWIDTH_MIN 10

namespace types
{
class Cell;
class ThreadId;
class Callable;
}

class EXTERN_AST ConfigVariable
{
    //module list
private :
    static std::list<std::wstring> m_ModuleList;

public :
    static void setModuleList(std::list<std::wstring>& _module_list);
    static std::list<std::wstring> getModuleList();


    //SCI
private :
    static std::wstring m_SCIPath;

public :
    static void setSCIPath(const std::wstring& _SCIPath);
    static std::wstring& getSCIPath();

    //SCIHOME
private :
    static std::wstring m_SCIHOME;

public :
    static void setSCIHOME(const std::wstring& _m_SCIHOME);
    static std::wstring& getSCIHOME();

    //TMPDIR
private :
    static std::wstring m_TMPDIR;

public :
    static void setTMPDIR(const std::wstring& _TMPDIR);
    static std::wstring& getTMPDIR();

    // Force Quit
private :
    static bool m_bForceQuit;

public :
    static void setForceQuit(bool _bForceQuit);
    static bool getForceQuit(void);

    // Exit Status
private :
    static int m_iExitStatus;

public :
    static void setExitStatus(int _iExitStatus);
    static int getExitStatus(void);

    // Digit precision, ex format function
private :
    static int m_iFormatSize;

public :
    static void setFormatSize(int _iFormatSize);
    static int getFormatSize(void);

    // printf format ( 0 -> "e", 1 -> "v")
private :
    static int m_iFormatMode;

public :
    static void setFormatMode(int _iFormatMode);
    static int getFormatMode(void);


    // Screen console width
private :
    static int m_iConsoleWidth;

public :
    static void setConsoleWidth(int _iConsoleWidth);
    static int getConsoleWidth(void);

    // Screen console lines
private :
    static int m_iConsoleLines;

public :
    static void setConsoleLines(int _iConsoleLines);
    static int getConsoleLines(void);

    // Scilab mode
private :
    static int m_iScilabMode;

public :
    static void setScilabMode(int _iScilabMode);
    static int getScilabMode(void);

    //Warning mode
private :
    static bool m_bWarningMode;

public :
    static void setWarningMode(bool _bWarningMode);
    static bool getWarningMode(void);

    // WarningStop
private :
    static bool m_bWarningStop;

public :
    static void setWarningStop(bool _bWarningStop);
    static bool getWarningStop(void);

    // WarningStop
private :
    static bool m_bOldEmptyBehaviour;

public :
    static void setOldEmptyBehaviour(bool _bOldEmptyBehaviour);
    static bool getOldEmptyBehaviour(void);

    //HOME
private :
    static std::wstring m_HOME;

public :
    static void setHOME(const std::wstring& _m_HOME);
    static std::wstring& getHOME();

    //Clear last error information
public :
    static void setLastErrorClear(void);

    //Clear last error information
private :
    static bool m_bLastErrorCall;
public :
    static void setLastErrorCall(void);
    static void clearLastError(void);

    //Last Error Message
private :
    static std::wstring m_wstError;

public :
    static void setLastErrorMessage(const std::wstring& _wstError);
    static std::wstring& getLastErrorMessage();

    //Last Error ID
private :
    static int m_iError;
    static bool m_bError;

public :
    static void setLastErrorNumber(int _iError);
    static int getLastErrorNumber();
    static void setError();
    static bool isError();
    static void resetError();

    //Last Error Line
private :
    static int m_iErrorLine;

public :
    static void setLastErrorLine(int _iLine);
    static int getLastErrorLine();

    //Last Error Function
private :
    static std::wstring m_wstErrorFunction;
public:
    static void setLastErrorFunction(const std::wstring& _wstFunction);
    static std::wstring& getLastErrorFunction();

    //verbose ";" after instruction
    //set before function call to know status of e.isVerbose in functions
private:
    static bool m_bVerbose;

public :
    static void setVerbose(bool _bVerbose);
    static bool getVerbose(void);


    //silent error ( try catch, errcatch, ... )
private :
    static bool m_iSilentError;
public:
    static void setSilentError(bool _iSilentError);
    static bool isSilentError(void);

    //Prompt Mode
public :
    /*
    Prompt mode
    normal = 0,
    silent = -1,
    prompt = 2,
    exec = 1,
    exec3 = 3,
    step = 4,
    step7 = 7
    */

private :
    static int m_iUserMode;
    static int m_iPromptMode;
    static bool m_printInput;
    static bool m_printOutput;
    static bool m_printCompact;
    static bool m_printInteractive;

public :
    static void setUserMode(int _iPromptMode);
    static int getUserMode(void);

    static void setPromptMode(int _iPromptMode);
    static int getPromptMode(void);

    static void setPrintInput(bool val);
    static bool isPrintInput(void);
    static bool togglePrintInput(void);

    static void setPrintOutput(bool val);
    static bool isPrintOutput(void);
    static bool togglePrintOutput(void);

    static void setPrintInteractive(bool val);
    static bool isPrintInteractive(void);
    static bool togglePrintInteractive(void);

    static void setPrintCompact(bool val);
    static bool isPrintCompact(void);
    static bool togglePrintCompact(void);


    // Pause level
private :
    static int m_iPauseLevel;
    static std::list<int> m_listScope;

public :
    static void IncreasePauseLevel();
    static void DecreasePauseLevel();
    static int getPauseLevel();
    static int getActivePauseLevel();
    // Dynamic Libraries

    typedef struct
    {
        wchar_t* pwstLibraryName;      /** name of dynamic library **/
        DynLibHandle hLib;              /** handle of the library **/
    } DynamicLibraryStr;

    typedef void(*dynlib_ptr)();

    typedef struct
    {
        wchar_t* pwstEntryPointName;    /** name of interface **/
        int iLibIndex;                  /** name of interface **/
        dynlib_ptr functionPtr;         /** entrypoint for the interface **/
        bool bOK;                       /** flag set to TRUE if entrypoint can be used **/
    } EntryPointStr;

private :
    static std::list<EntryPointStr*> m_EntryPointList;
    static std::vector<DynamicLibraryStr*> m_DynLibList;
public :

    /* tools fucntions */
    static void setLibraryName(DynamicLibraryStr* _pDynamicLibrary, wchar_t* _pwstLibraryName);
    static void setEntryPointName(EntryPointStr* _pEntryPoint, wchar_t* _pwstEntryPointName);

    /* "Constructors" */
    static DynamicLibraryStr* getNewDynamicLibraryStr();
    static EntryPointStr* getNewEntryPointStr();

    /* Dynamic libraries functions */
    static std::vector<DynamicLibraryStr*>* getDynamicLibraryList();
    static int addDynamicLibrary(DynamicLibraryStr* _pDynamicLibrary);
    static void removeDynamicLibrary(int _iDynamicLibraryIndex);
    static DynamicLibraryStr* getDynamicLibrary(int _iDynamicLibraryIndex);
    static bool isDynamicLibrary(int _iDynamicLibraryIndex);

    /* Entry point functions */
    static std::list<EntryPointStr*>* getEntryPointList();
    static void addEntryPoint(EntryPointStr* _pEP);
    static void removeEntryPoint(int _iEntryPointIndex);
    static EntryPointStr* getEntryPoint(wchar_t* _pwstEntryPointName, int _iDynamicLibraryIndex = -1);
    static int getEntryPointPosition(wchar_t* _pwstEntryPointName, int _iDynamicLibraryIndex = -1);
    static dynlib_ptr getEntryPointFromPosition(int position);
    static std::vector<std::wstring> getEntryPointNameList();

    //dynamic modules
private :
    static std::map<std::wstring, DynLibHandle> m_DynModules;
public :
    static void addDynModule(const std::wstring& _name, DynLibHandle _lib);
    static void removeDynModule(const std::wstring& _name);
    static DynLibHandle getDynModule(const std::wstring& _name);
    static int getDynModuleCount();
    static DynLibHandle* getAllDynModule();
    static void cleanDynModule();

    // Command Line Arguments
private :
    static std::vector<std::wstring> m_Args;
    static bool m_bTimed;
    static bool m_bSerialize;
public :
    static void setCommandLineArgs(int _iArgs, char** _pstArgs);
    static wchar_t** getCommandLineArgs(int* _piCount);
    static bool getTimed();
    static void setTimed(bool _bTimed);
    static bool getSerialize();
    static void setSerialize(bool _bSerialize);

    //schur function
private :
    static types::Callable* m_schurFunction;

public :
    static void setSchurFunction(types::Callable* _schurFunction);
    static types::Callable* getSchurFunction();

    //grand (module randlib)
private :
    static int m_currentBaseGen;
    static int m_currentClcg4;

public :
    static void setCurrentBaseGen(int _currentBaseGen);
    static int getCurrentBaseGen();

    static void setCurrentClcg4(int _currentClcg4);
    static int getCurrentClcg4();

    //Start and end finish flag
private :
    static bool m_bStartProcessing;
    static bool m_bEndProcessing;

public :
    static void setStartProcessing(bool _bStartProcessing);
    static bool getStartProcessing();
    static void setEndProcessing(bool _bEndFinished);
    static bool getEndProcessing();

    // ieee
private :
    static int m_iIeee;

public :
    static void setIeee(int _iIeee);
    static int getIeee();

    // simp mode
private :
    static int m_iSimpMode;

public :
    static void setSimpMode(int _iSimpMode);
    static int getSimpMode();

    // funcprot mode
private :
    static int m_iFuncprot;

public :
    static void setFuncprot(int _iFuncprot);
    static int getFuncprot();

    // where
public :
    // On macro call, some information are pushed to the call stack
    struct WhereEntry
    {
        int m_line;
        int m_absolute_line;
        int m_scope_lvl;
        types::Callable* call;
        const std::wstring* m_file_name;
    };

    // On error, every information is copied back as values from the Callable to avoid being freed on call stack return
    struct WhereErrorEntry
    {
        int m_line;
        int m_absolute_line;
        int m_first_line;
        std::wstring m_function_name;
        std::wstring m_file_name;
    };

    static void where_begin(int _iLineNum, int _iLineLocation, types::Callable* _pCall);
    static void where_end();
    static const std::vector<WhereEntry>& getWhere();
    static void fillWhereError(int _iErrorLine);
    static void resetWhereError();

    static void macroFirstLine_begin(int _iLine);
    static void macroFirstLine_end();
    static int getMacroFirstLines();
    static void setFileNameToLastWhere(const std::wstring* _fileName);
    static void whereErrorToString(std::wostringstream &ostr);
private :
    static std::vector<WhereEntry> m_Where;
    static std::vector<WhereErrorEntry> m_WhereError;
    static std::vector<int> m_FirstMacroLine;
    //module called with variable by reference
private :
    static std::list<std::wstring> m_ReferenceModules;
public :
    static bool checkReferenceModule(const std::wstring& _module);
    static void addReferenceModule(const std::wstring& _module);
    static void removeReferenceModule(const std::wstring& _module);
    static std::list<std::wstring> getReferenceModules();

    //analyzer options

private :
    static int m_analyzerOptions;
public :
    static void setAnalyzerOptions(int _val);
    static int getAnalyzerOptions(void);

    //divide by zero
private:
    static bool m_dividebyzero;
public:
    static void setDivideByZero(bool _dividebyzero);
    static bool isDivideByZero(void);

    //mex info
private:
    static std::string mexFunctionName;
public:
    static void setMexFunctionName(const std::string& name);
    static std::string& getMexFunctionName();

    // executed file with exec
private:
    static int m_iFileID;
public:
    static void setExecutedFileID(int _iFileID);
    static int getExecutedFileID();

    // string read from console by scilabRead
private:
    static std::atomic<char*> m_pcConsoleReadStr;
public:
    static void setConsoleReadStr(char* _pcConsoleReadStr);
    static char* getConsoleReadStr();

    // tell if the command return by scilabRead is a scilab command or not
private:
    static std::atomic<int> m_isScilabCommand;
public:
    static void setScilabCommand(int _isciCmd);
    static int isScilabCommand();

    //debugger information
    static bool m_bEnabledebug;
    static std::unique_ptr<ast::ConstVisitor> m_defaultvisitor;

    static bool getEnableDebug();
    static void setEnableDebug(bool _enable);

    static void setDefaultVisitor(ast::ConstVisitor* _default);
    static ast::ConstVisitor* getDefaultVisitor();

    //manage CTRL C in console
private :
    static bool executionbreak;
public :
    static bool isExecutionBreak();
    static void setExecutionBreak();
    static void resetExecutionBreak();
private:
    static int recursionLimit;
    static int recursionLevel;

    // manage recursion stack
public :
    static int getRecursionLimit();
    static int setRecursionLimit(int val);

    static int getRecursionLevel();
    static void resetRecursionLevel();
    static bool increaseRecursion();
    static void decreaseRecursion();
private:
    static bool webMode;
public:
    static bool getWebMode();
    static void setWebMode(bool);

};

#endif /* !__CONFIGVARIABLE_HXX__ */