2007-12-30 17:41:49 +01:00
|
|
|
/***************************************************************************
|
|
|
|
|
2009-08-17 12:41:51 +02:00
|
|
|
gbx_subr.h
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-31 03:39:20 +01:00
|
|
|
(c) 2000-2012 Benoît Minisini <gambas@users.sourceforge.net>
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
2009-08-17 12:41:51 +02:00
|
|
|
the Free Software Foundation; either version 2, or (at your option)
|
2007-12-30 17:41:49 +01:00
|
|
|
any later version.
|
|
|
|
|
|
|
|
This program 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. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
2011-06-03 02:51:09 +02:00
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
2011-12-31 03:39:20 +01:00
|
|
|
MA 02110-1301, USA.
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
#ifndef __GBX_SUBR_H
|
|
|
|
#define __GBX_SUBR_H
|
|
|
|
|
|
|
|
#include "gb_error.h"
|
|
|
|
#include "gbx_exec.h"
|
|
|
|
|
|
|
|
|
|
|
|
typedef
|
|
|
|
void (*SUBR_FUNC)(VALUE *);
|
|
|
|
|
|
|
|
typedef
|
|
|
|
double (*MATH_FUNC)(double);
|
|
|
|
|
|
|
|
typedef
|
|
|
|
double (*MATH_FUNC_2)(double, double);
|
|
|
|
|
|
|
|
/*
|
|
|
|
#ifndef __GBX_SUBR_C
|
|
|
|
EXTERN int NPARAM;
|
|
|
|
#endif
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define SUBR_ENTER() \
|
2010-06-05 01:48:53 +02:00
|
|
|
int NPARAM = code & 0x3F; \
|
2007-12-30 17:41:49 +01:00
|
|
|
VALUE *PARAM = (SP - NPARAM)
|
|
|
|
|
|
|
|
#define SUBR_GET_PARAM(nparam) \
|
|
|
|
VALUE *PARAM = (SP - nparam);
|
|
|
|
|
|
|
|
#define SUBR_ENTER_PARAM(nparam) \
|
|
|
|
const int NPARAM = nparam; \
|
|
|
|
SUBR_GET_PARAM(NPARAM);
|
|
|
|
|
|
|
|
#define RETURN RP
|
|
|
|
|
|
|
|
#define SUBR_LEAVE() SUBR_leave(NPARAM)
|
|
|
|
|
|
|
|
/* BORROW(RP); \
|
|
|
|
SUBR_leave_void(NPARAM); \
|
|
|
|
*SP++ = *RP; \
|
|
|
|
RP->type = T_VOID;*/
|
|
|
|
|
|
|
|
#define SUBR_LEAVE_VOID() SUBR_leave_void(NPARAM);
|
|
|
|
/*SP->type = T_VOID; \
|
|
|
|
SP++;*/
|
|
|
|
|
|
|
|
|
|
|
|
/* Common routines */
|
|
|
|
|
2008-01-17 22:39:26 +01:00
|
|
|
void SUBR_leave(int nparam);
|
|
|
|
void SUBR_leave_void(int nparam);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-06-05 01:48:53 +02:00
|
|
|
#define SUBR_check_string(_value) (TYPE_is_string((_value)->type) ? ((_value)->_string.len == 0) : SUBR_check_string_real(_value))
|
|
|
|
|
2011-09-06 22:47:26 +02:00
|
|
|
#define VOID_STRING(_value) \
|
|
|
|
do { \
|
|
|
|
RELEASE_STRING(_value); \
|
|
|
|
STRING_void_value(_value); \
|
|
|
|
} while(0);
|
|
|
|
|
2010-06-05 01:48:53 +02:00
|
|
|
bool SUBR_check_string_real(VALUE *param);
|
2008-01-17 22:39:26 +01:00
|
|
|
void SUBR_check_integer(VALUE *param);
|
|
|
|
void SUBR_check_float(VALUE *param);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2008-01-17 22:39:26 +01:00
|
|
|
int SUBR_get_integer(VALUE *param);
|
|
|
|
double SUBR_get_float(VALUE *param);
|
|
|
|
void *SUBR_get_pointer(VALUE *param);
|
2010-11-26 21:30:58 +01:00
|
|
|
void *SUBR_get_pointer_or_string(VALUE *param);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2008-01-17 22:39:26 +01:00
|
|
|
char *SUBR_get_string(VALUE *param);
|
|
|
|
char *SUBR_copy_string(VALUE *param);
|
|
|
|
void SUBR_get_string_len(VALUE *param, char **str, int *len);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2009-09-10 21:30:41 +02:00
|
|
|
bool SUBR_get_boolean(VALUE *param);
|
|
|
|
|
2009-09-20 19:32:12 +02:00
|
|
|
TYPE SUBR_get_type(VALUE *param);
|
2009-09-17 22:58:27 +02:00
|
|
|
TYPE SUBR_check_good_type(VALUE *param, int count);
|
|
|
|
|
2007-12-30 17:41:49 +01:00
|
|
|
/* subr_math.c */
|
|
|
|
|
2010-06-09 01:08:04 +02:00
|
|
|
//void SUBR_add(ushort code);
|
|
|
|
//void SUBR_sub(ushort code);
|
|
|
|
//void SUBR_mul(ushort code);
|
|
|
|
//void SUBR_div(ushort code);
|
|
|
|
void SUBR_quo(ushort code);
|
|
|
|
void SUBR_rem(ushort code);
|
2012-07-10 04:37:39 +02:00
|
|
|
void SUBR_pow(ushort code);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-06-05 01:48:53 +02:00
|
|
|
void SUBR_and_(ushort code);
|
|
|
|
void SUBR_not(ushort code);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-06-13 22:25:34 +02:00
|
|
|
void SUBR_neg(ushort code);
|
|
|
|
void SUBR_int(ushort code);
|
|
|
|
void SUBR_abs(ushort code);
|
|
|
|
void SUBR_fix(ushort code);
|
2010-06-05 01:48:53 +02:00
|
|
|
void SUBR_sgn(ushort code);
|
|
|
|
void SUBR_pi(ushort code);
|
|
|
|
void SUBR_math(ushort code);
|
|
|
|
void SUBR_math2(ushort code);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-06-05 01:48:53 +02:00
|
|
|
void SUBR_randomize(ushort code);
|
|
|
|
void SUBR_rnd(ushort code);
|
|
|
|
void SUBR_round(ushort code);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2012-01-31 03:33:01 +01:00
|
|
|
void SUBR_isnan(ushort code);
|
|
|
|
|
2007-12-30 17:41:49 +01:00
|
|
|
/* subr_string.c */
|
|
|
|
|
2010-06-05 01:48:53 +02:00
|
|
|
void SUBR_cat(ushort code);
|
|
|
|
void SUBR_file(ushort code);
|
2008-01-27 15:00:04 +01:00
|
|
|
//void SUBR_left(void);
|
|
|
|
//void SUBR_right(void);
|
|
|
|
//void SUBR_mid(void);
|
|
|
|
//void SUBR_len(void);
|
2010-06-05 01:48:53 +02:00
|
|
|
void SUBR_trim(ushort code);
|
2008-01-17 22:39:26 +01:00
|
|
|
void SUBR_space(void);
|
|
|
|
void SUBR_string(void);
|
2010-11-24 02:30:36 +01:00
|
|
|
void SUBR_upper(ushort code);
|
2008-01-17 22:39:26 +01:00
|
|
|
void SUBR_lower(void);
|
|
|
|
void SUBR_chr(void);
|
2010-06-05 01:48:53 +02:00
|
|
|
void SUBR_asc(ushort code);
|
|
|
|
void SUBR_instr(ushort code);
|
|
|
|
void SUBR_like(ushort code);
|
2008-01-17 22:39:26 +01:00
|
|
|
void SUBR_scan(void);
|
2010-06-05 01:48:53 +02:00
|
|
|
void SUBR_subst(ushort code);
|
|
|
|
void SUBR_replace(ushort code);
|
|
|
|
void SUBR_split(ushort code);
|
2008-01-17 22:39:26 +01:00
|
|
|
void SUBR_iconv(void);
|
2010-06-05 01:48:53 +02:00
|
|
|
void SUBR_sconv(ushort code);
|
|
|
|
void SUBR_is_chr(ushort code);
|
2009-01-01 14:42:17 +01:00
|
|
|
void SUBR_tr(void);
|
2010-06-05 01:48:53 +02:00
|
|
|
void SUBR_quote(ushort code);
|
2012-05-19 23:35:26 +02:00
|
|
|
void SUBR_unquote(ushort code);
|
2012-01-31 03:33:01 +01:00
|
|
|
void SUBR_swap(ushort code);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
/* subr_test.c */
|
|
|
|
|
2010-06-09 01:08:04 +02:00
|
|
|
//void SUBR_comp(ushort code);
|
|
|
|
//void SUBR_compn(ushort code);
|
2011-09-09 03:50:57 +02:00
|
|
|
//void SUBR_compi(ushort code);
|
2010-06-05 01:48:53 +02:00
|
|
|
void SUBR_case(ushort code);
|
|
|
|
void SUBR_bit(ushort code);
|
|
|
|
void SUBR_min_max(ushort code);
|
|
|
|
void SUBR_if(ushort code);
|
|
|
|
void SUBR_choose(ushort code);
|
2008-01-17 22:39:26 +01:00
|
|
|
void SUBR_near(void);
|
2010-06-05 01:48:53 +02:00
|
|
|
void SUBR_strcomp(ushort code);
|
2010-12-29 09:21:51 +01:00
|
|
|
void SUBR_is(ushort code);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
/* subr_conv.c */
|
|
|
|
|
2010-06-05 01:48:53 +02:00
|
|
|
void SUBR_is_type(ushort code);
|
|
|
|
void SUBR_conv(ushort code);
|
|
|
|
void SUBR_type(ushort code);
|
2008-01-17 22:39:26 +01:00
|
|
|
void SUBR_str(void);
|
|
|
|
void SUBR_val(void);
|
2010-06-05 01:48:53 +02:00
|
|
|
void SUBR_format(ushort code);
|
2010-12-20 04:26:00 +01:00
|
|
|
void SUBR_hex_bin(ushort code);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
/* subr_time.c */
|
|
|
|
|
2008-01-17 22:39:26 +01:00
|
|
|
void SUBR_timer(void);
|
|
|
|
void SUBR_now(void);
|
2010-06-05 01:48:53 +02:00
|
|
|
void SUBR_year(ushort code);
|
|
|
|
void SUBR_time(ushort code);
|
|
|
|
void SUBR_date(ushort code);
|
|
|
|
void SUBR_date_op(ushort code);
|
|
|
|
void SUBR_week(ushort code);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
/* subr_file.c */
|
|
|
|
|
2010-06-05 01:48:53 +02:00
|
|
|
void SUBR_open(ushort code);
|
2008-01-17 22:39:26 +01:00
|
|
|
void SUBR_close(void);
|
2010-06-05 01:48:53 +02:00
|
|
|
void SUBR_print(ushort code);
|
2008-01-17 22:39:26 +01:00
|
|
|
void SUBR_linput(void);
|
2010-06-05 01:48:53 +02:00
|
|
|
void SUBR_eof(ushort code);
|
|
|
|
void SUBR_lof(ushort code);
|
|
|
|
void SUBR_seek(ushort code);
|
|
|
|
void SUBR_input(ushort code);
|
|
|
|
void SUBR_read(ushort code);
|
|
|
|
void SUBR_write(ushort code);
|
2008-01-17 22:39:26 +01:00
|
|
|
void SUBR_flush(void);
|
2010-06-05 01:48:53 +02:00
|
|
|
void SUBR_lock(ushort code);
|
|
|
|
void SUBR_inp_out(ushort code);
|
2008-01-17 22:39:26 +01:00
|
|
|
|
2010-06-05 01:48:53 +02:00
|
|
|
void SUBR_stat(ushort code);
|
2011-07-17 12:57:55 +02:00
|
|
|
void SUBR_exist(ushort code);
|
2010-06-05 01:48:53 +02:00
|
|
|
void SUBR_dir(ushort code);
|
2012-01-15 09:54:57 +01:00
|
|
|
void SUBR_kill(ushort code);
|
2012-04-11 02:27:18 +02:00
|
|
|
void SUBR_mkdir(ushort code);
|
2008-01-17 22:39:26 +01:00
|
|
|
void SUBR_rmdir(void);
|
2012-01-15 09:54:57 +01:00
|
|
|
void SUBR_move(ushort code);
|
2012-01-31 03:33:01 +01:00
|
|
|
void SUBR_link(ushort code);
|
2010-06-05 01:48:53 +02:00
|
|
|
void SUBR_temp(ushort code);
|
2008-01-17 22:39:26 +01:00
|
|
|
void SUBR_isdir(void);
|
2010-06-05 01:48:53 +02:00
|
|
|
void SUBR_access(ushort code);
|
|
|
|
void SUBR_rdir(ushort code);
|
2008-01-17 22:39:26 +01:00
|
|
|
void SUBR_dfree();
|
|
|
|
|
|
|
|
void SUBR_exit_inp_out(void);
|
2007-12-30 17:41:49 +01:00
|
|
|
#define SUBR_exit SUBR_exit_inp_out
|
|
|
|
|
|
|
|
/* subr_extern.c */
|
|
|
|
|
2010-06-05 01:48:53 +02:00
|
|
|
void SUBR_alloc(ushort code);
|
2008-01-17 22:39:26 +01:00
|
|
|
void SUBR_free(void);
|
2010-06-05 01:48:53 +02:00
|
|
|
void SUBR_realloc(ushort code);
|
|
|
|
void SUBR_strptr(ushort code);
|
2008-01-19 02:36:38 +01:00
|
|
|
void SUBR_varptr(void);
|
2010-07-14 18:33:29 +02:00
|
|
|
void SUBR_ptr(ushort code);
|
2010-11-24 17:00:39 +01:00
|
|
|
void SUBR_make(ushort code);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
/* subr_misc.c */
|
|
|
|
|
2008-01-17 22:39:26 +01:00
|
|
|
void SUBR_error(void);
|
|
|
|
void SUBR_shell(void);
|
2010-06-05 01:48:53 +02:00
|
|
|
void SUBR_wait(ushort code);
|
2008-01-17 22:39:26 +01:00
|
|
|
void SUBR_sleep(void);
|
2010-06-05 01:48:53 +02:00
|
|
|
void SUBR_exec(ushort code);
|
|
|
|
void SUBR_eval(ushort code);
|
|
|
|
void SUBR_array(ushort code);
|
|
|
|
void SUBR_collection(ushort code);
|
2008-01-17 22:39:26 +01:00
|
|
|
void SUBR_debug(void);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2008-01-17 22:39:26 +01:00
|
|
|
void EVAL_string(char *expr);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
#endif
|