94455dd2925446df17619b8f30d059c8f132698c
[iec.git] / src / type3_AndroidCloud / anbox-master / external / android-emugl / host / tools / emugen / tests / t.001 / expected / encoder / foo_enc.cpp
1 // Generated Code - DO NOT EDIT !!
2 // generated by 'emugen'
3
4
5 #include <memory>
6 #include <string.h>
7 #include "foo_opcodes.h"
8
9 #include "foo_enc.h"
10
11
12 #include <stdio.h>
13
14 namespace {
15
16 void enc_unsupported()
17 {
18         ALOGE("Function is unsupported\n");
19 }
20
21 void fooAlphaFunc_enc(void *self , FooInt func, FooFloat ref)
22 {
23
24         foo_encoder_context_t *ctx = (foo_encoder_context_t *)self;
25         IOStream *stream = ctx->m_stream;
26         ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
27         bool useChecksum = checksumCalculator->getVersion() > 0;
28
29          unsigned char *ptr;
30          unsigned char *buf;
31          const size_t sizeWithoutChecksum = 8 + 4 + 4;
32          const size_t checksumSize = checksumCalculator->checksumByteSize();
33          const size_t totalSize = sizeWithoutChecksum + checksumSize;
34         buf = stream->alloc(totalSize);
35         ptr = buf;
36         int tmp = OP_fooAlphaFunc;memcpy(ptr, &tmp, 4); ptr += 4;
37         memcpy(ptr, &totalSize, 4);  ptr += 4;
38
39                 memcpy(ptr, &func, 4); ptr += 4;
40                 memcpy(ptr, &ref, 4); ptr += 4;
41
42         if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
43         if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
44
45 }
46
47 FooBoolean fooIsBuffer_enc(void *self , void* stuff)
48 {
49
50         foo_encoder_context_t *ctx = (foo_encoder_context_t *)self;
51         IOStream *stream = ctx->m_stream;
52         ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
53         bool useChecksum = checksumCalculator->getVersion() > 0;
54
55         const unsigned int __size_stuff =  (4 * sizeof(float));
56          unsigned char *ptr;
57          unsigned char *buf;
58          const size_t sizeWithoutChecksum = 8 + __size_stuff + 1*4;
59          const size_t checksumSize = checksumCalculator->checksumByteSize();
60          const size_t totalSize = sizeWithoutChecksum + checksumSize;
61         buf = stream->alloc(totalSize);
62         ptr = buf;
63         int tmp = OP_fooIsBuffer;memcpy(ptr, &tmp, 4); ptr += 4;
64         memcpy(ptr, &totalSize, 4);  ptr += 4;
65
66         *(unsigned int *)(ptr) = __size_stuff; ptr += 4;
67         memcpy(ptr, stuff, __size_stuff);ptr += __size_stuff;
68
69         if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
70         if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
71
72
73         FooBoolean retval;
74         stream->readback(&retval, 1);
75         if (useChecksum) checksumCalculator->addBuffer(&retval, 1);
76         if (useChecksum) {
77                 std::unique_ptr<unsigned char[]> checksumBuf(new unsigned char[checksumSize]);
78                 stream->readback(checksumBuf.get(), checksumSize);
79                 if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) {
80                         ALOGE("fooIsBuffer: GL communication error, please report this issue to b.android.com.\n");
81                         abort();
82                 }
83         }
84         return retval;
85 }
86
87 void fooDoEncoderFlush_enc(void *self , FooInt param)
88 {
89
90         foo_encoder_context_t *ctx = (foo_encoder_context_t *)self;
91         IOStream *stream = ctx->m_stream;
92         ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
93         bool useChecksum = checksumCalculator->getVersion() > 0;
94
95          unsigned char *ptr;
96          unsigned char *buf;
97          const size_t sizeWithoutChecksum = 8 + 4;
98          const size_t checksumSize = checksumCalculator->checksumByteSize();
99          const size_t totalSize = sizeWithoutChecksum + checksumSize;
100         buf = stream->alloc(totalSize);
101         ptr = buf;
102         int tmp = OP_fooDoEncoderFlush;memcpy(ptr, &tmp, 4); ptr += 4;
103         memcpy(ptr, &totalSize, 4);  ptr += 4;
104
105                 memcpy(ptr, &param, 4); ptr += 4;
106
107         if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
108         if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
109
110         stream->flush();
111 }
112
113 void fooTakeConstVoidPtrConstPtr_enc(void *self , const void* const* param)
114 {
115
116         foo_encoder_context_t *ctx = (foo_encoder_context_t *)self;
117         IOStream *stream = ctx->m_stream;
118         ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
119         bool useChecksum = checksumCalculator->getVersion() > 0;
120
121         const unsigned int __size_param = ;
122          unsigned char *ptr;
123          unsigned char *buf;
124          const size_t sizeWithoutChecksum = 8 + __size_param + 1*4;
125          const size_t checksumSize = checksumCalculator->checksumByteSize();
126          const size_t totalSize = sizeWithoutChecksum + checksumSize;
127         buf = stream->alloc(totalSize);
128         ptr = buf;
129         int tmp = OP_fooTakeConstVoidPtrConstPtr;memcpy(ptr, &tmp, 4); ptr += 4;
130         memcpy(ptr, &totalSize, 4);  ptr += 4;
131
132         *(unsigned int *)(ptr) = __size_param; ptr += 4;
133         memcpy(ptr, param, __size_param);ptr += __size_param;
134
135         if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
136         if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
137
138 }
139
140 }  // namespace
141
142 foo_encoder_context_t::foo_encoder_context_t(IOStream *stream, ChecksumCalculator *checksumCalculator)
143 {
144         m_stream = stream;
145         m_checksumCalculator = checksumCalculator;
146
147         this->fooAlphaFunc = &fooAlphaFunc_enc;
148         this->fooIsBuffer = &fooIsBuffer_enc;
149         this->fooUnsupported = (fooUnsupported_client_proc_t) &enc_unsupported;
150         this->fooDoEncoderFlush = &fooDoEncoderFlush_enc;
151         this->fooTakeConstVoidPtrConstPtr = &fooTakeConstVoidPtrConstPtr_enc;
152 }
153