forked from livecode/livecode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrevtestexternal.mm
More file actions
128 lines (90 loc) · 3.69 KB
/
revtestexternal.mm
File metadata and controls
128 lines (90 loc) · 3.69 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
/* 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/>. */
#include <cstdio>
#include <cstdarg>
#import <Foundation/Foundation.h>
#include <LiveCode.h>
////////////////////////////////////////////////////////////////////////////////
NSArray *revTestExternalTestObjcArrays(NSArray *array)
{
NSMutableArray *t_array = [array mutableCopy];
[t_array addObject:@"Hello"];
return array;
}
NSDictionary *revTestExternalTestObjcDictionaries(NSDictionary *dictionary)
{
id t_content;
t_content = [dictionary objectForKey: @"changeThisValue"];
NSMutableDictionary *t_dictionary = [dictionary mutableCopy];
if (t_content != nil)
[t_dictionary setValue:@"Value Changed!" forKey:@"changeThisValue"];
[t_dictionary setValue: @"Hello" forKey: @"greetings"];
return t_dictionary;
}
NSDictionary *revTestExternalTestSameDictionary(NSDictionary *dictionary)
{
return dictionary;
}
NSDictionary *revTestExternalTestArrayToDictionaryCopy(NSDictionary *p_array)
{
char** t_keys = (char**)malloc(1 * sizeof(char*));
LCArrayRef t_array;
LCArrayRef t_innerarray;
LCArrayCreate(kLCValueOptionCaseSensitiveFalse, &t_array);
LCArrayCreate(kLCValueOptionCaseSensitiveFalse, &t_innerarray);
char *t_value = (char*)malloc(7);
strcpy(t_value, "hidden");
t_value[6] = 0;
LCArrayStoreKey(t_innerarray, kLCValueOptionAsCString, "state", &(t_value));
LCArrayStoreKey(t_array, kLCValueOptionAsLCArray, "innerValue", &t_innerarray);
LCArrayListKeys(t_array, 0, t_keys, 2);
NSMutableDictionary *t_dictionary = [p_array mutableCopy];
for (uint32_t i = 0; i < 1; ++i)
{
bool t_exist;
char *t_value;
LCArrayLookupKey(t_array, kLCValueOptionAsCString, t_keys[i], &t_exist, &t_value);
NSString* t_value_nsstring = [[NSString alloc] initWithCString:t_value encoding:NSMacOSRomanStringEncoding];
NSString* t_key_nsstring = [[NSString alloc] initWithCString:t_keys[i] encoding:NSMacOSRomanStringEncoding];
[t_dictionary setValue:t_value_nsstring forKey:t_key_nsstring];
[t_value_nsstring release];
[t_key_nsstring release];
}
free(t_value);
free(t_keys);
return revTestExternalTestObjcDictionaries(t_dictionary);
}
NSNumber * revTestExternalTestObjcNumber(NSNumber *number)
{
double t_double;
t_double = [number doubleValue];
t_double += 3.14;
return [NSNumber numberWithDouble: t_double];
}
NSData* revTestExternalTestObjcData(NSData* data)
{
char* t_bytes;
uint32_t t_length;
fprintf(stderr, "revTestExternalTestObjcData\n");
t_length = [data length];
t_bytes = (char*)malloc(t_length);
fprintf(stderr, "\tlength: %u\n", t_length);
[data getBytes:t_bytes length:t_length];
for (uint32_t i = 0; i < t_length; ++i)
t_bytes[i]++;
return [NSData dataWithBytes:t_bytes length:t_length];
}
NSString* revTestExternalTestObjcString(NSString* string)
{
return [string stringByAppendingString: string];
}
////////////////////////////////////////////////////////////////////////////////