[259] | 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 ***** */
|
---|
[326] | 34 | #ifdef __OS2__
|
---|
| 35 | # include <os2.h>
|
---|
| 36 | #endif
|
---|
[259] | 37 | #include <stdio.h>
|
---|
| 38 | #include <stdlib.h>
|
---|
| 39 | #include <string.h>
|
---|
| 40 |
|
---|
[326] | 41 | #ifdef HAVE_IO_H
|
---|
| 42 | # include <io.h>
|
---|
| 43 | #endif
|
---|
| 44 | #ifdef HAVE_UNISTD_H
|
---|
| 45 | # include <unistd.h>
|
---|
| 46 | #endif
|
---|
[259] | 47 | #include <fcntl.h>
|
---|
[326] | 48 | #include <sys/stat.h>
|
---|
[259] | 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 */
|
---|
[272] | 58 | extern PPARSEINFO pParseInfo;
|
---|
[259] | 59 |
|
---|
| 60 | static void printOverridenMethods(GPtrArray *pArray)
|
---|
| 61 | {
|
---|
| 62 | int a;
|
---|
| 63 |
|
---|
| 64 | for(a=0;a<pArray->len;a++)
|
---|
| 65 | {
|
---|
| 66 | POVERMETHOD pom=(POVERMETHOD)g_ptr_array_index(pArray, a);
|
---|
| 67 | g_printf("\t\tName:\t\t%s\n", pom->chrName);
|
---|
| 68 | }
|
---|
| 69 | }
|
---|
| 70 |
|
---|
| 71 | static void printInstanceVars(GPtrArray *pArray)
|
---|
| 72 | {
|
---|
| 73 | int a;
|
---|
| 74 |
|
---|
| 75 | for(a=0;a<pArray->len;a++)
|
---|
| 76 | {
|
---|
| 77 | int b;
|
---|
| 78 | PMETHODPARAM piv=(PMETHODPARAM)g_ptr_array_index(pArray, a);
|
---|
| 79 | g_printf("\t\tType:\t\t%s", piv->chrType);
|
---|
| 80 | for(b=0;b<piv->uiStar;b++)
|
---|
| 81 | g_printf("*");
|
---|
| 82 | g_printf("\n\t\tName:\t\t%s\n\n", piv->chrName);
|
---|
| 83 | }
|
---|
| 84 | }
|
---|
| 85 |
|
---|
| 86 |
|
---|
| 87 | static void printMethodParams(GPtrArray *pArray)
|
---|
| 88 | {
|
---|
| 89 | int a;
|
---|
| 90 |
|
---|
| 91 | for(a=0;a<pArray->len;a++)
|
---|
| 92 | {
|
---|
| 93 | int b;
|
---|
| 94 | PMETHODPARAM pm=(PMETHODPARAM)g_ptr_array_index(pArray, a);
|
---|
| 95 | switch(pm->uiDirection)
|
---|
| 96 | {
|
---|
| 97 | case PARM_DIRECTION_IN:
|
---|
| 98 | g_printf("\t\t\tDirection:\t%s\n", "in");
|
---|
| 99 | break;
|
---|
| 100 | case PARM_DIRECTION_OUT:
|
---|
| 101 | g_printf("\t\t\tDirection:\t%s\n", "out");
|
---|
| 102 | break;
|
---|
| 103 | case PARM_DIRECTION_INOUT:
|
---|
| 104 | g_printf("\t\t\tDirection:\t%s\n", "inout");
|
---|
| 105 | break;
|
---|
| 106 | default:
|
---|
| 107 | break;
|
---|
| 108 | }
|
---|
| 109 | g_printf("\t\t\tType:\t\t%s", pm->chrType);
|
---|
| 110 | for(b=0;b<pm->uiStar;b++)
|
---|
| 111 | g_printf("*");
|
---|
| 112 | g_printf("\n\t\t\tName:\t\t%s\n", pm->chrName);
|
---|
| 113 | }
|
---|
| 114 | }
|
---|
| 115 |
|
---|
| 116 |
|
---|
| 117 | static void printMethods(GPtrArray *pArray)
|
---|
| 118 | {
|
---|
| 119 | int a;
|
---|
| 120 |
|
---|
| 121 | for(a=0;a<pArray->len;a++)
|
---|
| 122 | {
|
---|
| 123 | int b;
|
---|
| 124 | PMETHOD pm=(PMETHOD)g_ptr_array_index(pArray, a);
|
---|
| 125 | g_printf("\t\tReturn type:\t%s", pm->mpReturn.chrType);
|
---|
| 126 | for(b=0;b<pm->mpReturn.uiStar;b++)
|
---|
| 127 | g_printf("*");
|
---|
| 128 | g_printf("\n\t\tName:\t\t%s\n", pm->chrName);
|
---|
| 129 | if(pm->pParamArray->len)
|
---|
| 130 | {
|
---|
| 131 | g_printf("\t\tNum parameters:\t%d\n", pm->pParamArray->len);
|
---|
| 132 | printMethodParams(pm->pParamArray);
|
---|
| 133 | }
|
---|
| 134 | else
|
---|
| 135 | g_printf("\t\t(No parameters)\n\n");
|
---|
| 136 | }
|
---|
| 137 | }
|
---|
| 138 |
|
---|
[272] | 139 | void printAllInterfaces(void)
|
---|
[259] | 140 | {
|
---|
| 141 | int a;
|
---|
| 142 |
|
---|
[272] | 143 | for(a=0;a<pParseInfo->pInterfaceArray->len;a++)
|
---|
[259] | 144 | {
|
---|
[272] | 145 | PINTERFACE pif=g_ptr_array_index(pParseInfo->pInterfaceArray, a);
|
---|
[259] | 146 | g_printf("Found Interface:\n");
|
---|
| 147 | g_printf("\tName:\t\t%s\n", pif->chrName);
|
---|
[261] | 148 | g_printf("\tParent:\t\t%s\n", (pif->chrParent ? pif->chrParent : "No parent"));
|
---|
[259] | 149 | g_printf("\tMajor:\t\t%ld\n", pif->ulMajor);
|
---|
| 150 | g_printf("\tMinor:\t\t%ld\n", pif->ulMinor);
|
---|
| 151 | g_printf("\tForward decl.:\t%s\n", (pif->fIsForwardDeclaration ? "Yes" : "No"));
|
---|
[271] | 152 | g_printf("\tMetaclass:\t%s\n", (pif->chrMetaClass ? pif->chrMetaClass : "None"));
|
---|
| 153 | g_printf("\tSource file:\t%s\n", pif->chrSourceFileName);
|
---|
[275] | 154 | if(pif->chrFileStem)
|
---|
| 155 | g_printf("\tFile stem:\t%s\n", pif->chrFileStem);
|
---|
[259] | 156 | /* Print instance vars */
|
---|
| 157 | g_printf("\tInstance vars:\t%d\n", pif->pInstanceVarArray->len);
|
---|
| 158 | printInstanceVars(pif->pInstanceVarArray);
|
---|
| 159 | /* Print methods */
|
---|
| 160 | g_printf("\tNew methods:\t%d\n", pif->pMethodArray->len);
|
---|
| 161 | printMethods(pif->pMethodArray);
|
---|
| 162 | /* Print overriden methods */
|
---|
| 163 | g_printf("\tOverriden methods:\t%d\n", pif->pOverrideArray->len);
|
---|
| 164 | printOverridenMethods(pif->pOverrideArray);
|
---|
| 165 | }
|
---|
| 166 | }
|
---|
[272] | 167 |
|
---|
| 168 | void printInterface(PINTERFACE pif)
|
---|
| 169 | {
|
---|
| 170 | g_printf("Found Interface:\n");
|
---|
| 171 | g_printf("\tName:\t\t%s\n", pif->chrName);
|
---|
| 172 | g_printf("\tParent:\t\t%s\n", (pif->chrParent ? pif->chrParent : "No parent"));
|
---|
| 173 | g_printf("\tMajor:\t\t%ld\n", pif->ulMajor);
|
---|
| 174 | g_printf("\tMinor:\t\t%ld\n", pif->ulMinor);
|
---|
| 175 | g_printf("\tForward decl.:\t%s\n", (pif->fIsForwardDeclaration ? "Yes" : "No"));
|
---|
| 176 | g_printf("\tMetaclass:\t%s\n", (pif->chrMetaClass ? pif->chrMetaClass : "None"));
|
---|
| 177 | g_printf("\tSource file:\t%s\n", pif->chrSourceFileName);
|
---|
[275] | 178 | if(pif->chrFileStem)
|
---|
| 179 | g_printf("\tFile stem:\t%s\n", pif->chrFileStem);
|
---|
[272] | 180 | /* Print instance vars */
|
---|
| 181 | g_printf("\tInstance vars:\t%d\n", pif->pInstanceVarArray->len);
|
---|
| 182 | printInstanceVars(pif->pInstanceVarArray);
|
---|
| 183 | /* Print methods */
|
---|
| 184 | g_printf("\tNew methods:\t%d\n", pif->pMethodArray->len);
|
---|
| 185 | printMethods(pif->pMethodArray);
|
---|
| 186 | /* Print overriden methods */
|
---|
| 187 | g_printf("\tOverriden methods:\t%d\n", pif->pOverrideArray->len);
|
---|
| 188 | printOverridenMethods(pif->pOverrideArray);
|
---|
| 189 | }
|
---|