From: Alexis Laferrière Date: Tue, 16 Jun 2015 19:44:39 +0000 (-0400) Subject: lib/exec: move the C structure se_exec_data to the light FFI X-Git-Tag: v0.7.6~19^2~14 X-Git-Url: http://nitlanguage.org lib/exec: move the C structure se_exec_data to the light FFI Signed-off-by: Alexis Laferrière --- diff --git a/lib/standard/exec.nit b/lib/standard/exec.nit index a635a00..517edf3 100644 --- a/lib/standard/exec.nit +++ b/lib/standard/exec.nit @@ -22,6 +22,25 @@ in "C" `{ #include #include #include + #include + #include + #include +`} + +in "C Header" `{ + #include + + // FIXME this should be in the "C" block when bug on module blocks is fixed + // or, even better, replace the C structure by a Nit object. + typedef struct se_exec_data se_exec_data_t; + struct se_exec_data { + pid_t id; + int running; + int status; + int in_fd; + int out_fd; + int err_fd; + }; `} # Simple sub-process @@ -281,8 +300,13 @@ redef class NativeString `} end -private extern class NativeProcess - fun id: Int is extern "exec_NativeProcess_NativeProcess_id_0" +private extern class NativeProcess `{ se_exec_data_t* `} + + fun id: Int `{ return self->id; `} + fun status: Int `{ return self->status; `} + fun in_fd: Int `{ return self->in_fd; `} + fun out_fd: Int `{ return self->out_fd; `} + fun err_fd: Int `{ return self->err_fd; `} fun is_finished: Bool `{ int result = (int)0; @@ -302,7 +326,6 @@ private extern class NativeProcess return result; `} - fun status: Int is extern "exec_NativeProcess_NativeProcess_status_0" fun wait `{ int status; if (self->running) { @@ -311,9 +334,5 @@ private extern class NativeProcess self->running = 0; } `} - - fun in_fd: Int is extern "exec_NativeProcess_NativeProcess_in_fd_0" - fun out_fd: Int is extern "exec_NativeProcess_NativeProcess_out_fd_0" - fun err_fd: Int is extern "exec_NativeProcess_NativeProcess_err_fd_0" end diff --git a/lib/standard/exec_nit.h b/lib/standard/exec_nit.h deleted file mode 100644 index fbd040a..0000000 --- a/lib/standard/exec_nit.h +++ /dev/null @@ -1,46 +0,0 @@ -#ifndef __EXEC_NIT_H -#define __EXEC_NIT_H -/* This file is part of NIT ( http://www.nitlanguage.org ). - * - * Copyright 2004-2008 Jean Privat - * Copyright 2008 Floréal Morandat - * - * This file is free software, which comes along with NIT. This software is - * distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A - * PARTICULAR PURPOSE. You can modify it is you want, provided this header - * is kept unaltered, and a notification of the changes is added. - * You are allowed to redistribute it and sell it, alone or is a part of - * another product. - */ - -#include -#include -#include -#include - -typedef struct se_exec_data se_exec_data_t; -struct se_exec_data { - pid_t id; - int running; - int status; - int in_fd; - int out_fd; - int err_fd; -}; - -se_exec_data_t* exec_Process_Process_basic_exec_execute_4(void *, char *, char *, int, int); - -int string_NativeString_NativeString_system_0(const char*); - -#define exec_NativeProcess_NativeProcess_id_0(self) (((se_exec_data_t*)self)->id) -#define exec_NativeProcess_NativeProcess_status_0(self) (((se_exec_data_t*)self)->status) - -#define exec_NativeProcess_NativeProcess_in_fd_0(self) (((se_exec_data_t*)self)->in_fd) -#define exec_NativeProcess_NativeProcess_out_fd_0(self) (((se_exec_data_t*)self)->out_fd) -#define exec_NativeProcess_NativeProcess_err_fd_0(self) (((se_exec_data_t*)self)->err_fd) - -int exec_NativeProcess_NativeProcess_is_finished_0(void*); -void exec_NativeProcess_NativeProcess_wait_0(void*); - -#endif