annotate dyncall/dyncall_callf.c @ 553:a93bb23fca8c

win build fix
author Tassilo Philipp
date Mon, 20 Jun 2022 15:25:01 +0200
parents 71c884e610f0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
1 /*
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
2
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
3 Package: dyncall
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
4 Library: dyncall
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
5 File: dyncall/dyncall_callf.c
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
6 Description: formatted call C interface (extension module)
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
7 License:
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
8
533
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 362
diff changeset
9 Copyright (c) 2007-2022 Daniel Adler <dadler@uni-goettingen.de>,
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
10 Tassilo Philipp <tphilipp@potion-studios.com>
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
11
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
12 Permission to use, copy, modify, and distribute this software for any
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
13 purpose with or without fee is hereby granted, provided that the above
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
14 copyright notice and this permission notice appear in all copies.
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
15
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
16 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
17 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
18 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
19 ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
20 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
21 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
22 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
23
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
24 */
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
25
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
26
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
27
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
28 #include "dyncall_callf.h"
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
29
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
30
533
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 362
diff changeset
31 static void handle_mode(DCCallVM* vm, const DCsigchar** sigptr)
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 362
diff changeset
32 {
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 362
diff changeset
33 if(*((*sigptr)+1) != '\0') {
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 362
diff changeset
34 DCint mode = dcGetModeFromCCSigChar(*(*sigptr)++);
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 362
diff changeset
35 if(mode != DC_ERROR_UNSUPPORTED_MODE)
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 362
diff changeset
36 dcMode(vm, mode);
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 362
diff changeset
37 }
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 362
diff changeset
38 }
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 362
diff changeset
39
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 362
diff changeset
40
171
011b5e3a8548 - compatibility for older platforms - use ANSI comments
cslag
parents: 74
diff changeset
41 /* Shareable implementation for argument binding used in ArgF and CallF below. */
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
42 static void dcArgF_impl(DCCallVM* vm, const DCsigchar** sigptr, va_list args)
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
43 {
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
44 DCsigchar ch;
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
45 while((ch=*(*sigptr)++) != '\0' && ch != DC_SIGCHAR_ENDARG) {
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
46 switch(ch) {
533
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 362
diff changeset
47 /* calling convention modes */
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 362
diff changeset
48 case DC_SIGCHAR_CC_PREFIX: handle_mode(vm, sigptr); break;
358
30aae7371373 - extended signature with calling convention mode switches for fastcall (gnu), default, cdecl, stdcall, arm (arm), arm (thumb), syscall
Tassilo Philipp
parents: 281
diff changeset
49 /* types */
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
50 case DC_SIGCHAR_BOOL: dcArgBool (vm, (DCbool) va_arg(args, DCint )); break;
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
51 case DC_SIGCHAR_CHAR: dcArgChar (vm, (DCchar) va_arg(args, DCint )); break;
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
52 case DC_SIGCHAR_UCHAR: dcArgChar (vm, (DCchar)(DCuchar) va_arg(args, DCint )); break;
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
53 case DC_SIGCHAR_SHORT: dcArgShort (vm, (DCshort) va_arg(args, DCint )); break;
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
54 case DC_SIGCHAR_USHORT: dcArgShort (vm, (DCshort)(DCushort)va_arg(args, DCint )); break;
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
55 case DC_SIGCHAR_INT: dcArgInt (vm, (DCint) va_arg(args, DCint )); break;
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
56 case DC_SIGCHAR_UINT: dcArgInt (vm, (DCint)(DCuint) va_arg(args, DCint )); break;
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
57 case DC_SIGCHAR_LONG: dcArgLong (vm, (DClong) va_arg(args, DClong )); break;
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
58 case DC_SIGCHAR_ULONG: dcArgLong (vm, (DCulong) va_arg(args, DClong )); break;
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
59 case DC_SIGCHAR_LONGLONG: dcArgLongLong(vm, (DClonglong) va_arg(args, DClonglong)); break;
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
60 case DC_SIGCHAR_ULONGLONG: dcArgLongLong(vm, (DCulonglong) va_arg(args, DClonglong)); break;
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
61 case DC_SIGCHAR_FLOAT: dcArgFloat (vm, (DCfloat) va_arg(args, DCdouble )); break;
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
62 case DC_SIGCHAR_DOUBLE: dcArgDouble (vm, (DCdouble) va_arg(args, DCdouble )); break;
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
63 case DC_SIGCHAR_POINTER: dcArgPointer (vm, (DCpointer) va_arg(args, DCpointer )); break;
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
64 case DC_SIGCHAR_STRING: dcArgPointer (vm, (DCpointer) va_arg(args, DCpointer )); break;
533
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 362
diff changeset
65 case DC_SIGCHAR_AGGREGATE: {
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 362
diff changeset
66 /* aggregates expect 2 va args, a DCaggr*, then a ptr to the aggregate */
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 362
diff changeset
67 DCaggr* ag = va_arg(args, DCaggr*);
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 362
diff changeset
68 dcArgAggr(vm, ag, va_arg(args, DCpointer));
362
78dfa2f9783a - added helper function dcGetModeFromCCSigChar() mapping callconv sig chars to respective mode
Tassilo Philipp
parents: 359
diff changeset
69 break;
533
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 362
diff changeset
70 }
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
71 }
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
72 }
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
73 }
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
74
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
75 void dcVArgF(DCCallVM* vm, const DCsigchar* signature, va_list args)
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
76 {
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
77 dcArgF_impl(vm, &signature, args);
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
78 }
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
79
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
80 void dcArgF(DCCallVM* vm, const DCsigchar* signature, ...)
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
81 {
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
82 va_list va;
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
83 va_start(va, signature);
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
84 dcVArgF(vm,signature,va);
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
85 va_end(va);
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
86 }
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
87
533
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 362
diff changeset
88
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 362
diff changeset
89 /* msvc introduced C99'w va_copy() late (in 2013 w/ msvc 18.00); plan9 APE does
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 362
diff changeset
90 * not have it either; luckily given their va_list being only a ptr in both
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 362
diff changeset
91 * cases, work around the issue for older versions */
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 362
diff changeset
92 #if (defined(DC__C_MSVC) || defined(DC__OS_Plan9)) && !defined(va_copy)
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 362
diff changeset
93 #define va_copy(dst, src) ((dst)=(src))
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 362
diff changeset
94 #endif
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 362
diff changeset
95
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 362
diff changeset
96
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
97 void dcVCallF(DCCallVM* vm, DCValue* result, DCpointer funcptr, const DCsigchar* signature, va_list args)
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
98 {
533
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 362
diff changeset
99 DCaggr* ret_ag = NULL; /* only needed for when func returns an aggregate */
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
100 const DCsigchar* ptr = signature;
533
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 362
diff changeset
101
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 362
diff changeset
102 /* need preparatory call if return type is an aggregate, so check end of sig */
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 362
diff changeset
103 /* @@@ugly */
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 362
diff changeset
104 while(*ptr && ptr[1]) ++ptr;
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 362
diff changeset
105 if(*ptr == DC_SIGCHAR_AGGREGATE) {
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 362
diff changeset
106 va_list args_;
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 362
diff changeset
107 va_copy(args_, args);
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 362
diff changeset
108
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 362
diff changeset
109 /* iterate va_list to get return type related args*/
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 362
diff changeset
110 ptr = signature;
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 362
diff changeset
111 while(*ptr) {
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 362
diff changeset
112 switch(*ptr++) {
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 362
diff changeset
113 /* calling convention modes */
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 362
diff changeset
114 case DC_SIGCHAR_CC_PREFIX: handle_mode(vm, &ptr); break; /* needs handling before dcBeginCallAggr */
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 362
diff changeset
115 /* types */
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 362
diff changeset
116 case DC_SIGCHAR_BOOL:
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 362
diff changeset
117 case DC_SIGCHAR_CHAR:
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 362
diff changeset
118 case DC_SIGCHAR_UCHAR:
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 362
diff changeset
119 case DC_SIGCHAR_SHORT:
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 362
diff changeset
120 case DC_SIGCHAR_USHORT:
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 362
diff changeset
121 case DC_SIGCHAR_INT:
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 362
diff changeset
122 case DC_SIGCHAR_UINT: va_arg(args_, DCint ); break;
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 362
diff changeset
123 case DC_SIGCHAR_LONG:
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 362
diff changeset
124 case DC_SIGCHAR_ULONG: va_arg(args_, DClong ); break;
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 362
diff changeset
125 case DC_SIGCHAR_LONGLONG:
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 362
diff changeset
126 case DC_SIGCHAR_ULONGLONG: va_arg(args_, DClonglong); break;
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 362
diff changeset
127 case DC_SIGCHAR_FLOAT:
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 362
diff changeset
128 case DC_SIGCHAR_DOUBLE: va_arg(args_, DCdouble ); break;
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 362
diff changeset
129 case DC_SIGCHAR_POINTER:
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 362
diff changeset
130 case DC_SIGCHAR_STRING: va_arg(args_, DCpointer ); break;
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 362
diff changeset
131 case DC_SIGCHAR_AGGREGATE:
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 362
diff changeset
132 /* aggregate as retval expects 2 more va args, a DCaggr*, then a ptr to the aggregate */
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 362
diff changeset
133 ret_ag = va_arg(args_, DCaggr*);
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 362
diff changeset
134 result->p = va_arg(args_, DCpointer);
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 362
diff changeset
135 break;
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 362
diff changeset
136 }
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 362
diff changeset
137 }
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 362
diff changeset
138 dcBeginCallAggr(vm, ret_ag);
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 362
diff changeset
139
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 362
diff changeset
140 va_end(args_);
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 362
diff changeset
141 }
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 362
diff changeset
142
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 362
diff changeset
143 /* push args */
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 362
diff changeset
144 ptr = signature;
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
145 dcArgF_impl(vm, &ptr, args);
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
146
533
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 362
diff changeset
147 /* call */
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
148 switch(*ptr) {
74
f2a8dfd795e8 - pointer cast for callf to make C++ compilers happy that don't do void* implicit casts (also, as DC_POINTER might be set to something other than void*, this cast would be needed)
cslag
parents: 0
diff changeset
149 case DC_SIGCHAR_VOID: dcCallVoid (vm,funcptr); break;
f2a8dfd795e8 - pointer cast for callf to make C++ compilers happy that don't do void* implicit casts (also, as DC_POINTER might be set to something other than void*, this cast would be needed)
cslag
parents: 0
diff changeset
150 case DC_SIGCHAR_BOOL: result->B = dcCallBool (vm,funcptr); break;
f2a8dfd795e8 - pointer cast for callf to make C++ compilers happy that don't do void* implicit casts (also, as DC_POINTER might be set to something other than void*, this cast would be needed)
cslag
parents: 0
diff changeset
151 case DC_SIGCHAR_CHAR: result->c = dcCallChar (vm,funcptr); break;
f2a8dfd795e8 - pointer cast for callf to make C++ compilers happy that don't do void* implicit casts (also, as DC_POINTER might be set to something other than void*, this cast would be needed)
cslag
parents: 0
diff changeset
152 case DC_SIGCHAR_UCHAR: result->C = (DCuchar)dcCallChar (vm,funcptr); break;
f2a8dfd795e8 - pointer cast for callf to make C++ compilers happy that don't do void* implicit casts (also, as DC_POINTER might be set to something other than void*, this cast would be needed)
cslag
parents: 0
diff changeset
153 case DC_SIGCHAR_SHORT: result->s = dcCallShort (vm,funcptr); break;
f2a8dfd795e8 - pointer cast for callf to make C++ compilers happy that don't do void* implicit casts (also, as DC_POINTER might be set to something other than void*, this cast would be needed)
cslag
parents: 0
diff changeset
154 case DC_SIGCHAR_USHORT: result->S = dcCallShort (vm,funcptr); break;
f2a8dfd795e8 - pointer cast for callf to make C++ compilers happy that don't do void* implicit casts (also, as DC_POINTER might be set to something other than void*, this cast would be needed)
cslag
parents: 0
diff changeset
155 case DC_SIGCHAR_INT: result->i = dcCallInt (vm,funcptr); break;
f2a8dfd795e8 - pointer cast for callf to make C++ compilers happy that don't do void* implicit casts (also, as DC_POINTER might be set to something other than void*, this cast would be needed)
cslag
parents: 0
diff changeset
156 case DC_SIGCHAR_UINT: result->I = dcCallInt (vm,funcptr); break;
f2a8dfd795e8 - pointer cast for callf to make C++ compilers happy that don't do void* implicit casts (also, as DC_POINTER might be set to something other than void*, this cast would be needed)
cslag
parents: 0
diff changeset
157 case DC_SIGCHAR_LONG: result->j = dcCallLong (vm,funcptr); break;
f2a8dfd795e8 - pointer cast for callf to make C++ compilers happy that don't do void* implicit casts (also, as DC_POINTER might be set to something other than void*, this cast would be needed)
cslag
parents: 0
diff changeset
158 case DC_SIGCHAR_ULONG: result->J = dcCallLong (vm,funcptr); break;
f2a8dfd795e8 - pointer cast for callf to make C++ compilers happy that don't do void* implicit casts (also, as DC_POINTER might be set to something other than void*, this cast would be needed)
cslag
parents: 0
diff changeset
159 case DC_SIGCHAR_LONGLONG: result->l = dcCallLongLong (vm,funcptr); break;
f2a8dfd795e8 - pointer cast for callf to make C++ compilers happy that don't do void* implicit casts (also, as DC_POINTER might be set to something other than void*, this cast would be needed)
cslag
parents: 0
diff changeset
160 case DC_SIGCHAR_ULONGLONG: result->L = dcCallLongLong (vm,funcptr); break;
f2a8dfd795e8 - pointer cast for callf to make C++ compilers happy that don't do void* implicit casts (also, as DC_POINTER might be set to something other than void*, this cast would be needed)
cslag
parents: 0
diff changeset
161 case DC_SIGCHAR_FLOAT: result->f = dcCallFloat (vm,funcptr); break;
f2a8dfd795e8 - pointer cast for callf to make C++ compilers happy that don't do void* implicit casts (also, as DC_POINTER might be set to something other than void*, this cast would be needed)
cslag
parents: 0
diff changeset
162 case DC_SIGCHAR_DOUBLE: result->d = dcCallDouble (vm,funcptr); break;
f2a8dfd795e8 - pointer cast for callf to make C++ compilers happy that don't do void* implicit casts (also, as DC_POINTER might be set to something other than void*, this cast would be needed)
cslag
parents: 0
diff changeset
163 case DC_SIGCHAR_POINTER: result->p = dcCallPointer (vm,funcptr); break;
f2a8dfd795e8 - pointer cast for callf to make C++ compilers happy that don't do void* implicit casts (also, as DC_POINTER might be set to something other than void*, this cast would be needed)
cslag
parents: 0
diff changeset
164 case DC_SIGCHAR_STRING: result->Z = (DCstring)dcCallPointer(vm,funcptr); break;
533
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 362
diff changeset
165 case DC_SIGCHAR_AGGREGATE: {
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 362
diff changeset
166 result->p = dcCallAggr(vm, funcptr, ret_ag, result->p);
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 362
diff changeset
167 break;
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 362
diff changeset
168 }
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
169 }
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
170 }
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
171
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
172 void dcCallF(DCCallVM* vm, DCValue* result, DCpointer funcptr, const DCsigchar* signature, ...)
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
173 {
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
174 va_list va;
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
175 va_start(va, signature);
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
176 dcVCallF(vm,result,funcptr,signature,va);
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
177 va_end(va);
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
178 }
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
179