medit/moo/mooutils/mooscript/mooscript-value.h

112 lines
2.8 KiB
C
Raw Normal View History

/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4; coding: utf-8 -*-
*
2006-02-24 20:03:13 -08:00
* mooscript-value.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_VALUE_H__
#define __MOO_SCRIPT_VALUE_H__
#include <glib-object.h>
G_BEGIN_DECLS
2006-02-24 20:39:12 -08:00
typedef struct _MSValue MSValue;
typedef enum {
2006-02-24 20:39:12 -08:00
MS_VALUE_NONE,
MS_VALUE_INT,
MS_VALUE_STRING,
MS_VALUE_OBJECT,
MS_VALUE_GVALUE,
MS_VALUE_LIST
} MSValueType;
typedef enum {
2006-02-24 20:39:12 -08:00
MS_OP_PLUS,
MS_OP_MINUS,
MS_OP_MULT,
MS_OP_DIV,
MS_OP_AND,
MS_OP_OR,
MS_OP_EQ,
MS_OP_NEQ,
MS_OP_LT,
MS_OP_GT,
MS_OP_LE,
MS_OP_GE,
MS_OP_FORMAT,
MS_BINARY_OP_LAST
2006-02-24 20:39:12 -08:00
} MSBinaryOp;
typedef enum {
2006-02-24 20:39:12 -08:00
MS_OP_UMINUS,
MS_OP_NOT,
MS_OP_LEN,
MS_UNARY_OP_LAST
2006-02-24 20:39:12 -08:00
} MSUnaryOp;
2006-02-24 20:39:12 -08:00
struct _MSValue {
guint ref_count;
2006-02-24 20:39:12 -08:00
MSValueType type;
union {
int ival;
char *str;
gpointer ptr;
GValue *gval;
struct {
2006-02-24 20:39:12 -08:00
MSValue **elms;
guint n_elms;
} list;
};
};
2006-02-24 20:39:12 -08:00
const char *ms_binary_op_name (MSBinaryOp op);
gpointer ms_binary_op_cfunc (MSBinaryOp op);
const char *ms_unary_op_name (MSUnaryOp op);
gpointer ms_unary_op_cfunc (MSUnaryOp op);
2006-02-24 20:39:12 -08:00
MSValue *ms_value_none (void);
MSValue *ms_value_false (void);
MSValue *ms_value_true (void);
MSValue *ms_value_bool (gboolean val);
2006-02-24 20:39:12 -08:00
MSValue *ms_value_int (int val);
MSValue *ms_value_string (const char *string);
MSValue *ms_value_take_string (char *string);
MSValue *ms_value_object (gpointer object);
MSValue *ms_value_gvalue (GValue *gval);
2006-02-24 20:39:12 -08:00
MSValue *ms_value_list (guint n_elms);
void ms_value_list_set_elm (MSValue *list,
guint index,
2006-02-24 20:39:12 -08:00
MSValue *elm);
2006-02-24 20:39:12 -08:00
MSValue *ms_value_ref (MSValue *val);
void ms_value_unref (MSValue *val);
2006-02-24 20:39:12 -08:00
gboolean ms_value_get_bool (MSValue *val);
gboolean ms_value_get_int (MSValue *val,
int *ival);
2006-02-24 20:39:12 -08:00
char *ms_value_print (MSValue *val);
2006-02-24 20:39:12 -08:00
gboolean ms_value_equal (MSValue *a,
MSValue *b);
int ms_value_cmp (MSValue *a,
MSValue *b);
G_END_DECLS
2006-02-24 20:03:13 -08:00
#endif /* __MOO_SCRIPT_VALUE_H__ */