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
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
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/>. */
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
{
35 gpy_object_t
* gpy_obj_dict_new (gpy_typedef_t
* type
,
41 void gpy_obj_dict_destroy (gpy_object_t
* self
)
46 void gpy_obj_dict_print (gpy_object_t
* self
, FILE * fd
,
53 gpy_object_t
* gpy_obj_dict_clear (gpy_object_t
* self
,
60 bool gpy_obj_dict_eval_bool (gpy_object_t
* self
)
66 gpy_object_t
** gpy_obj_dict_getRefSlice (gpy_object_t
* decl
,
73 gpy_object_t
* gpy_obj_dict_getSlice (gpy_object_t
* decl
,
76 gpy_object_t
** rs
= gpy_obj_dict_getRefSlice (decl
, slice
);
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
},
87 static struct gpy_typedef_t dict_obj
= {
89 sizeof (struct gpy_object_dict
),
91 &gpy_obj_dict_destroy
,
95 &gpy_obj_dict_eval_bool
,
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
);