mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-01-03 02:31:03 -08:00
* .gitignore: Add new files.
* INSTALL.android: Explain how to build Emacs for ancient
versions of Android.
* admin/merge-gnulib (GNULIB_MODULES): Add getdelim.
* build-aux/config.guess (timestamp, version):
* build-aux/config.sub (timestamp, version): Autoupdate.
* configure.ac (BUILD_DETAILS, ANDROID_MIN_SDK):
(ANDROID_STUBIFY): Allow specifying CFLAGS via ANDROID_CFLAGS.
Add new configure tests for Android API version when not
explicitly specified.
* doc/emacs/android.texi (Android): Add reference to ``Other
Input Devices''.
(Android File System): Remove restrictions on directory-files on
the assets directory.
* doc/emacs/emacs.texi (Top): Add Other Input Devices to menu.
* doc/emacs/input.texi (Other Input Devices): New node.
* doc/lispref/commands.texi (Touchscreen Events): Document
changes to touchscreen input events.
* doc/lispref/frames.texi (Pop-Up Menus): Likewise.
* etc/NEWS: Announce changes.
* java/Makefile.in: Use lib-src/asset-directory-tool to generate
an `directory-tree' file placed in /assets.
* java/debug.sh: Large adjustments to support Android 2.2 and
later.
* java/org/gnu/emacs/EmacsContextMenu.java (inflateMenuItems):
* java/org/gnu/emacs/EmacsCopyArea.java (perform):
* java/org/gnu/emacs/EmacsDialog.java (toAlertDialog):
* java/org/gnu/emacs/EmacsDrawLine.java (perform):
* java/org/gnu/emacs/EmacsDrawRectangle.java (perform):
* java/org/gnu/emacs/EmacsDrawable.java (EmacsDrawable):
* java/org/gnu/emacs/EmacsFillPolygon.java (perform):
* java/org/gnu/emacs/EmacsFillRectangle.java (perform):
* java/org/gnu/emacs/EmacsGC.java (EmacsGC):
* java/org/gnu/emacs/EmacsPixmap.java (EmacsPixmap):
(destroyHandle):
* java/org/gnu/emacs/EmacsSdk7FontDriver.java (draw): Avoid
redundant canvas saves and restores.
* java/org/gnu/emacs/EmacsService.java (run):
* java/org/gnu/emacs/EmacsView.java (EmacsView):
(handleDirtyBitmap):
* java/org/gnu/emacs/EmacsWindow.java (changeWindowBackground)
(EmacsWindow): Make compatible with Android 2.2 and later.
* lib-src/Makefile.in (DONT_INSTALL): Add asset-directory-tool
on Android.:(asset-directory-tool{EXEEXT}): New target.
* lib-src/asset-directory-tool.c (struct directory_tree, xmalloc)
(main_1, main_2, main): New file.
* lib, m4: Merge from gnulib. This will be reverted before
merging to master.
* lisp/button.el (button-map):
(push-button):
* lisp/frame.el (display-popup-menus-p): Improve touchscreen
support.
* lisp/subr.el (event-start):
(event-end): Handle touchscreen events.
* lisp/touch-screen.el (touch-screen-handle-timeout):
(touch-screen-handle-point-update):
(touch-screen-handle-point-up):
(touch-screen-track-tap):
(touch-screen-track-drag):
(touch-screen-drag-mode-line-1):
(touch-screen-drag-mode-line): New functions.
([mode-line touchscreen-begin]):
([bottom-divider touchscreen-begin]): Bind new events.
* lisp/wid-edit.el (widget-event-point):
(widget-keymap):
(widget-event-start):
(widget-button--check-and-call-button):
(widget-button-click): Improve touchscreen support.
* src/alloc.c (make_lisp_symbol): Avoid ICE on Android NDK GCC.
(mark_pinned_symbols): Likewise.
* src/android.c (struct android_emacs_window): New struct.
(window_class): New variable.
(android_run_select_thread): Add workaround for Android platform
bug.
(android_extract_long, android_scan_directory_tree): New
functions.
(android_file_access_p): Use those functions instead.
(android_init_emacs_window): New function.
(android_init_emacs_gc_class): Update signature of `markDirty'.
(android_change_gc, android_set_clip_rectangles): Tell the GC
whether or not clip rects were dirtied.
(android_swap_buffers): Do not look up method every time.
(struct android_dir): Adjust for new directory tree lookup.
(android_opendir, android_readdir, android_closedir): Likewise.
(android_four_corners_bilinear): Fix coding style.
(android_ftruncate): New function.
* src/android.h: Update prototypes. Replace ftruncate with
android_ftruncate when necessary.
* src/androidterm.c (handle_one_android_event): Pacify GCC. Fix
touch screen tool bar bug.
* src/emacs.c (using_utf8): Fix compilation error.
* src/fileio.c (Ffile_system_info): Return Qnil when fsusage.o
is not built.
* src/filelock.c (BOOT_TIME_FILE): Fix definition for Android.
* src/frame.c (Fx_parse_geometry): Fix uninitialized variable
uses.
* src/keyboard.c (lispy_function_keys): Fix `back'.
* src/menu.c (x_popup_menu_1): Handle touch screen events.
(Fx_popup_menu): Document changes.
* src/sfnt.c (main): Improve tests.
* src/sfntfont-android.c (sfntfont_android_put_glyphs): Fix
minor problem.
(init_sfntfont_android): Check for
HAVE_DECL_ANDROID_GET_DEVICE_API_LEVEL.
* src/sfntfont.c (struct sfnt_font_desc): New fields `adstyle'
and `languages'.
(sfnt_parse_style): Append tokens to adstyle.
(sfnt_parse_languages): New function.
(sfnt_enum_font_1): Parse supported languages and adstyle.
(sfntfont_list_1): Handle new fields.
(sfntfont_text_extents): Fix uninitialized variable use.
(syms_of_sfntfont, mark_sfntfont): Adjust accordingly.
177 lines
6.1 KiB
C
177 lines
6.1 KiB
C
/* Type-safe arrays which grow dynamically. Shared definitions.
|
|
Copyright (C) 2017-2023 Free Software Foundation, Inc.
|
|
This file is part of the GNU C Library.
|
|
|
|
The GNU C Library is free software; you can redistribute it and/or
|
|
modify it under the terms of the GNU Lesser General Public
|
|
License as published by the Free Software Foundation; either
|
|
version 2.1 of the License, or (at your option) any later version.
|
|
|
|
The GNU C Library 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
|
|
Lesser General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
License along with the GNU C Library; if not, see
|
|
<https://www.gnu.org/licenses/>. */
|
|
|
|
/* To use the dynarray facility, you need to include
|
|
<malloc/dynarray-skeleton.c> and define the parameter macros
|
|
documented in that file.
|
|
|
|
A minimal example which provides a growing list of integers can be
|
|
defined like this:
|
|
|
|
struct int_array
|
|
{
|
|
// Pointer to result array followed by its length,
|
|
// as required by DYNARRAY_FINAL_TYPE.
|
|
int *array;
|
|
size_t length;
|
|
};
|
|
|
|
#define DYNARRAY_STRUCT dynarray_int
|
|
#define DYNARRAY_ELEMENT int
|
|
#define DYNARRAY_PREFIX dynarray_int_
|
|
#define DYNARRAY_FINAL_TYPE struct int_array
|
|
#include <malloc/dynarray-skeleton.c>
|
|
|
|
To create a three-element array with elements 1, 2, 3, use this
|
|
code:
|
|
|
|
struct dynarray_int dyn;
|
|
dynarray_int_init (&dyn);
|
|
for (int i = 1; i <= 3; ++i)
|
|
{
|
|
int *place = dynarray_int_emplace (&dyn);
|
|
assert (place != NULL);
|
|
*place = i;
|
|
}
|
|
struct int_array result;
|
|
bool ok = dynarray_int_finalize (&dyn, &result);
|
|
assert (ok);
|
|
assert (result.length == 3);
|
|
assert (result.array[0] == 1);
|
|
assert (result.array[1] == 2);
|
|
assert (result.array[2] == 3);
|
|
free (result.array);
|
|
|
|
If the elements contain resources which must be freed, define
|
|
DYNARRAY_ELEMENT_FREE appropriately, like this:
|
|
|
|
struct str_array
|
|
{
|
|
char **array;
|
|
size_t length;
|
|
};
|
|
|
|
#define DYNARRAY_STRUCT dynarray_str
|
|
#define DYNARRAY_ELEMENT char *
|
|
#define DYNARRAY_ELEMENT_FREE(ptr) free (*ptr)
|
|
#define DYNARRAY_PREFIX dynarray_str_
|
|
#define DYNARRAY_FINAL_TYPE struct str_array
|
|
#include <malloc/dynarray-skeleton.c>
|
|
|
|
Compared to scratch buffers, dynamic arrays have the following
|
|
features:
|
|
|
|
- They have an element type, and are not just an untyped buffer of
|
|
bytes.
|
|
|
|
- When growing, previously stored elements are preserved. (It is
|
|
expected that scratch_buffer_grow_preserve and
|
|
scratch_buffer_set_array_size eventually go away because all
|
|
current users are moved to dynamic arrays.)
|
|
|
|
- Scratch buffers have a more aggressive growth policy because
|
|
growing them typically means a retry of an operation (across an
|
|
NSS service module boundary), which is expensive.
|
|
|
|
- For the same reason, scratch buffers have a much larger initial
|
|
stack allocation. */
|
|
|
|
#ifndef _DYNARRAY_H
|
|
#define _DYNARRAY_H
|
|
|
|
#include <stddef.h>
|
|
#include <string.h>
|
|
|
|
struct dynarray_header
|
|
{
|
|
size_t used;
|
|
size_t allocated;
|
|
void *array;
|
|
};
|
|
|
|
/* Marker used in the allocated member to indicate that an error was
|
|
encountered. */
|
|
static inline size_t
|
|
__dynarray_error_marker (void)
|
|
{
|
|
return -1;
|
|
}
|
|
|
|
/* Internal function. See the has_failed function in
|
|
dynarray-skeleton.c. */
|
|
static inline bool
|
|
__dynarray_error (struct dynarray_header *list)
|
|
{
|
|
return list->allocated == __dynarray_error_marker ();
|
|
}
|
|
|
|
/* Internal function. Enlarge the dynamically allocated area of the
|
|
array to make room for one more element. SCRATCH is a pointer to
|
|
the scratch area (which is not heap-allocated and must not be
|
|
freed). ELEMENT_SIZE is the size, in bytes, of one element.
|
|
Return false on failure, true on success. */
|
|
bool __libc_dynarray_emplace_enlarge (struct dynarray_header *,
|
|
void *scratch, size_t element_size);
|
|
|
|
/* Internal function. Enlarge the dynamically allocated area of the
|
|
array to make room for at least SIZE elements (which must be larger
|
|
than the existing used part of the dynamic array). SCRATCH is a
|
|
pointer to the scratch area (which is not heap-allocated and must
|
|
not be freed). ELEMENT_SIZE is the size, in bytes, of one element.
|
|
Return false on failure, true on success. */
|
|
bool __libc_dynarray_resize (struct dynarray_header *, size_t size,
|
|
void *scratch, size_t element_size);
|
|
|
|
/* Internal function. Like __libc_dynarray_resize, but clear the new
|
|
part of the dynamic array. */
|
|
bool __libc_dynarray_resize_clear (struct dynarray_header *, size_t size,
|
|
void *scratch, size_t element_size);
|
|
|
|
/* Internal type. */
|
|
struct dynarray_finalize_result
|
|
{
|
|
void *array;
|
|
size_t length;
|
|
};
|
|
|
|
/* Internal function. Copy the dynamically-allocated area to an
|
|
explicitly-sized heap allocation. SCRATCH is a pointer to the
|
|
embedded scratch space. ELEMENT_SIZE is the size, in bytes, of the
|
|
element type. On success, true is returned, and pointer and length
|
|
are written to *RESULT. On failure, false is returned. The caller
|
|
has to take care of some of the memory management; this function is
|
|
expected to be called from dynarray-skeleton.c. */
|
|
bool __libc_dynarray_finalize (struct dynarray_header *list, void *scratch,
|
|
size_t element_size,
|
|
struct dynarray_finalize_result *result);
|
|
|
|
|
|
/* Internal function. Terminate the process after an index error.
|
|
SIZE is the number of elements of the dynamic array. INDEX is the
|
|
lookup index which triggered the failure. */
|
|
_Noreturn void __libc_dynarray_at_failure (size_t size, size_t index);
|
|
|
|
#ifndef _ISOMAC
|
|
libc_hidden_proto (__libc_dynarray_emplace_enlarge)
|
|
libc_hidden_proto (__libc_dynarray_resize)
|
|
libc_hidden_proto (__libc_dynarray_resize_clear)
|
|
libc_hidden_proto (__libc_dynarray_finalize)
|
|
libc_hidden_proto (__libc_dynarray_at_failure)
|
|
#endif
|
|
|
|
#endif /* _DYNARRAY_H */
|