~ubuntu-branches/debian/stretch/libxr/stretch

« back to all changes in this revision

Viewing changes to xdl-compiler/xdl.h

  • Committer: Bazaar Package Importer
  • Author(s): Fabien Boucher
  • Date: 2009-10-14 00:52:51 UTC
  • Revision ID: james.westby@ubuntu.com-20091014005251-epx05xv5ef9188q0
Tags: upstream-1.0
ImportĀ upstreamĀ versionĀ 1.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* 
 
2
 * Copyright 2006-2008 Ondrej Jirman <ondrej.jirman@zonio.net>
 
3
 * 
 
4
 * This file is part of libxr.
 
5
 *
 
6
 * Libxr is free software: you can redistribute it and/or modify it under the
 
7
 * terms of the GNU Lesser General Public License as published by the Free
 
8
 * Software Foundation, either version 2 of the License, or (at your option) any
 
9
 * later version.
 
10
 *
 
11
 * Libxr is distributed in the hope that it will be useful, but WITHOUT ANY
 
12
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
 
13
 * A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
 
14
 * details.
 
15
 *
 
16
 * You should have received a copy of the GNU Lesser General Public License
 
17
 * along with libxr.  If not, see <http://www.gnu.org/licenses/>.
 
18
 */
 
19
 
 
20
#ifndef __XDL_MODEL_H__
 
21
#define __XDL_MODEL_H__
 
22
 
 
23
#include <glib.h>
 
24
 
 
25
/** @file xdl model header
 
26
 */
 
27
 
 
28
/* types */
 
29
 
 
30
enum
 
31
{
 
32
  TD_BASE,
 
33
  TD_STRUCT,
 
34
  TD_ARRAY,
 
35
  TD_BLOB,
 
36
  TD_ANY,
 
37
};
 
38
 
 
39
typedef struct _xdl_typedef xdl_typedef;
 
40
typedef struct _xdl_struct_member xdl_struct_member;
 
41
typedef struct _xdl_method_param xdl_method_param;
 
42
typedef struct _xdl_method xdl_method;
 
43
typedef struct _xdl_servlet xdl_servlet;
 
44
typedef struct _xdl_model xdl_model;
 
45
typedef struct _xdl_error_code xdl_error_code;
 
46
 
 
47
struct _xdl_typedef
 
48
{
 
49
  int type;                /* typedef node type */
 
50
  char* name;              /* name of the type (for use in XDL) */
 
51
  char* cname;             /* name of the type (for use in XDL) */
 
52
  char* ctype;             /* C type name */
 
53
  char* cnull;             /* null value in C for this type */
 
54
  xdl_servlet* servlet;    /* servlet owning this type */
 
55
 
 
56
  char* march_name;
 
57
  char* demarch_name;
 
58
  char* free_func;
 
59
  char* copy_func;
 
60
 
 
61
  GSList* struct_members;  /* struct memners list */
 
62
  xdl_typedef* item_type; /* array item type */
 
63
  char* doc;
 
64
};
 
65
 
 
66
struct _xdl_struct_member
 
67
{
 
68
  char* name;
 
69
  xdl_typedef* type;
 
70
};
 
71
 
 
72
/* methods */
 
73
 
 
74
struct _xdl_method_param
 
75
{
 
76
  char* name;
 
77
  int pass_ownership;
 
78
  xdl_typedef* type;
 
79
};
 
80
 
 
81
struct _xdl_method
 
82
{
 
83
  char* name;
 
84
  GSList* params;
 
85
  xdl_typedef* return_type;
 
86
  char* stub_impl;
 
87
  int stub_impl_line;
 
88
  char* doc;
 
89
};
 
90
 
 
91
/* servlets */
 
92
 
 
93
struct _xdl_servlet
 
94
{
 
95
  char* name;
 
96
 
 
97
  GSList* types;    /* servlet types */
 
98
  GSList* methods;  /* methods */
 
99
  GSList* errors;
 
100
 
 
101
  char* stub_header;
 
102
  char* stub_init;
 
103
  char* stub_fini;
 
104
  char* stub_attrs;
 
105
  char* stub_pre_call;
 
106
  char* stub_post_call;
 
107
  char* stub_fallback;
 
108
  char* stub_download;
 
109
  char* stub_upload;
 
110
  int stub_header_line;
 
111
  int stub_init_line;
 
112
  int stub_fini_line;
 
113
  int stub_attrs_line;
 
114
  int stub_pre_call_line;
 
115
  int stub_post_call_line;
 
116
  int stub_fallback_line;
 
117
  int stub_download_line;
 
118
  int stub_upload_line;
 
119
 
 
120
  char* doc;
 
121
};
 
122
 
 
123
/* error */
 
124
 
 
125
struct _xdl_error_code
 
126
{
 
127
  char* name;
 
128
  char* cenum; /* C enum value */
 
129
  int code;
 
130
  char* doc;
 
131
};
 
132
 
 
133
/* parser */
 
134
 
 
135
struct _xdl_model
 
136
{
 
137
  char* name;
 
138
  GSList* errors;
 
139
  GSList* servlets;
 
140
  GSList* types;    /* global types */
 
141
 
 
142
  // parser helpers
 
143
  xdl_servlet* cur_servlet;
 
144
};
 
145
 
 
146
xdl_model* xdl_new();
 
147
 
 
148
xdl_model* xdl_parse_string(const char* str, GError** err);
 
149
xdl_model* xdl_parse_file(const char* str, GError** err);
 
150
 
 
151
xdl_error_code* xdl_error_new(xdl_model *xdl, xdl_servlet *servlet, char* name, int code);
 
152
 
 
153
xdl_typedef* xdl_typedef_new_array(xdl_model *xdl, xdl_servlet *servlet, xdl_typedef* item);
 
154
xdl_typedef* xdl_typedef_new_struct(xdl_model *xdl, xdl_servlet *servlet, char* name);
 
155
 
 
156
gint xdl_method_compare(xdl_method* m1, xdl_method* m2);
 
157
 
 
158
xdl_typedef* xdl_typedef_find(xdl_model *xdl, xdl_servlet *servlet, const char* name);
 
159
char* xdl_typedef_vala_name(xdl_typedef* t);
 
160
char* xdl_typedef_xdl_name(xdl_typedef* t);
 
161
 
 
162
void xdl_process(xdl_model *ctx);
 
163
 
 
164
#endif