medit/moo/mooscript/mooscript-context.h

114 lines
4.2 KiB
C
Raw Normal View History

2006-05-21 16:11:05 -07:00
/*
2006-02-24 20:03:13 -08:00
* mooscript-context.h
*
* Copyright (C) 2004-2006 by Yevgen Muntyan <muntyan@math.tamu.edu>
*
* 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_CONTEXT_H__
#define __MOO_SCRIPT_CONTEXT_H__
#include <mooscript/mooscript-func.h>
G_BEGIN_DECLS
2006-05-24 00:02:54 -07:00
#define MS_TYPE_CONTEXT (ms_context_get_type ())
#define MS_CONTEXT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), MS_TYPE_CONTEXT, MSContext))
#define MS_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MS_TYPE_CONTEXT, MSContextClass))
#define MS_IS_CONTEXT(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), MS_TYPE_CONTEXT))
#define MS_IS_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MS_TYPE_CONTEXT))
#define MS_CONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MS_TYPE_CONTEXT, MSContextClass))
2006-08-20 12:38:20 -07:00
typedef struct _MSContextPrivate MSContextPrivate;
2006-02-24 20:39:12 -08:00
typedef struct _MSContextClass MSContextClass;
typedef struct _MSVariable MSVariable;
2006-02-24 20:39:12 -08:00
struct _MSVariable {
guint ref_count;
2006-02-24 20:39:12 -08:00
MSValue *value;
MSFunc *func; /* called with no arguments */
};
typedef enum {
2006-02-24 20:39:12 -08:00
MS_ERROR_NONE = 0,
MS_ERROR_TYPE,
MS_ERROR_VALUE,
MS_ERROR_NAME,
MS_ERROR_RUNTIME,
MS_ERROR_LAST
2006-02-24 20:39:12 -08:00
} MSError;
2006-02-24 20:39:12 -08:00
struct _MSContext {
GObject object;
2006-08-20 12:38:20 -07:00
MSContextPrivate *priv;
2006-02-26 01:30:57 -08:00
gpointer window;
};
2006-02-24 20:39:12 -08:00
struct _MSContextClass {
GObjectClass object_class;
2006-05-24 00:02:54 -07:00
MSValue* (*get_env_var) (MSContext *ctx,
const char *name);
};
2006-02-24 20:39:12 -08:00
GType ms_context_get_type (void) G_GNUC_CONST;
2006-02-24 20:39:12 -08:00
MSVariable *ms_variable_new_value (MSValue *value);
MSVariable *ms_variable_new_func (MSFunc *func);
MSVariable *ms_variable_ref (MSVariable *var);
void ms_variable_unref (MSVariable *var);
2006-04-07 22:39:13 -07:00
MSContext *ms_context_new (gpointer window);
2006-05-14 16:45:13 -07:00
MSValue *ms_context_run_script (MSContext *ctx,
const char *script);
MSValue *ms_context_eval_variable (MSContext *ctx,
const char *name);
gboolean ms_context_assign_variable (MSContext *ctx,
const char *name,
2006-02-24 20:39:12 -08:00
MSValue *value);
gboolean ms_context_assign_positional (MSContext *ctx,
guint n,
MSValue *value);
2006-04-19 11:06:05 -07:00
gboolean ms_context_assign_string (MSContext *ctx,
const char *name,
const char *value);
2006-05-24 00:02:54 -07:00
MSValue *ms_context_get_env_variable (MSContext *ctx,
const char *name);
2006-02-24 20:39:12 -08:00
MSVariable *ms_context_lookup_var (MSContext *ctx,
const char *name);
2006-02-24 20:39:12 -08:00
gboolean ms_context_set_var (MSContext *ctx,
const char *name,
2006-02-24 20:39:12 -08:00
MSVariable *var);
2006-02-24 20:39:12 -08:00
gboolean ms_context_set_func (MSContext *ctx,
const char *name,
2006-02-24 20:39:12 -08:00
MSFunc *func);
2006-02-24 20:39:12 -08:00
MSValue *ms_context_set_error (MSContext *ctx,
MSError error,
const char *message);
2006-02-24 20:39:12 -08:00
MSValue *ms_context_format_error (MSContext *ctx,
MSError error,
const char *format,
...);
2006-02-24 20:39:12 -08:00
const char *ms_context_get_error_msg (MSContext *ctx);
void ms_context_clear_error (MSContext *ctx);
G_END_DECLS
2006-02-24 20:03:13 -08:00
#endif /* __MOO_SCRIPT_CONTEXT_H__ */