source: trunk/idl-compiler/c/printdata.c@ 260

Last change on this file since 260 was 259, checked in by cinc, 18 years ago

Started work on an IDL compiler

File size: 4.7 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#include <os2.h>
35#include <stdio.h>
36#include <stdlib.h>
37#include <string.h>
38
39#include <io.h>
40#include <fcntl.h>
41#include <sys\stat.h>
42
43#include <gtk/gtk.h>
44#include <glib/gprintf.h>
45
46#include "nom.h"
47#include "nomtk.h"
48
49#include "parser.h"
50
51/* The pointer array holding the interfaces we found */
52extern GPtrArray* pInterfaceArray;
53
54static void printOverridenMethods(GPtrArray *pArray)
55{
56 int a;
57
58 for(a=0;a<pArray->len;a++)
59 {
60 POVERMETHOD pom=(POVERMETHOD)g_ptr_array_index(pArray, a);
61 g_printf("\t\tName:\t\t%s\n", pom->chrName);
62 }
63}
64
65static void printInstanceVars(GPtrArray *pArray)
66{
67 int a;
68
69 for(a=0;a<pArray->len;a++)
70 {
71 int b;
72 PMETHODPARAM piv=(PMETHODPARAM)g_ptr_array_index(pArray, a);
73 g_printf("\t\tType:\t\t%s", piv->chrType);
74 for(b=0;b<piv->uiStar;b++)
75 g_printf("*");
76 g_printf("\n\t\tName:\t\t%s\n\n", piv->chrName);
77 }
78}
79
80
81static void printMethodParams(GPtrArray *pArray)
82{
83 int a;
84
85 for(a=0;a<pArray->len;a++)
86 {
87 int b;
88 PMETHODPARAM pm=(PMETHODPARAM)g_ptr_array_index(pArray, a);
89 switch(pm->uiDirection)
90 {
91 case PARM_DIRECTION_IN:
92 g_printf("\t\t\tDirection:\t%s\n", "in");
93 break;
94 case PARM_DIRECTION_OUT:
95 g_printf("\t\t\tDirection:\t%s\n", "out");
96 break;
97 case PARM_DIRECTION_INOUT:
98 g_printf("\t\t\tDirection:\t%s\n", "inout");
99 break;
100 default:
101 break;
102 }
103 g_printf("\t\t\tType:\t\t%s", pm->chrType);
104 for(b=0;b<pm->uiStar;b++)
105 g_printf("*");
106 g_printf("\n\t\t\tName:\t\t%s\n", pm->chrName);
107 }
108}
109
110
111static void printMethods(GPtrArray *pArray)
112{
113 int a;
114
115 for(a=0;a<pArray->len;a++)
116 {
117 int b;
118 PMETHOD pm=(PMETHOD)g_ptr_array_index(pArray, a);
119 g_printf("\t\tReturn type:\t%s", pm->mpReturn.chrType);
120 for(b=0;b<pm->mpReturn.uiStar;b++)
121 g_printf("*");
122 g_printf("\n\t\tName:\t\t%s\n", pm->chrName);
123 if(pm->pParamArray->len)
124 {
125 g_printf("\t\tNum parameters:\t%d\n", pm->pParamArray->len);
126 printMethodParams(pm->pParamArray);
127 }
128 else
129 g_printf("\t\t(No parameters)\n\n");
130 }
131}
132
133void printInterface(void)
134{
135 int a;
136
137 for(a=0;a<pInterfaceArray->len;a++)
138 {
139 PINTERFACE pif=g_ptr_array_index(pInterfaceArray, a);
140 g_printf("Found Interface:\n");
141 g_printf("\tName:\t\t%s\n", pif->chrName);
142 g_printf("\tMajor:\t\t%ld\n", pif->ulMajor);
143 g_printf("\tMinor:\t\t%ld\n", pif->ulMinor);
144 g_printf("\tForward decl.:\t%s\n", (pif->fIsForwardDeclaration ? "Yes" : "No"));
145
146 /* Print instance vars */
147 g_printf("\tInstance vars:\t%d\n", pif->pInstanceVarArray->len);
148 printInstanceVars(pif->pInstanceVarArray);
149 /* Print methods */
150 g_printf("\tNew methods:\t%d\n", pif->pMethodArray->len);
151 printMethods(pif->pMethodArray);
152 /* Print overriden methods */
153 g_printf("\tOverriden methods:\t%d\n", pif->pOverrideArray->len);
154 printOverridenMethods(pif->pOverrideArray);
155 }
156}
Note: See TracBrowser for help on using the repository browser.