If you're hacky enough, you can now call into auto-generated interfaces from
[wvapps.git] / xplcidl / scriptest.cc
blobee560b5d008e40c0617aaa0afbfd7898ae803821
1 #include "masterdispatch.h"
2 #include "wvmoniker.h"
3 #include "IObject.h"
4 #include "IMulti.hpp"
5 #include "uniscript.h"
6 #include <stdio.h>
7 #include <assert.h>
9 int main()
12 IObject *obj = wvcreate<IObject>("mymulti:5 hello world!");
13 assert(obj);
15 AnyType any2(obj, IObject_IID, obj);
16 AnyType any2b(any2);
17 printf("switch2: %p -> %d\n",
18 (IObject *)any2.obj, any2.switchto(IString_IID));
19 printf("switch2b: %p -> %d\n",
20 (IObject *)any2b.obj, any2b.switchto(IString_IID));
22 AnyType x[] = { AnyType(98) };
23 master->call(any2, "setInt", 1, x);
24 AnyType ret = master->call(any2, "getInt", 0, NULL);
25 printf("return: %s\n", ret.str.cstr());
26 assert(ret.str.num() == 98);
28 AnyType x2[] = { AnyType("42 silly")};
29 master->call(any2, "setString", 1, x2);
30 ret = master->call(any2, "getInt", 0, NULL);
31 printf("return: %s\n", ret.str.cstr());
32 assert(ret.str.num() == 42);
34 obj->release();
38 WvString o = unicreate("mymulti:7 hello world!");
39 int x = atoi(unicall(o, "getInt"));
40 printf("x = %d\n", x);
41 unicall(o, "setString {blah blah}");
42 printf("x2 = '%s'\n", unicall(o, "getString"));
45 return 0;