GCCPY:
[official-gcc.git] / libgpython / runtime / gpy-object-dict.c
blob10e6c38220f143909001c8e12908cc0a0571f66b
1 /* This file is part of GCC.
3 GCC is free software; you can redistribute it and/or modify it under
4 the terms of the GNU General Public License as published by the Free
5 Software Foundation; either version 3, or (at your option) any later
6 version.
8 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
9 WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
11 for more details.
13 You should have received a copy of the GNU General Public License
14 along with GCC; see the file COPYING3. If not see
15 <http://www.gnu.org/licenses/>. */
17 #ifdef HAVE_CONFIG_H
18 # include "config.h"
19 #endif
21 #include <stdio.h>
22 #include <stdlib.h>
23 #include <string.h>
24 #include <stdbool.h>
26 #include <gpython/gpython.h>
27 #include <gpython/vectors.h>
28 #include <gpython/objects.h>
29 #include <gpython/runtime.h>
31 struct gpy_object_dict {
32 int length;
35 gpy_object_t * gpy_obj_dict_new (gpy_typedef_t * type,
36 gpy_object_t * args)
38 return NULL;
41 void gpy_obj_dict_destroy (gpy_object_t * self)
43 return;
46 void gpy_obj_dict_print (gpy_object_t * self, FILE * fd,
47 bool newline)
49 return;
52 static
53 gpy_object_t * gpy_obj_dict_clear (gpy_object_t * self,
54 gpy_object_t ** args)
56 return NULL;
59 static
60 bool gpy_obj_dict_eval_bool (gpy_object_t * self)
62 return false;
65 static
66 gpy_object_t ** gpy_obj_dict_getRefSlice (gpy_object_t * decl,
67 gpy_object_t * slice)
69 return NULL;
72 static
73 gpy_object_t * gpy_obj_dict_getSlice (gpy_object_t * decl,
74 gpy_object_t * slice)
76 gpy_object_t ** rs = gpy_obj_dict_getRefSlice (decl, slice);
77 return *rs;
80 static struct gpy_builtinAttribs_t dict_methods[] = {
81 /* 1 argument since we have to pass in self */
82 { "clear", 1, (GPY_CFUNC) &gpy_obj_dict_clear },
83 /* ... */
84 { NULL, 0, NULL }
87 static struct gpy_typedef_t dict_obj = {
88 "Dict",
89 sizeof (struct gpy_object_dict),
90 &gpy_obj_dict_new,
91 &gpy_obj_dict_destroy,
92 &gpy_obj_dict_print,
93 NULL,
94 NULL,
95 &gpy_obj_dict_eval_bool,
96 NULL,
97 NULL,
98 dict_methods,
99 &gpy_obj_dict_getSlice,
100 &gpy_obj_dict_getRefSlice,
103 void gpy_obj_dict_mod_init (gpy_vector_t * const vec)
105 gpy_wrap_builtins (&dict_obj, nitems (dict_methods));
106 gpy_vec_push (vec, &dict_obj);