mframe.head
上传用户:shenzhenrh
上传日期:2013-05-12
资源大小:2904k
文件大小:4k
源码类别:

信息检索与抽取

开发平台:

Unix_Linux

  1. /* Interface for functions that dissect/make method calls 
  2.    Copyright (C) 1994, 1996, 1998 Free Software Foundation, Inc.
  3.    
  4.    Written by:  Andrew Kachites McCallum <mccallum@gnu.ai.mit.edu>
  5.    Created: Oct 1994
  6.    
  7.    This file is part of the GNUstep Base Library.
  8.    This library is free software; you can redistribute it and/or
  9.    modify it under the terms of the GNU Library General Public
  10.    License as published by the Free Software Foundation; either
  11.    version 2 of the License, or (at your option) any later version.
  12.    
  13.    This library is distributed in the hope that it will be useful,
  14.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  16.    Library General Public License for more details.
  17.    
  18.    You should have received a copy of the GNU Library General Public
  19.    License along with this library; if not, write to the Free
  20.    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21.    */ 
  22. #ifndef __mframe_h_GNUSTEP_BASE_INCLUDE
  23. #define __mframe_h_GNUSTEP_BASE_INCLUDE
  24. #if NeXT_runtime
  25. typedef union {
  26.   char *arg_ptr;
  27.   char arg_regs[sizeof (char*)];
  28. } *arglist_t;
  29. #endif
  30. /* These functions are used to pull apart method calls, and put them
  31.    back together again.  They are useful for things like distributed
  32.    objects, and cross-language communication glue between Objective C
  33.    and other languages. */
  34. /* xxx Currently these function only work with the GNU Objective C
  35.    runtime, not the NeXT runtime. */
  36. /* Extract the arguments to a method call, as found in ARGFRAME,
  37.    according to type string TYPES, and encode them by calling ENCODER.
  38.    Return YES if and only if the method has some pass-by-reference
  39.    arguments. */
  40. BOOL
  41. mframe_dissect_call (arglist_t argframe, const char *types,
  42.      void (*encoder)(int,void*,const char*,int));
  43. BOOL
  44. mframe_dissect_call_opts (arglist_t argframe, const char *types,
  45.      void (*encoder)(int,void*,const char*,int),
  46. BOOL pass_pointers);
  47. /* Decode the arguments to a method call by calling DECODER, knowing
  48.    what to decode by looking at type string ENCODED_TYPES.  Build an
  49.    argframe of type arglist_t, and invoke the method.  Then encode the
  50.    return value and the pass-by-reference values using ENCODER. */
  51. void
  52. mframe_do_call (const char *encoded_types,
  53. void(*decoder)(int,void*,const char*),
  54. void(*encoder)(int,void*,const char*,int));
  55. void
  56. mframe_do_call_opts (const char *encoded_types,
  57. void(*decoder)(int,void*,const char*),
  58. void(*encoder)(int,void*,const char*,int),
  59. BOOL pass_pointers);
  60. /* Decode the return value and pass-by-reference arguments using
  61.    DECODER, knowning what to decode by looking at type string TYPES
  62.    and OUT_PARAMETERS, and put then into ARGFRAME.  Return the
  63.    retval_t structure that can be passed to __builtin_return(). */
  64. retval_t 
  65. mframe_build_return (arglist_t argframe, const char *types, 
  66.      BOOL out_parameters,
  67.      void(*decoder)(int,void*,const char*,int));
  68. retval_t 
  69. mframe_build_return_opts (arglist_t argframe, const char *types, 
  70.      BOOL out_parameters,
  71.      void(*decoder)(int,void*,const char*,int),
  72.      BOOL pass_pointers);
  73. /*
  74.  * Copy the return value from retframe into the specified buffer.
  75.  */
  76. BOOL
  77. mframe_decode_return(const char *type, void* buffer, void* retframe);
  78. /*
  79.  * Return the value of the specified type in 'retval' using argFrame.
  80.  */
  81. void*
  82. mframe_handle_return(const char* type, void* retval, arglist_t argFrame);
  83. /*
  84.  * Step through method encoding information extracting details.
  85.  */
  86. const char *
  87. mframe_next_arg(const char *typePtr, NSArgumentInfo *info);
  88. /*
  89.  * Generate method encoding with stack/register offsets from a simple
  90.  * type encoding string.  Store results in 'buf' or allocate memory
  91.  * using objc_malloc() if 'buf' is a nul pointer.
  92.  */
  93. char*
  94. mframe_build_signature(const char *typePtr, int *size, int *narg, char *buf);
  95. arglist_t
  96. mframe_create_argframe(const char *types, void** retbuf);
  97. void
  98. mframe_destroy_argframe(const char *types, arglist_t argframe);
  99. #define ROUND(V, A) 
  100.   ({ typeof(V) __v=(V); typeof(A) __a=(A); 
  101.      __a*((__v+__a-1)/__a); })