summaryrefslogtreecommitdiff
path: root/modules/tclsci/src/c/TCL_Command.h
blob: 5e53f2bb64f80fc2e490fab96805b2699ae46a5d (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
/*
 *  Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
 *  Copyright (C) 2007-2008 - INRIA - Bruno JOFRET
 *
 *  This file must be used under the terms of the CeCILL.
 *  This source file is licensed as described in the file COPYING, which
 *  you should have received as part of this distribution.  The terms
 *  are also available at
 *  http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
 *
 */

/*
** Manage Tcl Loop as a standalone one.
** An  important  constraint  of  the  Tcl  threads implementation
** is that only the thread that created a Tcl interpreter can use that interpreter.
*/

#ifndef __TCL_COMMAND_H__
#define __TCL_COMMAND_H__

#include <tcl.h>
#include <string.h>

#include "Thread_Wrapper.h"

/*
** TCL Event loop refresh rate.
*/
#define TIME_TO_SLEEP 10000

/*
** This function start an endless Tcl Loop
** in order the Scilab Global Tcl Interpreter
** do some "update" and let the Tcl Applications live.
*/
void		startTclLoop(void);

/*
** Send Tcl Command
** Ask the interpreter to execute some command.
** Manage mutex and lock process.
*/
#define		sendTclCommand(command)	sendTclCommandToSlave(command, NULL)

/*
** Send Tcl File
** Ask the interpreter to load some file
** Manage mutex and lock process.
*/
#define		sendTclFile(command)	sendTclFileToSlave(command, NULL)

/*
** Send Tcl Command To Slave
** Ask the interpreter to execute some command.
** Manage mutex and lock process.
*/

int		sendTclCommandToSlave(char* command, char* slave);

/*
** Send Tcl File To Slave
** Ask the interpreter to load some file
** Manage mutex and lock process.
*/
int		sendTclFileToSlave(char* command, char* slave);

/*
** Get Tcl Command Return Value
** Porpagate return value of Tcl Interpreter
** caught in thread.
*/
int		getTclCommandReturn(void);

/*
** Get Tcl Command Result
** Porpagate return message of Tcl Interpreter
** caught in thread.
** This can be an error or a string value.
*/
char		*getTclCommandResult(void);

/* The tclLoop thread Id
in order to wait it ends when closing Scilab */
__threadId TclThread;

__threadSignal InterpReady;
__threadSignalLock InterpReadyLock;

#endif /* !__TCL_COMMAND_H__ */