Skip to content

Commit d0a4528

Browse files
committed
[[ Bug 20527 ]] Fix incorrect java binding string parsing
1 parent ce0da83 commit d0a4528

4 files changed

Lines changed: 31 additions & 1 deletion

File tree

docs/lcb/notes/20527.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# LiveCode Builder Foreign Function Interface
2+
3+
# [20527] Parse complex java binding strings correctly
4+

libfoundation/src/foundation-java-private.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,9 @@ static bool __NextArgument(MCStringRef p_arguments, MCRange& x_range)
124124

125125
// Consume the ;
126126
t_length++;
127+
128+
// Correct the length for the starting point
129+
t_length -= x_range.offset;
127130
}
128131

129132
x_range . length = t_length;

tests/lcb/stdlib/java.lcb

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,4 +345,27 @@ public handler TestNativeTypeAfterObjectType()
345345
end unsafe
346346
end handler
347347

348+
__safe foreign handler RegionMatches(in pString as JString, in pCaseless as JBoolean, in pOffset as JInt, in pOther as JString, in pOtherOffset as JInt, in pLength as JInt) returns JBoolean binds to "java:java.lang.String>regionMatches(ZILjava/lang/String;II)Z"
349+
350+
public handler TestBindingStringObjectTypeInMiddle()
351+
if not the operating system is in ["mac", "linux"] then
352+
skip test "called foreign handler with signature Ljava/lang/CharSequence;I" because "not implemented on" && the operating system
353+
return
354+
end if
355+
356+
if the operating system is "linux" then
357+
skip test "called foreign handler with signature Ljava/lang/CharSequence;I" because "bug 19934"
358+
return
359+
end if
360+
361+
variable tString as JString
362+
put StringToJString("something") into tString
363+
364+
variable tOther as JString
365+
put StringToJString("NOTHING") into tOther
366+
367+
test "called foreign handler with signature (ZILjava/lang/String;II)Z" when \
368+
RegionMatches(tString, true, 4, tOther, 2, 5)
369+
end handler
370+
348371
end module

tests/lcb/vm/foreign-binding.lcb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ end handler
3333
---------
3434

3535
foreign handler CreateJavaObject() returns JObject binds to "java:java.lang.Object>new()"
36-
foreign handler CreateJavaObjectDoesntExist() returns JObject binds to "java:java.lang.Object>new_doesnt_exist()"
36+
foreign handler CreateJavaObjectDoesntExist() returns JObject binds to "java:java.lang.Object>new_doesnt_exist()Ljava/lang/Object;"
3737

3838
private handler TestForeignBinding_NonExistentJava()
3939
unsafe

0 commit comments

Comments
 (0)