| 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 | #define INCL_DOSPROCESS
|
|---|
| 35 | #define INCL_DOS
|
|---|
| 36 | #define INCL_DOSPROFILE
|
|---|
| 37 | #define INCL_DOSERRORS
|
|---|
| 38 |
|
|---|
| 39 | #include <os2.h>
|
|---|
| 40 | #include <stdio.h>
|
|---|
| 41 | #include <stdlib.h>
|
|---|
| 42 | #include <string.h>
|
|---|
| 43 |
|
|---|
| 44 | #include <io.h>
|
|---|
| 45 | #include <fcntl.h>
|
|---|
| 46 | #include <sys\stat.h>
|
|---|
| 47 |
|
|---|
| 48 | #include <glib.h>
|
|---|
| 49 | #include <glib/gprintf.h>
|
|---|
| 50 |
|
|---|
| 51 | #include "nom.h"
|
|---|
| 52 | #include "nomtk.h"
|
|---|
| 53 | #include "nomgc.h"
|
|---|
| 54 | #include "aclass.h"
|
|---|
| 55 |
|
|---|
| 56 | #define ULONG_TESTVALUE_1 0xffeeddcc
|
|---|
| 57 | #define ULONG_TESTVALUE_2 0x55aa1122
|
|---|
| 58 |
|
|---|
| 59 | AClass* createAClassObject()
|
|---|
| 60 | {
|
|---|
| 61 | AClass* aClass;
|
|---|
| 62 |
|
|---|
| 63 | aClass=AClassNew();
|
|---|
| 64 |
|
|---|
| 65 | if(nomIsObj(aClass))
|
|---|
| 66 | g_message("AClass creation\t\t\t\tOK\n");
|
|---|
| 67 | else
|
|---|
| 68 | g_message("AClass creation\t\t\t\t\tFAILED\n");
|
|---|
| 69 | return aClass;
|
|---|
| 70 | }
|
|---|
| 71 |
|
|---|
| 72 | /**
|
|---|
| 73 | Main entry point for the idl compiler.
|
|---|
| 74 | */
|
|---|
| 75 | int main(int argc, char **argv)
|
|---|
| 76 | {
|
|---|
| 77 | NOMClassMgr *NOMClassMgrObject;
|
|---|
| 78 | HREGDLL hReg=NULLHANDLE;
|
|---|
| 79 | AClass* aObject;
|
|---|
| 80 | ULONG ulRC;
|
|---|
| 81 |
|
|---|
| 82 | #if 0
|
|---|
| 83 | /* Preload the DLL otherwise it won't be found by the GC registering function */
|
|---|
| 84 | if((rc=DosLoadModule(uchrError, sizeof(uchrError),"nobjtk.dll", &hModuleGC))!=NO_ERROR)
|
|---|
| 85 | {
|
|---|
| 86 | printf("DosLoadmodule for nobjtk.dll failed with rc=0x%x because of module %s.\n", (int)rc, uchrError);
|
|---|
| 87 | return 1;
|
|---|
| 88 | };
|
|---|
| 89 | fprintf(stderr, "DLL handle for nobjtk.dll is: 0x%x\n", (int)hModuleGC);
|
|---|
| 90 | #endif
|
|---|
| 91 | nomInitGarbageCollection(NULL);
|
|---|
| 92 |
|
|---|
| 93 | /* Register DLLs with the garbage collector */
|
|---|
| 94 | hReg=nomBeginRegisterDLLWithGC();
|
|---|
| 95 | if(NULLHANDLE==hReg)
|
|---|
| 96 | return 1;
|
|---|
| 97 |
|
|---|
| 98 | #if 0
|
|---|
| 99 | //g_assert(nomRegisterDLLByName(hReg, "GLIB2.DLL" ));
|
|---|
| 100 | //g_assert(nomRegisterDLLByName(hReg, "GOBJECT2.DLL"));
|
|---|
| 101 | g_assert(nomRegisterDLLByName(hReg, "GMODULE2.DLL"));
|
|---|
| 102 | g_assert(nomRegisterDLLByName(hReg, "GDK2.DLL"));
|
|---|
| 103 | g_assert(nomRegisterDLLByName(hReg, "GDKPIX2.DLL"));
|
|---|
| 104 | g_assert(nomRegisterDLLByName(hReg, "GTK2.DLL" ));
|
|---|
| 105 | g_assert(nomRegisterDLLByName(hReg, "ATK.DLL" ));
|
|---|
| 106 | #endif
|
|---|
| 107 | g_assert(nomRegisterDLLByName(hReg, "NOBJTK.DLL"));
|
|---|
| 108 |
|
|---|
| 109 | nomEndRegisterDLLWithGC(hReg);
|
|---|
| 110 |
|
|---|
| 111 | g_message("NOM test application started.");
|
|---|
| 112 |
|
|---|
| 113 | /* Init NOM */
|
|---|
| 114 | NOMClassMgrObject=nomEnvironmentNew();
|
|---|
| 115 |
|
|---|
| 116 | /* Try to create an object */
|
|---|
| 117 | aObject=createAClassObject();
|
|---|
| 118 | g_assert(aObject);
|
|---|
| 119 |
|
|---|
| 120 | /* -- Call methods on the object --- */
|
|---|
| 121 | g_message("================================================================");
|
|---|
| 122 | g_message("===== Testing init values of instance variables. Must be 0 =====");
|
|---|
| 123 | g_message("================================================================");
|
|---|
| 124 |
|
|---|
| 125 | ulRC=_tstQueryUlongVar1(aObject, NULLHANDLE);
|
|---|
| 126 | g_message("Calling tstQueryUlongVar1():\t%ld\t\t%s", ulRC, (0!=ulRC ? "FAILED" : "OK"));
|
|---|
| 127 | g_assert(0==ulRC);
|
|---|
| 128 |
|
|---|
| 129 | ulRC=_tstQueryUlongVar2(aObject, NULLHANDLE);
|
|---|
| 130 | g_message("Calling tstQueryUlongVar2():\t%ld\t\t%s\n", ulRC, (0!=ulRC ? "FAILED" : "OK"));
|
|---|
| 131 | g_assert(0==ulRC);
|
|---|
| 132 |
|
|---|
| 133 | g_message("=================================================");
|
|---|
| 134 | g_message("===== Testing setting of instance variables =====");
|
|---|
| 135 | g_message("=================================================");
|
|---|
| 136 | _tstSetUlongVar1(aObject, ULONG_TESTVALUE_1, NULLHANDLE);
|
|---|
| 137 | ulRC=_tstQueryUlongVar1(aObject, NULLHANDLE);
|
|---|
| 138 | g_message("Calling tstQueryUlongVar1():\t0x%lx\t\t%s", ulRC, (ULONG_TESTVALUE_1!=ulRC ? "FAILED" : "OK"));
|
|---|
| 139 | g_assert(ULONG_TESTVALUE_1==ulRC);
|
|---|
| 140 |
|
|---|
| 141 | ulRC=_tstQueryUlongVar2(aObject, NULLHANDLE);
|
|---|
| 142 | g_message("Calling tstQueryUlongVar2():\t0x%lx\t\t%s\n", ulRC, (0!=ulRC ? "FAILED" : "OK"));
|
|---|
| 143 | g_assert(0==ulRC);
|
|---|
| 144 |
|
|---|
| 145 | _tstSetUlongVar2(aObject, ULONG_TESTVALUE_2, NULLHANDLE);
|
|---|
| 146 | ulRC=_tstQueryUlongVar1(aObject, NULLHANDLE);
|
|---|
| 147 | g_message("Calling tstQueryUlongVar1():\t0x%lx\t\t%s", ulRC, (ULONG_TESTVALUE_1!=ulRC ? "FAILED" : "OK"));
|
|---|
| 148 | g_assert(ULONG_TESTVALUE_1==ulRC);
|
|---|
| 149 |
|
|---|
| 150 | ulRC=_tstQueryUlongVar2(aObject, NULLHANDLE);
|
|---|
| 151 | g_message("Calling tstQueryUlongVar2():\t0x%lx\t\t%s\n", ulRC, (ULONG_TESTVALUE_2!=ulRC ? "FAILED" : "OK"));
|
|---|
| 152 | g_assert(ULONG_TESTVALUE_2==ulRC);
|
|---|
| 153 |
|
|---|
| 154 | return 0;
|
|---|
| 155 | };
|
|---|
| 156 |
|
|---|
| 157 |
|
|---|
| 158 |
|
|---|
| 159 |
|
|---|
| 160 |
|
|---|
| 161 |
|
|---|
| 162 |
|
|---|
| 163 |
|
|---|