allow decl_vars as struct args
[m6w6/ext-psi] / src / context.c
index 199f533317ed7dfce6981ec01778a3fdfd819511..d1eb05e35323aed7137f258c808b24420cb402e6 100644 (file)
@@ -178,7 +178,7 @@ struct psi_context *psi_context_init(struct psi_context *C, struct psi_context_o
                struct psi_decl_var *fname = psi_decl_var_init(predef_decl->var_name, predef_decl->pointer_level, predef_decl->array_size);
                struct psi_decl_arg *tdef, *func = psi_decl_arg_init(ftype, fname);
                struct psi_plist *args = psi_plist_init((psi_plist_dtor) psi_decl_arg_free);
-               struct psi_decl *decl = psi_decl_init(psi_decl_abi_init("default"), func, args);
+               struct psi_decl *decl = psi_decl_init(func, args);
 
                for (farg = &predef_decl[1]; farg->type_tag; ++farg) {
                        struct psi_decl_type *arg_type = psi_decl_type_init(farg->type_tag, farg->type_name);
@@ -240,6 +240,7 @@ void psi_context_build(struct psi_context *C, const char *paths)
                        for (i = 0; i < n; ++i) {
                                char psi[MAXPATHLEN];
                                struct psi_parser P;
+                               struct psi_parser_input *I;
 
                                if (MAXPATHLEN <= slprintf(psi, MAXPATHLEN, "%s/%s", ptr, entries[i]->d_name)) {
                                        C->error(PSI_DATA(C), NULL, PSI_WARNING, "Path to PSI file too long: %s/%s",
@@ -250,15 +251,15 @@ void psi_context_build(struct psi_context *C, const char *paths)
                                                psi, strerror(errno));
                                        continue;
                                }
-                               if (!psi_parser_open_file(&P, psi)) {
+                               if (!(I = psi_parser_open_file(&P, psi, true))) {
                                        C->error(PSI_DATA(C), NULL, PSI_WARNING, "Failed to open PSI file (%s): %s",
                                                psi, strerror(errno));
                                        continue;
                                }
-
-                               psi_parser_parse(&P);
+                               psi_parser_parse(&P, I);
                                psi_context_add_data(C, PSI_DATA(&P));
                                psi_parser_dtor(&P);
+                               free(I);
                        }
                }