Skip to content

Commit ef1d9d5

Browse files
committed
Merge branch 'feature/externals_v5' of https://github.com/montegoulding/livecode into feature-externals_api_v5
2 parents 14f28fe + 9f2cbd4 commit ef1d9d5

File tree

4 files changed

+93
-47
lines changed

4 files changed

+93
-47
lines changed

lcidlc/lcidlc.vcproj

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,10 @@
167167
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
168168
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
169169
>
170+
<File
171+
RelativePath=".\src\Coder.cpp"
172+
>
173+
</File>
170174
<File
171175
RelativePath=".\src\Error.cpp"
172176
>
@@ -209,6 +213,10 @@
209213
Filter="h;hpp;hxx;hm;inl;inc;xsd"
210214
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
211215
>
216+
<File
217+
RelativePath=".\src\Coder.h"
218+
>
219+
</File>
212220
<File
213221
RelativePath=".\src\Error.h"
214222
>
@@ -272,7 +280,7 @@
272280
>
273281
<Tool
274282
Name="VCCustomBuildTool"
275-
CommandLine="&quot;$(SolutionDir)prebuilt\bin\Revolution.exe&quot; &quot;$(ProjectDir)encode_source.rev&quot; &quot;$(InputPath)&quot; &quot;$(InputDir)EncodedJavaSupport.c&quot; &quot;g_java_support_template&quot;"
283+
CommandLine="&quot;$(SolutionDir)prebuilt\bin\Revolution.exe&quot; &quot;$(ProjectDir)encode_source.rev&quot; &quot;$(InputPath)&quot; &quot;$(InputDir)EncodedJavaSupport.c&quot; &quot;g_java_support_template&quot;&#x0D;&#x0A;"
276284
Outputs="$(InputDir)EncodedJavaSupport.c"
277285
/>
278286
</FileConfiguration>
@@ -281,7 +289,7 @@
281289
>
282290
<Tool
283291
Name="VCCustomBuildTool"
284-
CommandLine="&quot;$(SolutionDir)prebuilt\bin\Revolution.exe&quot; &quot;$(ProjectDir)encode_source.rev&quot; &quot;$(InputPath)&quot; &quot;$(InputDir)EncodedJavaSupport.c&quot; &quot;g_java_support_template&quot;"
292+
CommandLine="&quot;$(SolutionDir)prebuilt\bin\Revolution.exe&quot; &quot;$(ProjectDir)encode_source.rev&quot; &quot;$(InputPath)&quot; &quot;$(InputDir)EncodedJavaSupport.c&quot; &quot;g_java_support_template&quot;&#x0D;&#x0A;"
285293
Outputs="$(InputDir)EncodedJavaSupport.c"
286294
/>
287295
</FileConfiguration>
@@ -294,7 +302,7 @@
294302
>
295303
<Tool
296304
Name="VCCustomBuildTool"
297-
CommandLine="&quot;$(SolutionDir)prebuilt\bin\Revolution.exe&quot; &quot;$(ProjectDir)encode_source.rev&quot; &quot;$(InputPath)&quot; &quot;$(InputDir)EncodedSupport.c&quot; &quot;g_support_template&quot;"
305+
CommandLine="&quot;$(SolutionDir)prebuilt\bin\Revolution.exe&quot; &quot;$(ProjectDir)encode_source.rev&quot; &quot;$(InputPath)&quot; &quot;$(InputDir)EncodedSupport.c&quot; &quot;g_support_template&quot;&#x0D;&#x0A;"
298306
Outputs="$(InputDir)EncodedSupport.c"
299307
/>
300308
</FileConfiguration>
@@ -303,7 +311,7 @@
303311
>
304312
<Tool
305313
Name="VCCustomBuildTool"
306-
CommandLine="&quot;$(SolutionDir)prebuilt\bin\Revolution.exe&quot; &quot;$(ProjectDir)encode_source.rev&quot; &quot;$(InputPath)&quot; &quot;$(InputDir)EncodedSupport.c&quot; &quot;g_support_template&quot;"
314+
CommandLine="&quot;$(SolutionDir)prebuilt\bin\Revolution.exe&quot; &quot;$(ProjectDir)encode_source.rev&quot; &quot;$(InputPath)&quot; &quot;$(InputDir)EncodedSupport.c&quot; &quot;g_support_template&quot;&#x0D;&#x0A;"
307315
Outputs="$(InputDir)EncodedSupport.c"
308316
/>
309317
</FileConfiguration>

lcidlc/src/InterfaceGenerate.cpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ class CStringTypeMapper: public CTypesTypeMapper
363363

364364
virtual void Default(CoderRef p_coder, ParameterType p_mode, const char *p_name, ValueRef p_value)
365365
{
366-
CoderWriteStatement(p_coder, "success = default__%s(\"%s\", %s)", StringGetCStringPtr(p_value), p_name);
366+
CoderWriteStatement(p_coder, "success = default__cstring(\"%s\", %s)", StringGetCStringPtr(p_value), p_name);
367367
CodeInOutCopy(p_coder, p_mode, p_name);
368368
}
369369

@@ -496,7 +496,7 @@ class JavaStringTypeMapper: public TypeMapper
496496

497497
virtual void Default(CoderRef p_coder, ParameterType p_mode, const char *p_name, ValueRef p_value)
498498
{
499-
CoderWriteStatement(p_coder, "%s = default__java_string(__java_env, \"%s\", %s)", StringGetCStringPtr(p_value), p_name);
499+
CoderWriteStatement(p_coder, "success = default__java_string(__java_env, \"%s\", %s)", StringGetCStringPtr(p_value), p_name);
500500
}
501501

502502
virtual void Store(CoderRef p_coder, ParameterType p_mode, const char *p_name, const char *p_target)
@@ -1088,7 +1088,7 @@ static void map_parameter(InterfaceRef self, HandlerMapping p_mapping, HandlerPa
10881088
r_param . is_optional = p_parameter -> is_optional;
10891089
}
10901090

1091-
static bool InterfaceGenerateVariant(InterfaceRef self, CoderRef p_coder, Handler *p_handler, HandlerVariant *p_variant, HandlerMapping p_mapping)
1091+
static void InterfaceGenerateVariant(InterfaceRef self, CoderRef p_coder, Handler *p_handler, HandlerVariant *p_variant, HandlerMapping p_mapping)
10921092
{
10931093
Handler *t_handler;
10941094
t_handler = p_handler;
@@ -1249,17 +1249,11 @@ static bool InterfaceGenerateVariant(InterfaceRef self, CoderRef p_coder, Handle
12491249
}
12501250
else
12511251
CoderWrite(p_coder, "%s(", NameGetCString(t_variant -> binding));
1252+
1253+
for(uint32_t k = 0; k < p_variant -> parameter_count; k++)
1254+
CoderWrite(p_coder, ", %s", t_mapped_params[k] . var_name);
12521255

1253-
for(uint32_t k = 0; k < t_variant -> parameter_count; k++)
1254-
{
1255-
HandlerParameter *t_parameter;
1256-
t_parameter = &t_variant -> parameters[k];
1257-
if (k > 0 || t_variant -> return_type_indirect)
1258-
CoderWrite(p_coder, ", ");
1259-
CoderWrite(p_coder, "%sparam__%s", t_parameter -> mode == kParameterTypeInOut || t_parameter -> mode == kParameterTypeOut ? t_ref_char : "", NameGetCString(t_parameter -> name));
1260-
}
1261-
1262-
CoderWrite(p_coder, ")");
1256+
CoderWrite(p_coder, ")");
12631257

12641258
CoderEndStatement(p_coder);
12651259

@@ -1301,8 +1295,14 @@ static bool InterfaceGenerateVariant(InterfaceRef self, CoderRef p_coder, Handle
13011295
CoderWrite(p_coder, "returnvalue = __java_env -> CallStatic%sMethod(s_java_class, s_method", t_java_method_type);
13021296
else
13031297
CoderWrite(p_coder, "__java_env -> CallStaticVoidMethod(s_java_class, s_method");
1304-
for(uindex_t i = 0; i < p_variant -> parameter_count; i++)
1305-
CoderWrite(p_coder, ", t_param_%d", i);
1298+
1299+
for(uint32_t k = 0; k < p_variant -> parameter_count; k++)
1300+
{
1301+
HandlerParameter *t_parameter;
1302+
t_parameter = &p_variant -> parameters[k];
1303+
CoderWrite(p_coder, ", param__%s", NameGetCString(t_parameter -> name));
1304+
}
1305+
13061306
CoderWrite(p_coder, ")");
13071307
CoderEndStatement(p_coder);
13081308

@@ -1458,7 +1458,7 @@ static bool InterfaceGenerateHandlers(InterfaceRef self, CoderRef p_coder)
14581458

14591459
CoderWriteLine(p_coder, "static bool handler__%s(MCVariableRef *argv, uint32_t argc, MCVariableRef result)", NameGetCString(t_handler -> name));
14601460
CoderWriteLine(p_coder, "{");
1461-
CoderWriteLine(p_coder, "\thandler__%s_env_t env;");
1461+
CoderWriteLine(p_coder, "\thandler__%s_env_t env;", NameGetCString(t_handler -> name));
14621462
CoderWriteLine(p_coder, "\tenv . argv = argv;");
14631463
CoderWriteLine(p_coder, "\tenv . argc = argc;");
14641464
CoderWriteLine(p_coder, "\tenv . result = result;");

lcidlc/src/Support.mm

Lines changed: 62 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2913,7 +2913,62 @@ static jobject java__get_engine(void)
29132913
}
29142914

29152915
//////////
2916+
29162917

2918+
static LCError java_from__cstring(JNIEnv *env, const char* p_value, jobject& r_value)
2919+
{
2920+
LCError err;
2921+
err = kLCErrorNone;
2922+
2923+
size_t t_char_count;
2924+
jchar *t_jchar_value;
2925+
t_jchar_value = nil;
2926+
if (err == kLCErrorNone)
2927+
{
2928+
t_char_count = strlen(p_value);
2929+
t_jchar_value = (jchar *)malloc(sizeof(jchar) * t_char_count);
2930+
if (t_jchar_value == nil)
2931+
err = kLCErrorOutOfMemory;
2932+
}
2933+
2934+
if (err == kLCErrorNone)
2935+
{
2936+
for(uint32_t i = 0; i < t_char_count; i++)
2937+
t_jchar_value[i] = p_value[i];
2938+
}
2939+
2940+
jobject t_java_value;
2941+
if (err == kLCErrorNone)
2942+
{
2943+
t_java_value = (jobject)env -> NewString(t_jchar_value, t_char_count);
2944+
if (t_java_value == nil || env -> ExceptionOccurred() != nil)
2945+
{
2946+
env -> ExceptionClear();
2947+
err = kLCErrorOutOfMemory;
2948+
}
2949+
}
2950+
2951+
free(t_jchar_value);
2952+
2953+
if (err == kLCErrorNone)
2954+
r_value = t_java_value;
2955+
2956+
return err;
2957+
}
2958+
2959+
static bool default__java_string(JNIEnv *env, const char *p_value, jobject& r_java_value)
2960+
{
2961+
LCError err;
2962+
err = kLCErrorNone;
2963+
2964+
err = java_from__cstring(env, p_value, r_java_value);
2965+
2966+
if (err == kLCErrorNone)
2967+
return true;
2968+
else
2969+
return error__out_of_memory();
2970+
}
2971+
29172972
static bool fetch__java_string(JNIEnv *env, const char *arg, MCVariableRef var, jobject& r_value)
29182973
{
29192974
LCError err;
@@ -2923,31 +2978,13 @@ static bool fetch__java_string(JNIEnv *env, const char *arg, MCVariableRef var,
29232978
t_cstring_value = nil;
29242979
if (err == kLCErrorNone)
29252980
err = LCValueFetch(var, kLCValueOptionAsCString, &t_cstring_value);
2981+
2982+
jobject t_java_value;
2983+
t_java_value = nil;
2984+
if (err == kLCErrorNone)
2985+
err = java_from__cstring(env, t_cstring_value, t_java_value);
29262986

2927-
size_t t_char_count;
2928-
jchar *t_jchar_value;
2929-
t_jchar_value = nil;
2930-
if (err == kLCErrorNone)
2931-
{
2932-
t_char_count = strlen(t_cstring_value);
2933-
t_jchar_value = (jchar *)malloc(sizeof(jchar) * t_char_count);
2934-
if (t_jchar_value == nil)
2935-
err = kLCErrorOutOfMemory;
2936-
}
2937-
2938-
jobject t_java_value;
2939-
if (err == kLCErrorNone)
2940-
{
2941-
t_java_value = (jobject)env -> NewString(t_jchar_value, t_char_count);
2942-
if (t_java_value == nil || env -> ExceptionOccurred() != nil)
2943-
{
2944-
env -> ExceptionClear();
2945-
err = kLCErrorOutOfMemory;
2946-
}
2947-
}
2948-
2949-
free(t_jchar_value);
2950-
free(t_cstring_value);
2987+
free(t_cstring_value);
29512988

29522989
if (err == kLCErrorNone)
29532990
{
@@ -2957,7 +2994,7 @@ static bool fetch__java_string(JNIEnv *env, const char *arg, MCVariableRef var,
29572994

29582995
return fetch__report_error(err, arg);
29592996
}
2960-
2997+
29612998
static bool fetch__java_data(JNIEnv *env, const char *arg, MCVariableRef var, jobject& r_value)
29622999
{
29633000
LCError err;

revtestexternal/revtestexternal.vcproj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
/>
3939
<Tool
4040
Name="VCCLCompilerTool"
41+
AdditionalOptions="/I &quot;C:\livecode\lcidlc\include&quot;"
4142
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;REVTESTEXTERNAL_EXPORTS"
4243
MinimalRebuild="true"
4344
BasicRuntimeChecks="3"
@@ -200,7 +201,7 @@
200201
>
201202
<Tool
202203
Name="VCCustomBuildTool"
203-
CommandLine="&quot;$(OutDir)\lcidlc.exe&quot; &quot;$(InputPath)&quot; &quot;$(InputPath).cpp&quot;"
204+
CommandLine="&quot;$(OutDir)\lcidlc.exe&quot; &quot;$(InputPath)&quot; &quot;$(InputPath).cpp&quot;&#x0D;&#x0A;"
204205
AdditionalDependencies="$(OutDir)lcidlc.exe"
205206
Outputs="$(InputPath).cpp"
206207
/>
@@ -210,7 +211,7 @@
210211
>
211212
<Tool
212213
Name="VCCustomBuildTool"
213-
CommandLine="&quot;$(OutDir)\lcidlc.exe&quot; &quot;$(InputPath)&quot; &quot;$(InputPath).cpp&quot;"
214+
CommandLine="&quot;$(OutDir)\lcidlc.exe&quot; &quot;$(InputPath)&quot; &quot;$(InputPath).cpp&quot;&#x0D;&#x0A;"
214215
AdditionalDependencies="$(OutDir)lcidlc.exe"
215216
Outputs="$(InputPath).cpp"
216217
/>

0 commit comments

Comments
 (0)