/* Interface for functions that dissect/make method calls Copyright (C) 1994, 1996, 1998 Free Software Foundation, Inc. Written by: Andrew Kachites McCallum Created: Oct 1994 This file is part of the GNUstep Base Library. 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 Library 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., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. */ #ifndef __mframe_h_GNUSTEP_BASE_INCLUDE #define __mframe_h_GNUSTEP_BASE_INCLUDE #include "GNUstepBase/preface.h" #ifdef HAVE_MALLOC_H #include #endif #include "GNUstepBase/DistributedObjects.h" /* For NSArgumentInfo we include NSMethodSignature.h */ #include "Foundation/NSMethodSignature.h" #if NeXT_runtime typedef union { char *arg_ptr; char arg_regs[sizeof (char*)]; } *arglist_t; #endif /* These functions are used to pull apart method calls, and put them back together again. They are useful for things like distributed objects, and cross-language communication glue between Objective C and other languages. */ /* xxx Currently these function only work with the GNU Objective C runtime, not the NeXT runtime. */ /* Extract the arguments to a method call, as found in ARGFRAME, according to type string TYPES, and encode them by calling ENCODER. Return YES if and only if the method has some pass-by-reference arguments. */ BOOL mframe_dissect_call (arglist_t argframe, const char *types, void (*encoder)(DOContext*), DOContext *ctxt); /* Decode the arguments to a method call by calling DECODER, knowing what to decode by looking at type string ENCODED_TYPES. Build an argframe of type arglist_t, and invoke the method. Then encode the return value and the pass-by-reference values using ENCODER. */ void mframe_do_call (DOContext *ctxt, void(*decoder)(DOContext*), void(*encoder)(DOContext*)); /* Decode the return value and pass-by-reference arguments using DECODER, knowning what to decode by looking at type string TYPES and OUT_PARAMETERS, and put then into ARGFRAME. Return the retval_t structure that can be passed to __builtin_return(). */ retval_t mframe_build_return (arglist_t argframe, const char *types, BOOL out_parameters, void(*decoder)(DOContext*), DOContext *ctxt); /* * Copy the return value from retframe into the specified buffer. */ BOOL mframe_decode_return(const char *type, void* buffer, void* retframe); /* * Return the value of the specified type in 'retval' using argFrame. */ void* mframe_handle_return(const char* type, void* retval, arglist_t argFrame); /* * Step through method encoding information extracting details. */ const char * mframe_next_arg(const char *typePtr, NSArgumentInfo *info, char *outTypes); /* * Generate method encoding with stack/register offsets from a simple * type encoding string. Store results in 'buf' or allocate memory * using objc_malloc() if 'buf' is a nul pointer. */ char* mframe_build_signature(const char *typePtr, int *size, int *narg, char *buf); arglist_t mframe_create_argframe(const char *types, void** retbuf); void mframe_destroy_argframe(const char *types, arglist_t argframe); #define ROUND(V, A) \ ({ typeof(V) __v=(V); typeof(A) __a=(A); \ __a*((__v+__a-1)/__a); }) int method_types_get_sizeof_arguments (struct objc_method* mth); char* method_types_get_next_argument (arglist_t argf, const char **type); char* method_types_get_first_argument (struct objc_method* m, arglist_t argframe, const char** type);