winzik/docker/ext/php-sdl-system.patch
David Nurdin db72321bd9 Android natif : ffmpeg dans l'app, ouverture d'URL, presse-papiers, auto-mise à jour
- project.yaml android.ffmpeg : ffmpeg 8.0.1 (LGPL, LAME 3.100 pour le MP3) compilé avec le NDK par ABI
  (tools/android/build.sh build_ffmpeg, cache ~/.jumphp/android-native/ffmpeg), empaqueté en
  lib/<abi>/libffmpeg.so (useLegacyPackaging : déballé dans nativeLibraryDir), chemin donné à PHP par
  JUMPHP_FFMPEG (GameActivity)
- PHP Android : proc_open revient (le -include de jumphp-android.h passé à make et non plus à configure :
  il faisait échouer tous les tests de fonctions d'unistd.h, fork compris) ; --enable-posix ; arbre PHP
  par clé de build
- php-sdl : docker/ext/php-sdl-system.patch (SDL_OpenURL, SDL_Set/Get/HasClipboardText) ;
  SdlProvider sur Android : Shell::openUrl ouvre le navigateur, Clipboard::copy/paste le presse-papiers
- project.yaml android.self_update : JumPHP\Native\AndroidApp::install($apk) (ApkProvider content://,
  REQUEST_INSTALL_PACKAGES, page « sources inconnues » puis reprise), JUMPHP_ANDROID_VERSION_CODE/_NAME
- WinZik : android.ffmpeg et android.self_update ; docs/android-native.md

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-20 11:52:52 +01:00

102 lines
2.5 KiB
Diff

diff -ru a/src/php_sdl.c b/src/php_sdl.c
--- a/src/php_sdl.c
+++ b/src/php_sdl.c
@@ -335,6 +335,11 @@
// Platform
ZEND_FE(SDL_GetPlatform, arginfo_SDL_GetPlatform)
+ /* JumPHP: the system's browser, the clipboard */
+ ZEND_FE(SDL_OpenURL, arginfo_SDL_OpenURL)
+ ZEND_FE(SDL_SetClipboardText, arginfo_SDL_SetClipboardText)
+ ZEND_FE(SDL_GetClipboardText, arginfo_SDL_GetPlatform)
+ ZEND_FE(SDL_HasClipboardText, arginfo_SDL_GetPlatform)
// Keyboard
ZEND_FE(SDL_GetKeyboardFocus, arginfo_none)
diff -ru a/src/platform.c b/src/platform.c
--- a/src/platform.c
+++ b/src/platform.c
@@ -30,6 +30,59 @@
RETURN_STRING(SDL_GetPlatform());
}
+/* JumPHP: int SDL_OpenURL(string $url): 0 on success */
+PHP_FUNCTION(SDL_OpenURL)
+{
+ char *url;
+ size_t url_len;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &url, &url_len) == FAILURE) {
+ RETURN_THROWS();
+ }
+#if SDL_VERSION_ATLEAST(2, 0, 14)
+ RETURN_LONG(SDL_OpenURL(url));
+#else
+ RETURN_LONG(-1);
+#endif
+}
+
+/* JumPHP: int SDL_SetClipboardText(string $text): 0 on success */
+PHP_FUNCTION(SDL_SetClipboardText)
+{
+ char *text;
+ size_t text_len;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &text, &text_len) == FAILURE) {
+ RETURN_THROWS();
+ }
+ RETURN_LONG(SDL_SetClipboardText(text));
+}
+
+/* JumPHP: string SDL_GetClipboardText(): "" when empty */
+PHP_FUNCTION(SDL_GetClipboardText)
+{
+ char *text;
+
+ if (zend_parse_parameters_none() == FAILURE) {
+ RETURN_THROWS();
+ }
+ text = SDL_GetClipboardText();
+ if (text == NULL) {
+ RETURN_EMPTY_STRING();
+ }
+ RETVAL_STRING(text);
+ SDL_free(text);
+}
+
+/* JumPHP: bool SDL_HasClipboardText() */
+PHP_FUNCTION(SDL_HasClipboardText)
+{
+ if (zend_parse_parameters_none() == FAILURE) {
+ RETURN_THROWS();
+ }
+ RETURN_BOOL(SDL_HasClipboardText() == SDL_TRUE);
+}
+
/* {{{ MINIT */
PHP_MINIT_FUNCTION(sdl_platform)
{
diff -ru a/src/platform.h b/src/platform.h
--- a/src/platform.h
+++ b/src/platform.h
@@ -30,6 +30,20 @@
PHP_FUNCTION(SDL_GetPlatform);
+/* JumPHP: SDL_OpenURL (SDL 2.0.14+: the browser, Android's Intent.ACTION_VIEW), the clipboard */
+ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_OpenURL, 0, 0, 1)
+ ZEND_ARG_INFO(0, url)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_SetClipboardText, 0, 0, 1)
+ ZEND_ARG_INFO(0, text)
+ZEND_END_ARG_INFO()
+
+PHP_FUNCTION(SDL_OpenURL);
+PHP_FUNCTION(SDL_SetClipboardText);
+PHP_FUNCTION(SDL_GetClipboardText);
+PHP_FUNCTION(SDL_HasClipboardText);
+
PHP_MINIT_FUNCTION(sdl_platform);
#ifdef __cplusplus