/[ascend]/trunk/base/generic/compiler/notequery.c
ViewVC logotype

Contents of /trunk/base/generic/compiler/notequery.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1927 - (show annotations) (download) (as text)
Wed Oct 8 07:18:25 2008 UTC (13 years, 10 months ago) by jpye
File MIME type: text/x-csrc
File size: 4292 byte(s)
Working towards new notes_get_refined.
1 /* ASCEND modelling environment
2 Copyright (C) 2008 Carnegie Mellon University
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
7 any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA.
18 *//** @file
19 Query function(s) for the NOTES database in notate.h
20 */
21
22 #include "notequery.h"
23 #include "notate.h"
24 #include "symtab.h"
25 #include <utilities/error.h>
26
27 struct gl_list_t *notes_get_refined(
28 symchar *dbid
29 ,const struct TypeDescription *t
30 ,symchar *lang
31 ,symchar *id
32 ,symchar *method
33 ){
34 struct gl_list_t *types = GetAncestorNames(t);
35
36 CONSOLE_DEBUG("not implemented");
37 struct gl_list_t *res = gl_create(1);
38 return res;
39 }
40
41
42 const char *notes_get_for_variable(symchar *dbid
43 , const struct TypeDescription *t
44 , const symchar *varname
45 , const symchar *lang
46 ){
47 struct gl_list_t *noteslist;
48
49 struct gl_list_t *types = GetAncestorNames(t);
50 struct gl_list_t *langs = gl_create(1);
51 struct gl_list_t *ids = gl_create(1);
52
53 int i;
54 for(i=1; i<=gl_length(types); ++i){
55 CONSOLE_DEBUG("ancestor %d: %s",i,SCP((symchar *)gl_fetch(types,i)));
56 }
57
58 symchar *inl = AddSymbol("inline");
59 gl_append_ptr(langs,(VOIDPTR)inl);
60
61 gl_append_ptr(ids,(VOIDPTR)varname);
62
63 noteslist = GetNotesList(dbid,types,langs,ids,NOTESWILDLIST,NOTESWILDLIST);
64
65 gl_destroy(types);
66 gl_destroy(langs);
67 gl_destroy(ids);
68
69 CONSOLE_DEBUG("noteslist = %ld items",gl_length(noteslist));
70
71 if(gl_length(noteslist)==0){
72 CONSOLE_DEBUG("empty notes list returned");
73 return NULL;
74 }
75 struct Note *n = (struct Note *)gl_fetch(noteslist,1);
76
77 CONSOLE_DEBUG("note ID = %s, lang = %s",SCP(GetNoteId(n)),SCP(GetNoteLanguage(n)));
78
79 CONSOLE_DEBUG("note text = %s",BraceCharString(GetNoteText(n)));
80
81 return BraceCharString(GetNoteText(n));
82 }
83
84 struct gl_list_t *notes_get_vars_with_lang(
85 symchar *dbid
86 , const struct TypeDescription *t
87 , const symchar *lang
88 ){
89 int i;
90 struct gl_list_t *noteslist;
91 struct gl_list_t *refinednoteslist;
92
93 struct gl_list_t *types = GetAncestorNames(t);
94 struct gl_list_t *langs = gl_create(1);
95
96 #if 0
97 CONSOLE_DEBUG("type '%s' has %ld ancestor types",SCP(GetName(t)),gl_length(types));
98 for(i=1; i<=gl_length(types); ++i){
99 CONSOLE_DEBUG("ancestor %d: %s",i,SCP((symchar *)gl_fetch(types,i)));
100 }
101 #endif
102
103 /*CONSOLE_DEBUG("Looking for notes of type '%s'",SCP(lang));*/
104 gl_append_ptr(langs,(VOIDPTR)lang);
105
106 /* create a new list with our top-level type at the start */
107 struct gl_list_t *typesall = gl_create(1 + gl_length(types));
108 for(i=1;i<=gl_length(types);++i){
109 //CONSOLE_DEBUG("Appending '%s' to typesall",SCP(GetName((struct TypeDescription *)gl_fetch(types,i))));
110 gl_append_ptr(typesall,gl_fetch(types,i));
111 }
112 gl_append_ptr(typesall,(VOIDPTR)GetName(t));
113 /* CONSOLE_DEBUG("length of types = %ld, typesall = %ld",gl_length(types), gl_length(typesall)); */
114
115 gl_destroy(types);
116
117 #if 0
118 for(i=1;i<=gl_length(typesall);++i){
119 struct TypeDescription *t;
120 CONSOLE_DEBUG("typesall[%d] = '%s'",i,SCP((symchar *)gl_fetch(typesall,i)));
121 }
122 #endif
123
124 noteslist = GetNotesList(dbid,typesall,langs,NOTESWILDLIST,NOTESWILDLIST,NOTESWILDLIST);
125
126 gl_destroy(typesall);
127 gl_destroy(langs);
128
129 /* CONSOLE_DEBUG("noteslist = %ld items",gl_length(noteslist)); */
130
131 refinednoteslist = gl_create(gl_length(noteslist));
132
133 const symchar *lastid = NULL;
134 /* CONSOLE_DEBUG("refinednotes list has %ld elements",gl_length(refinednoteslist)); */
135 for(i=1; i<=gl_length(noteslist); ++i){
136 struct Note *n = (struct Note *)gl_fetch(noteslist,i);
137 if(GetNoteId(n)==NULL)continue;
138
139 gl_append_ptr(refinednoteslist,(VOIDPTR)n);
140 lastid = GetNoteId(n);
141 }
142 gl_destroy(noteslist);
143
144 if(gl_length(refinednoteslist)==0){
145 gl_destroy(refinednoteslist);
146 CONSOLE_DEBUG("empty notes list returned");
147 return NULL;
148 }
149
150 return refinednoteslist;
151 }
152

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22