diff options
| author | Po Lu | 2023-01-28 16:29:22 +0800 |
|---|---|---|
| committer | Po Lu | 2023-01-28 16:29:22 +0800 |
| commit | 198b8160cfeeb178d3b2073c8d03afdafe338908 (patch) | |
| tree | 590c73006536ddfcc8acd8eff8fb80e31c2a009b /java/README | |
| parent | 5bd38905ac67221503f027737912fa0df3602a02 (diff) | |
| download | emacs-198b8160cfeeb178d3b2073c8d03afdafe338908.tar.gz emacs-198b8160cfeeb178d3b2073c8d03afdafe338908.zip | |
Update Android port
* doc/emacs/android.texi (Android File System): Describe an
easier way to disable scoped storage.
* java/AndroidManifest.xml.in: Add new permission to allow that.
* java/README: Add more text describing Java.
* java/org/gnu/emacs/EmacsContextMenu.java (Item): New fields
`isCheckable' and `isChecked'.
(EmacsContextMenu, addItem): New arguments.
(inflateMenuItems): Set checked status as appropriate.
* java/org/gnu/emacs/EmacsCopyArea.java (perform): Disallow
operations where width and height are less than or equal to
zero.
* lisp/menu-bar.el (menu-bar-edit-menu): Make
execute-extended-command available as a menu item.
* src/androidmenu.c (android_init_emacs_context_menu)
(android_menu_show):
* src/menu.c (have_boxes): Implement menu check boxes.
Diffstat (limited to 'java/README')
| -rw-r--r-- | java/README | 63 |
1 files changed, 59 insertions, 4 deletions
diff --git a/java/README b/java/README index 44f5a415162..3bce2556403 100644 --- a/java/README +++ b/java/README | |||
| @@ -292,15 +292,15 @@ public class EmacsFrobinicator | |||
| 292 | } | 292 | } |
| 293 | } | 293 | } |
| 294 | 294 | ||
| 295 | Java arrays are similar to C arrays in that they can not grow. But | 295 | Java arrays are similar to C arrays in that they can not grow. But |
| 296 | they are very much unlike C arrays in that they are always references | 296 | they are very much unlike C arrays in that they are always references |
| 297 | (as opposed to decaying into pointers in various situations), and | 297 | (as opposed to decaying into pointers in only some situations), and |
| 298 | contain information about their length. | 298 | contain information about their length. |
| 299 | 299 | ||
| 300 | If another function named ``frobinicate1'' takes an array as an | 300 | If another function named ``frobinicate1'' takes an array as an |
| 301 | argument, then it need not take the length of the array. | 301 | argument, then it need not take the length of the array. |
| 302 | 302 | ||
| 303 | Instead, it simply iterates over the array like so: | 303 | Instead, it may simply iterate over the array like so: |
| 304 | 304 | ||
| 305 | int i, k; | 305 | int i, k; |
| 306 | 306 | ||
| @@ -339,10 +339,65 @@ struct emacs_array_container | |||
| 339 | 339 | ||
| 340 | or, possibly even better, | 340 | or, possibly even better, |
| 341 | 341 | ||
| 342 | typedef int my_array[10]; | 342 | typedef int emacs_array_container[10]; |
| 343 | 343 | ||
| 344 | Alas, Java has no equivalent of `typedef'. | 344 | Alas, Java has no equivalent of `typedef'. |
| 345 | 345 | ||
| 346 | Like in C, Java string literals are delimited by double quotes. | ||
| 347 | Unlike C, however, strings are not NULL-terminated arrays of | ||
| 348 | characters, but a distinct type named ``String''. They store their | ||
| 349 | own length, characters in Java's 16-bit ``char'' type, and are capable | ||
| 350 | of holding NULL bytes. | ||
| 351 | |||
| 352 | Instead of writing: | ||
| 353 | |||
| 354 | wchar_t character; | ||
| 355 | extern char *s; | ||
| 356 | size_t s; | ||
| 357 | |||
| 358 | for (/* determine n, s in a loop. */) | ||
| 359 | s += mbstowc (&character, s, n); | ||
| 360 | |||
| 361 | or: | ||
| 362 | |||
| 363 | const char *byte; | ||
| 364 | |||
| 365 | for (byte = my_string; *byte; ++byte) | ||
| 366 | /* do something with *byte. */; | ||
| 367 | |||
| 368 | or perhaps even: | ||
| 369 | |||
| 370 | size_t length, i; | ||
| 371 | char foo; | ||
| 372 | |||
| 373 | length = strlen (my_string); | ||
| 374 | |||
| 375 | for (i = 0; i < length; ++i) | ||
| 376 | foo = my_string[i]; | ||
| 377 | |||
| 378 | you write: | ||
| 379 | |||
| 380 | char foo; | ||
| 381 | int i; | ||
| 382 | |||
| 383 | for (i = 0; i < myString.length (); ++i) | ||
| 384 | foo = myString.charAt (0); | ||
| 385 | |||
| 386 | Java also has stricter rules on what can be used as a truth value in a | ||
| 387 | conditional. While in C, any non-zero value is true, Java requires | ||
| 388 | that every truth value be of the boolean type ``boolean''. | ||
| 389 | |||
| 390 | What this means is that instead of simply writing: | ||
| 391 | |||
| 392 | if (foo || bar) | ||
| 393 | |||
| 394 | where foo can either be 1 or 0, and bar can either be NULL or a | ||
| 395 | pointer to something, you must explicitly write: | ||
| 396 | |||
| 397 | if (foo != 0 || bar != null) | ||
| 398 | |||
| 399 | in Java. | ||
| 400 | |||
| 346 | JAVA NATIVE INTERFACE | 401 | JAVA NATIVE INTERFACE |
| 347 | 402 | ||
| 348 | Java also provides an interface for C code to interface with Java. | 403 | Java also provides an interface for C code to interface with Java. |