#pragma once
/***********************************************************
 Copyright (c) 2019 Qualcomm Technologies, Inc.
 All Rights Reserved.
 Confidential and Proprietary - Qualcomm Technologies, Inc.
************************************************************/

/**
 * Example interface showcasing what SMCInvoke can do.
 */

/** @cond */

/** MINK IDL allows us to define structs which can be passed
    directly to function calls as parameters. Here we define
    a results struct; which we can use to return both the
    result of the current addition and the total sum from the
    context to the caller. */

// AUTOGENERATED FILE: DO NOT EDIT

#include <cstdint>
#include "object.h"
#include "proxy_base.hpp"
#include "impl_base.hpp"
#include "IAdder.hpp"

class IAdderImplBase : protected ImplBase, public IIAdder {
   public:
    IAdderImplBase() {}
    virtual ~IAdderImplBase() {}

   protected:
    virtual int32_t invoke(ObjectOp op, ObjectArg* a, ObjectCounts k) {
        switch (ObjectOp_methodID(op)) {
            case OP_add: {
                if (k != ObjectCounts_pack(1, 1, 0, 0) ||
                    a[0].b.size != 8 ||
                    a[1].b.size != 4) {
                    break;
                }
                const struct s1 {
                    uint32_t m_val1;
                    int32_t m_val2;
                }* i = (const struct s1*)a[0].b.ptr;
                uint32_t* result_ptr = (uint32_t*)a[1].b.ptr;
                return add(i->m_val1, i->m_val2, result_ptr);
            }
            case OP_addArray: {
                if (k != ObjectCounts_pack(1, 1, 0, 0) ||
                    a[1].b.size != 4) {
                    break;
                }
                const uint32_t* intArray_ptr = (const uint32_t*)a[0].b.ptr;
                size_t intArray_len = a[0].b.size / 4;
                uint32_t* result_ptr = (uint32_t*)a[1].b.ptr;
                return addArray(intArray_ptr, intArray_len, result_ptr);
            }
            case OP_addStruct: {
                if (k != ObjectCounts_pack(1, 1, 0, 0) ||
                    a[0].b.size != 8 ||
                    a[1].b.size != 4) {
                    break;
                }
                const additionStruct* inStruct_ptr = (const additionStruct*)a[0].b.ptr;
                uint32_t* result_ptr = (uint32_t*)a[1].b.ptr;
                return addStruct(*inStruct_ptr, result_ptr);
            }
            case OP_getStatus: {
                if (k != ObjectCounts_pack(0, 1, 0, 0) ||
                    a[0].b.size != 28) {
                    break;
                }
                statusStruct* status_ptr = (statusStruct*)a[0].b.ptr;
                return getStatus(*status_ptr);
            }
            default: { return Object_ERROR_INVALID; }
        }
        return Object_ERROR_INVALID;
    }
};

