| 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 | # define INCL_DOSPROCESS
|
|---|
| 36 | # define INCL_DOS
|
|---|
| 37 | # define INCL_DOSPROFILE
|
|---|
| 38 | # define INCL_DOSERRORS
|
|---|
| 39 | # include <os2.h>
|
|---|
| 40 | #endif /* __OS2__ */
|
|---|
| 41 |
|
|---|
| 42 | #include <stdio.h>
|
|---|
| 43 | #include <stdlib.h>
|
|---|
| 44 | #include <string.h>
|
|---|
| 45 |
|
|---|
| 46 | #ifdef HAVE_IO_H
|
|---|
| 47 | # include <io.h>
|
|---|
| 48 | #endif
|
|---|
| 49 | #ifdef HAVE_UNISTD_H
|
|---|
| 50 | # include <unistd.h>
|
|---|
| 51 | #endif
|
|---|
| 52 | #include <fcntl.h>
|
|---|
| 53 | #include <sys/stat.h>
|
|---|
| 54 |
|
|---|
| 55 | #include <glib.h>
|
|---|
| 56 | #include <glib/gprintf.h>
|
|---|
| 57 |
|
|---|
| 58 | #include "nom.h"
|
|---|
| 59 | #include "nomtk.h"
|
|---|
| 60 | #include "nomgc.h"
|
|---|
| 61 |
|
|---|
| 62 | #include "aclass.h"
|
|---|
| 63 | #include "bclass.h"
|
|---|
| 64 |
|
|---|
| 65 | #define ULONG_TESTVALUE_1 0xffeeddcc
|
|---|
| 66 | #define ULONG_TESTVALUE_2 0x55aa1122
|
|---|
| 67 | #define ULONG_TESTVALUE_BCLASS_1 0x50403020
|
|---|
| 68 | #define ULONG_TESTVALUE_BCLASS_2 0xf0e0d0c0
|
|---|
| 69 |
|
|---|
| 70 | AClass* createAClassObject()
|
|---|
| 71 | {
|
|---|
| 72 | AClass* aClass;
|
|---|
| 73 |
|
|---|
| 74 | aClass=AClassNew();
|
|---|
| 75 |
|
|---|
| 76 | if(nomIsObj(aClass))
|
|---|
| 77 | g_message("AClass creation\t\t\t\tOK\n");
|
|---|
| 78 | else
|
|---|
| 79 | g_message("AClass creation\t\t\t\t\tFAILED\n");
|
|---|
| 80 | return aClass;
|
|---|
| 81 | }
|
|---|
| 82 |
|
|---|
| 83 | AClass* createBClassObject()
|
|---|
| 84 | {
|
|---|
| 85 | BClass* bClass;
|
|---|
| 86 |
|
|---|
| 87 | bClass=BClassNew();
|
|---|
| 88 |
|
|---|
| 89 | if(nomIsObj(bClass))
|
|---|
| 90 | g_message("BClass creation\t\t\t\tOK\n");
|
|---|
| 91 | else
|
|---|
| 92 | g_message("BClass creation\t\t\t\t\tFAILED\n");
|
|---|
| 93 | return bClass;
|
|---|
| 94 | }
|
|---|
| 95 |
|
|---|
| 96 | void tstAClassInstanceVarInitValues(AClass * aObject)
|
|---|
| 97 | {
|
|---|
| 98 | gulong ulRC;
|
|---|
| 99 |
|
|---|
| 100 | g_message("================================================================");
|
|---|
| 101 | g_message("===== Testing init values of instance variables. Must be 0 =====");
|
|---|
| 102 | g_message("================================================================");
|
|---|
| 103 |
|
|---|
| 104 | ulRC=_tstQueryUlongVar1(aObject, NULL);
|
|---|
| 105 | g_message("Calling tstQueryUlongVar1():\t%ld\t\t%s", ulRC, (0!=ulRC ? "FAILED" : "OK"));
|
|---|
| 106 | g_assert(0==ulRC);
|
|---|
| 107 |
|
|---|
| 108 | ulRC=_tstQueryUlongVar2(aObject, NULL);
|
|---|
| 109 | g_message("Calling tstQueryUlongVar2():\t%ld\t\t%s\n", ulRC, (0!=ulRC ? "FAILED" : "OK"));
|
|---|
| 110 | g_assert(0==ulRC);
|
|---|
| 111 | }
|
|---|
| 112 |
|
|---|
| 113 |
|
|---|
| 114 | void tstBClassInstanceVarInitValues(BClass * aObject)
|
|---|
| 115 | {
|
|---|
| 116 | gulong ulRC;
|
|---|
| 117 |
|
|---|
| 118 | g_message("================================================================");
|
|---|
| 119 | g_message("===== Testing init values of instance variables. Must be 0 =====");
|
|---|
| 120 | g_message("================================================================");
|
|---|
| 121 |
|
|---|
| 122 | ulRC=_tstQueryBClassUlongVar1(aObject, NULL);
|
|---|
| 123 | g_message("Calling tstQueryBClassUlongVar1():\t%ld\t\t%s", ulRC, (0!=ulRC ? "FAILED" : "OK"));
|
|---|
| 124 | g_assert(0==ulRC);
|
|---|
| 125 |
|
|---|
| 126 | ulRC=_tstQueryBClassUlongVar2(aObject, NULL);
|
|---|
| 127 | g_message("Calling tstQueryBClassUlongVar2():\t%ld\t\t%s\n", ulRC, (0!=ulRC ? "FAILED" : "OK"));
|
|---|
| 128 | g_assert(0==ulRC);
|
|---|
| 129 | }
|
|---|
| 130 |
|
|---|
| 131 |
|
|---|
| 132 | void tstSetAClassInstanceVar(AClass * aObject)
|
|---|
| 133 | {
|
|---|
| 134 | gulong ulRC;
|
|---|
| 135 |
|
|---|
| 136 | g_message("========================================================");
|
|---|
| 137 | g_message("===== Testing setting of AClass instance variables =====");
|
|---|
| 138 | g_message("========================================================");
|
|---|
| 139 | /* Set 1. value */
|
|---|
| 140 | _tstSetUlongVar1(aObject, ULONG_TESTVALUE_1, NULL);
|
|---|
| 141 | ulRC=_tstQueryUlongVar1(aObject, NULL);
|
|---|
| 142 | g_message("Calling tstQueryUlongVar1():\t0x%lx\t\t%s", ulRC, (ULONG_TESTVALUE_1!=ulRC ? "FAILED" : "OK"));
|
|---|
| 143 | g_assert(ULONG_TESTVALUE_1==ulRC);
|
|---|
| 144 |
|
|---|
| 145 | ulRC=_tstQueryUlongVar2(aObject, NULL);
|
|---|
| 146 | g_message("Calling tstQueryUlongVar2():\t0x%lx\t\t\t%s\n", ulRC, (0!=ulRC ? "FAILED" : "OK"));
|
|---|
| 147 | g_assert(0==ulRC);
|
|---|
| 148 |
|
|---|
| 149 | /* Set 2. value */
|
|---|
| 150 | _tstSetUlongVar2(aObject, ULONG_TESTVALUE_2, NULL);
|
|---|
| 151 | ulRC=_tstQueryUlongVar1(aObject, NULL);
|
|---|
| 152 | g_message("Calling tstQueryUlongVar1():\t0x%lx\t\t%s", ulRC, (ULONG_TESTVALUE_1!=ulRC ? "FAILED" : "OK"));
|
|---|
| 153 | g_assert(ULONG_TESTVALUE_1==ulRC);
|
|---|
| 154 |
|
|---|
| 155 | ulRC=_tstQueryUlongVar2(aObject, NULL);
|
|---|
| 156 | g_message("Calling tstQueryUlongVar2():\t0x%lx\t\t%s\n\n", ulRC, (ULONG_TESTVALUE_2!=ulRC ? "FAILED" : "OK"));
|
|---|
| 157 | g_assert(ULONG_TESTVALUE_2==ulRC);
|
|---|
| 158 | }
|
|---|
| 159 |
|
|---|
| 160 | void tstSetBClassInstanceVar(BClass * aObject)
|
|---|
| 161 | {
|
|---|
| 162 | gulong ulRC;
|
|---|
| 163 |
|
|---|
| 164 | g_message("========================================================");
|
|---|
| 165 | g_message("===== Testing setting of BClass instance variables =====");
|
|---|
| 166 | g_message("========================================================");
|
|---|
| 167 | /* Set 1. value */
|
|---|
| 168 | _tstSetBClassUlongVar1(aObject, ULONG_TESTVALUE_BCLASS_1, NULL);
|
|---|
| 169 |
|
|---|
| 170 | /* AClass */
|
|---|
| 171 | ulRC=_tstQueryUlongVar1(aObject, NULL);
|
|---|
| 172 | g_message("Calling tstQueryUlongVar1():\t0x%lx\t\t%s", ulRC, (ULONG_TESTVALUE_1!=ulRC ? "FAILED" : "OK"));
|
|---|
| 173 | g_assert(ULONG_TESTVALUE_1==ulRC);
|
|---|
| 174 | ulRC=_tstQueryUlongVar2(aObject, NULL);
|
|---|
| 175 | g_message("Calling tstQueryUlongVar2():\t0x%lx\t\t%s", ulRC, (ULONG_TESTVALUE_2!=ulRC ? "FAILED" : "OK"));
|
|---|
| 176 | g_assert(ULONG_TESTVALUE_2==ulRC);
|
|---|
| 177 |
|
|---|
| 178 | /* BClass*/
|
|---|
| 179 | ulRC=_tstQueryBClassUlongVar1(aObject, NULL);
|
|---|
| 180 | g_message("Calling tstQueryBClassUlongVar1():\t0x%lx\t\t%s", ulRC, (ULONG_TESTVALUE_BCLASS_1!=ulRC ? "FAILED" : "OK"));
|
|---|
| 181 | g_assert(ULONG_TESTVALUE_BCLASS_1==ulRC);
|
|---|
| 182 |
|
|---|
| 183 | ulRC=_tstQueryBClassUlongVar2(aObject, NULL);
|
|---|
| 184 | g_message("Calling tstQueryBClassUlongVar2():\t0x%lx\t\t\t%s\n\n", ulRC, (0!=ulRC ? "FAILED" : "OK"));
|
|---|
| 185 | g_assert(0==ulRC);
|
|---|
| 186 |
|
|---|
| 187 |
|
|---|
| 188 |
|
|---|
| 189 | /* Set 2. value */
|
|---|
| 190 | _tstSetBClassUlongVar2(aObject, ULONG_TESTVALUE_BCLASS_2, NULL);
|
|---|
| 191 |
|
|---|
| 192 | /* AClass */
|
|---|
| 193 | ulRC=_tstQueryUlongVar1(aObject, NULL);
|
|---|
| 194 | g_message("Calling tstQueryUlongVar1():\t0x%lx\t\t%s", ulRC, (ULONG_TESTVALUE_1!=ulRC ? "FAILED" : "OK"));
|
|---|
| 195 | g_assert(ULONG_TESTVALUE_1==ulRC);
|
|---|
| 196 | ulRC=_tstQueryUlongVar2(aObject, NULL);
|
|---|
| 197 | g_message("Calling tstQueryUlongVar2():\t0x%lx\t\t%s", ulRC, (ULONG_TESTVALUE_2!=ulRC ? "FAILED" : "OK"));
|
|---|
| 198 | g_assert(ULONG_TESTVALUE_2==ulRC);
|
|---|
| 199 |
|
|---|
| 200 | /* BClass*/
|
|---|
| 201 | ulRC=_tstQueryBClassUlongVar1(aObject, NULL);
|
|---|
| 202 | g_message("Calling tstQueryBClassUlongVar1():\t0x%lx\t\t%s", ulRC, (ULONG_TESTVALUE_BCLASS_1!=ulRC ? "FAILED" : "OK"));
|
|---|
| 203 | g_assert(ULONG_TESTVALUE_BCLASS_1==ulRC);
|
|---|
| 204 |
|
|---|
| 205 | ulRC=_tstQueryBClassUlongVar2(aObject, NULL);
|
|---|
| 206 | g_message("Calling tstQueryBClassUlongVar2():\t0x%lx\t\t%s\n\n", ulRC, (ULONG_TESTVALUE_BCLASS_2!=ulRC ? "FAILED" : "OK"));
|
|---|
| 207 | g_assert(ULONG_TESTVALUE_BCLASS_2==ulRC);
|
|---|
| 208 |
|
|---|
| 209 | }
|
|---|
| 210 |
|
|---|
| 211 |
|
|---|
| 212 | /**
|
|---|
| 213 | Main entry point for the idl compiler.
|
|---|
| 214 | */
|
|---|
| 215 | int main(int argc, char **argv)
|
|---|
| 216 | {
|
|---|
| 217 | NOMClassMgr *NOMClassMgrObject;
|
|---|
| 218 | HREGDLL hReg=NULL;
|
|---|
| 219 | AClass* aObject;
|
|---|
| 220 | BClass* bObject;
|
|---|
| 221 |
|
|---|
| 222 | #if 0
|
|---|
| 223 | /* Preload the DLL otherwise it won't be found by the GC registering function */
|
|---|
| 224 | if((rc=DosLoadModule(uchrError, sizeof(uchrError),"nobjtk.dll", &hModuleGC))!=NO_ERROR)
|
|---|
| 225 | {
|
|---|
| 226 | printf("DosLoadmodule for nobjtk.dll failed with rc=0x%x because of module %s.\n", (int)rc, uchrError);
|
|---|
| 227 | return 1;
|
|---|
| 228 | };
|
|---|
| 229 | fprintf(stderr, "DLL handle for nobjtk.dll is: 0x%x\n", (int)hModuleGC);
|
|---|
| 230 | #endif
|
|---|
| 231 | nomInitGarbageCollection(NULL);
|
|---|
| 232 |
|
|---|
| 233 | /* Register DLLs with the garbage collector */
|
|---|
| 234 | hReg=nomBeginRegisterDLLWithGC();
|
|---|
| 235 | if(NULL==hReg)
|
|---|
| 236 | return 1;
|
|---|
| 237 |
|
|---|
| 238 | #if 0
|
|---|
| 239 | //g_assert(nomRegisterDLLByName(hReg, "GLIB2.DLL" ));
|
|---|
| 240 | //g_assert(nomRegisterDLLByName(hReg, "GOBJECT2.DLL"));
|
|---|
| 241 | g_assert(nomRegisterDLLByName(hReg, "GMODULE2.DLL"));
|
|---|
| 242 | g_assert(nomRegisterDLLByName(hReg, "GDK2.DLL"));
|
|---|
| 243 | g_assert(nomRegisterDLLByName(hReg, "GDKPIX2.DLL"));
|
|---|
| 244 | g_assert(nomRegisterDLLByName(hReg, "GTK2.DLL" ));
|
|---|
| 245 | g_assert(nomRegisterDLLByName(hReg, "ATK.DLL" ));
|
|---|
| 246 | #endif
|
|---|
| 247 | g_assert(nomRegisterDLLByName(hReg, "NOBJTK.DLL"));
|
|---|
| 248 |
|
|---|
| 249 | nomEndRegisterDLLWithGC(hReg);
|
|---|
| 250 |
|
|---|
| 251 | g_message("NOM test application started.");
|
|---|
| 252 |
|
|---|
| 253 | /* Init NOM */
|
|---|
| 254 | NOMClassMgrObject=nomEnvironmentNew();
|
|---|
| 255 |
|
|---|
| 256 | g_message("\n");
|
|---|
| 257 | g_message("================================================================");
|
|---|
| 258 | g_message("===== Testing AClass, child of NOMObject =====");
|
|---|
| 259 | g_message("================================================================");
|
|---|
| 260 | /* Try to create an AClass object */
|
|---|
| 261 | aObject=createAClassObject();
|
|---|
| 262 | g_assert(aObject);
|
|---|
| 263 |
|
|---|
| 264 | /* -- Call methods on the object --- */
|
|---|
| 265 | tstAClassInstanceVarInitValues(aObject);
|
|---|
| 266 | tstSetAClassInstanceVar(aObject);
|
|---|
| 267 |
|
|---|
| 268 | g_message("================================================================");
|
|---|
| 269 | g_message("===== Testing BClass, child of AClass =====");
|
|---|
| 270 | g_message("================================================================");
|
|---|
| 271 | /* Try to create an AClass object */
|
|---|
| 272 | bObject=createBClassObject();
|
|---|
| 273 | g_assert(bObject);
|
|---|
| 274 |
|
|---|
| 275 | tstAClassInstanceVarInitValues(bObject);
|
|---|
| 276 | tstBClassInstanceVarInitValues(bObject);
|
|---|
| 277 |
|
|---|
| 278 | tstSetAClassInstanceVar(bObject);
|
|---|
| 279 | tstSetBClassInstanceVar(bObject);
|
|---|
| 280 |
|
|---|
| 281 | return 0;
|
|---|
| 282 | };
|
|---|
| 283 |
|
|---|
| 284 |
|
|---|
| 285 |
|
|---|
| 286 |
|
|---|
| 287 |
|
|---|
| 288 |
|
|---|
| 289 |
|
|---|
| 290 |
|
|---|