/***********************************************************
 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. */
#pragma once
// AUTOGENERATED FILE: DO NOT EDIT

#include <stdint.h>
#include "object.h"
#include "IAdder.h"

#define IAdder_DEFINE_INVOKE(func, prefix, type) \
  int32_t func(ObjectCxt h, ObjectOp op, ObjectArg *a, ObjectCounts k) \
  { \
    type me = (type) h; \
    switch (ObjectOp_methodID(op)) { \
      case Object_OP_release: { \
        if (k != ObjectCounts_pack(0, 0, 0, 0)) { \
          break; \
        } \
        return prefix##release(me); \
      } \
      case Object_OP_retain: { \
        if (k != ObjectCounts_pack(0, 0, 0, 0)) { \
          break; \
        } \
        return prefix##retain(me); \
      } \
      case IAdder_OP_add: { \
        if (k != ObjectCounts_pack(1, 1, 0, 0) || \
          a[0].b.size != 8 || \
          a[1].b.size != 4) { \
          break; \
        } \
        const struct { \
          uint32_t m_val1; \
          int32_t m_val2; \
        } *i = a[0].b.ptr; \
        uint32_t *result_ptr = (uint32_t*)a[1].b.ptr; \
        return prefix##add(me, i->m_val1, i->m_val2, result_ptr); \
      } \
      case IAdder_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 / sizeof(uint32_t); \
        uint32_t *result_ptr = (uint32_t*)a[1].b.ptr; \
        return prefix##addArray(me, intArray_ptr, intArray_len, result_ptr); \
      } \
      case IAdder_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 prefix##addStruct(me, inStruct_ptr, result_ptr); \
      } \
      case IAdder_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 prefix##getStatus(me, status_ptr); \
      } \
    } \
    return Object_ERROR_INVALID; \
  }


