From 7fe60435bce6595a9c58a9bfd8244d74b5320e96 Mon Sep 17 00:00:00 2001 From: Benjamin Franzke Date: Tue, 15 Jan 2013 08:46:13 +0100 Subject: Import DirectFB141_2k11R3_beta5 --- Source/FusionDale/include/fusiondale_util.h | 184 ++++++++++++++++++++++++++++ 1 file changed, 184 insertions(+) create mode 100755 Source/FusionDale/include/fusiondale_util.h (limited to 'Source/FusionDale/include/fusiondale_util.h') diff --git a/Source/FusionDale/include/fusiondale_util.h b/Source/FusionDale/include/fusiondale_util.h new file mode 100755 index 0000000..51539dd --- /dev/null +++ b/Source/FusionDale/include/fusiondale_util.h @@ -0,0 +1,184 @@ +/* + (c) Copyright 2006-2007 directfb.org + + All rights reserved. + + Written by Denis Oliver Kropp . + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the + Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +#ifndef __FUSIONDALE_UTIL_H__ +#define __FUSIONDALE_UTIL_H__ + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include + +#include +#include +#include + + +#define COMA_GENCALL_PREPARE( coma, length ) \ + do { \ + DirectResult ret; \ + \ + D_ASSERT( coma != NULL ); \ + D_ASSERT( length > 0 ); \ + \ + ret = coma->GetLocal( coma, length, &ptr ); \ + if (ret) { \ + D_DERROR( ret, "IComa::GetLocal( %zu ) failed!\n", length ); \ + return ret; \ + } \ + } while (0) + +#define COMA_GENCALL_PREPARE_FROM( coma, from ) \ + do { \ + DirectResult ret; \ + \ + D_ASSERT( coma != NULL ); \ + D_ASSERT( from != NULL ); \ + \ + ret = coma->GetLocal( coma, sizeof(*from), &ptr ); \ + if (ret) { \ + D_DERROR( ret, "IComa::GetLocal( %zu ) failed!\n", sizeof(*from) ); \ + return ret; \ + } \ + \ + direct_memcpy( ptr, from, sizeof(*from) ); \ + } while (0) + +#define COMA_GENCALL_EXECUTE( component, methodid ) \ + do { \ + DirectResult ret; \ + \ + D_ASSERT( component != NULL ); \ + \ + ret = component->Call( component, methodid, ptr, &result ); \ + if (ret) { \ + D_DERROR( ret, "IComaComponent::Call( %lu, %p ) failed!\n", \ + (ComaMethodID) methodid, ptr ); \ + return ret; \ + } \ + } while (0) + +#define COMA_GENCALL_EXECUTE_TO( component, methodid, to ) \ + do { \ + DirectResult ret; \ + \ + D_ASSERT( component != NULL ); \ + D_ASSERT( to != NULL ); \ + \ + ret = component->Call( component, methodid, ptr, &result ); \ + if (ret) { \ + D_DERROR( ret, "IComaComponent::Call( %lu, %p ) failed!\n", \ + (ComaMethodID) methodid, ptr ); \ + return ret; \ + } \ + \ + direct_memcpy( to, ptr, sizeof(*to) ); \ + } while (0) + +/**********************************************************************************************************************/ + +#define COMA_GENCALL_DEFINE___( NAME, METHOD, METHOD_ID ) \ + static inline DirectResult \ + NAME ## _GenCall_ ## METHOD( IComa *coma, \ + IComaComponent *component ) \ + { \ + void *ptr = NULL; \ + int result; \ + \ + D_ASSERT( coma != NULL ); \ + D_ASSERT( component != NULL ); \ + \ + COMA_GENCALL_EXECUTE( component, METHOD_ID ); \ + \ + return (DirectResult)result; \ + } + +#define COMA_GENCALL_DEFINE_I_( NAME, METHOD, METHOD_ID ) \ + static inline DirectResult \ + NAME ## _GenCall_ ## METHOD( IComa *coma, \ + IComaComponent *component, \ + NAME ## Call ## METHOD *data ) \ + { \ + void *ptr; \ + int result; \ + \ + D_ASSERT( coma != NULL ); \ + D_ASSERT( component != NULL ); \ + D_ASSERT( data != NULL ); \ + \ + COMA_GENCALL_PREPARE_FROM( coma, data ); \ + \ + COMA_GENCALL_EXECUTE( component, METHOD_ID ); \ + \ + return (DirectResult)result; \ + } + +#define COMA_GENCALL_DEFINE__O( NAME, METHOD, METHOD_ID ) \ + static inline DirectResult \ + NAME ## _GenCall_ ## METHOD( IComa *coma, \ + IComaComponent *component, \ + NAME ## Call ## METHOD *data ) \ + { \ + void *ptr; \ + int result; \ + \ + D_ASSERT( coma != NULL ); \ + D_ASSERT( component != NULL ); \ + D_ASSERT( data != NULL ); \ + \ + COMA_GENCALL_PREPARE( coma, sizeof(*data) ); \ + \ + COMA_GENCALL_EXECUTE_TO( component, METHOD_ID, data ); \ + \ + return (DirectResult)result; \ + } + +#define COMA_GENCALL_DEFINE_IO( NAME, METHOD, METHOD_ID ) \ + static inline DirectResult \ + NAME ## _GenCall_ ## METHOD( IComa *coma, \ + IComaComponent *component, \ + NAME ## Call ## METHOD *data ) \ + { \ + void *ptr; \ + int result; \ + \ + D_ASSERT( coma != NULL ); \ + D_ASSERT( component != NULL ); \ + D_ASSERT( data != NULL ); \ + \ + COMA_GENCALL_PREPARE_FROM( coma, data ); \ + \ + COMA_GENCALL_EXECUTE_TO( component, METHOD_ID, data ); \ + \ + return (DirectResult)result; \ + } + + +#ifdef __cplusplus +} +#endif + +#endif + -- cgit