#ifndef _MATT_COM_H
#define _MATT_COM_H

#include <windows.h>
#include <atlbase.h> 

namespace matt_com {

#define COM_ASSERT(cond) matt_com::__com_assert(cond,__FILE__,__LINE__);
void __com_assert(int cond, const char* file, int line);

#define INT_RESULT VT_I4
#define STRING_RESULT VT_BSTR
#define HANDLE_RESULT VT_DISPATCH

void com_init();
void com_fin();
void* create_object(const wchar_t* name);
void* get_com_method(void* obj, const wchar_t* name);
void* get_com_args(const char* fmt, ...);
void* object_call(void* obj, void* method, void* args);
void release_method(void* method);
void release_object(void* obj);
void release_args(void* args);
void release_result(void* ret);
int get_result_type(void* ptr);
wchar_t* get_result_string(void* ptr);
int get_result_int(void* ptr);
void* get_result_handle(void* ptr);

}

#endif