2006-05-21 16:11:05 -07:00
|
|
|
/*
|
2006-02-24 20:03:13 -08:00
|
|
|
* mooscript-func.h
|
2005-12-19 18:02:54 -08:00
|
|
|
*
|
2006-02-23 06:03:17 -08:00
|
|
|
* Copyright (C) 2004-2006 by Yevgen Muntyan <muntyan@math.tamu.edu>
|
2005-12-19 18:02:54 -08: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
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* See COPYING file that comes with this distribution.
|
|
|
|
*/
|
|
|
|
|
2006-02-24 20:03:13 -08:00
|
|
|
#ifndef __MOO_SCRIPT_FUNC_H__
|
|
|
|
#define __MOO_SCRIPT_FUNC_H__
|
2005-12-19 18:02:54 -08:00
|
|
|
|
2006-04-06 01:32:16 -07:00
|
|
|
#include <mooscript/mooscript-value.h>
|
2005-12-19 18:02:54 -08:00
|
|
|
|
|
|
|
G_BEGIN_DECLS
|
|
|
|
|
|
|
|
|
2006-02-24 20:39:12 -08:00
|
|
|
#define MS_TYPE_FUNC (ms_func_get_type ())
|
|
|
|
#define MS_FUNC(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), MS_TYPE_FUNC, MSFunc))
|
|
|
|
#define MS_FUNC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MS_TYPE_FUNC, MSFuncClass))
|
|
|
|
#define MS_IS_FUNC(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), MS_TYPE_FUNC))
|
|
|
|
#define MS_IS_FUNC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MS_TYPE_FUNC))
|
|
|
|
#define MS_FUNC_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MS_TYPE_FUNC, MSFuncClass))
|
|
|
|
|
|
|
|
#define MS_TYPE_CFUNC (ms_cfunc_get_type ())
|
|
|
|
#define MS_CFUNC(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), MS_TYPE_CFUNC, MSCFunc))
|
|
|
|
#define MS_CFUNC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MS_TYPE_CFUNC, MSCFuncClass))
|
|
|
|
#define MS_IS_CFUNC(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), MS_TYPE_CFUNC))
|
|
|
|
#define MS_IS_CFUNC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MS_TYPE_CFUNC))
|
|
|
|
#define MS_CFUNC_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MS_TYPE_CFUNC, MSCFuncClass))
|
|
|
|
|
2006-08-20 12:38:20 -07:00
|
|
|
typedef struct _MSContext MSContext;
|
2006-02-24 20:39:12 -08:00
|
|
|
typedef struct _MSFuncClass MSFuncClass;
|
|
|
|
typedef struct _MSCFunc MSCFunc;
|
|
|
|
typedef struct _MSCFuncClass MSCFuncClass;
|
|
|
|
|
|
|
|
struct _MSFunc {
|
2005-12-19 18:02:54 -08:00
|
|
|
GObject object;
|
|
|
|
};
|
|
|
|
|
2006-02-24 20:39:12 -08:00
|
|
|
typedef MSValue* (*MSFuncCall) (MSFunc *func,
|
|
|
|
MSValue **args,
|
2005-12-19 18:02:54 -08:00
|
|
|
guint n_args,
|
2006-02-24 20:39:12 -08:00
|
|
|
MSContext *ctx);
|
2005-12-19 18:02:54 -08:00
|
|
|
|
2006-02-24 20:39:12 -08:00
|
|
|
struct _MSFuncClass {
|
2005-12-19 18:02:54 -08:00
|
|
|
GObjectClass object_class;
|
2006-02-24 20:39:12 -08:00
|
|
|
MSFuncCall call;
|
2005-12-19 18:02:54 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2006-02-24 20:39:12 -08:00
|
|
|
typedef MSValue* (*MSCFunc_Var) (MSValue **args,
|
2005-12-19 18:02:54 -08:00
|
|
|
guint n_args,
|
2006-02-24 20:39:12 -08:00
|
|
|
MSContext *ctx);
|
|
|
|
typedef MSValue* (*MSCFunc_0) (MSContext *ctx);
|
|
|
|
typedef MSValue* (*MSCFunc_1) (MSValue *arg1,
|
|
|
|
MSContext *ctx);
|
|
|
|
typedef MSValue* (*MSCFunc_2) (MSValue *arg1,
|
|
|
|
MSValue *arg2,
|
|
|
|
MSContext *ctx);
|
|
|
|
typedef MSValue* (*MSCFunc_3) (MSValue *arg1,
|
|
|
|
MSValue *arg2,
|
|
|
|
MSValue *arg3,
|
|
|
|
MSContext *ctx);
|
2006-06-04 20:16:51 -07:00
|
|
|
typedef MSValue* (*MSCFunc_4) (MSValue *arg1,
|
|
|
|
MSValue *arg2,
|
|
|
|
MSValue *arg3,
|
|
|
|
MSValue *arg4,
|
|
|
|
MSContext *ctx);
|
2006-02-24 20:39:12 -08:00
|
|
|
|
|
|
|
struct _MSCFunc {
|
|
|
|
MSFunc func;
|
2005-12-19 18:02:54 -08:00
|
|
|
int n_args;
|
|
|
|
void (*cfunc) (void);
|
|
|
|
};
|
|
|
|
|
2006-02-24 20:39:12 -08:00
|
|
|
struct _MSCFuncClass {
|
|
|
|
MSFuncClass func_class;
|
2005-12-19 18:02:54 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2006-02-24 20:39:12 -08:00
|
|
|
GType ms_func_get_type (void) G_GNUC_CONST;
|
|
|
|
GType ms_cfunc_get_type (void) G_GNUC_CONST;
|
2005-12-19 18:02:54 -08:00
|
|
|
|
2006-02-24 20:39:12 -08:00
|
|
|
MSFunc *ms_cfunc_new_var (MSCFunc_Var cfunc);
|
|
|
|
MSFunc *ms_cfunc_new_0 (MSCFunc_0 cfunc);
|
|
|
|
MSFunc *ms_cfunc_new_1 (MSCFunc_1 cfunc);
|
|
|
|
MSFunc *ms_cfunc_new_2 (MSCFunc_2 cfunc);
|
|
|
|
MSFunc *ms_cfunc_new_3 (MSCFunc_3 cfunc);
|
2006-06-04 20:16:51 -07:00
|
|
|
MSFunc *ms_cfunc_new_4 (MSCFunc_4 cfunc);
|
2005-12-19 18:02:54 -08:00
|
|
|
|
|
|
|
|
|
|
|
G_END_DECLS
|
|
|
|
|
2006-02-24 20:03:13 -08:00
|
|
|
#endif /* __MOO_SCRIPT_FUNC_H__ */
|