[DEVELOPMENT ENVIRONMENT]
* NEW: The EXEC and SHELL syntax has changed. [INTERPRETER] * NEW: Stream.Blocking is new property to set if reading from the stream is blocking or not. * NEW: EXEC or SHELL used without the AS keyword creates a blocking process stream. [COMPILER] * NEW: EXEC or SHELL can be used with AS and without FOR. [GB.QT] * NEW: Toolbox windows are automatically transient for the current active window. git-svn-id: svn://localhost/gambas/trunk@1657 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
parent
e87e085b3e
commit
6fc736d883
10 changed files with 96 additions and 38 deletions
|
@ -1,5 +1,5 @@
|
|||
# Gambas Project File 3.0
|
||||
# Compiled with Gambas 2.99.0 (r1601)
|
||||
# Compiled with Gambas 2.99.0 (r1645)
|
||||
Title=Gambas 3
|
||||
Startup=Project
|
||||
Icon=img/logo/new-logo.png
|
||||
|
|
|
@ -707,14 +707,14 @@ Private Sub Start(sCmd As String)
|
|||
sExec &= " " & Quote.Shell(sArg)
|
||||
Next
|
||||
|
||||
$hProcess = Shell sExec For Read Write
|
||||
$hProcess = Shell sExec For Read Write As "Process"
|
||||
|
||||
Else
|
||||
|
||||
aExec = [System.Path &/ "bin/gbx" & System.Version, "-g", "-f", File.Dir(SConv(Project.Path)), "--"]
|
||||
aExec.Insert(Project.Arguments)
|
||||
|
||||
$hProcess = Exec aExec For Read Write 'AS $hProcess
|
||||
$hProcess = Exec aExec For Read Write As "Process"
|
||||
|
||||
Endif
|
||||
|
||||
|
|
|
@ -274,9 +274,9 @@ Private Sub RunCommand(sCmd As String, Optional sDir As String)
|
|||
$sOutput = ""
|
||||
$bEnd = False
|
||||
If sDir Then
|
||||
Shell "(cd " & SConv(Quote.Shell(sDir)) & ";" & sCmd & ") 2>&1" For Read 'TO sOutput
|
||||
Shell "(cd " & SConv(Quote.Shell(sDir)) & ";" & sCmd & ") 2>&1" For Read As "Process"
|
||||
Else
|
||||
Shell sCmd & " 2>&1" For Read
|
||||
Shell sCmd & " 2>&1" For Read As "Process"
|
||||
Endif
|
||||
Repeat
|
||||
Sleep 0.01
|
||||
|
@ -357,8 +357,7 @@ Private Function MakeDebPackage(sSys As String)
|
|||
' Rename the source archive project directory to the package name
|
||||
'TRY MOVE Path &/ (sPrefix & Subst("&1", Project.Name)) TO sPackagePath
|
||||
Try Kill sArch
|
||||
Try Shell "cp -Rf " & sPackagePath & " " & sPackagePath & ".orig"
|
||||
|
||||
Try Shell "cp -Rf " & sPackagePath & " " & sPackagePath & ".orig" Wait
|
||||
|
||||
Try Mkdir sPackagePath &/ "debian"
|
||||
|
||||
|
@ -535,10 +534,9 @@ Private Function MakeDebPackage(sSys As String)
|
|||
|
||||
AddLog(("Creating package..."))
|
||||
sCmd = "cd " & Quote.Shell(sPackagePath) & "; fakeroot dpkg-buildpackage -d"
|
||||
Shell sCmd Wait For Read
|
||||
Shell sCmd Wait
|
||||
If Process.LastValue > 2 Then Error.Raise(("'dpkg-buildpackage' has failed."))
|
||||
|
||||
|
||||
Try Shell "rm -Rf " & Quote.Shell(sPackagePath) Wait
|
||||
Try Shell "rm -f " & Quote.Shell(Path) &/ "*.dsc.asc" Wait
|
||||
|
||||
|
@ -930,7 +928,7 @@ Private Function MakeRpmPackage(sSys As String)
|
|||
'sTemp = Temp$
|
||||
$sOutput = ""
|
||||
$bEnd = False
|
||||
Shell sCmd & " 2>&1" Wait For Read 'TO sOutput
|
||||
Shell sCmd & " 2>&1" Wait For Read As "Process" 'TO sOutput
|
||||
' REPEAT
|
||||
' SLEEP 0.01
|
||||
' WAIT
|
||||
|
|
|
@ -33,7 +33,7 @@ End
|
|||
Private Sub Run(sCmd As String, Optional sRemove As String)
|
||||
|
||||
$bEnd = False
|
||||
Shell sCmd & " 2>&1" For Read 'TO sOutput
|
||||
Shell sCmd & " 2>&1" For Read As "Process" 'TO sOutput
|
||||
|
||||
If sRemove Then sCmd = Replace(sCmd, sRemove, "")
|
||||
|
||||
|
|
|
@ -1597,10 +1597,10 @@ void MyMainWindow::showActivate(QWidget *transient)
|
|||
doReparent(newParentWidget, getWFlags(), pos());
|
||||
}
|
||||
|
||||
/*#ifndef NO_X_WINDOW
|
||||
if (THIS != CWINDOW_Main)
|
||||
X11_set_transient_for(winId(), QWIDGET(CWINDOW_Main)->winId());
|
||||
#endif*/
|
||||
#ifndef NO_X_WINDOW
|
||||
if (newParentWidget && getTool())
|
||||
X11_set_transient_for(winId(), newParentWidget->winId());
|
||||
#endif
|
||||
|
||||
//qDebug("showActivate %p", _object);
|
||||
|
||||
|
|
|
@ -541,7 +541,7 @@ static void trans_exec_shell(bool shell)
|
|||
{
|
||||
int mode = TS_EXEC_NONE;
|
||||
bool wait;
|
||||
bool as = FALSE;
|
||||
bool as = TRUE;
|
||||
|
||||
/* programme <20>ex<65>uter */
|
||||
TRANS_expression(FALSE);
|
||||
|
@ -563,7 +563,6 @@ static void trans_exec_shell(bool shell)
|
|||
if (TRANS_is(RS_OUTPUT))
|
||||
mode |= TS_EXEC_WRITE;
|
||||
}
|
||||
as = TRUE;
|
||||
}
|
||||
else if (TRANS_is(RS_TO))
|
||||
{
|
||||
|
@ -573,6 +572,9 @@ static void trans_exec_shell(bool shell)
|
|||
mode = TS_EXEC_STRING;
|
||||
wait = TRUE;
|
||||
}
|
||||
|
||||
if (wait)
|
||||
as = FALSE;
|
||||
|
||||
CODE_push_boolean(wait);
|
||||
CODE_push_number(mode);
|
||||
|
|
|
@ -688,6 +688,15 @@ BEGIN_PROPERTY(CSTREAM_eof)
|
|||
GB_ReturnBoolean(CSTREAM_stream(THIS_STREAM)->common.eof);
|
||||
|
||||
END_PROPERTY
|
||||
|
||||
BEGIN_PROPERTY(CSTREAM_blocking)
|
||||
|
||||
if (READ_PROPERTY)
|
||||
GB_ReturnBoolean(STREAM_is_blocking(CSTREAM_stream(THIS_STREAM)));
|
||||
else
|
||||
STREAM_blocking(CSTREAM_stream(THIS_STREAM), VPROP(GB_BOOLEAN));
|
||||
|
||||
END_PROPERTY
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -702,6 +711,7 @@ GB_DESC NATIVE_Stream[] =
|
|||
GB_PROPERTY("EndOfLine", "i", CSTREAM_eol),
|
||||
GB_METHOD("Close", NULL, CSTREAM_close, NULL),
|
||||
GB_PROPERTY_READ("EndOfFile", "b", CSTREAM_eof),
|
||||
GB_PROPERTY("Blocking", "b", CSTREAM_blocking),
|
||||
|
||||
GB_END_DECLARE
|
||||
};
|
||||
|
|
|
@ -610,8 +610,8 @@ CPROCESS *CPROCESS_create(int mode, void *cmd, char *name)
|
|||
|
||||
/*printf("** CPROCESS_create <<<< \n");*/
|
||||
|
||||
if (!name || !*name)
|
||||
name = "Process";
|
||||
//if (!name || !*name)
|
||||
// name = "Process";
|
||||
|
||||
OBJECT_new((void **)(void *)&process, CLASS_Process, name, OP ? (OBJECT *)OP : (OBJECT *)CP);
|
||||
|
||||
|
@ -620,6 +620,9 @@ CPROCESS *CPROCESS_create(int mode, void *cmd, char *name)
|
|||
|
||||
OBJECT_UNREF_KEEP(process, "CPROCESS_create");
|
||||
|
||||
if (!name || !*name)
|
||||
STREAM_blocking(CSTREAM_stream(process), TRUE);
|
||||
|
||||
/*printf("** CPROCESS_create >>>> \n");*/
|
||||
|
||||
return process;
|
||||
|
|
|
@ -289,7 +289,7 @@ char STREAM_getchar(STREAM *stream)
|
|||
}
|
||||
|
||||
|
||||
void STREAM_read_max(STREAM *stream, void *addr, int len)
|
||||
static void STREAM_read_max(STREAM *stream, void *addr, int len)
|
||||
{
|
||||
bool is_term = stream->common.is_term;
|
||||
bool err;
|
||||
|
@ -400,6 +400,42 @@ void STREAM_seek(STREAM *stream, int64_t pos, int whence)
|
|||
}
|
||||
}
|
||||
|
||||
static void fill_buffer(STREAM *stream, char *addr)
|
||||
{
|
||||
bool err;
|
||||
STREAM_eff_read = 0;
|
||||
int flags, fd;
|
||||
|
||||
fd = STREAM_handle(stream);
|
||||
|
||||
err = (*(stream->type->read))(stream, addr, 1);
|
||||
if (!err)
|
||||
{
|
||||
flags = fcntl(fd, F_GETFL);
|
||||
if ((flags & O_NONBLOCK) == 0)
|
||||
fcntl(fd, F_SETFL, flags | O_NONBLOCK);
|
||||
|
||||
err = (*(stream->type->read))(stream, addr + 1, STREAM_BUFFER_SIZE - 1);
|
||||
|
||||
if ((flags & O_NONBLOCK) == 0)
|
||||
fcntl(fd, F_SETFL, flags);
|
||||
}
|
||||
|
||||
if (err)
|
||||
{
|
||||
switch(errno)
|
||||
{
|
||||
case 0:
|
||||
case EAGAIN:
|
||||
break;
|
||||
case EIO:
|
||||
break; //THROW(E_READ);
|
||||
default:
|
||||
THROW_SYSTEM(errno, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void input(STREAM *stream, char **addr, boolean line)
|
||||
{
|
||||
|
@ -428,7 +464,7 @@ static void input(STREAM *stream, char **addr, boolean line)
|
|||
}
|
||||
}
|
||||
|
||||
if (STREAM_eof(stream))
|
||||
if (!STREAM_is_blocking(stream) && STREAM_eof(stream))
|
||||
THROW(E_EOF);
|
||||
|
||||
buffer = stream->common.buffer;
|
||||
|
@ -463,7 +499,8 @@ static void input(STREAM *stream, char **addr, boolean line)
|
|||
stream->common.buffer_pos = buffer_pos;
|
||||
stream->common.buffer_len = buffer_len;
|
||||
|
||||
STREAM_read_max(stream, buffer, STREAM_BUFFER_SIZE);
|
||||
fill_buffer(stream, buffer);
|
||||
//STREAM_read_max(stream, buffer, STREAM_BUFFER_SIZE);
|
||||
|
||||
buffer_pos = 0;
|
||||
buffer_len = STREAM_eff_read;
|
||||
|
@ -513,22 +550,6 @@ static void input(STREAM *stream, char **addr, boolean line)
|
|||
break;
|
||||
|
||||
len++;
|
||||
//COMMON_buffer[len++] = c;
|
||||
|
||||
// Optimized eof
|
||||
|
||||
/*
|
||||
if (STREAM_eof(stream))
|
||||
{
|
||||
stream->common.eof = TRUE;
|
||||
break;
|
||||
}
|
||||
*/
|
||||
/*if ((*eof_func)(stream))
|
||||
{
|
||||
stream->common.eof = TRUE;
|
||||
break;
|
||||
}*/
|
||||
}
|
||||
|
||||
if (len > 0)
|
||||
|
@ -1066,4 +1087,25 @@ int STREAM_write_direct(int fd, char *buffer, int len)
|
|||
}
|
||||
|
||||
|
||||
void STREAM_blocking(STREAM *stream, bool block)
|
||||
{
|
||||
int fd = STREAM_handle(stream);
|
||||
|
||||
if (fd < 0)
|
||||
return;
|
||||
|
||||
if (block)
|
||||
fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) & ~O_NONBLOCK);
|
||||
else
|
||||
fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) | O_NONBLOCK);
|
||||
}
|
||||
|
||||
bool STREAM_is_blocking(STREAM *stream)
|
||||
{
|
||||
int fd = STREAM_handle(stream);
|
||||
|
||||
if (fd < 0)
|
||||
return TRUE;
|
||||
|
||||
return (fcntl(fd, F_GETFL) & O_NONBLOCK) == 0;
|
||||
}
|
||||
|
|
|
@ -231,4 +231,7 @@ void STREAM_lock(STREAM *stream);
|
|||
|
||||
#define STREAM_is_closed(_stream) ((_stream)->type == NULL)
|
||||
|
||||
void STREAM_blocking(STREAM *stream, bool block);
|
||||
bool STREAM_is_blocking(STREAM *stream);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue