1/*
2 * Copyright (c) 2006-2008, The RubyCocoa Project.
3 * Copyright (c) 2001-2006, FUJIMOTO Hisakuni.
4 * All Rights Reserved.
5 *
6 * RubyCocoa is free software, covered under either the Ruby's license or the
7 * LGPL. See the COPYRIGHT file for more information.
8 */
9
10#import "osx_ruby.h"
11
12/* Ruby and FFI use both autoconf, and some variables collide. */
13#if defined(PACKAGE_BUGREPORT)
14# undef PACKAGE_BUGREPORT
15#endif
16
17#if defined(PACKAGE_NAME)
18# undef PACKAGE_NAME
19#endif
20
21#if defined(PACKAGE_STRING)
22# undef PACKAGE_STRING
23#endif
24
25#if defined(PACKAGE_TARNAME)
26# undef PACKAGE_TARNAME
27#endif
28
29#if defined(PACKAGE_VERSION)
30# undef PACKAGE_VERSION
31#endif
32
33#if defined(WORDS_BIGENDIAN)
34# undef WORDS_BIGENDIAN
35#endif
36
37#import "ffi.h"
38
39struct bsBoxed;
40struct bsCallEntry;
41
42ffi_type *ffi_type_for_octype(const char *octypestr);
43ffi_type *bs_boxed_ffi_type(struct bsBoxed *bs_boxed);
44
45VALUE rb_ffi_dispatch(
46  struct bsCallEntry *call_entry,
47  char **arg_octypes,
48  int expected_argc,
49  int given_argc,
50  int argc_delta,
51  VALUE *argv,
52  ffi_type **arg_types,
53  void **arg_values,
54  char *ret_octype,
55  void *func_sym,
56  void (*retain_if_necessary)(VALUE arg, BOOL is_retval, void *ctx),
57  void *retain_if_necessary_ctx,
58  VALUE *result);
59
60void *ffi_make_closure(
61  const char *rettype,
62  const char **argtypes,
63  unsigned argc,
64  void (*handler)(ffi_cif *,void *,void **,void *),
65  void *context);
66
67void ffi_dispatch_closure_in_main_thread(
68  void (*handler)(ffi_cif *,void *,void **,void *),
69  ffi_cif *cif,
70  void *resp,
71  void **args,
72  void *userdata,
73  void (*finished_handler)(ffi_cif *,void *,void **,void *));
74