forked from livecode/livecode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfoundation-foreign.cpp
More file actions
702 lines (589 loc) · 19.4 KB
/
Copy pathfoundation-foreign.cpp
File metadata and controls
702 lines (589 loc) · 19.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
/* Copyright (C) 2003-2013 Runtime Revolution Ltd.
This file is part of LiveCode.
LiveCode is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License v3 as published by the Free
Software Foundation.
LiveCode 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 General Public License
for more details.
You should have received a copy of the GNU General Public License
along with LiveCode. If not see <http://www.gnu.org/licenses/>. */
#include <foundation.h>
#include <foundation-auto.h>
#include "foundation-private.h"
////////////////////////////////////////////////////////////////////////////////
MC_DLLEXPORT_DEF MCTypeInfoRef kMCBoolTypeInfo;
MC_DLLEXPORT_DEF MCTypeInfoRef kMCUIntTypeInfo;
MC_DLLEXPORT_DEF MCTypeInfoRef kMCIntTypeInfo;
MC_DLLEXPORT_DEF MCTypeInfoRef kMCFloatTypeInfo;
MC_DLLEXPORT_DEF MCTypeInfoRef kMCDoubleTypeInfo;
MC_DLLEXPORT_DEF MCTypeInfoRef kMCPointerTypeInfo;
MC_DLLEXPORT_DEF MCTypeInfoRef kMCSizeTypeInfo;
MC_DLLEXPORT_DEF MCTypeInfoRef kMCSSizeTypeInfo;
MCTypeInfoRef kMCForeignImportErrorTypeInfo;
MCTypeInfoRef kMCForeignExportErrorTypeInfo;
////////////////////////////////////////////////////////////////////////////////
MC_DLLEXPORT_DEF
bool MCForeignValueCreate(MCTypeInfoRef p_typeinfo, void *p_contents, MCForeignValueRef& r_value)
{
bool t_success;
t_success = true;
MCTypeInfoRef t_resolved_typeinfo;
t_resolved_typeinfo = __MCTypeInfoResolve(p_typeinfo);
__MCForeignValue *t_value;
if (!__MCValueCreate(kMCValueTypeCodeForeignValue, sizeof(__MCForeignValue) + t_resolved_typeinfo -> foreign . descriptor . size, (__MCValue*&)t_value))
return false;
if (!t_resolved_typeinfo -> foreign . descriptor . copy(p_contents, t_value + 1))
{
MCMemoryDelete(t_value);
return false;
}
t_value -> typeinfo = MCValueRetain(p_typeinfo);
r_value = t_value;
return true;
}
MC_DLLEXPORT_DEF
bool MCForeignValueCreateAndRelease(MCTypeInfoRef p_typeinfo, void *p_contents, MCForeignValueRef& r_value)
{
bool t_success;
t_success = true;
MCTypeInfoRef t_resolved_typeinfo;
t_resolved_typeinfo = __MCTypeInfoResolve(p_typeinfo);
__MCForeignValue *t_value;
if (!__MCValueCreate(kMCValueTypeCodeForeignValue, sizeof(__MCForeignValue) + t_resolved_typeinfo -> foreign . descriptor . size, (__MCValue*&)t_value))
return false;
if (!t_resolved_typeinfo -> foreign . descriptor . move(p_contents, t_value + 1))
{
MCMemoryDelete(t_value);
return false;
}
t_value -> typeinfo = MCValueRetain(p_typeinfo);
r_value = t_value;
return true;
}
MC_DLLEXPORT_DEF
bool MCForeignValueExport(MCTypeInfoRef p_typeinfo, MCValueRef p_value, MCForeignValueRef& r_value)
{
bool t_success;
t_success = true;
MCTypeInfoRef t_resolved_typeinfo;
t_resolved_typeinfo = __MCTypeInfoResolve(p_typeinfo);
__MCForeignValue *t_value;
if (!__MCValueCreate(kMCValueTypeCodeForeignValue, sizeof(__MCForeignValue) + t_resolved_typeinfo -> foreign . descriptor . size, (__MCValue*&)t_value))
return false;
if (!t_resolved_typeinfo -> foreign . descriptor . doexport(p_value, false, t_value + 1))
{
MCMemoryDelete(t_value);
return false;
}
t_value -> typeinfo = MCValueRetain(p_typeinfo);
r_value = t_value;
return true;
}
MC_DLLEXPORT_DEF
void *MCForeignValueGetContentsPtr(MCValueRef self)
{
return ((__MCForeignValue *)self) + 1;
}
////////////////////////////////////////////////////////////////////////////////
void __MCForeignValueDestroy(__MCForeignValue *self)
{
MCTypeInfoRef t_resolved_typeinfo;
t_resolved_typeinfo = __MCTypeInfoResolve(self -> typeinfo);
t_resolved_typeinfo -> foreign . descriptor . finalize(self + 1);
}
hash_t __MCForeignValueHash(__MCForeignValue *self)
{
MCTypeInfoRef t_resolved_typeinfo;
t_resolved_typeinfo = __MCTypeInfoResolve(self -> typeinfo);
hash_t t_hash;
if (!t_resolved_typeinfo -> foreign . descriptor . hash(self + 1, t_hash))
return 0;
return t_hash;
}
bool __MCForeignValueIsEqualTo(__MCForeignValue *self, __MCForeignValue *other_self)
{
MCTypeInfoRef t_resolved_typeinfo;
t_resolved_typeinfo = __MCTypeInfoResolve(self -> typeinfo);
bool t_result;
if (!t_resolved_typeinfo -> foreign . descriptor . equal(self + 1, other_self + 1, t_result))
return false;
return t_result;
}
bool __MCForeignValueCopyDescription(__MCForeignValue *self, MCStringRef& r_description)
{
MCTypeInfoRef t_resolved_typeinfo;
t_resolved_typeinfo = __MCTypeInfoResolve(self->typeinfo);
bool (*t_describe_func)(void *, MCStringRef &);
t_describe_func = t_resolved_typeinfo->foreign.descriptor.describe;
if (NULL != t_describe_func)
return t_describe_func (MCForeignValueGetContentsPtr (self),
r_description);
else
return MCStringFormat(r_description, "<foreign: %p>", self);
}
////////////////////////////////////////////////////////////////////////////////
// bool foreign type handlers
static void __bool_finalize(void *)
{
}
static bool __bool_copy(void *from, void *to)
{
*(bool *)to = *(bool *)from; return true;
}
static bool __bool_equal(void *left, void *right, bool& r_equal)
{
r_equal = *(bool *)left == *(bool *)right; return true;
}
static bool __bool_hash(void *value, hash_t& r_hash)
{
r_hash = (hash_t)*(bool *)value; return true;
}
static bool __bool_import(void *contents, bool release, MCValueRef& r_value)
{
if (*(bool *)contents)
r_value = MCValueRetain(kMCTrue);
else
r_value = MCValueRetain(kMCFalse);
return true;
}
static bool __bool_export(MCValueRef value, bool release, void *contents)
{
*(bool *)contents = value == kMCTrue;
if (release)
MCValueRelease(value);
return true;
}
// pointer handlers
static bool __pointer_initialize(void *contents)
{
*(void **)contents = nil;
return true;
}
static void __pointer_finalize(void *contents)
{
}
static bool __pointer_defined(void *contents)
{
return *(void **)contents != nil;
}
static bool __pointer_copy(void *from, void *to)
{
*(void **)to = *(void **)from;
return true;
}
static bool __pointer_equal(void *left, void *right, bool& r_equal)
{
r_equal = *(void **)left == *(void **)right;
return true;
}
static bool __pointer_hash(void *value, hash_t& r_hash)
{
r_hash = MCHashPointer(*(void **)value);
return true;
}
// numeric foreign type handlers
template<typename T> static void __numeric_finalize(void *)
{
}
template<typename T> static bool __numeric_copy(void *from, void *to)
{
*(T *)to = *(T *)from;
return true;
}
template<typename T> static bool __numeric_equal(void *left, void *right, bool& r_equal)
{
r_equal = *(T *)left == *(T *)right;
return true;
}
static bool __int_hash(void *value, hash_t& r_hash)
{
r_hash = MCHashInteger(*(integer_t *)value);
return true;
}
static bool
__uint_hash(void *value,
hash_t & r_hash)
{
r_hash = MCHashUInteger(*(uinteger_t *) value);
return true;
}
static bool __float_hash(void *value, hash_t& r_hash)
{
r_hash = MCHashDouble(*(float *)value);
return true;
}
static bool __double_hash(void *value, hash_t& r_hash)
{
r_hash = MCHashDouble(*(double *)value);
return true;
}
static bool
__size_hash (void *value,
hash_t & r_hash)
{
r_hash = MCHashUSize(*reinterpret_cast<size_t *>(value));
return true;
}
static bool
__ssize_hash (void *value,
hash_t & r_hash)
{
r_hash = MCHashSize(*reinterpret_cast<ssize_t *>(value));
return true;
}
static bool __int_import(void *contents, bool release, MCValueRef& r_value)
{
return MCNumberCreateWithInteger(*(integer_t *)contents, (MCNumberRef&)r_value);
}
static bool __uint_import(void *contents, bool release, MCValueRef& r_value)
{
return MCNumberCreateWithUnsignedInteger(*(uinteger_t *)contents, (MCNumberRef&)r_value);
}
static bool
__size_import (void *contents,
bool release,
MCValueRef & r_value)
{
size_t t_value = *(size_t *) contents;
if (t_value > UINTEGER_MAX)
{
MCErrorCreateAndThrow (kMCForeignImportErrorTypeInfo,
"type", kMCSizeTypeInfo,
"reason", MCSTR("too large for Number representation"),
nil);
return false;
}
return MCNumberCreateWithUnsignedInteger((uinteger_t) t_value,
(MCNumberRef &) r_value);
}
static bool
__ssize_import (void *contents,
bool release,
MCValueRef & r_value)
{
ssize_t t_value = *(ssize_t *) contents;
if (t_value < INTEGER_MIN || t_value > INTEGER_MAX)
{
MCErrorCreateAndThrow (kMCForeignImportErrorTypeInfo,
"type", kMCSizeTypeInfo,
"reason", MCSTR("too large for Number representation"),
nil);
return false;
}
return MCNumberCreateWithInteger((integer_t) t_value,
(MCNumberRef &) r_value);
}
static bool __float_import(void *contents, bool release, MCValueRef& r_value)
{
return MCNumberCreateWithReal(*(float *)contents, (MCNumberRef&)r_value);
}
static bool __double_import(void *contents, bool release, MCValueRef& r_value)
{
return MCNumberCreateWithReal(*(double *)contents, (MCNumberRef&)r_value);
}
static bool __int_export(MCValueRef value, bool release, void *contents)
{
*(integer_t *)contents = MCNumberFetchAsInteger((MCNumberRef)value);
if (release)
MCValueRelease(value);
return true;
}
template <typename T>
static bool
__uint_export (MCValueRef value,
bool release,
void *contents,
MCTypeInfoRef typeinfo)
{
/* Unsigned values can't be negative */
if (0 > MCNumberFetchAsReal ((MCNumberRef) value))
{
MCErrorCreateAndThrow (kMCForeignExportErrorTypeInfo,
"type", typeinfo,
"reason", MCSTR("cannot store negative value in unsigned integer"),
nil);
return false;
}
*(T *)contents = MCNumberFetchAsUnsignedInteger((MCNumberRef)value);
if (release)
MCValueRelease(value);
return true;
}
static bool
__uint_export(MCValueRef value, bool release, void *contents)
{
return __uint_export<uinteger_t>(value, release, contents, kMCUIntTypeInfo);
}
static bool __float_export(MCValueRef value, bool release, void *contents)
{
*(float *)contents = MCNumberFetchAsReal((MCNumberRef)value);
if (release)
MCValueRelease(value);
return true;
}
static bool __double_export(MCValueRef value, bool release, void *contents)
{
*(double *)contents = MCNumberFetchAsReal((MCNumberRef)value);
if (release)
MCValueRelease(value);
return true;
}
static bool
__size_export(MCValueRef value, bool release, void *contents)
{
return __uint_export<size_t>(value, release, contents, kMCSizeTypeInfo);
}
static bool
__ssize_export(MCValueRef value, bool release, void *contents)
{
return __uint_export<ssize_t>(value, release, contents, kMCSSizeTypeInfo);
}
static bool
__bool_describe (void *contents,
MCStringRef & r_string)
{
return MCStringCopy (MCSTR(*((bool *) contents) ? "<foreign true>" : "<foreign false>"), r_string);
}
static bool
__int_describe (void *contents,
MCStringRef & r_string)
{
return MCStringFormat (r_string, "<foreign integer %i>",
*((integer_t *) contents));
}
static bool
__uint_describe (void *contents,
MCStringRef & r_string)
{
return MCStringFormat (r_string, "<foreign unsigned integer %u>",
*((uinteger_t *) contents));
}
static bool
__float_describe (void *contents,
MCStringRef & r_string)
{
return MCStringFormat (r_string, "<foreign float %g>",
(double) *((float *) contents));
}
static bool
__double_describe (void *contents,
MCStringRef & r_string)
{
return MCStringFormat (r_string, "<foreign double %g>",
*((double *) contents));
}
static bool
__pointer_describe (void *contents,
MCStringRef & r_string)
{
return MCStringFormat (r_string, "<foreign pointer %p>",
*((void **) contents));
}
static bool
__size_describe (void *contents,
MCStringRef & r_string)
{
return MCStringFormat (r_string, "<foreign size %zu>",
*((size_t *) contents));
}
static bool
__ssize_describe (void *contents,
MCStringRef & r_string)
{
return MCStringFormat (r_string, "<foreign ssize %zd>",
*((ssize_t *) contents));
}
static bool __build_typeinfo(const char *p_name, MCForeignTypeDescriptor *p_desc, MCTypeInfoRef& r_typeinfo)
{
MCAutoStringRef t_name_string;
if (!MCStringCreateWithCString(p_name, &t_name_string))
return false;
MCNewAutoNameRef t_name_name;
if (!MCNameCreate(*t_name_string, &t_name_name))
return false;
if (!MCNamedForeignTypeInfoCreate(*t_name_name, p_desc, r_typeinfo))
return false;
return true;
}
bool __MCForeignValueInitialize(void)
{
MCForeignPrimitiveType p;
MCForeignTypeDescriptor d;
d . size = sizeof(bool);
d . basetype = kMCNullTypeInfo;
d . bridgetype = kMCBooleanTypeInfo;
p = kMCForeignPrimitiveTypeBool;
d . layout = &p;
d . layout_size = 1;
d . initialize = nil;
d . finalize = __bool_finalize;
d . defined = nil;
d . move = __bool_copy;
d . copy = __bool_copy;
d . equal = __bool_equal;
d . hash = __bool_hash;
d . doimport = __bool_import;
d . doexport = __bool_export;
d . describe = __bool_describe;
if (!__build_typeinfo("__builtin__.bool", &d, kMCBoolTypeInfo))
return false;
d . size = sizeof(integer_t);
d . basetype = kMCNullTypeInfo;
d . bridgetype = kMCNumberTypeInfo;
p = kMCForeignPrimitiveTypeSInt32;
d . layout = &p;
d . layout_size = 1;
d . initialize = nil;
d . finalize = __numeric_finalize<integer_t>;
d . defined = nil;
d . move = __numeric_copy<integer_t>;
d . copy = __numeric_copy<integer_t>;
d . equal = __numeric_equal<integer_t>;
d . hash = __int_hash;
d . doimport = __int_import;
d . doexport = __int_export;
d . describe = __int_describe;
if (!__build_typeinfo("__builtin__.int", &d, kMCIntTypeInfo))
return false;
d . size = sizeof(uinteger_t);
d . basetype = kMCNullTypeInfo;
d . bridgetype = kMCNumberTypeInfo;
p = kMCForeignPrimitiveTypeUInt32;
d . layout = &p;
d . layout_size = 1;
d . initialize = nil;
d . finalize = __numeric_finalize<uinteger_t>;
d . defined = nil;
d . move = __numeric_copy<uinteger_t>;
d . copy = __numeric_copy<uinteger_t>;
d . equal = __numeric_equal<uinteger_t>;
d . hash = __uint_hash;
d . doimport = __uint_import;
d . doexport = __uint_export;
d . describe = __uint_describe;
if (!__build_typeinfo("__builtin__.uint", &d, kMCUIntTypeInfo))
return false;
d . size = sizeof(float);
d . basetype = kMCNullTypeInfo;
d . bridgetype = kMCNumberTypeInfo;
p = kMCForeignPrimitiveTypeFloat32;
d . layout = &p;
d . layout_size = 1;
d . initialize = nil;
d . finalize = __numeric_finalize<float>;
d . defined = nil;
d . move = __numeric_copy<float>;
d . copy = __numeric_copy<float>;
d . equal = __numeric_equal<float>;
d . hash = __float_hash;
d . doimport = __float_import;
d . doexport = __float_export;
d . describe = __float_describe;
if (!__build_typeinfo("__builtin__.float", &d, kMCFloatTypeInfo))
return false;
d . size = sizeof(double);
d . basetype = kMCNullTypeInfo;
d . bridgetype = kMCNumberTypeInfo;
p = kMCForeignPrimitiveTypeFloat64;
d . layout = &p;
d . layout_size = 1;
d . initialize = nil;
d . finalize = __numeric_finalize<double>;
d . defined = nil;
d . move = __numeric_copy<double>;
d . copy = __numeric_copy<double>;
d . equal = __numeric_equal<double>;
d . hash = __double_hash;
d . doimport = __double_import;
d . doexport = __double_export;
d . describe = __double_describe;
if (!__build_typeinfo("__builtin__.double", &d, kMCDoubleTypeInfo))
return false;
d . size = sizeof(void *);
d . basetype = kMCNullTypeInfo;
d . bridgetype = kMCNullTypeInfo;
p = kMCForeignPrimitiveTypePointer;
d . layout = &p;
d . layout_size = 1;
d . initialize = __pointer_initialize;
d . finalize = __pointer_finalize;
d . defined = __pointer_defined;
d . move = __pointer_copy;
d . copy = __pointer_copy;
d . equal = __pointer_equal;
d . hash = __pointer_hash;
d . doimport = nil;
d . doexport = nil;
d . describe = __pointer_describe;
if (!__build_typeinfo("__builtin__.pointer", &d, kMCPointerTypeInfo))
return false;
d . size = sizeof(size_t);
d . basetype = kMCNullTypeInfo;
d . bridgetype = kMCNumberTypeInfo;
#if SIZE_MAX == UINT64_MAX
p = kMCForeignPrimitiveTypeUInt64;
#elif SIZE_MAX == UINT32_MAX
p = kMCForeignPrimitiveTypeUInt32;
#else
# error "Unsupported storage layout for size_t"
#endif
d . layout = &p;
d . layout_size = 1;
d . initialize = nil;
d . finalize = __numeric_finalize<size_t>;
d . defined = nil;
d . move = __numeric_copy<size_t>;
d . copy = __numeric_copy<size_t>;
d . equal = __numeric_equal<size_t>;
d . hash = __size_hash;
d . doimport = __size_import;
d . doexport = __size_export;
d . describe = __size_describe;
if (!__build_typeinfo("__builtin__.size", &d, kMCSizeTypeInfo))
return false;
d . size = sizeof(ssize_t);
d . basetype = kMCNullTypeInfo;
d . bridgetype = kMCNumberTypeInfo;
#if SSIZE_MAX == INT64_MAX
p = kMCForeignPrimitiveTypeUInt64;
#elif SSIZE_MAX == INT32_MAX
p = kMCForeignPrimitiveTypeUInt32;
#else
# error "Unsupported storage layout for ssize_t"
#endif
d . layout = &p;
d . layout_size = 1;
d . initialize = nil;
d . finalize = __numeric_finalize<ssize_t>;
d . defined = nil;
d . move = __numeric_copy<ssize_t>;
d . copy = __numeric_copy<ssize_t>;
d . equal = __numeric_equal<ssize_t>;
d . hash = __ssize_hash;
d . doimport = __ssize_import;
d . doexport = __ssize_export;
d . describe = __ssize_describe;
if (!__build_typeinfo("__builtin__.ssize", &d, kMCSSizeTypeInfo))
return false;
/* ---------- */
if (!MCNamedErrorTypeInfoCreate (MCNAME("livecode.lang.ForeignTypeImportError"), MCNAME("runtime"), MCSTR("error importing foreign '%{type}' value: %{reason}"), kMCForeignImportErrorTypeInfo))
return false;
if (!MCNamedErrorTypeInfoCreate (MCNAME("livecode.lang.ForeignTypeExportError"), MCNAME("runtime"), MCSTR("error exporting foreign '%{type}' value: %{reason}"), kMCForeignExportErrorTypeInfo))
return false;
return true;
}
void __MCForeignValueFinalize(void)
{
MCValueRelease(kMCBoolTypeInfo);
MCValueRelease(kMCIntTypeInfo);
MCValueRelease(kMCUIntTypeInfo);
MCValueRelease(kMCFloatTypeInfo);
MCValueRelease(kMCDoubleTypeInfo);
MCValueRelease(kMCPointerTypeInfo);
MCValueRelease(kMCSizeTypeInfo);
MCValueRelease (kMCForeignImportErrorTypeInfo);
MCValueRelease (kMCForeignExportErrorTypeInfo);
}
////////////////////////////////////////////////////////////////////////////////