2 * File: PYSCLang_Module_GUIStuff.cpp
3 * Project : Psycollider
7 * benjamin.golinvaux@euresys.com
8 * messenger: bgolinvaux@hotmail.com
10 * currently maintained by:
11 * Christopher Frauenberger
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License as
16 * published by the Free Software Foundation; either version 2 of the
17 * License, or (at your option) any later version.
19 * This program is distributed in the hope that it will be useful, but
20 * WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 * General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
32 #include "CXX/Objects.hxx"
33 #include "CXX/Extensions.hxx"
38 #include "PySCLang_Module.h"
44 const int kPostBufferSize
= 1024;
46 static char* _postBuffer
= NULL
;
50 int PySCLang_vpost(const char *fmt
, va_list ap
)
52 if(_postBuffer
== NULL
)
53 _postBuffer
= new char[kPostBufferSize
];
55 int size
= _vscprintf(fmt
, ap
);
57 int size
= vprintf(fmt
, ap
);
60 if (size
< kPostBufferSize
) {
61 vsprintf(_postBuffer
, fmt
, ap
);
62 //_txtCtrl->AppendText(wxString(_postBuffer));
64 if( PySCLang_Module::scLogSink_s
!= NULL
) {
65 /* make the Python call thread safe (global interpreter clock) */
66 PyGILState_STATE gstate
;
67 gstate
= PyGILState_Ensure();
69 PyObject
*arglist
= Py_BuildValue("(s)", _postBuffer
);
70 PyEval_CallObject(PySCLang_Module::scLogSink_s
, arglist
);
72 PyGILState_Release(gstate
);
74 else { // no log sink callable..
80 char* tmpPostBuffer
= new char[size
+1]; // +1 : NULL ending
81 vsprintf(tmpPostBuffer
, fmt
, ap
);
82 cout
<< tmpPostBuffer
<< flush
; //implement in python !!!!!!
83 delete [] tmpPostBuffer
;
88 void setPostFile(FILE* file
)
90 // we're not using that , are we ?
95 int vpost(const char *fmt
, va_list ap
);
98 int vpost(const char *fmt
, va_list ap
)
100 PySCLang_vpost(fmt
, ap
);
104 void post(const char *fmt
, ...)
108 PySCLang_vpost(fmt
, ap
);
111 void postfl(const char *fmt
, ...)
115 PySCLang_vpost(fmt
, ap
);
118 void postText(const char *str
, long len
)
120 char* txt
= new char[len
+1];
127 void postChar(char c
)
135 void error(const char *fmt
, ...)
139 PySCLang_vpost(fmt
, ap
);
143 void flushPostBuf(void)
147 void closeAllGUIScreens()
156 void initSCViewPrimitives()
160 void initCocoaFilePrimitives()
164 void initRendezvousPrimitives()
170 void initSpeechPrimitives()
175 long scMIDIout(int port
, int len
, int statushi
, int chan
, int data1
, int data2
)