1 // Generated Code - DO NOT EDIT !!
2 // generated by 'emugen'
6 #include "foo_opcodes.h"
11 #include "ProtocolUtils.h"
13 #include "ChecksumCalculatorThreadInfo.h"
17 typedef unsigned int tsize_t; // Target "size_t", which is 32-bit for now. It may or may not be the same as host's size_t when emugen is compiled.
19 #ifdef OPENGL_DEBUG_PRINTOUT
20 # define DEBUG(...) do { if (emugl_cxt_logger) { emugl_cxt_logger(__VA_ARGS__); } } while(0)
22 # define DEBUG(...) ((void)0)
26 # define SET_LASTCALL(name) sprintf(lastCall, #name)
28 # define SET_LASTCALL(name) ((void)0)
31 using namespace emugl;
33 size_t foo_decoder_context_t::decode(void *buf, size_t len, IOStream *stream)
37 if (len < 8) return pos;
38 unsigned char *ptr = (unsigned char *)buf;
39 bool unknownOpcode = false;
41 char lastCall[256] = {0};
43 while ((len - pos >= 8) && !unknownOpcode) {
44 uint32_t opcode = *(uint32_t *)ptr;
45 size_t packetLen = *(uint32_t *)(ptr + 4);
46 if (len - pos < packetLen) return pos;
47 bool useChecksum = ChecksumCalculatorThreadInfo::getVersion() > 0;
48 size_t checksumSize = 0;
50 checksumSize = ChecksumCalculatorThreadInfo::checksumByteSize();
53 case OP_fooAlphaFunc: {
54 FooInt var_func = Unpack<FooInt,uint32_t>(ptr + 8);
55 FooFloat var_ref = Unpack<FooFloat,uint32_t>(ptr + 8 + 4);
57 ChecksumCalculatorThreadInfo::validOrDie(ptr, 8 + 4 + 4, ptr + 8 + 4 + 4, checksumSize,
58 "8 + 4 + 4::decode, OP_foo_decoder_context_t: GL checksumCalculator failure\n");
60 DEBUG("foo(%p): fooAlphaFunc(%d %f )\n", stream,var_func, var_ref);
61 this->fooAlphaFunc(var_func, var_ref);
62 SET_LASTCALL("fooAlphaFunc");
65 case OP_fooIsBuffer: {
66 uint32_t size_stuff __attribute__((unused)) = Unpack<uint32_t,uint32_t>(ptr + 8);
67 InputBuffer inptr_stuff(ptr + 8 + 4, size_stuff);
69 ChecksumCalculatorThreadInfo::validOrDie(ptr, 8 + 4 + size_stuff, ptr + 8 + 4 + size_stuff, checksumSize,
70 "8 + 4 + size_stuff::decode, OP_foo_decoder_context_t: GL checksumCalculator failure\n");
72 size_t totalTmpSize = sizeof(FooBoolean);
73 totalTmpSize += checksumSize;
74 unsigned char *tmpBuf = stream->alloc(totalTmpSize);
75 DEBUG("foo(%p): fooIsBuffer(%p(%u) )\n", stream,(void*)(inptr_stuff.get()), size_stuff);
76 *(FooBoolean *)(&tmpBuf[0]) = this->fooIsBuffer((void*)(inptr_stuff.get()));
78 ChecksumCalculatorThreadInfo::writeChecksum(&tmpBuf[0], totalTmpSize - checksumSize, &tmpBuf[totalTmpSize - checksumSize], checksumSize);
81 SET_LASTCALL("fooIsBuffer");
84 case OP_fooUnsupported: {
85 uint32_t size_params __attribute__((unused)) = Unpack<uint32_t,uint32_t>(ptr + 8);
86 InputBuffer inptr_params(ptr + 8 + 4, size_params);
88 ChecksumCalculatorThreadInfo::validOrDie(ptr, 8 + 4 + size_params, ptr + 8 + 4 + size_params, checksumSize,
89 "8 + 4 + size_params::decode, OP_foo_decoder_context_t: GL checksumCalculator failure\n");
91 DEBUG("foo(%p): fooUnsupported(%p(%u) )\n", stream,(void*)(inptr_params.get()), size_params);
92 this->fooUnsupported((void*)(inptr_params.get()));
93 SET_LASTCALL("fooUnsupported");
96 case OP_fooDoEncoderFlush: {
97 FooInt var_param = Unpack<FooInt,uint32_t>(ptr + 8);
99 ChecksumCalculatorThreadInfo::validOrDie(ptr, 8 + 4, ptr + 8 + 4, checksumSize,
100 "8 + 4::decode, OP_foo_decoder_context_t: GL checksumCalculator failure\n");
102 DEBUG("foo(%p): fooDoEncoderFlush(%d )\n", stream,var_param);
103 this->fooDoEncoderFlush(var_param);
104 SET_LASTCALL("fooDoEncoderFlush");
107 case OP_fooTakeConstVoidPtrConstPtr: {
108 uint32_t size_param __attribute__((unused)) = Unpack<uint32_t,uint32_t>(ptr + 8);
109 InputBuffer inptr_param(ptr + 8 + 4, size_param);
111 ChecksumCalculatorThreadInfo::validOrDie(ptr, 8 + 4 + size_param, ptr + 8 + 4 + size_param, checksumSize,
112 "8 + 4 + size_param::decode, OP_foo_decoder_context_t: GL checksumCalculator failure\n");
114 DEBUG("foo(%p): fooTakeConstVoidPtrConstPtr(%p(%u) )\n", stream,(const void* const*)(inptr_param.get()), size_param);
115 this->fooTakeConstVoidPtrConstPtr((const void* const*)(inptr_param.get()));
116 SET_LASTCALL("fooTakeConstVoidPtrConstPtr");
120 unknownOpcode = true;
122 if (!unknownOpcode) {