]> git.buserror.net Git - polintos/scott/priv.git/blob - idlcomp/tests/cpp-caller.cc
Initial checkin from Perforce.
[polintos/scott/priv.git] / idlcomp / tests / cpp-caller.cc
1 #include <stdio.h>
2 #include <System.h>
3
4 using namespace System;
5 using RunTime::Array;
6
7 int main()
8 {
9         IO::FileStream f;
10         IO::IStream i;
11         IO::OStream o;
12         IO::IOStream io;
13
14         printf("sizeof(*FileStream) == %lu\n", sizeof(*f));
15         printf("sizeof(*IOStream) == %lu\n", sizeof(*io));
16         printf("sizeof(*IStream) == %lu\n", sizeof(*i));
17
18         printf("sizeof(FileStream) == %lu\n", sizeof(f));
19         printf("sizeof(IOStream) == %lu\n", sizeof(io));
20         printf("sizeof(IStream) == %lu\n", sizeof(i));
21         
22         i = f;
23         io = IO::IOStream::downcast(i);
24         
25         if (!io)
26                 printf("io is null\n");
27         else {
28                 uint8_t buf[256];
29                 Array<uint8_t> abuf(buf, 256);
30                 uint64_t len = 64;
31                 
32                 io.read(&abuf, &len);
33                 io.write(Array<uint8_t>(buf, 128), &len);
34         }
35         
36         return 0;
37 }
38
39 uint64_t call1(IO::FileStream fs)
40 {
41         uint64_t size;
42         fs.size(&size);
43         return size;
44 }
45
46 void call2(IO::FileStream fs)
47 {
48         fs.seek(666, IO::FileStream_ns::SeekType::FromCurrent);
49 }
50
51 uint64_t call3(Mem::Cache c)
52 {
53         uint64_t size;
54         c.get_size(&size);
55         return size;
56 }
57
58 uint64_t call4(Mem::Cache c)
59 {
60         uint64_t size;
61         c.get_size(&size);
62         c.get_size(&size);
63         return size;
64 }
65
66
67 uint64_t call5(Mem::Cache c)
68 {
69         uint64_t size;
70         Mem::Mappable m = c;
71         m.get_size(&size);
72         m = c;
73         m.get_size(&size);
74         return size;
75 }
76
77 uint64_t call6(Mem::Cache c)
78 {
79         uint64_t size;
80         Mem::Mappable m = c;
81         m.get_size(&size);
82         m.get_size(&size);
83         return size;
84 }
85
86 //const unsigned long System::IO::_i_IOStream::guid[16] = {};