This repository was archived by the owner on Aug 31, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 226
Expand file tree
/
Copy pathLiveCode.h
More file actions
1675 lines (1509 loc) · 61.3 KB
/
LiveCode.h
File metadata and controls
1675 lines (1509 loc) · 61.3 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
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* Copyright (C) 2003-2015 LiveCode 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/>. */
#ifndef __LIVECODE__
#define __LIVECODE__
#if defined(__cplusplus)
extern "C" {
#endif
////////////////////////////////////////////////////////////////////////////////
#if defined(_WIN64) || defined(_WIN32)
#define __WINDOWS__
#elif defined(__APPLE__)
# include <TargetConditionals.h>
# if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
# define __IOS__
# elif TARGET_OS_MAC
# define __MAC__
# else
# error unsupported platform
# endif
#elif defined(__linux__)
#define __LINUX__
#elif defined(__ANDROID__)
// #define __ANDROID__
#else
#error unsupported platform
#endif
////////////////////////////////////////////////////////////////////////////////
typedef enum LCError
{
// No errors occurred, the operation succeeded.
kLCErrorNone = 0,
// Memory ran out while performing the operation.
kLCErrorOutOfMemory = 1,
// The requested operation, or operation with requested options is not
// supported.
kLCErrorNotImplemented = 2,
// A request was made for a boolean value, but the source was not convertible
// to one.
kLCErrorNotABoolean = 9,
// A request was made for a numeric value, but the source was not convertible
// to one.
kLCErrorNotANumber = 10,
// A request was made for a integer value, but the source was not convertible
// to one.
kLCErrorNotAnInteger = 11,
// A request was made for a binary string value, but the source was not
// convertible to one.
kLCErrorNotABinaryString = 12,
// A request was made for a string value, but the source was not convertible
// to one.
kLCErrorNotAString = 13,
// A request was made for an array value, but the source was not convertible
// to one.
kLCErrorNotAnArray = 14,
// A request was made for a number, but the source was too big to fit in the
// requested type.
kLCErrorNumberTooBig = 16,
// No object handle was passed to an object manipulation function
kLCErrorNoObject = 23,
// No long id string was passed to object resolve
kLCErrorNoObjectId = 24,
// No message string was passed to dispatch
kLCErrorNoObjectMessage = 25,
// No arguments were passed to dispatch when a non-zero arg count was passed
kLCErrorNoObjectArguments = 26,
// The chunk string passed to object resolve was malformed
kLCErrorMalformedObjectChunk = 27,
// The object chunk could not be resolved
kLCErrorCouldNotResolveObject = 28,
// The object has been deleted since the handle was acquired
kLCErrorObjectDoesNotExist = 29,
// There is no 'defaultStack' in the requested context
kLCErrorNoDefaultStack = 30,
// An operation was aborted
kLCErrorAborted = 31,
// An operation caused an error to be thrown
kLCErrorFailed = 32,
// An operation caused 'exit to top' to be invkoed
kLCErrorExited = 33,
// The property argument to object set/get was nil
kLCErrorNoObjectProperty = 34,
// The value argument to object set/get was nil
kLCErrorNoObjectPropertyValue = 35,
// The query option passed to InterfaceQuery was unknown
kLCErrorInvalidInterfaceQuery = 36,
// Returned if LicenseCheck fails.
kLCErrorUnlicensed = 42,
//////////
// A string could not be encoded as a (native) cstring
kLCErrorCannotEncodeCString = 16384,
// No wait object was passed to a wait manipulation function
kLCErrorNoWait = 16385,
// The wait is already running and cannot be run or destroyed
kLCErrorWaitRunning = 16386,
// An illegal set of options was passed to an array function
kLCErrorBadValueOptions = 16387,
// The path passed to an array function was too short (of zero-length)
kLCErrorBadArrayPath = 16388,
// The keys buffer passed to an 'AllKeys' function is too small
kLCErrorArrayBufferTooSmall = 16389,
// The object passed to LCImageAttach was not an image object.
kLCErrorNotAnImageObject = 16390,
// No image object was passed to a image manipulation function.
kLCErrorNoImage = 16391,
// The mask of an image object was requested, but none was attached.
kLCErrorMaskNotAttached = 16392,
// The value was requested as a (native) char, but the source was not convertible.
kLCErrorNotAChar = 16393,
// An array cannot be encoded as a sequence (i.e. NSArray).
kLCErrorNotASequence = 16394,
// A dictionary could not be encoded as an array.
kLCErrorCannotEncodeMap = 16395
} LCError;
typedef struct LCBytes
{
void *buffer;
unsigned int length;
} LCBytes;
////////////////////////////////////////////////////////////////////////////////
// THREADS
//
// The LiveCode engine runs on a pair of threads and care has to be taken to
// ensure code is executed on the correct one.
//
// On startup, in addition to the main thread started by the OS - the 'system'
// thread; there is an auxillary thread - the 'script' or 'engine' thread.
//
// The engine thread is the one on which script executes and, more importantly,
// where the stack of current waits accumulate.
//
// The system thread is where most system code and calls must be made (most OSes
// only support access to frameworks such as UI and Video playback from the main
// application thread).
//
// Therefore, it is necessary in many cases for external handlers to switch
// between these two threads to perform specific functions. The main primitive
// for doing this is LCRunOnSystemThread (and LCRunBlockOnSystemThread - iOS
// only). This call ensures a given callback is executed immediately on the
// system thread.
//
// As the pair of threads run co-operatively, there is no synchronization issue
// to worry about - when LCRunOnSystemThread is called, the current thread will
// pause while the code is executed on the system thread and control will then
// return to the current thread.
//
// In cases where an external handler does not need to use anything other than
// 'native' context LC API calls then the external handler can be marked as
// 'tail' in the IDL. This causes the entire handler to be executed on the
// system thread - which can simplify coding in many cases. Note that it is illegal
// to call anything other than native context LC APIs - if you need to call
// such APIs from a handler it cannot be marked 'tail' and you must switch
// explicitly to the system thread to call system APIs (using LCRunOnSystemThread).
// CONTEXTS
//
// The LiveCode API specifies three different 'contexts' in which calls can be
// made. These are (from most restrictive to least):
// Native context (any thread)
// Dispatch context (engine thread only)
// Handler context (engine thread only)
// The contexts are cumulative in the sense that handler context also counts as
// being dispatch context.
//
// Calls marked as being safe in 'Native' context can be made at any time and
// from any thread - it doesn't matter where the code is currently executing nor
// how it was invoked.
//
// Calls marked as being safe in 'Dispatch' context can only be made when the
// code is running in an environment provided by the engine. Such calls typically
// require access to engine structures, or their invocation may result in
// script being executed. For example, any code executing as the result of a
// handler entry point, or the callback invoked via LCPostOnMainThread is in
// dispatch context.
//
// Calls marked as being safe in 'Handler' context can only be made when the
// code is running as a result of a handler entry point invocation. Such calls
// typically only make sense in such a context as they require a LiveCode
// handler/object context to make sense.
//
// In general, the 'context safety' of API calls only comes into play when you
// are using multiple threads, or using LCPostOnMainThread.
//
// For reference, here is a list of all calls ordered by context safety:
//
// Native Context
// LCObjectPost
// LCWaitBreak
// LCRunOnMainThread
// LCPostOnMainThread
// LCInterfaceQueryView (main thread only)
// Dispatch Context
// LCObjectResolve
// LCObjectExists
// LCObjectRetain
// LCObjectRelease
// LCObjectSend
// LCObjectGet
// LCObjectSet
// LCImageAttach
// LCImageDetach
// LCImageDescribe
// LCImageDescribeMask
// LCImageUpdate
// LCImageUpdateRect
// Handler Context
// LCExceptionRaise
// LCContextMe
// LCContextTarget
// LCContextDefaultStack
// LCContextDefaultCard
// LCWaitCreate
// LCWaitDestroy
// LCWaitRun
// LCWaitReset
// LCInterfacePresentModalViewController
// LCInterfaceDismissModalViewController
// VALUES
//
// A number of LiveCode API calls allow storing and fetching values such as
// integers, reals, strings and arrays. All of these calls operate in a uniform
// way with regards passing and returning native types in the appropriate way.
//
// Such calls will take an 'options' parameter and a (generic) 'value'
// parameter. The 'value' parameter is always of type 'void *' and must be
// passed a pointer to a (native) variable of the correct type as specified by
// 'options'. This corresponds as follows:
// AsBoolean - pointer to bool variable
// AsInteger - pointer to int variable
// AsReal - pointer to double variable
// AsCString - pointer to (const) char * variable
// AsCData - pointer to (const) LCBytes variable
// AsObjcNumber - pointer to NSNumber * variable
// AsObjcString - pointer to NSString * variable
// AsObjcData - pointer to NSData * variable
//
// When storing, or passing a value into an API call, the call will copy the
// specified value (in this case CString and CData values are considered
// 'const'). For example:
// const char *t_my_string;
// t_my_string = "Hello World!";
// LCObjectSet(t_object, kLCValueOptionAsCString, "text", nil, &t_my_string);
//
// When fetching, or getting a value out an API call, the ownership depends on
// the type. For atomic types (bool, int, double) there is no ownership issue.
// For 'c' types (c-string and c-data), the ownership passes to the caller which
// is then responsible for calling 'free()' on the buffers. For obj-c types, the
// returned values are autoreleased and so the caller does not have to worry
// about explicitly releasing them. For example:
// char *t_obj_string;
// LCObjectGet(t_object, kLCValueOptionAsCString, "text", nil, &t_obj_string);
// ... use t_obj_string ...
// free(t_obj_string);
//
////////////////////////////////////////////////////////////////////////////////
// Function:
// LCExceptionRaise
// Parameters:
// (in) format - const char *
// Errors:
// <none>
// Context Safety:
// Must be called from handler context.
// Semantics:
// Set the error to throw on return from the current external handler.
//
// The thrown string is constructed using the printf-style formatting string
// 'format' and any subsequent arguments as appropriate.
//
void LCExceptionRaise(const char *format, ...);
////////////////////////////////////////////////////////////////////////////////
enum
{
kLCValueOptionMaskAs = 0xff,
kLCValueOptionMaskCaseSensitive = 3 << 30,
kLCValueOptionMaskConvertOctals = 3 << 28,
kLCValueOptionMaskNumberFormat = 3 << 26,
// The 'value' parameter is a pointer to a bool variable.
kLCValueOptionAsBoolean = 1,
// The 'value' parameter is a pointer to an int variable.
kLCValueOptionAsInteger = 2,
// The 'value' parameter is a pointer to a double variable.
kLCValueOptionAsReal = 4,
// The 'value' parameter is a pointer to an LCBytes variable.
kLCValueOptionAsCData = 5,
// The 'value' parameter is a pointer to a char * variable (native encoding)
kLCValueOptionAsCString = 6,
// SN-2014-07-01: [[ ExternalsApiV6 ]] Unicode strings
// The 'value' parameter is a point to an LCBytes storing a UTF-8-encoded string
kLCValueOptionAsUTF8CData = 7,
// The 'value' parameter is a point to a char * variable (UTF-8 encoding)
kLCValueOptionAsUTF8CString = 8,
// The 'value' parameter is a point to an LCBytes storing a UTF-16-encoded string
kLCValueOptionAsUTF16CData = 9,
// The 'value' parameter is a point to a uint16_t * variable (UTF-16 encoding)
kLCValueOptionAsUTF16CString = 10,
// The 'value' parameter is a pointer to an LCArrayRef variable.
kLCValueOptionAsLCArray = 16,
// The 'value' parameter is a pointer to an NSNumber* variable.
kLCValueOptionAsObjcNumber = 17,
// The 'value' parameter is a pointer to an NSString* variable.
kLCValueOptionAsObjcString = 18,
// The 'value' parameter is a pointer to an NSData* variable.
kLCValueOptionAsObjcData = 19,
// The 'value' parameter is a pointer to an NSArray* variable.
kLCValueOptionAsObjcArray = 20,
// The 'value' parameter is a pointer to an NSDictionary *variable.
kLCValueOptionAsObjcDictionary = 21,
// The 'value' parameter is a pointer to a char variable (native encoding)
kLCValueOptionAsCChar = 22,
// SN-2015-02-13: [[ ExternalsApiV6 ]] Added CF-type arguments, which
// are NOT autoreleased when used as input
// The 'value' parameter is a pointer to an CFNumberRef variable.
kLCValueOptionAsCFNumber = 23,
// The 'value' parameter is a pointer to an CFStringRef variable.
kLCValueOptionAsCFString = 24,
// The 'value' parameter is a pointer to an CFDataRef variable.
kLCValueOptionAsCFData = 25,
// The 'value' parameter is a pointer to an CFArrayRef variable.
kLCValueOptionAsCFArray = 26,
// The 'value' parameter is a pointer to an CFDictionaryRef variable.
kLCValueOptionAsCFDictionary = 27,
// Treat array keys as case-insensitive.
kLCValueOptionCaseSensitiveFalse = 0 << 30,
// Treat array keys as case-sensitive.
kLCValueOptionCaseSensitiveTrue = 1 << 30,
// Treat array keys case-sensitivity using the current caseSensitive value
// in effect in the calling (LiveCode) handler.
// Must only be used in handler context.
kLCValueOptionCaseSensitiveFromContext = 3 << 30,
// When converting a string to a number, ignore leading 0's.
kLCValueOptionConvertOctalsFalse = 0 << 28,
// When converting a string to a number, treat a leading 0 as indicating
// the number is in base 8.
kLCValueOptionConvertOctalsTrue = 1 << 28,
// When converting a string to a number, treat a leading 0 as per the
// current convertOctals value in effect in the calling (LiveCode) handler.
// Must only be used in handler context.
kLCValueOptionConvertOctalsFromContext = 3 << 28,
// When converting a number to a string, use decimal (not scientific)
// format.
kLCValueOptionNumberFormatDecimal = 0 << 26,
// When converting a number to a string, use standard scientific format
// x.xxxxxxxxxxe+-xxxxx
kLCValueOptionNumberFormatScientific = 1 << 26,
// When converting a number to a string, use decimal or scientific format
// depending on whichever is more compact.
kLCValueOptionNumberFormatCompact = 2 << 26,
// When converting a number to a string, use the current numberFormat
// settings in effect in the calling (LiveCode) handler.
// Must only be used in handler context.
kLCValueOptionNumberFormatFromContext = 3 << 26,
};
enum
{
kLCLicenseEditionNone = 0,
kLCLicenseEditionCommunity = 1000,
kLCLicenseEditionCommunityPlus = 1500,
kLCLicenseEditionIndy = 2000,
kLCLicenseEditionBusiness = 3000,
};
////////////////////////////////////////////////////////////////////////////////
typedef struct __LCArray *LCArrayRef;
LCError LCArrayCreate(unsigned int options, LCArrayRef* r_array);
LCError LCArrayRetain(LCArrayRef array);
LCError LCArrayRelease(LCArrayRef array);
LCError LCArrayCountKeys(LCArrayRef array, unsigned int options, unsigned int *r_count);
LCError LCArrayCountKeysOnPath(LCArrayRef array, unsigned int options, const char **path, unsigned int path_length, unsigned int *r_count);
LCError LCArrayListKeys(LCArrayRef array, unsigned int options, char **key_buffer, unsigned int key_buffer_size);
LCError LCArrayListKeysOnPath(LCArrayRef array, unsigned int options, const char **path, unsigned int path_length, char **key_buffer, unsigned int key_buffer_size);
LCError LCArrayRemoveKeys(LCArrayRef array, unsigned int options);
LCError LCArrayRemoveKeysOnPath(LCArrayRef array, unsigned int options, const char **path, unsigned int path_length);
LCError LCArrayHasKey(LCArrayRef array, unsigned int options, const char *key, bool *r_exists);
LCError LCArrayHasKeyOnPath(LCArrayRef array, unsigned int options, const char **path, unsigned int path_length, const char *key, bool *r_exists);
LCError LCArrayHasKeyWithPath(LCArrayRef array, unsigned int options, const char **path, unsigned int path_length, bool *r_exists);
LCError LCArrayFetchKey(LCArrayRef array, unsigned int options, const char *key, void *r_value);
LCError LCArrayFetchKeyOnPath(LCArrayRef array, unsigned int options, const char **path, unsigned int path_length, const char *key, void *r_value);
LCError LCArrayFetchKeyWithPath(LCArrayRef array, unsigned int options, const char **path, unsigned int path_length, void *r_value);
LCError LCArrayLookupKey(LCArrayRef array, unsigned int options, const char *key, bool *r_exists, void *r_value);
LCError LCArrayLookupKeyOnPath(LCArrayRef array, unsigned int options, const char **path, unsigned int path_length, const char *key, bool *r_exists, void *r_value);
LCError LCArrayLookupKeyWithPath(LCArrayRef array, unsigned int options, const char **path, unsigned int path_length, bool *r_exists, void *r_value);
LCError LCArrayStoreKey(LCArrayRef array, unsigned int options, const char *key, void *value);
LCError LCArrayStoreKeyOnPath(LCArrayRef array, unsigned int options, const char **path, unsigned int path_length, const char *key, void *value);
LCError LCArrayStoreKeyWithPath(LCArrayRef array, unsigned int options, const char **path, unsigned int path_length, void *value);
LCError LCArrayRemoveKey(LCArrayRef array, unsigned int options, const char *key);
LCError LCArrayRemoveKeyOnPath(LCArrayRef array, unsigned int options, const char **path, unsigned int path_length, const char *key);
LCError LCArrayRemoveKeyWithPath(LCArrayRef array, unsigned int options, const char **path, unsigned int path_length);
////////////////////////////////////////////////////////////////////////////////
#ifdef __ANDROID__
// Function:
// LCAttachCurrentThread
// Parameters:
// none
// Errors:
// Failed - System was unable to attach the current thread to the Java VM
//
LCError LCAttachCurrentThread(void);
// Function:
// LCDetachCurrentThread
// Parameters:
// none
// Errors:
// Failed - System was unable to detach the current thread from the Java VM
//
LCError LCDetachCurrentThread(void);
#endif
////////////////////////////////////////////////////////////////////////////////
typedef struct __LCObject *LCObjectRef;
// Parameters:
// LCObjectResolve
// Parmaeters:
// (in) chunk - const char *
// (out) r_object - LCObjectRef
// Errors:
// OutOfMemory - memory ran out while attempting to perform the operation
// NoObjectId - the 'chunk' parameter was nil
// MalformedObjectChunk - a parse error occurred processing 'chunk'
// CouldNotResolveObject - the object referred to by 'chunk' could not be found
// Context Safety:
// Must be called from dispatch context.
// Semantics:
// Parses the 'chunk' parameter as an object reference and attempts to locate
// it. If no error occurs, a weak object handle is returned in 'r_object'.
//
// The caller is responsible for calling 'LCObjectRelease' on the handle when
// it is no longer needed.
//
// A weak object handle is an indirect reference to a LiveCode object. It's
// lifespan is independent of that of the target object and is controlled by
// a reference count.
//
LCError LCObjectResolve(const char *chunk, LCObjectRef *r_object);
// Function:
// LCObjectExists
// Parameters:
// (in) object - LCObjectRef
// (out) r_exists - bool
// Errors:
// NoObject - the 'object' parameter was nil
// Context Safety:
// Must be called from dispatch context.
// Semantics:
// Checks to see if the object referred to by the handle 'object' still
// exists. The 'r_exists' parameter is set to 'true' if it is still there, or
// 'false' otherwise.
//
//
LCError LCObjectExists(LCObjectRef object, bool *r_exists);
// Function:
// LCObjectRetain
// Parameters:
// (in) object - LCObjectRef
// Errors:
// NoObject - the 'object' parameter was nil
// Context Safety:
// Must be called from dispatch context.
// Semantics:
// Increase the reference count of the handle passed in 'object'.
//
LCError LCObjectRetain(LCObjectRef object);
// Function:
// LCObjectRelease
// Parameters:
// (in) object - LCObjectRef
// Errors:
// NoObject - the 'object' parameter was nil
// Context Safety:
// Must be called from dispatch context.
// Semantics:
// Decrease the reference count of the handle passed in 'object'. If the
// reference count reaches zero, the handle is destroyed and is no longer
// valid.
//
LCError LCObjectRelease(LCObjectRef object);
// Function:
// LCObjectSend
// Parameters:
// (in) object - LCObjectRef
// (in) message - const char *
// (in) signature - const char *
// (in) ... - variadic argument list
// Errors:
// OutOfMemory - memory ran out while attempting to perform the operation
// NoObject - the 'object' parameter was nil
// NoObjectMessage - the 'message' parameter was nil
// ObjectDoesNotExist - the object handles target no longer exists
// Exited - the message caused 'exit to top' to be called
// Failed - the message caused an error to be thrown
// Context Safety:
// Must be called in dispatch context.
// Semantics:
// Sends 'message' to 'object' with the given parameters. The caller blocks
// until the message has been handled.
//
// The parameter list is constructed based on the 'signature' c-string. Each
// character in the signature determines the type of the subsequent arguments
// and is used to convert them to a form suitable for LiveCode script.
//
// The characters that are currently understood are:
// 'b' - the parameter is of 'bool' type, converts to 'true' or 'false'
// 'i' - the parameter is of 'int' type, converts to a number
// 'r' - the parameter is of 'double' type, converts to a number
// 'z' - the parameter is of 'c-string' type, converts to a (text) string
// 'u' - the parameter is of 'utf8 c-string' type, converts to a (text) string
// 'w' - the parameter is of 'utf16 c-string' type, converts to a (text) string
// 'y' - the parameter is of 'c-data' type, converts to a (binary) string
// 'v' - the parameter is of 'utf8 c-data' type, converts to a (text) string
// 't' - the parameter is of 'utf16 c-data' type, converts to a (text) string
// 'c' - the parameter is of 'char' type, converts to a (text) string
// 'N' - the parameter is of 'NSNumber*' type, converts to a number
// 'S' - the parameter is of 'NSString*' type, converts to a (text) string
// 'D' - the parameter is of 'NSData*' type, converts to a (binary) string
// 'A' - the parameter is of 'NSArray*' type, converts to a sequentially indexed array
// 'M' - the parameter is of 'NSDictionary*' type, converts to a key/value map array
//
// The parameters appear in the resulting LiveCode message in the same order
// that they appear in the signature.
//
// The 'z' & 'u' types should be passed a 'const char *' (zero-terminated) string.
// The 'w' type should be passed a 'const uint16_t *' (zero-terminated) string.
// The 'y','v' & 't' types should be passed a 'const LCBytes *' type.
//
LCError LCObjectSend(LCObjectRef object, const char *message, const char *signature, ...);
// Function:
// LCObjectPost
// Parameters:
// (in) object - LCObjectRef
// (in) message - const char *
// (in) signature - const char *
// (in) ... - variadic argument list
// Errors:
// OutOfMemory - memory ran out while attempting to perform the operation
// NoObject - the 'object' parameter was nil
// NoObjectMessage - the 'message' parameter was nil
// ObjectDoesNotExist - the object handles target no longer exists
// Context Safety:
// May be called in universal context.
// Semantics:
// Appends an event to the internal event queue. When the event is dispatched
// 'message' is sent to the target object with the given parameters.
//
// Note: Posting from an auxillary thread will block until the main thread
// reaches a suitable point to process the request and schedule the event.
//
LCError LCObjectPost(LCObjectRef object, const char *message, const char *signature, ...);
// Function:
// LCObjectGet
// Parameters:
// (in) object - LCObjectRef
// (in) options - unsigned int
// (in) property - const char *
// (in) key - const char *
// (out) value - depends on options
// Errors:
// OutOfMemory - memory ran out while attempting to perform the operation
// NoObject - the 'object' parameter was nil
// NoObjectProperty - the 'property' parameter was nil
// NoObjectPropertyValue - the 'value' parameter was nil
// ObjectDoesNotExist - the object handles target no longer exists
// Exited - the message caused 'exit to top' to be called
// Failed - the message caused an error to be thrown
// NotABoolean - the value was requested as a boolean, and it is not a boolean
// NotANumber - the value was requested as a number, and it is not a number
// NotAnInteger - the value was requested as an integer, and it is not an
// integer
// NotABinaryString - the value was requested as binary data, and it is not
// binary data
// NotAString - the value was requested as a string, and it is not a string
// NotAnArray - the value was requested as an array, and it is not an array
// NotAChar - the value was requested as a char, and it is not a char
// Context Safety:
// Must be called in dispatch context.
// Semantics:
// Fetches the value of the given (array) property from the specified object
// and returns the value in the way specified by 'options'. The usage of
// options and values is as described in the section on 'values'.
//
// This method works in an identical way to property fetching in script.
//
// i.e.
// LCObjectGet(object, ..., property, NULL, value)
// is the same as:
// put the <property> of <object> into <value>
//
// i.e.
// LCObjectGet(object, ..., property, key, value)
// is the same as:
// put the <property>[<key>] of <object> into <value>
//
// Note that just like the script analogs, if <property> is not an engine
// property custom properties are used (with getprop messages dispatched as
// needed), and thus the current custom property set of the object comes into
// effect when required.
//
LCError LCObjectGet(LCObjectRef object, unsigned int options, const char *property, const char *key, void *value);
// Function:
// LCObjectSet
// Parameters:
// (in) object - LCObjectRef
// (in) options - unsigned int
// (in) property - const char *
// (in) key - const char *
// (out) value - depends on options
// Errors:
// OutOfMemory - memory ran out while attempting to perform the operation
// NoObject - the 'object' parameter was nil
// NoObjectProperty - the 'property' parameter was nil
// NoObjectPropertyValue - the 'value' parameter was nil
// ObjectDoesNotExist - the object handles target no longer exists
// Exited - the message caused 'exit to top' to be called
// Failed - the message caused an error to be thrown
// NotABoolean - the value was requested as a boolean, and it is not a boolean
// NotANumber - the value was requested as a number, and it is not a number
// NotAnInteger - the value was requested as an integer, and it is not an
// integer
// NotABinaryString - the value was requested as binary data, and it is not
// binary data
// NotAString - the value was requested as a string, and it is not a string
// NotAnArray - the value was requested as an array, and it is not an array
// NotAChar - the value was requested as a char, and it is not a char
// Context Safety:
// Must be called in dispatch context.
// Semantics:
// Sets the value of the given (array) property to the given value in the way
// specified by 'options'. The usage of options and values is as described in
// the section on 'values'.
//
// This method works in an identical way to property setting in script.
//
// i.e.
// LCObjectSet(object, ..., property, NULL, value)
// is the same as:
// set the <property> of <object> to <value>
//
// i.e.
// LCObjectSet(object, ..., property, key, value)
// is the same as:
// set the <property>[<key>] of <object> to <value>
//
// Note that just like the script analogs, if <property> is not an engine
// property custom properties are used (with setprop messages dispatched as
// needed), and thus the current custom property set of the object comes into
// effect when required.
//
LCError LCObjectSet(LCObjectRef object, unsigned int options, const char *property, const char *key, void *value);
////////////////////////////////////////////////////////////////////////////////
// Function:
// LCContextMe
// Parameters:
// (out) r_me - LCObjectRef
// Errors:
// OutOfMemory - memory ran out while attempting to perform the operation
// Context Safety:
// Must be called from handler context.
// Semantics:
// Returns a weak object handle to object's whose script invoked the external
// handler.
//
// The caller is responsible for calling 'LCObjectRelease' on the handle when
// it is no longer needed.
//
LCError LCContextMe(LCObjectRef *r_me);
// Function:
// LCContextTarget
// Parameters:
// (out) r_target - LCObjectRef
// Errors:
// OutOfMemory - memory ran out while attempting to perform the operation
// Context Safety:
// Must be called from handler context.
// Semantics:
// Returns a weak object handle to 'the target'.
//
// The caller is responsible for calling 'LCObjectRelease' on the handle when
// it is no longer needed.
//
LCError LCContextTarget(LCObjectRef *r_target);
// Function:
// LCContextDefaultStack
// Parameters:
// (out) r_default_stack - LCObjectRef
// Errors:
// OutOfMemory - memory ran out while attempting to perform the operation
// Context Safety:
// Must be called from handler context.
// Semantics:
// Returns a weak object handle to 'the defaultStack'.
//
// The caller is responsible for calling 'LCObjectRelease' on the handle when
// it is no longer needed.
//
LCError LCContextDefaultStack(LCObjectRef *r_default_stack);
// Function:
// LCContextDefaultCard
// Parameters:
// (out) r_default_card - LCObjectRef
// Errors:
// OutOfMemory - memory ran out while attempting to perform the operation
// Context Safety:
// Must be called from handler context.
// Semantics:
// Returns a weak object handle to 'this card of the defaultStack'.
//
// The caller is responsible for calling 'LCObjectRelease' on the handle when
// it is no longer needed.
//
LCError LCContextDefaultCard(LCObjectRef *r_default_card);
// Function:
// LCContextCaseSensitive
// Parameters:
// (out) r_case_sensitive - bool
// Errors:
// OutOfMemory - memory ran out while attempting to perform the operation
// Context Safety:
// Must be called from handler context.
// Semantics:
// Returns a the current value of the local 'caseSensitive' property.
//
LCError LCContextCaseSensitive(bool* r_case_sensitive);
// Function:
// LCContextConvertOctals
// Parameters:
// (out) r_convert_octals - bool
// Errors:
// OutOfMemory - memory ran out while attempting to perform the operation
// Context Safety:
// Must be called from handler context.
// Semantics:
// Returns a the current value of the local 'convertOctals' property.
//
LCError LCContextConvertOctals(bool *r_convert_octals);
// Function:
// LCContextWholeMatches
// Parameters:
// (out) r_whole_matches - bool
// Errors:
// OutOfMemory - memory ran out while attempting to perform the operation
// Context Safety:
// Must be called from handler context.
// Semantics:
// Returns a the current value of the local 'wholeMatches' property.
//
LCError LCContextWholeMatches(bool* r_whole_matches);
// Function:
// LCContextItemDelimiter
// Parameters:
// (in) options - unsigned int
// (out) value - depends on options
// Errors:
// OutOfMemory - memory ran out while attempting to perform the operation
// NotABoolean - the value was requested as a boolean, and it is not a boolean
// NotANumber - the value was requested as a number, and it is not a number
// NotAnInteger - the value was requested as an integer, and it is not an
// integer
// NotABinaryString - the value was requested as binary data, and it is not
// binary data
// NotAString - the value was requested as a string, and it is not a string
// NotAnArray - the value was requested as an array, and it is not an array
// NotAChar - the value was requested as a char, and it is not a char
// Context Safety:
// Must be called from handler context.
// Semantics:
// Returns a the current value of the local 'itemDelimiter' property.
//
LCError LCContextItemDelimiter(unsigned int options, void *r_value);
// Function:
// LCContextLineDelimiter
// Parameters:
// (in) options - unsigned int
// (out) value - depends on options
// Errors:
// OutOfMemory - memory ran out while attempting to perform the operation
// NotABoolean - the value was requested as a boolean, and it is not a boolean
// NotANumber - the value was requested as a number, and it is not a number
// NotAnInteger - the value was requested as an integer, and it is not an
// integer
// NotABinaryString - the value was requested as binary data, and it is not
// binary data
// NotAString - the value was requested as a string, and it is not a string
// NotAnArray - the value was requested as an array, and it is not an array
// NotAChar - the value was requested as a char, and it is not a char
// Context Safety:
// Must be called from handler context.
// Semantics:
// Returns a the current value of the local 'lineDelimiter' property.
//
LCError LCContextLineDelimiter(unsigned int options, void *r_value);
// Function:
// LCContextColumnDelimiter
// Parameters:
// (in) options - unsigned int
// (out) value - depends on options
// Errors:
// OutOfMemory - memory ran out while attempting to perform the operation
// NotABoolean - the value was requested as a boolean, and it is not a boolean
// NotANumber - the value was requested as a number, and it is not a number
// NotAnInteger - the value was requested as an integer, and it is not an
// integer
// NotABinaryString - the value was requested as binary data, and it is not
// binary data
// NotAString - the value was requested as a string, and it is not a string
// NotAnArray - the value was requested as an array, and it is not an array
// NotAChar - the value was requested as a char, and it is not a char
// Context Safety:
// Must be called from handler context.
// Semantics:
// Returns a the current value of the local 'columnDelimiter' property.
//
LCError LCContextColumnDelimiter(unsigned int options, void *r_value);
// Function:
// LCContextRowDelimiter
// Parameters:
// (in) options - unsigned int
// (out) value - depends on options
// Errors:
// OutOfMemory - memory ran out while attempting to perform the operation
// NotABoolean - the value was requested as a boolean, and it is not a boolean
// NotANumber - the value was requested as a number, and it is not a number
// NotAnInteger - the value was requested as an integer, and it is not an
// integer
// NotABinaryString - the value was requested as binary data, and it is not
// binary data
// NotAString - the value was requested as a string, and it is not a string
// NotAnArray - the value was requested as an array, and it is not an array
// NotAChar - the value was requested as a char, and it is not a char
// Context Safety:
// Must be called from handler context.
// Semantics:
// Returns a the current value of the local 'rowDelimiter' property.
//
LCError LCContextRowDelimiter(unsigned int options, void *r_value);
// Function:
// LCContextUnicodeItemDelimiter
// Parameters:
// (in) options - unsigned int
// (out) value - depends on options
// Errors:
// OutOfMemory - memory ran out while attempting to perform the operation
// NotABoolean - the value was requested as a boolean, and it is not a boolean
// NotANumber - the value was requested as a number, and it is not a number
// NotAnInteger - the value was requested as an integer, and it is not an
// integer
// NotABinaryString - the value was requested as binary data, and it is not
// binary data
// NotAString - the value was requested as a string, and it is not a string
// NotAnArray - the value was requested as an array, and it is not an array
// NotAChar - the value was requested as a char, and it is not a char
// Context Safety:
// Must be called from handler context.
// This function will only work if the external is called by an engine post-7.0
// and return NotImplemented for the earlier versions.
// The returned value must be free'd by the caller of this function.
// Semantics:
// Returns a the current value of the local 'itemDelimiter' property.
//
LCError LCContextUnicodeItemDelimiter(unsigned int options, void *r_value);
// Function:
// LCContextUnicodeLineDelimiter
// Parameters:
// (in) options - unsigned int
// (out) value - depends on options
// Errors:
// OutOfMemory - memory ran out while attempting to perform the operation
// NotABoolean - the value was requested as a boolean, and it is not a boolean
// NotANumber - the value was requested as a number, and it is not a number
// NotAnInteger - the value was requested as an integer, and it is not an
// integer
// NotABinaryString - the value was requested as binary data, and it is not
// binary data
// NotAString - the value was requested as a string, and it is not a string
// NotAnArray - the value was requested as an array, and it is not an array
// NotAChar - the value was requested as a char, and it is not a char
// Context Safety:
// Must be called from handler context.
// This function will only work if the external is called by an engine post-7.0
// and return NotImplemented for the earlier versions.
// The returned value must be free'd by the caller of this function.
// Semantics:
// Returns a the current value of the local 'lineDelimiter' property.
//
LCError LCContextUnicodeLineDelimiter(unsigned int options, void *r_value);
// Function:
// LCContextUnicodeColumnDelimiter
// Parameters:
// (in) options - unsigned int