source: trunk/nomc/c/printdata.c@ 389

Last change on this file since 389 was 380, checked in by cinc, 17 years ago

Compiler for a new programming language for use with NOM (C like).

  • Property svn:executable set to *
File size: 6.1 KB
Line 
1/* ***** BEGIN LICENSE BLOCK *****
2* Version: CDDL 1.0/LGPL 2.1
3*
4* The contents of this file are subject to the COMMON DEVELOPMENT AND
5* DISTRIBUTION LICENSE (CDDL) Version 1.0 (the "License"); you may not use
6* this file except in compliance with the License. You may obtain a copy of
7* the License at http://www.sun.com/cddl/
8*
9* Software distributed under the License is distributed on an "AS IS" basis,
10* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11* for the specific language governing rights and limitations under the
12* License.
13*
14* The Original Code is "NOM" Netlabs Object Model
15*
16* The Initial Developer of the Original Code is
17* netlabs.org: Chris Wohlgemuth <cinc-ml@netlabs.org>.
18* Portions created by the Initial Developer are Copyright (C) 2007
19* the Initial Developer. All Rights Reserved.
20*
21* Contributor(s):
22*
23* Alternatively, the contents of this file may be used under the terms of
24* the GNU Lesser General Public License Version 2.1 (the "LGPL"), in which
25* case the provisions of the LGPL are applicable instead of those above. If
26* you wish to allow use of your version of this file only under the terms of
27* the LGPL, and not to allow others to use your version of this file under
28* the terms of the CDDL, indicate your decision by deleting the provisions
29* above and replace them with the notice and other provisions required by the
30* LGPL. If you do not delete the provisions above, a recipient may use your
31* version of this file under the terms of any one of the CDDL or the LGPL.
32*
33* ***** END LICENSE BLOCK ***** */
34#ifdef __OS2__
35# include <os2.h>
36#endif
37#include <stdio.h>
38#include <stdlib.h>
39#include <string.h>
40
41#ifdef HAVE_IO_H
42# include <io.h>
43#endif
44#ifdef HAVE_UNISTD_H
45# include <unistd.h>
46#endif
47#include <fcntl.h>
48#include <sys/stat.h>
49
50#include <glib/gprintf.h>
51
52#include "nom.h"
53#include "nomtk.h"
54
55#include "parser.h"
56
57/* The pointer array holding the interfaces we found */
58//extern PPARSEINFO pParseInfo;
59
60extern GScanner *gScanner;
61
62#if 0
63static void printOverridenMethods(GPtrArray *pArray)
64{
65 int a;
66
67 for(a=0;a<pArray->len;a++)
68 {
69 POVERMETHOD pom=(POVERMETHOD)g_ptr_array_index(pArray, a);
70 g_printf("\t\tName:\t\t%s\n", pom->chrName);
71 }
72}
73
74static void printInstanceVars(GPtrArray *pArray)
75{
76 int a;
77
78 for(a=0;a<pArray->len;a++)
79 {
80 int b;
81 PMETHODPARAM piv=(PMETHODPARAM)g_ptr_array_index(pArray, a);
82 g_printf("\t\tType:\t\t%s", piv->chrType);
83 for(b=0;b<piv->uiStar;b++)
84 g_printf("*");
85 g_printf("\n\t\tName:\t\t%s\n\n", piv->chrName);
86 }
87}
88#endif
89
90
91static void printMethodParams(GPtrArray *pArray)
92{
93 int a;
94
95 for(a=0;a<pArray->len;a++)
96 {
97 int b;
98 PMETHODPARAM pm=(PMETHODPARAM)g_ptr_array_index(pArray, a);
99 switch(pm->uiDirection)
100 {
101 case PARM_DIRECTION_IN:
102 g_printf("\t\t\tDirection:\t%s\n", "in");
103 break;
104 case PARM_DIRECTION_OUT:
105 g_printf("\t\t\tDirection:\t%s\n", "out");
106 break;
107 case PARM_DIRECTION_INOUT:
108 g_printf("\t\t\tDirection:\t%s\n", "inout");
109 break;
110 default:
111 break;
112 }
113 g_printf("\t\t\tType:\t\t%s", pm->chrType);
114 for(b=0;b<pm->uiStar;b++)
115 g_printf("*");
116 g_printf("\n\t\t\tName:\t\t%s\n", pm->chrName);
117 }
118}
119
120
121static void printMethods(GPtrArray *pArray)
122{
123 int a;
124
125 for(a=0;a<pArray->len;a++)
126 {
127 int b;
128 PMETHOD pm=(PMETHOD)g_ptr_array_index(pArray, a);
129 g_printf("\t\tReturn type:\t%s", pm->mpReturn.chrType);
130 for(b=0;b<pm->mpReturn.uiStar;b++)
131 g_printf("*");
132 g_printf("\n\t\tName:\t\t%s\n", pm->chrName);
133 if(pm->pParamArray->len)
134 {
135 g_printf("\t\tNum parameters:\t%d\n", pm->pParamArray->len);
136 printMethodParams(pm->pParamArray);
137 }
138 else
139 g_printf("\t\t(No parameters)\n\n");
140 }
141}
142
143void printAllInterfaces(void)
144{
145 int a;
146 PPARSEINFO pParseInfo=(PPARSEINFO)gScanner->user_data;
147
148
149 for(a=0;a<pParseInfo->pInterfaceArray->len;a++)
150 {
151 PINTERFACE pif=g_ptr_array_index(pParseInfo->pInterfaceArray, a);
152 g_printf("Found Interface:\n");
153 g_printf("\tName:\t\t%s\n", pif->chrName);
154 g_printf("\tParent:\t\t%s\n", (pif->chrParent ? pif->chrParent : "No parent"));
155 //g_printf("\tMajor:\t\t%ld\n", pif->ulMajor);
156 //g_printf("\tMinor:\t\t%ld\n", pif->ulMinor);
157 g_printf("\tForward decl.:\t%s\n", (pif->fIsForwardDeclaration ? "Yes" : "No"));
158 //g_printf("\tMetaclass:\t%s\n", (pif->chrMetaClass ? pif->chrMetaClass : "None"));
159 g_printf("\tSource file:\t%s\n", pif->chrSourceFileName);
160 //if(pif->chrFileStem)
161 //g_printf("\tFile stem:\t%s\n", pif->chrFileStem);
162 /* Print instance vars */
163 //g_printf("\tInstance vars:\t%d\n", pif->pInstanceVarArray->len);
164 //printInstanceVars(pif->pInstanceVarArray);
165 /* Print methods */
166 g_printf("\tNew methods:\t%d\n", pif->pMethodArray->len);
167 printMethods(pif->pMethodArray);
168 /* Print overriden methods */
169 //g_printf("\tOverriden methods:\t%d\n", pif->pOverrideArray->len);
170 //printOverridenMethods(pif->pOverrideArray);
171 }
172}
173
174void printInterface(PINTERFACE pif)
175{
176 g_printf("Found Interface:\n");
177 g_printf("\tName:\t\t%s\n", pif->chrName);
178 g_printf("\tParent:\t\t%s\n", (pif->chrParent ? pif->chrParent : "No parent"));
179 //g_printf("\tMajor:\t\t%ld\n", pif->ulMajor);
180 //g_printf("\tMinor:\t\t%ld\n", pif->ulMinor);
181 g_printf("\tForward decl.:\t%s\n", (pif->fIsForwardDeclaration ? "Yes" : "No"));
182 //g_printf("\tMetaclass:\t%s\n", (pif->chrMetaClass ? pif->chrMetaClass : "None"));
183 g_printf("\tSource file:\t%s\n", pif->chrSourceFileName);
184 //if(pif->chrFileStem)
185 //g_printf("\tFile stem:\t%s\n", pif->chrFileStem);
186 /* Print instance vars */
187 //g_printf("\tInstance vars:\t%d\n", pif->pInstanceVarArray->len);
188 //printInstanceVars(pif->pInstanceVarArray);
189 /* Print methods */
190 g_printf("\tNew methods:\t%d\n", pif->pMethodArray->len);
191 printMethods(pif->pMethodArray);
192 /* Print overriden methods */
193 //g_printf("\tOverriden methods:\t%d\n", pif->pOverrideArray->len);
194 //printOverridenMethods(pif->pOverrideArray);
195}
Note: See TracBrowser for help on using the repository browser.