diff options
Diffstat (limited to 'host/commands/emugen/tests/t.001')
21 files changed, 955 insertions, 0 deletions
diff --git a/host/commands/emugen/tests/t.001/expected/decoder/foo_dec.cpp b/host/commands/emugen/tests/t.001/expected/decoder/foo_dec.cpp new file mode 100644 index 000000000..ec16b177f --- /dev/null +++ b/host/commands/emugen/tests/t.001/expected/decoder/foo_dec.cpp @@ -0,0 +1,178 @@ +// Generated Code - DO NOT EDIT !! +// generated by 'emugen' + + +#include <string.h> +#include "foo_opcodes.h" + +#include "foo_dec.h" + + +#include "ProtocolUtils.h" + +#include "ChecksumCalculatorThreadInfo.h" + +#include <stdio.h> + +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. + +#ifdef OPENGL_DEBUG_PRINTOUT +# define DEBUG(...) do { if (emugl_cxt_logger) { emugl_cxt_logger(__VA_ARGS__); } } while(0) +#else +# define DEBUG(...) ((void)0) +#endif + +#ifdef CHECK_GL_ERRORS +# define SET_LASTCALL(name) sprintf(lastCall, #name) +#else +# define SET_LASTCALL(name) +#endif +using namespace emugl; + +size_t foo_decoder_context_t::decode(void *buf, size_t len, IOStream *stream, ChecksumCalculator* checksumCalc) { + if (len < 8) return 0; +#ifdef CHECK_GL_ERRORS + char lastCall[256] = {0}; +#endif + unsigned char *ptr = (unsigned char *)buf; + const unsigned char* const end = (const unsigned char*)buf + len; + const size_t checksumSize = checksumCalc->checksumByteSize(); + const bool useChecksum = checksumSize > 0; + while (end - ptr >= 8) { + uint32_t opcode = *(uint32_t *)ptr; + int32_t packetLen = *(int32_t *)(ptr + 4); + if (end - ptr < packetLen) return ptr - (unsigned char*)buf; + switch(opcode) { + case OP_fooAlphaFunc: { + FooInt var_func = Unpack<FooInt,uint32_t>(ptr + 8); + FooFloat var_ref = Unpack<FooFloat,uint32_t>(ptr + 8 + 4); + if (useChecksum) { + ChecksumCalculatorThreadInfo::validOrDie(checksumCalc, ptr, 8 + 4 + 4, ptr + 8 + 4 + 4, checksumSize, + "foo_decoder_context_t::decode, OP_fooAlphaFunc: GL checksumCalculator failure\n"); + } + DEBUG("foo(%p): fooAlphaFunc(%d %f )\n", stream, var_func, var_ref); + this->fooAlphaFunc(var_func, var_ref); + SET_LASTCALL("fooAlphaFunc"); + break; + } + case OP_fooIsBuffer: { + uint32_t size_stuff __attribute__((unused)) = Unpack<uint32_t,uint32_t>(ptr + 8); + InputBuffer inptr_stuff(ptr + 8 + 4, size_stuff); + if (useChecksum) { + ChecksumCalculatorThreadInfo::validOrDie(checksumCalc, ptr, 8 + 4 + size_stuff, ptr + 8 + 4 + size_stuff, checksumSize, + "foo_decoder_context_t::decode, OP_fooIsBuffer: GL checksumCalculator failure\n"); + } + size_t totalTmpSize = sizeof(FooBoolean); + totalTmpSize += checksumSize; + unsigned char *tmpBuf = stream->alloc(totalTmpSize); + DEBUG("foo(%p): fooIsBuffer(%p(%u) )\n", stream, (void*)(inptr_stuff.get()), size_stuff); + *(FooBoolean *)(&tmpBuf[0]) = this->fooIsBuffer((void*)(inptr_stuff.get())); + if (useChecksum) { + ChecksumCalculatorThreadInfo::writeChecksum(checksumCalc, &tmpBuf[0], totalTmpSize - checksumSize, &tmpBuf[totalTmpSize - checksumSize], checksumSize); + } + stream->flush(); + SET_LASTCALL("fooIsBuffer"); + break; + } + case OP_fooUnsupported: { + uint32_t size_params __attribute__((unused)) = Unpack<uint32_t,uint32_t>(ptr + 8); + InputBuffer inptr_params(ptr + 8 + 4, size_params); + if (useChecksum) { + ChecksumCalculatorThreadInfo::validOrDie(checksumCalc, ptr, 8 + 4 + size_params, ptr + 8 + 4 + size_params, checksumSize, + "foo_decoder_context_t::decode, OP_fooUnsupported: GL checksumCalculator failure\n"); + } + DEBUG("foo(%p): fooUnsupported(%p(%u) )\n", stream, (void*)(inptr_params.get()), size_params); + this->fooUnsupported((void*)(inptr_params.get())); + SET_LASTCALL("fooUnsupported"); + break; + } + case OP_fooDoEncoderFlush: { + FooInt var_param = Unpack<FooInt,uint32_t>(ptr + 8); + if (useChecksum) { + ChecksumCalculatorThreadInfo::validOrDie(checksumCalc, ptr, 8 + 4, ptr + 8 + 4, checksumSize, + "foo_decoder_context_t::decode, OP_fooDoEncoderFlush: GL checksumCalculator failure\n"); + } + DEBUG("foo(%p): fooDoEncoderFlush(%d )\n", stream, var_param); + this->fooDoEncoderFlush(var_param); + SET_LASTCALL("fooDoEncoderFlush"); + break; + } + case OP_fooTakeConstVoidPtrConstPtr: { + uint32_t size_param __attribute__((unused)) = Unpack<uint32_t,uint32_t>(ptr + 8); + InputBuffer inptr_param(ptr + 8 + 4, size_param); + if (useChecksum) { + ChecksumCalculatorThreadInfo::validOrDie(checksumCalc, ptr, 8 + 4 + size_param, ptr + 8 + 4 + size_param, checksumSize, + "foo_decoder_context_t::decode, OP_fooTakeConstVoidPtrConstPtr: GL checksumCalculator failure\n"); + } + DEBUG("foo(%p): fooTakeConstVoidPtrConstPtr(%p(%u) )\n", stream, (const void* const*)(inptr_param.get()), size_param); + this->fooTakeConstVoidPtrConstPtr((const void* const*)(inptr_param.get())); + SET_LASTCALL("fooTakeConstVoidPtrConstPtr"); + break; + } + case OP_fooSetComplexStruct: { + uint32_t size_obj __attribute__((unused)) = Unpack<uint32_t,uint32_t>(ptr + 8); + InputBuffer inptr_obj(ptr + 8 + 4, size_obj); + void* inptr_obj_unpacked; + FooStruct unpacked; inptr_obj_unpacked = (void*)(&unpacked); fooStructUnpack((unsigned char*)(inptr_obj.get()), size_obj, inptr_obj_unpacked); + if (useChecksum) { + ChecksumCalculatorThreadInfo::validOrDie(checksumCalc, ptr, 8 + 4 + size_obj, ptr + 8 + 4 + size_obj, checksumSize, + "foo_decoder_context_t::decode, OP_fooSetComplexStruct: GL checksumCalculator failure\n"); + } + DEBUG("foo(%p): fooSetComplexStruct(%p(%u) )\n", stream, (const FooStruct*)(inptr_obj.get()), size_obj); + this->fooSetComplexStruct((const FooStruct*)(inptr_obj_unpacked)); + SET_LASTCALL("fooSetComplexStruct"); + break; + } + case OP_fooGetComplexStruct: { + uint32_t size_obj __attribute__((unused)) = Unpack<uint32_t,uint32_t>(ptr + 8); + if (useChecksum) { + ChecksumCalculatorThreadInfo::validOrDie(checksumCalc, ptr, 8 + 4, ptr + 8 + 4, checksumSize, + "foo_decoder_context_t::decode, OP_fooGetComplexStruct: GL checksumCalculator failure\n"); + } + size_t totalTmpSize = size_obj; + totalTmpSize += checksumSize; + unsigned char *tmpBuf = stream->alloc(totalTmpSize); + OutputBuffer outptr_obj(&tmpBuf[0], size_obj); + void* forPacking_obj = nullptr; + FooStruct tmp; forPacking_obj = (void*)tmp; + DEBUG("foo(%p): fooGetComplexStruct(%p(%u) )\n", stream, (FooStruct*)(outptr_obj.get()), size_obj); + this->fooGetComplexStruct((FooStruct*)(forPacking_obj)); + if (size_obj) { + fooStructPack((unsigned char*)outptr_obj.get(), (FooStruct*)forPacking_obj); } + outptr_obj.flush(); + if (useChecksum) { + ChecksumCalculatorThreadInfo::writeChecksum(checksumCalc, &tmpBuf[0], totalTmpSize - checksumSize, &tmpBuf[totalTmpSize - checksumSize], checksumSize); + } + stream->flush(); + SET_LASTCALL("fooGetComplexStruct"); + break; + } + case OP_fooInout: { + uint32_t size_count __attribute__((unused)) = Unpack<uint32_t,uint32_t>(ptr + 8); + InputBuffer inptr_count(ptr + 8 + 4, size_count); + if (useChecksum) { + ChecksumCalculatorThreadInfo::validOrDie(checksumCalc, ptr, 8 + 4 + size_count, ptr + 8 + 4 + size_count, checksumSize, + "foo_decoder_context_t::decode, OP_fooInout: GL checksumCalculator failure\n"); + } + size_t totalTmpSize = size_count; + totalTmpSize += checksumSize; + unsigned char *tmpBuf = stream->alloc(totalTmpSize); + OutputBuffer outptr_count(&tmpBuf[0], size_count); + memcpy(outptr_count.get(), inptr_count.get(), size_count); + DEBUG("foo(%p): fooInout(%p(%u) )\n", stream, (uint32_t*)(outptr_count.get()), size_count); + this->fooInout((uint32_t*)(outptr_count.get())); + outptr_count.flush(); + if (useChecksum) { + ChecksumCalculatorThreadInfo::writeChecksum(checksumCalc, &tmpBuf[0], totalTmpSize - checksumSize, &tmpBuf[totalTmpSize - checksumSize], checksumSize); + } + stream->flush(); + SET_LASTCALL("fooInout"); + break; + } + default: + return ptr - (unsigned char*)buf; + } //switch + ptr += packetLen; + } // while + return ptr - (unsigned char*)buf; +} diff --git a/host/commands/emugen/tests/t.001/expected/decoder/foo_dec.h b/host/commands/emugen/tests/t.001/expected/decoder/foo_dec.h new file mode 100644 index 000000000..d02509070 --- /dev/null +++ b/host/commands/emugen/tests/t.001/expected/decoder/foo_dec.h @@ -0,0 +1,20 @@ +// Generated Code - DO NOT EDIT !! +// generated by 'emugen' + +#ifndef GUARD_foo_decoder_context_t +#define GUARD_foo_decoder_context_t + +#include "OpenglRender/IOStream.h" +#include "ChecksumCalculator.h" +#include "foo_server_context.h" + + +#include "emugl/common/logging.h" + +struct foo_decoder_context_t : public foo_server_context_t { + + size_t decode(void *buf, size_t bufsize, IOStream *stream, ChecksumCalculator* checksumCalc); + +}; + +#endif // GUARD_foo_decoder_context_t diff --git a/host/commands/emugen/tests/t.001/expected/decoder/foo_opcodes.h b/host/commands/emugen/tests/t.001/expected/decoder/foo_opcodes.h new file mode 100644 index 000000000..ee453406f --- /dev/null +++ b/host/commands/emugen/tests/t.001/expected/decoder/foo_opcodes.h @@ -0,0 +1,17 @@ +// Generated Code - DO NOT EDIT !! +// generated by 'emugen' +#ifndef __GUARD_foo_opcodes_h_ +#define __GUARD_foo_opcodes_h_ + +#define OP_fooAlphaFunc 200 +#define OP_fooIsBuffer 201 +#define OP_fooUnsupported 202 +#define OP_fooDoEncoderFlush 203 +#define OP_fooTakeConstVoidPtrConstPtr 204 +#define OP_fooSetComplexStruct 205 +#define OP_fooGetComplexStruct 206 +#define OP_fooInout 207 +#define OP_last 208 + + +#endif diff --git a/host/commands/emugen/tests/t.001/expected/decoder/foo_server_context.cpp b/host/commands/emugen/tests/t.001/expected/decoder/foo_server_context.cpp new file mode 100644 index 000000000..5371fff2f --- /dev/null +++ b/host/commands/emugen/tests/t.001/expected/decoder/foo_server_context.cpp @@ -0,0 +1,23 @@ +// Generated Code - DO NOT EDIT !! +// generated by 'emugen' + + +#include <string.h> +#include "foo_server_context.h" + + +#include <stdio.h> + +int foo_server_context_t::initDispatchByName(void *(*getProc)(const char *, void *userData), void *userData) +{ + fooAlphaFunc = (fooAlphaFunc_server_proc_t) getProc("fooAlphaFunc", userData); + fooIsBuffer = (fooIsBuffer_server_proc_t) getProc("fooIsBuffer", userData); + fooUnsupported = (fooUnsupported_server_proc_t) getProc("fooUnsupported", userData); + fooDoEncoderFlush = (fooDoEncoderFlush_server_proc_t) getProc("fooDoEncoderFlush", userData); + fooTakeConstVoidPtrConstPtr = (fooTakeConstVoidPtrConstPtr_server_proc_t) getProc("fooTakeConstVoidPtrConstPtr", userData); + fooSetComplexStruct = (fooSetComplexStruct_server_proc_t) getProc("fooSetComplexStruct", userData); + fooGetComplexStruct = (fooGetComplexStruct_server_proc_t) getProc("fooGetComplexStruct", userData); + fooInout = (fooInout_server_proc_t) getProc("fooInout", userData); + return 0; +} + diff --git a/host/commands/emugen/tests/t.001/expected/decoder/foo_server_context.h b/host/commands/emugen/tests/t.001/expected/decoder/foo_server_context.h new file mode 100644 index 000000000..4f4491925 --- /dev/null +++ b/host/commands/emugen/tests/t.001/expected/decoder/foo_server_context.h @@ -0,0 +1,25 @@ +// Generated Code - DO NOT EDIT !! +// generated by 'emugen' +#ifndef __foo_server_context_t_h +#define __foo_server_context_t_h + +#include "foo_server_proc.h" + +#include "foo_types.h" + + +struct foo_server_context_t { + + fooAlphaFunc_server_proc_t fooAlphaFunc; + fooIsBuffer_server_proc_t fooIsBuffer; + fooUnsupported_server_proc_t fooUnsupported; + fooDoEncoderFlush_server_proc_t fooDoEncoderFlush; + fooTakeConstVoidPtrConstPtr_server_proc_t fooTakeConstVoidPtrConstPtr; + fooSetComplexStruct_server_proc_t fooSetComplexStruct; + fooGetComplexStruct_server_proc_t fooGetComplexStruct; + fooInout_server_proc_t fooInout; + virtual ~foo_server_context_t() {} + int initDispatchByName( void *(*getProc)(const char *name, void *userData), void *userData); +}; + +#endif diff --git a/host/commands/emugen/tests/t.001/expected/decoder/foo_server_proc.h b/host/commands/emugen/tests/t.001/expected/decoder/foo_server_proc.h new file mode 100644 index 000000000..593e4c411 --- /dev/null +++ b/host/commands/emugen/tests/t.001/expected/decoder/foo_server_proc.h @@ -0,0 +1,22 @@ +// Generated Code - DO NOT EDIT !! +// generated by 'emugen' +#ifndef __foo_server_proc_t_h +#define __foo_server_proc_t_h + + + +#include "foo_types.h" +#ifndef foo_APIENTRY +#define foo_APIENTRY +#endif +typedef void (foo_APIENTRY *fooAlphaFunc_server_proc_t) (FooInt, FooFloat); +typedef FooBoolean (foo_APIENTRY *fooIsBuffer_server_proc_t) (void*); +typedef void (foo_APIENTRY *fooUnsupported_server_proc_t) (void*); +typedef void (foo_APIENTRY *fooDoEncoderFlush_server_proc_t) (FooInt); +typedef void (foo_APIENTRY *fooTakeConstVoidPtrConstPtr_server_proc_t) (const void* const*); +typedef void (foo_APIENTRY *fooSetComplexStruct_server_proc_t) (const FooStruct*); +typedef void (foo_APIENTRY *fooGetComplexStruct_server_proc_t) (FooStruct*); +typedef void (foo_APIENTRY *fooInout_server_proc_t) (uint32_t*); + + +#endif diff --git a/host/commands/emugen/tests/t.001/expected/encoder/foo_client_context.cpp b/host/commands/emugen/tests/t.001/expected/encoder/foo_client_context.cpp new file mode 100644 index 000000000..d28b5a054 --- /dev/null +++ b/host/commands/emugen/tests/t.001/expected/encoder/foo_client_context.cpp @@ -0,0 +1,23 @@ +// Generated Code - DO NOT EDIT !! +// generated by 'emugen' + + +#include <string.h> +#include "foo_client_context.h" + + +#include <stdio.h> + +int foo_client_context_t::initDispatchByName(void *(*getProc)(const char *, void *userData), void *userData) +{ + fooAlphaFunc = (fooAlphaFunc_client_proc_t) getProc("fooAlphaFunc", userData); + fooIsBuffer = (fooIsBuffer_client_proc_t) getProc("fooIsBuffer", userData); + fooUnsupported = (fooUnsupported_client_proc_t) getProc("fooUnsupported", userData); + fooDoEncoderFlush = (fooDoEncoderFlush_client_proc_t) getProc("fooDoEncoderFlush", userData); + fooTakeConstVoidPtrConstPtr = (fooTakeConstVoidPtrConstPtr_client_proc_t) getProc("fooTakeConstVoidPtrConstPtr", userData); + fooSetComplexStruct = (fooSetComplexStruct_client_proc_t) getProc("fooSetComplexStruct", userData); + fooGetComplexStruct = (fooGetComplexStruct_client_proc_t) getProc("fooGetComplexStruct", userData); + fooInout = (fooInout_client_proc_t) getProc("fooInout", userData); + return 0; +} + diff --git a/host/commands/emugen/tests/t.001/expected/encoder/foo_client_context.h b/host/commands/emugen/tests/t.001/expected/encoder/foo_client_context.h new file mode 100644 index 000000000..d1c1675c0 --- /dev/null +++ b/host/commands/emugen/tests/t.001/expected/encoder/foo_client_context.h @@ -0,0 +1,30 @@ +// Generated Code - DO NOT EDIT !! +// generated by 'emugen' +#ifndef __foo_client_context_t_h +#define __foo_client_context_t_h + +#include "foo_client_proc.h" + +#include "foo_types.h" + + +struct foo_client_context_t { + + fooAlphaFunc_client_proc_t fooAlphaFunc; + fooIsBuffer_client_proc_t fooIsBuffer; + fooUnsupported_client_proc_t fooUnsupported; + fooDoEncoderFlush_client_proc_t fooDoEncoderFlush; + fooTakeConstVoidPtrConstPtr_client_proc_t fooTakeConstVoidPtrConstPtr; + fooSetComplexStruct_client_proc_t fooSetComplexStruct; + fooGetComplexStruct_client_proc_t fooGetComplexStruct; + fooInout_client_proc_t fooInout; + virtual ~foo_client_context_t() {} + + typedef foo_client_context_t *CONTEXT_ACCESSOR_TYPE(void); + static void setContextAccessor(CONTEXT_ACCESSOR_TYPE *f); + int initDispatchByName( void *(*getProc)(const char *name, void *userData), void *userData); + virtual void setError(unsigned int error){ (void)error; }; + virtual unsigned int getError(){ return 0; }; +}; + +#endif diff --git a/host/commands/emugen/tests/t.001/expected/encoder/foo_client_proc.h b/host/commands/emugen/tests/t.001/expected/encoder/foo_client_proc.h new file mode 100644 index 000000000..d9bbcb666 --- /dev/null +++ b/host/commands/emugen/tests/t.001/expected/encoder/foo_client_proc.h @@ -0,0 +1,22 @@ +// Generated Code - DO NOT EDIT !! +// generated by 'emugen' +#ifndef __foo_client_proc_t_h +#define __foo_client_proc_t_h + + + +#include "foo_types.h" +#ifndef foo_APIENTRY +#define foo_APIENTRY +#endif +typedef void (foo_APIENTRY *fooAlphaFunc_client_proc_t) (void * ctx, FooInt, FooFloat); +typedef FooBoolean (foo_APIENTRY *fooIsBuffer_client_proc_t) (void * ctx, void*); +typedef void (foo_APIENTRY *fooUnsupported_client_proc_t) (void * ctx, void*); +typedef void (foo_APIENTRY *fooDoEncoderFlush_client_proc_t) (void * ctx, FooInt); +typedef void (foo_APIENTRY *fooTakeConstVoidPtrConstPtr_client_proc_t) (void * ctx, const void* const*); +typedef void (foo_APIENTRY *fooSetComplexStruct_client_proc_t) (void * ctx, const FooStruct*); +typedef void (foo_APIENTRY *fooGetComplexStruct_client_proc_t) (void * ctx, FooStruct*); +typedef void (foo_APIENTRY *fooInout_client_proc_t) (void * ctx, uint32_t*); + + +#endif diff --git a/host/commands/emugen/tests/t.001/expected/encoder/foo_enc.cpp b/host/commands/emugen/tests/t.001/expected/encoder/foo_enc.cpp new file mode 100644 index 000000000..13a4dd56b --- /dev/null +++ b/host/commands/emugen/tests/t.001/expected/encoder/foo_enc.cpp @@ -0,0 +1,263 @@ +// Generated Code - DO NOT EDIT !! +// generated by 'emugen' + + +#include <string.h> +#include "foo_opcodes.h" + +#include "foo_enc.h" + + +#include <vector> + +#include <stdio.h> + +namespace { + +void enc_unsupported() +{ + ALOGE("Function is unsupported\n"); +} + +void fooAlphaFunc_enc(void *self , FooInt func, FooFloat ref) +{ + + foo_encoder_context_t *ctx = (foo_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_fooAlphaFunc;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &func, 4); ptr += 4; + memcpy(ptr, &ref, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +FooBoolean fooIsBuffer_enc(void *self , void* stuff) +{ + + foo_encoder_context_t *ctx = (foo_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_stuff = (4 * sizeof(float)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + __size_stuff + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_fooIsBuffer;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + *(unsigned int *)(ptr) = __size_stuff; ptr += 4; + memcpy(ptr, stuff, __size_stuff);ptr += __size_stuff; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + + FooBoolean retval; + stream->readback(&retval, 1); + if (useChecksum) checksumCalculator->addBuffer(&retval, 1); + if (useChecksum) { + unsigned char *checksumBufPtr = NULL; + unsigned char checksumBuf[ChecksumCalculator::kMaxChecksumSize]; + if (checksumSize > 0) checksumBufPtr = &checksumBuf[0]; + stream->readback(checksumBufPtr, checksumSize); + if (!checksumCalculator->validate(checksumBufPtr, checksumSize)) { + ALOGE("fooIsBuffer: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } + return retval; +} + +void fooDoEncoderFlush_enc(void *self , FooInt param) +{ + + foo_encoder_context_t *ctx = (foo_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_fooDoEncoderFlush;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, ¶m, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + stream->flush(); +} + +void fooTakeConstVoidPtrConstPtr_enc(void *self , const void* const* param) +{ + + foo_encoder_context_t *ctx = (foo_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_param = ; + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + __size_param + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_fooTakeConstVoidPtrConstPtr;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + *(unsigned int *)(ptr) = __size_param; ptr += 4; + memcpy(ptr, param, __size_param);ptr += __size_param; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void fooSetComplexStruct_enc(void *self , const FooStruct* obj) +{ + + foo_encoder_context_t *ctx = (foo_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_obj = fooStructEncodingSize(obj); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + __size_obj + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_fooSetComplexStruct;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + *(unsigned int *)(ptr) = __size_obj; ptr += 4; + fooStructPack(ptr, obj);ptr += __size_obj; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void fooGetComplexStruct_enc(void *self , FooStruct* obj) +{ + + foo_encoder_context_t *ctx = (foo_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_obj = fooStructEncodingSize(obj); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 0 + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_fooGetComplexStruct;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + *(unsigned int *)(ptr) = __size_obj; ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + std::vector<unsigned char> forUnpacking_obj(__size_obj); stream->readback(&forUnpacking_obj[0], __size_obj); fooStructUnpack(&forUnpacking_obj[0], obj); + if (useChecksum) checksumCalculator->addBuffer(obj, __size_obj); + if (useChecksum) { + unsigned char *checksumBufPtr = NULL; + unsigned char checksumBuf[ChecksumCalculator::kMaxChecksumSize]; + if (checksumSize > 0) checksumBufPtr = &checksumBuf[0]; + stream->readback(checksumBufPtr, checksumSize); + if (!checksumCalculator->validate(checksumBufPtr, checksumSize)) { + ALOGE("fooGetComplexStruct: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } +} + +void fooInout_enc(void *self , uint32_t* count) +{ + + foo_encoder_context_t *ctx = (foo_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_count = sizeof(uint32_t); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + __size_count + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_fooInout;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + *(unsigned int *)(ptr) = __size_count; ptr += 4; + memcpy(ptr, count, __size_count);ptr += __size_count; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + stream->readback(count, __size_count); + if (useChecksum) checksumCalculator->addBuffer(count, __size_count); + if (useChecksum) { + unsigned char *checksumBufPtr = NULL; + unsigned char checksumBuf[ChecksumCalculator::kMaxChecksumSize]; + if (checksumSize > 0) checksumBufPtr = &checksumBuf[0]; + stream->readback(checksumBufPtr, checksumSize); + if (!checksumCalculator->validate(checksumBufPtr, checksumSize)) { + ALOGE("fooInout: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } +} + +} // namespace + +foo_encoder_context_t::foo_encoder_context_t(IOStream *stream, ChecksumCalculator *checksumCalculator) +{ + m_stream = stream; + m_checksumCalculator = checksumCalculator; + + this->fooAlphaFunc = &fooAlphaFunc_enc; + this->fooIsBuffer = &fooIsBuffer_enc; + this->fooUnsupported = (fooUnsupported_client_proc_t) &enc_unsupported; + this->fooDoEncoderFlush = &fooDoEncoderFlush_enc; + this->fooTakeConstVoidPtrConstPtr = &fooTakeConstVoidPtrConstPtr_enc; + this->fooSetComplexStruct = &fooSetComplexStruct_enc; + this->fooGetComplexStruct = &fooGetComplexStruct_enc; + this->fooInout = &fooInout_enc; +} + diff --git a/host/commands/emugen/tests/t.001/expected/encoder/foo_enc.h b/host/commands/emugen/tests/t.001/expected/encoder/foo_enc.h new file mode 100644 index 000000000..beaabd43f --- /dev/null +++ b/host/commands/emugen/tests/t.001/expected/encoder/foo_enc.h @@ -0,0 +1,24 @@ +// Generated Code - DO NOT EDIT !! +// generated by 'emugen' + +#ifndef GUARD_foo_encoder_context_t +#define GUARD_foo_encoder_context_t + +#include "IOStream.h" +#include "ChecksumCalculator.h" +#include "foo_client_context.h" + + +#include "fooUtils.h" +#include "fooBase.h" + +struct foo_encoder_context_t : public foo_client_context_t { + + IOStream *m_stream; + ChecksumCalculator *m_checksumCalculator; + + foo_encoder_context_t(IOStream *stream, ChecksumCalculator *checksumCalculator); + virtual uint64_t lockAndWriteDma(void* data, uint32_t sz) { return 0; } +}; + +#endif // GUARD_foo_encoder_context_t diff --git a/host/commands/emugen/tests/t.001/expected/encoder/foo_entry.cpp b/host/commands/emugen/tests/t.001/expected/encoder/foo_entry.cpp new file mode 100644 index 000000000..92e8ef43a --- /dev/null +++ b/host/commands/emugen/tests/t.001/expected/encoder/foo_entry.cpp @@ -0,0 +1,72 @@ +// Generated Code - DO NOT EDIT !! +// generated by 'emugen' +#include <stdio.h> +#include <stdlib.h> +#include "foo_client_context.h" + +extern "C" { + void fooAlphaFunc(FooInt func, FooFloat ref); + FooBoolean fooIsBuffer(void* stuff); + void fooUnsupported(void* params); + void fooDoEncoderFlush(FooInt param); + void fooTakeConstVoidPtrConstPtr(const void* const* param); + void fooSetComplexStruct(const FooStruct* obj); + void fooGetComplexStruct(FooStruct* obj); + void fooInout(uint32_t* count); +}; + +#ifndef GET_CONTEXT +static foo_client_context_t::CONTEXT_ACCESSOR_TYPE *getCurrentContext = NULL; +void foo_client_context_t::setContextAccessor(CONTEXT_ACCESSOR_TYPE *f) { getCurrentContext = f; } +#define GET_CONTEXT foo_client_context_t * ctx = getCurrentContext() +#endif + +void fooAlphaFunc(FooInt func, FooFloat ref) +{ + GET_CONTEXT; + ctx->fooAlphaFunc(ctx, func, ref); +} + +FooBoolean fooIsBuffer(void* stuff) +{ + GET_CONTEXT; + if (n == NULL) { LOG(ERROR) << "NULL stuff"; return; } + return ctx->fooIsBuffer(ctx, stuff); +} + +void fooUnsupported(void* params) +{ + GET_CONTEXT; + ctx->fooUnsupported(ctx, params); +} + +void fooDoEncoderFlush(FooInt param) +{ + GET_CONTEXT; + ctx->fooDoEncoderFlush(ctx, param); +} + +void fooTakeConstVoidPtrConstPtr(const void* const* param) +{ + GET_CONTEXT; + ctx->fooTakeConstVoidPtrConstPtr(ctx, param); +} + +void fooSetComplexStruct(const FooStruct* obj) +{ + GET_CONTEXT; + ctx->fooSetComplexStruct(ctx, obj); +} + +void fooGetComplexStruct(FooStruct* obj) +{ + GET_CONTEXT; + ctx->fooGetComplexStruct(ctx, obj); +} + +void fooInout(uint32_t* count) +{ + GET_CONTEXT; + ctx->fooInout(ctx, count); +} + diff --git a/host/commands/emugen/tests/t.001/expected/encoder/foo_ftable.h b/host/commands/emugen/tests/t.001/expected/encoder/foo_ftable.h new file mode 100644 index 000000000..0b759b52c --- /dev/null +++ b/host/commands/emugen/tests/t.001/expected/encoder/foo_ftable.h @@ -0,0 +1,23 @@ +// Generated Code - DO NOT EDIT !! +// generated by 'emugen' +#ifndef __foo_client_ftable_t_h +#define __foo_client_ftable_t_h + + +static const struct _foo_funcs_by_name { + const char *name; + void *proc; +} foo_funcs_by_name[] = { + {"fooAlphaFunc", (void*)fooAlphaFunc}, + {"fooIsBuffer", (void*)fooIsBuffer}, + {"fooUnsupported", (void*)fooUnsupported}, + {"fooDoEncoderFlush", (void*)fooDoEncoderFlush}, + {"fooTakeConstVoidPtrConstPtr", (void*)fooTakeConstVoidPtrConstPtr}, + {"fooSetComplexStruct", (void*)fooSetComplexStruct}, + {"fooGetComplexStruct", (void*)fooGetComplexStruct}, + {"fooInout", (void*)fooInout}, +}; +static const int foo_num_funcs = sizeof(foo_funcs_by_name) / sizeof(struct _foo_funcs_by_name); + + +#endif diff --git a/host/commands/emugen/tests/t.001/expected/encoder/foo_opcodes.h b/host/commands/emugen/tests/t.001/expected/encoder/foo_opcodes.h new file mode 100644 index 000000000..ee453406f --- /dev/null +++ b/host/commands/emugen/tests/t.001/expected/encoder/foo_opcodes.h @@ -0,0 +1,17 @@ +// Generated Code - DO NOT EDIT !! +// generated by 'emugen' +#ifndef __GUARD_foo_opcodes_h_ +#define __GUARD_foo_opcodes_h_ + +#define OP_fooAlphaFunc 200 +#define OP_fooIsBuffer 201 +#define OP_fooUnsupported 202 +#define OP_fooDoEncoderFlush 203 +#define OP_fooTakeConstVoidPtrConstPtr 204 +#define OP_fooSetComplexStruct 205 +#define OP_fooGetComplexStruct 206 +#define OP_fooInout 207 +#define OP_last 208 + + +#endif diff --git a/host/commands/emugen/tests/t.001/expected/wrapper/foo_wrapper_context.cpp b/host/commands/emugen/tests/t.001/expected/wrapper/foo_wrapper_context.cpp new file mode 100644 index 000000000..e8781cccb --- /dev/null +++ b/host/commands/emugen/tests/t.001/expected/wrapper/foo_wrapper_context.cpp @@ -0,0 +1,23 @@ +// Generated Code - DO NOT EDIT !! +// generated by 'emugen' + + +#include <string.h> +#include "foo_wrapper_context.h" + + +#include <stdio.h> + +int foo_wrapper_context_t::initDispatchByName(void *(*getProc)(const char *, void *userData), void *userData) +{ + fooAlphaFunc = (fooAlphaFunc_wrapper_proc_t) getProc("fooAlphaFunc", userData); + fooIsBuffer = (fooIsBuffer_wrapper_proc_t) getProc("fooIsBuffer", userData); + fooUnsupported = (fooUnsupported_wrapper_proc_t) getProc("fooUnsupported", userData); + fooDoEncoderFlush = (fooDoEncoderFlush_wrapper_proc_t) getProc("fooDoEncoderFlush", userData); + fooTakeConstVoidPtrConstPtr = (fooTakeConstVoidPtrConstPtr_wrapper_proc_t) getProc("fooTakeConstVoidPtrConstPtr", userData); + fooSetComplexStruct = (fooSetComplexStruct_wrapper_proc_t) getProc("fooSetComplexStruct", userData); + fooGetComplexStruct = (fooGetComplexStruct_wrapper_proc_t) getProc("fooGetComplexStruct", userData); + fooInout = (fooInout_wrapper_proc_t) getProc("fooInout", userData); + return 0; +} + diff --git a/host/commands/emugen/tests/t.001/expected/wrapper/foo_wrapper_context.h b/host/commands/emugen/tests/t.001/expected/wrapper/foo_wrapper_context.h new file mode 100644 index 000000000..c9853d298 --- /dev/null +++ b/host/commands/emugen/tests/t.001/expected/wrapper/foo_wrapper_context.h @@ -0,0 +1,28 @@ +// Generated Code - DO NOT EDIT !! +// generated by 'emugen' +#ifndef __foo_wrapper_context_t_h +#define __foo_wrapper_context_t_h + +#include "foo_server_proc.h" + +#include "foo_types.h" + + +struct foo_wrapper_context_t { + + fooAlphaFunc_wrapper_proc_t fooAlphaFunc; + fooIsBuffer_wrapper_proc_t fooIsBuffer; + fooUnsupported_wrapper_proc_t fooUnsupported; + fooDoEncoderFlush_wrapper_proc_t fooDoEncoderFlush; + fooTakeConstVoidPtrConstPtr_wrapper_proc_t fooTakeConstVoidPtrConstPtr; + fooSetComplexStruct_wrapper_proc_t fooSetComplexStruct; + fooGetComplexStruct_wrapper_proc_t fooGetComplexStruct; + fooInout_wrapper_proc_t fooInout; + virtual ~foo_wrapper_context_t() {} + + typedef foo_wrapper_context_t *CONTEXT_ACCESSOR_TYPE(void); + static void setContextAccessor(CONTEXT_ACCESSOR_TYPE *f); + int initDispatchByName( void *(*getProc)(const char *name, void *userData), void *userData); +}; + +#endif diff --git a/host/commands/emugen/tests/t.001/expected/wrapper/foo_wrapper_entry.cpp b/host/commands/emugen/tests/t.001/expected/wrapper/foo_wrapper_entry.cpp new file mode 100644 index 000000000..733c8248d --- /dev/null +++ b/host/commands/emugen/tests/t.001/expected/wrapper/foo_wrapper_entry.cpp @@ -0,0 +1,71 @@ +// Generated Code - DO NOT EDIT !! +// generated by 'emugen' +#include <stdio.h> +#include <stdlib.h> +#include "foo_wrapper_context.h" + +extern "C" { + void fooAlphaFunc(FooInt func, FooFloat ref); + FooBoolean fooIsBuffer(void* stuff); + void fooUnsupported(void* params); + void fooDoEncoderFlush(FooInt param); + void fooTakeConstVoidPtrConstPtr(const void* const* param); + void fooSetComplexStruct(const FooStruct* obj); + void fooGetComplexStruct(FooStruct* obj); + void fooInout(uint32_t* count); +}; + +#ifndef GET_CONTEXT +static foo_wrapper_context_t::CONTEXT_ACCESSOR_TYPE *getCurrentContext = NULL; +void foo_wrapper_context_t::setContextAccessor(CONTEXT_ACCESSOR_TYPE *f) { getCurrentContext = f; } +#define GET_CONTEXT foo_wrapper_context_t * ctx = getCurrentContext() +#endif + +void fooAlphaFunc(FooInt func, FooFloat ref) +{ + GET_CONTEXT; + ctx->fooAlphaFunc( func, ref); +} + +FooBoolean fooIsBuffer(void* stuff) +{ + GET_CONTEXT; + return ctx->fooIsBuffer( stuff); +} + +void fooUnsupported(void* params) +{ + GET_CONTEXT; + ctx->fooUnsupported( params); +} + +void fooDoEncoderFlush(FooInt param) +{ + GET_CONTEXT; + ctx->fooDoEncoderFlush( param); +} + +void fooTakeConstVoidPtrConstPtr(const void* const* param) +{ + GET_CONTEXT; + ctx->fooTakeConstVoidPtrConstPtr( param); +} + +void fooSetComplexStruct(const FooStruct* obj) +{ + GET_CONTEXT; + ctx->fooSetComplexStruct( obj); +} + +void fooGetComplexStruct(FooStruct* obj) +{ + GET_CONTEXT; + ctx->fooGetComplexStruct( obj); +} + +void fooInout(uint32_t* count) +{ + GET_CONTEXT; + ctx->fooInout( count); +} + diff --git a/host/commands/emugen/tests/t.001/expected/wrapper/foo_wrapper_proc.h b/host/commands/emugen/tests/t.001/expected/wrapper/foo_wrapper_proc.h new file mode 100644 index 000000000..66ced3138 --- /dev/null +++ b/host/commands/emugen/tests/t.001/expected/wrapper/foo_wrapper_proc.h @@ -0,0 +1,22 @@ +// Generated Code - DO NOT EDIT !! +// generated by 'emugen' +#ifndef __foo_wrapper_proc_t_h +#define __foo_wrapper_proc_t_h + + + +#include "foo_types.h" +#ifndef foo_APIENTRY +#define foo_APIENTRY +#endif +typedef void (foo_APIENTRY *fooAlphaFunc_wrapper_proc_t) (FooInt, FooFloat); +typedef FooBoolean (foo_APIENTRY *fooIsBuffer_wrapper_proc_t) (void*); +typedef void (foo_APIENTRY *fooUnsupported_wrapper_proc_t) (void*); +typedef void (foo_APIENTRY *fooDoEncoderFlush_wrapper_proc_t) (FooInt); +typedef void (foo_APIENTRY *fooTakeConstVoidPtrConstPtr_wrapper_proc_t) (const void* const*); +typedef void (foo_APIENTRY *fooSetComplexStruct_wrapper_proc_t) (const FooStruct*); +typedef void (foo_APIENTRY *fooGetComplexStruct_wrapper_proc_t) (FooStruct*); +typedef void (foo_APIENTRY *fooInout_wrapper_proc_t) (uint32_t*); + + +#endif diff --git a/host/commands/emugen/tests/t.001/input/foo.attrib b/host/commands/emugen/tests/t.001/input/foo.attrib new file mode 100644 index 000000000..9b66c5796 --- /dev/null +++ b/host/commands/emugen/tests/t.001/input/foo.attrib @@ -0,0 +1,32 @@ +GLOBAL + base_opcode 200 + encoder_headers "fooUtils.h" "fooBase.h" + +fooIsBuffer + dir stuff in + len stuff (4 * sizeof(float)) + param_check stuff if (n == NULL) { LOG(ERROR) << "NULL stuff"; return; } + +fooUnsupported + dir params in + flag unsupported + +fooDoEncoderFlush + flag flushOnEncode + +fooSetComplexStruct + dir obj in + len obj fooStructEncodingSize(obj) + custom_pack obj fooStructPack(ptr, obj) + custom_unpack obj FooStruct unpacked; inptr_obj_unpacked = (void*)(&unpacked); fooStructUnpack((unsigned char*)(inptr_obj.get()), size_obj, inptr_obj_unpacked) + +fooGetComplexStruct + dir obj out + len obj fooStructEncodingSize(obj) + custom_host_pack_tmp_alloc obj FooStruct tmp; forPacking_obj = (void*)tmp + custom_host_pack obj fooStructPack((unsigned char*)outptr_obj.get(), (FooStruct*)forPacking_obj) + custom_guest_unpack obj std::vector<unsigned char> forUnpacking_obj(__size_obj); stream->readback(&forUnpacking_obj[0], __size_obj); fooStructUnpack(&forUnpacking_obj[0], obj) + +fooInout + dir count inout + len count sizeof(uint32_t) diff --git a/host/commands/emugen/tests/t.001/input/foo.in b/host/commands/emugen/tests/t.001/input/foo.in new file mode 100644 index 000000000..b12ad99f9 --- /dev/null +++ b/host/commands/emugen/tests/t.001/input/foo.in @@ -0,0 +1,8 @@ +FOO_ENTRY(void, fooAlphaFunc, FooInt func, FooFloat ref) +FOO_ENTRY(FooBoolean, fooIsBuffer, void* stuff) +FOO_ENTRY(void, fooUnsupported, void* params) +FOO_ENTRY(void, fooDoEncoderFlush, FooInt param) +FOO_ENTRY(void, fooTakeConstVoidPtrConstPtr, const void* const* param) +FOO_ENTRY(void, fooSetComplexStruct, const FooStruct* obj) +FOO_ENTRY(void, fooGetComplexStruct, FooStruct* obj) +FOO_ENTRY(void, fooInout, uint32_t* count) diff --git a/host/commands/emugen/tests/t.001/input/foo.types b/host/commands/emugen/tests/t.001/input/foo.types new file mode 100644 index 000000000..45e17c913 --- /dev/null +++ b/host/commands/emugen/tests/t.001/input/foo.types @@ -0,0 +1,12 @@ +FooBoolean 8 %d +FooInt 32 %d +FooShort 16 %d +FooFloat 32 %f +FooEnum 32 %08x +FooVoid 0 %x +FooChar 8 %d +FooChar* 32 0x%08x +void* 32 0x%08x +void*const* 32 0x%08x +FooStruct* 32 0x%08x +uint32_t* 32 0x%08x |