Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
appinventor-sources
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
appinventor-sources
Commits
eb147ef0
Commit
eb147ef0
authored
Feb 07, 2020
by
Evan W. Patton
Committed by
Jeffrey Schiller
Feb 18, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix dictionary issues with String/FString mismatch
Change-Id: If4549950bac9bd0aa35efdb7f5f77f70242cfe38
parent
6a9dbfd3
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
63 additions
and
6 deletions
+63
-6
appinventor/blocklyeditor/src/generators/yail.js
appinventor/blocklyeditor/src/generators/yail.js
+1
-1
appinventor/buildserver/src/com/google/appinventor/buildserver/resources/runtime.scm
.../com/google/appinventor/buildserver/resources/runtime.scm
+0
-4
appinventor/components/src/com/google/appinventor/components/runtime/util/YailDictionary.java
...e/appinventor/components/runtime/util/YailDictionary.java
+43
-1
appinventor/components/tests/com/google/appinventor/components/runtime/util/YailDictionaryTest.java
...pinventor/components/runtime/util/YailDictionaryTest.java
+19
-0
No files found.
appinventor/blocklyeditor/src/generators/yail.js
View file @
eb147ef0
...
...
@@ -52,7 +52,7 @@ Blockly.Yail.YAIL_CLOSE_BLOCK = ")\n";
Blockly
.
Yail
.
YAIL_COMMENT_MAJOR
=
"
;;;
"
;
Blockly
.
Yail
.
YAIL_COMPONENT_REMOVE
=
"
(remove-component
"
;
Blockly
.
Yail
.
YAIL_COMPONENT_TYPE
=
"
component
"
;
Blockly
.
Yail
.
YAIL_CONSTANT_ALL
=
'
com.google.appinventor.components.runtime.util.YailDictionary:ALL
'
;
Blockly
.
Yail
.
YAIL_CONSTANT_ALL
=
'
(static-field com.google.appinventor.components.runtime.util.YailDictionary
\'
ALL)
'
;
Blockly
.
Yail
.
YAIL_DEFINE
=
"
(def
"
;
Blockly
.
Yail
.
YAIL_DEFINE_EVENT
=
"
(define-event
"
;
Blockly
.
Yail
.
YAIL_DEFINE_GENERIC_EVENT
=
'
(define-generic-event
'
;
...
...
appinventor/buildserver/src/com/google/appinventor/buildserver/resources/runtime.scm
View file @
eb147ef0
...
...
@@ -2497,8 +2497,6 @@ Dictionary implementation.
(
*:remove
(
as
YailDictionary
yail-dictionary
)
key
))
(
define
(
yail-dictionary-lookup
key
yail-dictionary
default
)
(
android-log
(
format
#f
"Dictionary lookup key is ~A and table is ~A"
key
yail-dictionary
))
(
let
((
result
(
cond
((
instance?
yail-dictionary
YailList
)
(
yail-alist-lookup
key
yail-dictionary
default
))
...
...
@@ -2534,8 +2532,6 @@ Dictionary implementation.
(
*:size
(
as
YailDictionary
yail-dictionary
)))
(
define
(
yail-dictionary-alist-to-dict
alist
)
(
android-log
(
format
#f
"List alist table is ~A"
alist
))
(
let
loop
((
pairs-to-check
(
yail-list-contents
alist
)))
(
cond
((
null?
pairs-to-check
)
"The list of pairs has a null pair"
)
((
not
(
pair-ok?
(
car
pairs-to-check
)))
...
...
appinventor/components/src/com/google/appinventor/components/runtime/util/YailDictionary.java
View file @
eb147ef0
...
...
@@ -512,6 +512,49 @@ public class YailDictionary extends LinkedHashMap<Object, Object>
}
}
@Override
public
boolean
containsKey
(
Object
key
)
{
if
(
key
instanceof
FString
)
{
return
super
.
containsKey
(
key
.
toString
());
}
return
super
.
containsKey
(
key
);
}
@Override
public
boolean
containsValue
(
Object
value
)
{
if
(
value
instanceof
FString
)
{
return
super
.
containsValue
(
value
.
toString
());
}
return
super
.
containsValue
(
value
);
}
@Override
public
Object
get
(
Object
key
)
{
if
(
key
instanceof
FString
)
{
return
super
.
get
(
key
.
toString
());
}
return
super
.
get
(
key
);
}
@Override
public
Object
put
(
Object
key
,
Object
value
)
{
if
(
key
instanceof
FString
)
{
key
=
key
.
toString
();
}
if
(
value
instanceof
FString
)
{
value
=
value
.
toString
();
}
return
super
.
put
(
key
,
value
);
}
@Override
public
Object
remove
(
Object
key
)
{
if
(
key
instanceof
FString
)
{
return
super
.
remove
(
key
.
toString
());
}
return
super
.
remove
(
key
);
}
@Override
public
String
toString
()
{
try
{
...
...
@@ -539,7 +582,6 @@ public class YailDictionary extends LinkedHashMap<Object, Object>
}
@NonNull
@SuppressWarnings
(
"NullableProblems"
)
@Override
public
Iterator
<
YailList
>
iterator
()
{
return
new
DictIterator
(
entrySet
().
iterator
());
...
...
appinventor/components/tests/com/google/appinventor/components/runtime/util/YailDictionaryTest.java
View file @
eb147ef0
...
...
@@ -14,6 +14,7 @@ import static org.junit.Assert.assertFalse;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
import
static
org
.
junit
.
Assert
.
assertNotSame
;
import
static
org
.
junit
.
Assert
.
assertNull
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
com.google.appinventor.components.runtime.collect.Lists
;
import
com.google.appinventor.components.runtime.errors.DispatchableError
;
...
...
@@ -159,6 +160,24 @@ public class YailDictionaryTest {
dict
.
setValueForKeyPath
(
Arrays
.
asList
((
Object
)
"foo"
,
-
1
),
false
);
}
@Test
public
void
testFString
()
{
YailDictionary
target
=
new
YailDictionary
();
target
.
put
(
"key"
,
"value"
);
target
.
put
(
new
FString
(
"fstringkey"
),
new
FString
(
"fstringvalue"
));
assertTrue
(
target
.
containsKey
(
new
FString
(
"key"
)));
assertTrue
(
target
.
containsValue
(
new
FString
(
"value"
)));
assertTrue
(
target
.
containsKey
(
"fstringkey"
));
assertTrue
(
target
.
containsValue
(
"fstringvalue"
));
assertEquals
(
"value"
,
target
.
get
(
"key"
));
assertEquals
(
"value"
,
target
.
get
(
new
FString
(
"key"
)));
assertEquals
(
"fstringvalue"
,
target
.
get
(
"fstringkey"
));
assertEquals
(
"fstringvalue"
,
target
.
get
(
new
FString
(
"fstringkey"
)));
target
.
remove
(
new
FString
(
"key"
));
target
.
remove
(
new
FString
(
"fstringkey"
));
assertTrue
(
target
.
isEmpty
());
}
@Test
public
void
testToString
()
{
YailDictionary
dict
=
YailDictionary
.
makeDictionary
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment