diff --git a/.dockerignore b/.dockerignore
new file mode 100644
index 0000000..6b8710a
--- /dev/null
+++ b/.dockerignore
@@ -0,0 +1 @@
+.git
diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml
new file mode 100644
index 0000000..2ea5cd9
--- /dev/null
+++ b/.github/workflows/build-test.yml
@@ -0,0 +1,16 @@
+name: Build and test
+
+on:
+ push:
+ branches:
+ - master
+
+jobs:
+ main:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v1
+ - name: Build and tag image
+ run: docker build -t ponup/php-sdl .
+ - name: Run tests
+ run: docker run --rm ponup/php-sdl
diff --git a/.gitignore b/.gitignore
index a3f5442..4e12ae7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,6 +2,7 @@
*.lo
*.la
.deps
+*.dep
.libs
Makefile
Makefile.fragments
@@ -58,3 +59,5 @@ php_test_results*.txt
configure.ac
.vscode
.DS_Store
+tags
+*.dep
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 15e08d5..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1,32 +0,0 @@
-language: php
-
-php:
- - 7.3
-
-env:
- - REPORT_EXIT_STATUS=1
-
-before_install:
- - sudo add-apt-repository -y ppa:team-xbmc/ppa
- - sudo apt-get update -qq
- - |
- travis_retry curl -L https://www.libsdl.org/release/SDL2-2.0.8.tar.gz | tar xz
- pushd SDL2-2.0.8
- ./configure
- make
- sudo make install
- popd
-
-install:
- - sudo apt-get install libegl1-mesa-dev libgles2-mesa-dev
-
-before_script:
- - phpize
- - ./configure --quiet
- - make all install
- - echo "extension=sdl.so" >> `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"`
- - chmod +x run-tests.php
-
-script:
- - ./run-tests.php -q -p $(which php) --show-diff
-
diff --git a/CREDITS b/CREDITS
index 417db3b..ea3e033 100644
--- a/CREDITS
+++ b/CREDITS
@@ -1,2 +1,2 @@
SDL
-Santiago Lizardo, Remi Collet
+Santiago Lizardo, Remi Collet, Manuel Baldassarri, Benoit Viguier
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..46322f9
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,23 @@
+FROM debian:11
+
+ARG TARGET_PHP_VERSION=8.1
+
+RUN apt-get update
+RUN apt-get install -y make build-essential wget
+RUN apt-get install -y lsb-release apt-transport-https ca-certificates
+RUN wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
+RUN echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/php.list
+RUN apt-get update
+RUN apt-get install -y php${TARGET_PHP_VERSION}-dev
+RUN apt-get install -y libsdl2-dev
+RUN apt-get install -y xvfb
+COPY . /opt/php-sdl
+WORKDIR /opt/php-sdl
+RUN phpize
+RUN ./configure
+RUN make
+RUN make install
+RUN echo "extension=sdl.so" >> /etc/php/${TARGET_PHP_VERSION}/cli/php.ini
+
+ENTRYPOINT ["/opt/php-sdl/docker-entrypoint.sh"]
+
diff --git a/EXPERIMENTAL b/EXPERIMENTAL
deleted file mode 100644
index 6443e99..0000000
--- a/EXPERIMENTAL
+++ /dev/null
@@ -1,5 +0,0 @@
-this extension is experimental,
-its functions may change their names
-or move to extension all together
-so do not rely to much on them
-you have been warned!
diff --git a/LICENSE b/LICENSE
index 42536af..e4e776b 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,68 +1,7 @@
---------------------------------------------------------------------
- The PHP License, version 3.01
-Copyright (c) 1999 - 2012 The PHP Group. All rights reserved.
---------------------------------------------------------------------
+Copyright 2022 Santiago Lizardo
-Redistribution and use in source and binary forms, with or without
-modification, is permitted provided that the following conditions
-are met:
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in
- the documentation and/or other materials provided with the
- distribution.
-
- 3. The name "PHP" must not be used to endorse or promote products
- derived from this software without prior written permission. For
- written permission, please contact group@php.net.
-
- 4. Products derived from this software may not be called "PHP", nor
- may "PHP" appear in their name, without prior written permission
- from group@php.net. You may indicate that your software works in
- conjunction with PHP by saying "Foo for PHP" instead of calling
- it "PHP Foo" or "phpfoo"
-
- 5. The PHP Group may publish revised and/or new versions of the
- license from time to time. Each version will be given a
- distinguishing version number.
- Once covered code has been published under a particular version
- of the license, you may always continue to use it under the terms
- of that version. You may also choose to use such covered code
- under the terms of any subsequent version of the license
- published by the PHP Group. No one other than the PHP Group has
- the right to modify the terms applicable to covered code created
- under this License.
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
- 6. Redistributions of any form whatsoever must retain the following
- acknowledgment:
- "This product includes PHP software, freely available from
- ".
-
-THIS SOFTWARE IS PROVIDED BY THE PHP DEVELOPMENT TEAM ``AS IS'' AND
-ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
-PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PHP
-DEVELOPMENT TEAM OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
-STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
-OF THE POSSIBILITY OF SUCH DAMAGE.
-
---------------------------------------------------------------------
-
-This software consists of voluntary contributions made by many
-individuals on behalf of the PHP Group.
-
-The PHP Group can be contacted via Email at group@php.net.
-
-For more information on the PHP Group and the PHP project,
-please see .
-
-PHP includes the Zend Engine, freely available at
-.
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/README.md b/README.md
index c8352ab..c60690b 100644
--- a/README.md
+++ b/README.md
@@ -1,10 +1,11 @@
-
-[](https://travis-ci.org/Ponup/php-sdl)
+[](https://github.com/Ponup/php-sdl/actions/workflows/build-test.yml)
PHP-SDL
=======
-SDL (Simple DirectMedia Layer) bindings for the PHP language.
+SDL (Simple DirectMedia Layer) bindings for the PHP language. The extension allows you to create multimedia desktop applications with windows, input handling, events, and more.
+
+[
](input-handling-example.gif)
## Installation
@@ -12,14 +13,14 @@ SDL (Simple DirectMedia Layer) bindings for the PHP language.
* C compiler
* Automake tools
-* PHP devel
+* PHP8.1 devel
* libSDL2 devel libraries and headers
* UN*X OS (eg Linux, Macos)
### Via PECL
```bash
-pecl install sdl-devel
+pecl install sdl-beta
```
Then add
@@ -29,50 +30,49 @@ extension=sdl.so
```
to your _php.ini_ file.
+> If you have no idea about your ini file position you can run `php -i | grep ini` and see the list of you ini files.
+
## Documentation
The SDL extension mimics in almost every single aspect to the official C library, so until we write our own documentation, refer to the [C counterpart](https://wiki.libsdl.org/APIByCategory).
-### Example
+## Examples
Standard SDL2 API is available in procedural style:
```php
- $window = SDL_CreateWindow( "Foo window", 500, 50, 350, 300, SDL_WINDOW_SHOWN+SDL_WINDOW_RESIZABLE);
- SDL_SetWindowTitle($window, "Some new title");
- SDL_DestroyWindow($window);
-```
-
-And is also available in object oriented style:
-
-```php
- $window = new SDL_Window( "Foo window", 100, 50, 350, 300, SDL_Window::SHOWN|SDL_Window::RESIZABLE);
- $window->SetTitle("Some new title");
- unset($window); // will destroy the window
-```
-
-Building
-========
-
-To compile your new extension, you will have to execute the following steps:
-
-```bash
-$ phpize
-$ ./configure [--enable--sdl]
-$ make
-$ make test
-$ [sudo] make install
+$window = SDL_CreateWindow( "Foo window", 500, 50, 350, 300, SDL_WINDOW_SHOWN+SDL_WINDOW_RESIZABLE);
+SDL_SetWindowTitle($window, "Some new title");
+SDL_DestroyWindow($window);
```
-## Support and feature requests
+Complete examples can be found in the [examples](examples) folder.
-Please submit anything that needs our attention to [issues section](https://github.com/php-sdl/extension/issues) on Github. We are commited to attend any request in a short timespan if it's a sensible matter.
+## Related projects
+* [PHP-SDL_TTF](https://github.com/Ponup/php-sdl-ttf)
+* [PHP-SDL_Mixer](https://github.com/kea/php-sdl-mixer)
+* [PHP-SDL_Image](https://github.com/kea/php-sdl-image)
+* [PHP-OpenGL](https://github.com/ponup/php-opengl)
+* [PHP-OpenAL](https://github.com/Ponup/php-openal)
-## Projects using this extension
+## Projects using the extension
* [CubeCraft](https://github.com/Ponup/cubecraft)
* [Conway's game of life](https://github.com/Ponup/conways-game-of-life)
* [PhpOkoban](https://github.com/b-viguier/PhpOkoban)
* [Inphpinity](https://github.com/b-viguier/Inphpinity)
* [PhPresent](https://github.com/b-viguier/PhPresent)
+
+## Building
+
+To compile your new extension, you will have to execute the following steps:
+
+```bash
+phpize
+./configure [--with--sdl]
+make
+make test
+sudo make install
+```
+
diff --git a/config.m4 b/config.m4
index 03d0d69..e781c23 100644
--- a/config.m4
+++ b/config.m4
@@ -10,8 +10,8 @@ if test "$PHP_SDL" != "no"; then
export OLD_CPPFLAGS="$CPPFLAGS"
export CPPFLAGS="$CPPFLAGS $INCLUDES -DHAVE_SDL2 -Wall -Wfatal-errors"
- REQ_PHP_VERSION="7.3.0"
- REQ_PHP_VERSION_ID=70300
+ REQ_PHP_VERSION="8.0.0"
+ REQ_PHP_VERSION_ID=80000
if test -z "$PHP_VERSION_ID"; then
AC_MSG_CHECKING(PHP version)
AC_TRY_COMPILE([#include ], [
@@ -55,6 +55,36 @@ if test "$PHP_SDL" != "no"; then
PHP_SUBST(SDL_SHARED_LIBADD)
AC_DEFINE(HAVE_SDL2, 1, [ ])
- SDL_SOURCE_FILES="`find src -name "*.c"`"
+ PHP_CHECK_LIBRARY(SDL2, SDL_GetRevisionNumber, [
+ AC_DEFINE(HAVE_SDL_GETREVISIONNUMBER, 1, [ ])
+ ])
+
+ SDL_SOURCE_FILES="src/blendmode.c \
+ src/cpuinfo.c \
+ src/error.c \
+ src/event.c \
+ src/filesystem.c \
+ src/glcontext.c \
+ src/joystick.c \
+ src/keyboard.c \
+ src/messagebox.c \
+ src/mouse.c \
+ src/mutex.c \
+ src/php_sdl.c \
+ src/pixels.c \
+ src/platform.c \
+ src/power.c \
+ src/rect.c \
+ src/render.c \
+ src/rwops.c \
+ src/sdl.c \
+ src/shape.c \
+ src/surface.c \
+ src/timer.c \
+ src/version.c \
+ src/video.c \
+ src/window.c"
+
PHP_NEW_EXTENSION(sdl, $SDL_SOURCE_FILES, $ext_shared,, $PHP_SDL_CFLAGS)
+ PHP_ADD_BUILD_DIR($ext_builddir/src)
fi
diff --git a/config.w32 b/config.w32
new file mode 100644
index 0000000..5c35324
--- /dev/null
+++ b/config.w32
@@ -0,0 +1,18 @@
+// vim:ft=javascript
+
+ARG_ENABLE('sdl', 'Whether to enable SDL2 support', 'no');
+
+if(PHP_SDL != 'no') {
+ CHECK_LIB("SDL2.lib", "sdl", PHP_SDL);
+ CHECK_LIB("SDL2main.lib", "sdl", PHP_SDL);
+ CHECK_LIB("SDL2test.lib", "sdl", PHP_SDL);
+
+ var sdl_sources = 'php_sdl.c blendmode.c cpuinfo.c error.c event.c filesystem.c glcontext.c joystick.c keyboard.c messagebox.c mouse.c mutex.c pixels.c platform.c power.c rect.c render.c rwops.c sdl.c shape.c surface.c timer.c version.c video.c window.c';
+
+ EXTENSION('sdl', sdl_sources, PHP_SDL_SHARED);
+
+ var sdl_headers = 'php_sdl.h blendmode.h cpuinfo.h error.h event.h filesystem.h glcontext.h joystick.h keyboard.h messagebox.h mouse.h mutex.h pixels.h platform.h power.h rect.h render.h rwops.h sdl.h shape.h surface.h timer.h version.h video.h window.h';
+
+ PHP_INSTALL_HEADERS('ext/sdl', sdl_headers);
+ AC_DEFINE('HAVE_SDL', 1);
+}
diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh
new file mode 100755
index 0000000..5c338f8
--- /dev/null
+++ b/docker-entrypoint.sh
@@ -0,0 +1,10 @@
+#!/usr/bin/env bash
+
+Xvfb :99 -screen 0 800x600x24 -ac &
+
+chmod +x ./run-tests.php
+
+export DISPLAY=:99
+./run-tests.php -q --show-diff
+
+killall -9 Xvfb
diff --git a/examples/001-sdl-version.php b/examples/001-sdl-version.php
index 873de6f..8828e30 100644
--- a/examples/001-sdl-version.php
+++ b/examples/001-sdl-version.php
@@ -1,12 +1,11 @@
- new SDL_MessageBoxColor(0, 0, 0),
@@ -19,7 +22,8 @@
SDL_MessageBoxColor::BUTTON_SELECTED => new SDL_MessageBoxColor(0, 0, 255),
];
$dialog = new SDL_MessageBoxData(SDL_MessageBoxData::INFORMATION, "Message box data", 'Select Yes or No', $buttons, $colors);
-$dialog->Show($buttonId);
-
-echo 'Button selection: ', var_export($buttonId), PHP_EOL;
-
+if(0 === $dialog->Show($buttonId)) {
+ echo 'Button selection: ', $buttonId === BUTTON_ID_YES ? 'Yes' : 'No', PHP_EOL;
+} else {
+ printSdlErrorAndExit();
+}
diff --git a/examples/004-draw-points.php b/examples/004-draw-points.php
index c2ea513..e0eabd5 100644
--- a/examples/004-draw-points.php
+++ b/examples/004-draw-points.php
@@ -1,10 +1,12 @@
type == SDL_QUIT) {
+while (true) {
+ if (SDL_PollEvent($event) && $event->type == SDL_QUIT) {
break;
- }
+ }
}
SDL_DestroyRenderer($renderer);
SDL_DestroyWindow($window);
SDL_Quit();
-
diff --git a/examples/005-draw-rectangle.php b/examples/005-draw-rectangle.php
index dd0ef26..3fa7611 100644
--- a/examples/005-draw-rectangle.php
+++ b/examples/005-draw-rectangle.php
@@ -1,9 +1,13 @@
format, 0xef, 0xff, 0x87);
-for($t = $time * $step; $t; $t--) {
+for ($t = $time * $step; $t; $t--) {
if (!($t % $step)) {
- $secondsLeft = $t / $step;
- SDL_SetWindowTitle($window, "Will be closed in $secondsLeft seconds");
+ $secondsLeft = $t / $step;
+ SDL_SetWindowTitle($window, "Will be closed in $secondsLeft seconds");
}
// Display 1 rect in ~red
$surf->FillRect($rects[$time * $step - $t], $color);
- SDL_UpdateWindowSurfaceRects($window, array($rects[$time * $step - $t]));
+ SDL_UpdateWindowSurfaceRects($window, array($rects[$time * $step - $t]));
usleep(1000000 / $step);
- while(SDL_PollEvent($event)) {
- if($event->type == SDL_QUIT) break;
- }
+ while (SDL_PollEvent($event)) {
+ if ($event->type == SDL_QUIT) break;
+ }
}
SDL_DestroyWindow($window);
-
diff --git a/examples/007-input-handling.php b/examples/007-input-handling.php
index 95cb860..45341d9 100644
--- a/examples/007-input-handling.php
+++ b/examples/007-input-handling.php
@@ -1,25 +1,37 @@
format, 0xff, 0xff, 0xff);
+SDL_SetColorKey($image, true, $color);
+
$texture = SDL_CreateTextureFromSurface($renderer, $image);
$drect = $image->clip_rect;
SDL_FreeSurface($image);
-SDL_SetRenderDrawColor($renderer, 255, 0, 255, 255);
+SDL_SetRenderDrawColor($renderer, 0xbb, 0xcc, 0xdd, 0xff);
SDL_RenderClear($renderer);
SDL_RenderPresent($renderer);
-$joystick = SDL_JoystickOpen(0);
+
$rotCenter = new SDL_Point(10, 10);
$event = new SDL_Event;
$destRect = new SDL_Rect;
@@ -29,51 +41,54 @@
$destRect->h = 64;
$update = true;
while (!$quit) {
- $xJoystickMotion = SDL_JoystickGetAxis($joystick, 0);
- if($xJoystickMotion !== 0) {
- $x += ceil($xJoystickMotion / 32767) * 5;
- $update = true;
- }
- $yJoystickMotion = SDL_JoystickGetAxis($joystick, 1);
- if($yJoystickMotion !== 0) {
- $y += ceil($yJoystickMotion / 32767) * 5;
- $update = true;
+ if ($joystickFound) {
+ $xJoystickMotion = SDL_JoystickGetAxis($joystick, 0);
+ if ($xJoystickMotion !== 0) {
+ $x += ceil($xJoystickMotion / 32767) * 5;
+ $update = true;
+ }
+ $yJoystickMotion = SDL_JoystickGetAxis($joystick, 1);
+ if ($yJoystickMotion !== 0) {
+ $y += ceil($yJoystickMotion / 32767) * 5;
+ $update = true;
+ }
}
- while(SDL_PollEvent($event)) {
- switch ($event->type) {
- case SDL_QUIT:
- $quit = true;
- break;
- case SDL_MOUSEMOTION:
- $x = $event->motion->x;
- $y = $event->motion->y;
+ while (SDL_PollEvent($event)) {
+ switch ($event->type) {
+ case SDL_QUIT:
+ $quit = true;
+ break;
+ case SDL_MOUSEMOTION:
+ $x = $event->motion->x;
+ $y = $event->motion->y;
$update = true;
break;
case SDL_JOYAXISMOTION:
break;
- }
+ }
}
- if($update) {
+ if ($update) {
SDL_RenderClear($renderer);
$destRect->x = $x;
$destRect->y = $y;
-
+
if (SDL_RenderCopyEx($renderer, $texture, NULL, $destRect, 90, $rotCenter, SDL_FLIP_NONE) != 0) {
echo SDL_GetError(), PHP_EOL;
}
- SDL_RenderPresent($renderer);
+ SDL_RenderPresent($renderer);
$update = false;
}
- SDL_Delay(25);
+ SDL_Delay(5);
}
-SDL_JoystickClose($joystick);
+if ($joystickFound) {
+ SDL_JoystickClose($joystick);
+}
SDL_DestroyTexture($texture);
SDL_DestroyRenderer($renderer);
SDL_DestroyWindow($window);
SDL_Quit();
-
diff --git a/examples/008-shaped-window.php b/examples/008-shaped-window.php
index 7819d6c..4538c3f 100644
--- a/examples/008-shaped-window.php
+++ b/examples/008-shaped-window.php
@@ -1,17 +1,19 @@
type == SDL_QUIT) $quit = true;
- if($event->type == SDL_MOUSEBUTTONDOWN) $quit = true;
+while (!$quit) {
+ while (SDL_PollEvent($event)) {
+ $quit = in_array($event->type, [SDL_QUIT, SDL_MOUSEBUTTONDOWN]);
}
- SDL_Delay(20);
+ SDL_Delay(20);
}
SDL_DestroyRenderer($renderer);
SDL_DestroyWindow($window);
SDL_Quit();
-
diff --git a/examples/009-window-events.php b/examples/009-window-events.php
index 75e2d9f..5cfb804 100644
--- a/examples/009-window-events.php
+++ b/examples/009-window-events.php
@@ -1,5 +1,7 @@
type) {
- case SDL_QUIT:
- $quit = true;
- break;
- case SDL_WINDOWEVENT:
+ $keyboardState = SDL_GetKeyboardState($numkeys);
+ if($keyboardState[SDL_SCANCODE_RETURN]) {
+ echo 'SDL_SCANCODE_RETURN pressed', PHP_EOL;
+ }
+ if($keyboardState[SDL_SCANCODE_RIGHT]) {
+ echo 'SDL_SCANCODE_RIGHT pressed', PHP_EOL;
+ }
+ if($keyboardState[SDL_SCANCODE_UP]) {
+ echo 'SDL_SCANCODE_UP pressed', PHP_EOL;
+ }
+
+ while (SDL_PollEvent($event)) {
+ switch ($event->type) {
+ case SDL_QUIT:
+ $quit = true;
+ break;
+ case SDL_WINDOWEVENT:
$eventText = 'unknown';
switch ($event->window->event) {
case SDL_WINDOWEVENT_SHOWN:
@@ -70,10 +85,10 @@
break;
}
$window->setTitle($eventText);
- printf('Event{windowID=%d, timestamp=%s, description=%s}' . PHP_EOL, $event->window->windowID, $event->window->timestamp, $eventText);
- break;
- }
- }
+ printf('Event{windowID=%d, timestamp=%s, description=%s}' . PHP_EOL, $event->window->windowID, $event->window->timestamp, $eventText);
+ break;
+ }
+ }
SDL_Delay(5);
}
diff --git a/examples/010-draw-lines.php b/examples/010-draw-lines.php
index 9cc48f2..e59d201 100644
--- a/examples/010-draw-lines.php
+++ b/examples/010-draw-lines.php
@@ -1,10 +1,12 @@
0; ++$iteration) {
$side = $iteration % 4;
$sign = $side < 2 ? 1 : -1;
-
+
$x2 = $side % 2 ? $x1 + $sign * $offset : $x1;
$y2 = $side % 2 ? $y1 : $y1 + $sign * $offset;
@@ -44,4 +46,3 @@
SDL_DestroyRenderer($renderer);
SDL_DestroyWindow($window);
SDL_Quit();
-
diff --git a/examples/011-draw-with-subpixels.php b/examples/011-draw-with-subpixels.php
new file mode 100644
index 0000000..889d0a0
--- /dev/null
+++ b/examples/011-draw-with-subpixels.php
@@ -0,0 +1,122 @@
+clip_rect;
+$drect->y = 500;
+$dfrect = new SDL_FRect($drect->x, $drect->y, $drect->w, $drect->h);
+
+// Draw lines
+function line($iteration, $renderer)
+{
+ $x1 = 40.0;
+ $y1 = 40.0 + $iteration;
+ $x2 = SQUARE;
+ $y2 = SQUARE - $iteration;
+
+ SDL_RenderDrawLineF($renderer, $x1, $y1, $x2, $y2);
+}
+
+// Draw rects
+function rect($iteration, $renderer)
+{
+ $x1 = SQUARE + 20 + $iteration/2;
+ $y1 = SQUARE + $iteration/2 + 20;
+ $w = SQUARE - 10 - $iteration;
+ $h = SQUARE - 10 - $iteration;
+ $rect1 = new SDL_FRect($x1, $y1, $w, $h);
+ $rect2 = new SDL_FRect($x1 + 50, $y1 + 50, $w - 100 , $h - 100);
+ SDL_RenderDrawRectF($renderer, $rect1);
+ SDL_RenderFillRectF($renderer, $rect2);
+}
+
+// Draw points
+function points($iteration, $renderer)
+{
+ for ($x = SQUARE + 80; $x < WINDOW_WIDTH - 60; $x++) {
+ $y = sin($x*6/SQUARE + $iteration/10) * 120 + 250;
+ SDL_RenderDrawPointF($renderer, (float) $x, $y);
+ }
+}
+
+// Draw sprites
+function sprites($iteration, $renderer, $destRect, $destFRect, $texture)
+{
+ $destFRect->x = $iteration;
+ $destRect->x = (int) $destFRect->x + 100;
+ if (SDL_RenderCopyEx($renderer, $texture, null, $destRect, $iteration, null, SDL_FLIP_NONE) != 0) {
+ echo SDL_GetError(), PHP_EOL;
+ }
+ if (SDL_RenderCopyExF($renderer, $texture, null, $destFRect, $iteration, null, SDL_FLIP_NONE) != 0) {
+ echo SDL_GetError(), PHP_EOL;
+ }
+
+ $destRect2 = clone $destRect;
+ $destFRect2 = clone $destFRect;
+ $destRect2->y += 100;
+ $destFRect2->y += 100;
+ if (SDL_RenderCopy($renderer, $texture, null, $destRect2) != 0) {
+ echo SDL_GetError(), PHP_EOL;
+ }
+ if (SDL_RenderCopyF($renderer, $texture, null, $destFRect2) != 0) {
+ echo SDL_GetError(), PHP_EOL;
+ }
+}
+
+function getIncrement($i, $increment)
+{
+ if ($i > SQUARE) {
+ return -0.20;
+ }
+
+ if ($i < 20.0) {
+ return 0.20;
+ }
+
+ return $increment;
+}
+
+// Wait for quit event
+$event = new SDL_Event;
+$i = .0;
+$increment = 0.20;
+
+while (true) {
+ if (SDL_PollEvent($event) && $event->type == SDL_QUIT) {
+ break;
+ }
+ // Clear screen
+ SDL_SetRenderDrawColor($renderer, 47, 79, 79, 255);
+ SDL_RenderClear($renderer);
+
+ SDL_SetRenderDrawColor($renderer, 230, 230, 230, 255);
+ $increment = getIncrement($i, $increment);
+ $i += $increment;
+ line($i, $renderer);
+ rect($i, $renderer);
+ points($i, $renderer);
+ sprites($i, $renderer, $drect, $dfrect, $texture);
+
+ SDL_RenderPresent($renderer);
+ SDL_Delay(5);
+}
+
+SDL_DestroyRenderer($renderer);
+SDL_DestroyWindow($window);
+SDL_Quit();
diff --git a/examples/bootstrap.php b/examples/bootstrap.php
index 4518a46..b635538 100644
--- a/examples/bootstrap.php
+++ b/examples/bootstrap.php
@@ -1,6 +1,20 @@
-
-
+
sdl
pecl.php.net
SDL for PHP
@@ -16,26 +18,26 @@
remi@php.net
yes
- 2019-09-08
+
+ 2022-07-22
- 2.3.0
- 2.3.0
+ 2.7.0
+ 2.7.0
- devel
- devel
+ beta
+ beta
- PHP
+ PHP
- - Fix out of bounds error (remicollet)
- - Add basic joystick/gamepad support (santiagolizardo)
+ - Fix SDL_GetKeyboardState (https://github.com/Ponup/php-sdl/issues/68)
+
-
@@ -70,6 +72,8 @@
+
+
@@ -98,6 +102,8 @@
+
+
@@ -131,6 +137,7 @@
+
@@ -138,16 +145,92 @@
- 7.3.0
+ 8.0.0
- 1.9.0
+ 1.10.0
sdl
+
+ 2022-03-17
+
+
+ 2.6.0
+ 2.6.0
+
+
+ beta
+ beta
+
+ PHP
+
+ - Add float rect and float point render functions (Manuel Baldassarri)
+ - Add config file for Windows (Zorobabel)
+ - Fix PECL build (Manuel Baldassarri)
+ - Rename width parameter in SDL_Rect constructor (Manuel Baldassarri)
+
+
+
+
+ 2021-06-18
+
+
+ 2.5.0
+ 2.5.0
+
+
+ devel
+ devel
+
+ PHP
+
+ - Add support for PHP8 (Manuel Baldassarri)
+ - Remove support for PHP7 (Manuel Baldassarri)
+
+
+
+ 2020-08-23
+
+
+ 2.4.0
+ 2.4.0
+
+
+ devel
+ devel
+
+ PHP
+
+ - Fix duplicate symbols (remicollet)
+ - Fix parameters passed by reference in rect module (kea)
+ - Port SDL_Palette and SDL_PixelFormat to PHP7 (kea)
+ - Fix surface props initialisation (kea)
+ - Fix surface and powerinfo params by ref (kea)
+ - Fix SDL_Rect inheritance issue (santiagolizardo)
+ - Add SQL_QueryTexture binding (kea)
+
+
+
+ 2019-09-08
+
+
+ 2.3.0
+ 2.3.0
+
+
+ devel
+ devel
+
+ PHP
+
+ - Fix out of bounds error (remicollet)
+ - Add basic joystick/gamepad support (santiagolizardo)
+
+
2019-09-02
@@ -163,7 +246,7 @@
- Fix undefined symbol (sdl_window_to_zval)
- Tidy up GL context creation
-
+
2019-08-28
@@ -178,10 +261,10 @@
PHP
- - Add support for window events. (Benoit Viguier)
- - Add support for the SDL_RenderCopyEx, SDL_RenderDrawLine and SDL_RenderDrawRect functions. (Benoit Viguier)
- - Fix memory leak in the SDL_RenderCopy function. (Benoit Viguier)
-
+ - Add support for window events. (Benoit Viguier)
+ - Add support for the SDL_RenderCopyEx, SDL_RenderDrawLine and SDL_RenderDrawRect functions. (Benoit Viguier)
+ - Fix memory leak in the SDL_RenderCopy function. (Benoit Viguier)
+
@@ -198,7 +281,7 @@
- Code updated to support PHP7.
- Code that could be implemented in userland was removed from the extension.
- Unit tests improvements/changes.
-
+
diff --git a/src/blendmode.c b/src/blendmode.c
index c088e53..9b700b6 100644
--- a/src/blendmode.c
+++ b/src/blendmode.c
@@ -1,13 +1,11 @@
/*
- +----------------------------------------------------------------------+
- | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2018 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_01.txt |
+ | https://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
diff --git a/src/blendmode.h b/src/blendmode.h
index 214b33c..da2443f 100644
--- a/src/blendmode.h
+++ b/src/blendmode.h
@@ -1,6 +1,4 @@
/*
- +----------------------------------------------------------------------+
- | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2018 The PHP Group |
+----------------------------------------------------------------------+
diff --git a/src/cpuinfo.c b/src/cpuinfo.c
index fc9d1af..73a7a53 100644
--- a/src/cpuinfo.c
+++ b/src/cpuinfo.c
@@ -1,13 +1,11 @@
/*
- +----------------------------------------------------------------------+
- | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2018 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_01.txt |
+ | https://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
diff --git a/src/cpuinfo.h b/src/cpuinfo.h
index d4504b3..edf4e9f 100644
--- a/src/cpuinfo.h
+++ b/src/cpuinfo.h
@@ -1,6 +1,4 @@
/*
- +----------------------------------------------------------------------+
- | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2018 The PHP Group |
+----------------------------------------------------------------------+
diff --git a/src/error.c b/src/error.c
index 4b1d3ce..a5156d3 100644
--- a/src/error.c
+++ b/src/error.c
@@ -1,13 +1,11 @@
/*
- +----------------------------------------------------------------------+
- | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2018 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_01.txt |
+ | https://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
diff --git a/src/error.h b/src/error.h
index 451ee67..b43c758 100644
--- a/src/error.h
+++ b/src/error.h
@@ -1,6 +1,4 @@
/*
- +----------------------------------------------------------------------+
- | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2018 The PHP Group |
+----------------------------------------------------------------------+
diff --git a/src/event.c b/src/event.c
index a0760bc..29fa842 100644
--- a/src/event.c
+++ b/src/event.c
@@ -1,13 +1,11 @@
/*
- +----------------------------------------------------------------------+
- | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2018 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_01.txt |
+ | https://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
@@ -22,7 +20,8 @@
static zend_class_entry *php_sdl_event_ce;
static zend_object_handlers php_sdl_event_handlers;
-struct php_sdl_event {
+struct php_sdl_event
+{
zend_object zo;
};
@@ -33,85 +32,110 @@ zend_class_entry *get_php_sdl_event_ce(void)
zend_bool sdl_event_to_zval(SDL_Event *event, zval *value)
{
- if(NULL == event) {
+ if (NULL == event)
+ {
ZVAL_NULL(value);
return 0;
}
- if(value != NULL) {
+ if (value != NULL)
+ {
zval_ptr_dtor(value);
}
object_init_ex(value, php_sdl_event_ce);
- zend_update_property_long(php_sdl_event_ce, value, ZEND_STRL("type"), event->type);
-
- switch(event->type) {
- case SDL_MOUSEMOTION: {
- zval motion;
- object_init(&motion);
- add_property_long(&motion, "state", event->motion.state);
- add_property_long(&motion, "x", event->motion.x);
- add_property_long(&motion, "y", event->motion.y);
- add_property_zval(value, "motion", &motion);
- zval_ptr_dtor(&motion);
- } break;
- case SDL_MOUSEBUTTONDOWN: {
- zval button;
- object_init(&button);
- add_property_long(&button, "button", event->button.button);
- add_property_long(&button, "x", event->button.x);
- add_property_long(&button, "y", event->button.y);
- add_property_zval(value, "button", &button);
- zval_ptr_dtor(&button);
- } break;
- case SDL_KEYDOWN:
- case SDL_KEYUP: {
- zval keysym;
- object_init(&keysym);
- add_property_long(&keysym, "sym", event->key.keysym.sym);
-
- zval key;
- object_init(&key);
- add_property_zval(&key, "keysym", &keysym);
-
- add_property_zval(value, "key", &key);
- zval_ptr_dtor(&key);
- zval_ptr_dtor(&keysym);
- } break;
- case SDL_WINDOWEVENT: {
- zval window;
- object_init(&window);
- add_property_long(&window, "event", event->window.event);
- add_property_long(&window, "timestamp", event->window.timestamp);
- add_property_long(&window, "windowID", event->window.windowID);
- add_property_long(&window, "data1", event->window.data1);
- add_property_long(&window, "data2", event->window.data2);
- add_property_zval(value, "window", &window);
- zval_ptr_dtor(&window);
- } break;
- case SDL_JOYBUTTONDOWN:
- case SDL_JOYBUTTONUP: {
- zval joybutton;
- object_init(&joybutton);
- add_property_long(&joybutton, "type", event->jbutton.type);
- add_property_long(&joybutton, "timestamp", event->jbutton.timestamp);
- add_property_long(&joybutton, "which", event->jbutton.which);
- add_property_long(&joybutton, "button", event->jbutton.button);
- add_property_long(&joybutton, "state", event->jbutton.state);
- add_property_zval(value, "jbutton", &joybutton);
- zval_ptr_dtor(&joybutton);
- } break;
- case SDL_JOYAXISMOTION: {
- zval jaxis;
- object_init(&jaxis);
- add_property_long(&jaxis, "type", event->jaxis.type);
- add_property_long(&jaxis, "timestamp", event->jaxis.timestamp);
- add_property_long(&jaxis, "which", event->jaxis.which);
- add_property_long(&jaxis, "axis", event->jaxis.axis);
- add_property_long(&jaxis, "value", event->jaxis.value);
- add_property_zval(value, "jaxis", &jaxis);
- zval_ptr_dtor(&jaxis);
- } break;
+ zend_update_property_long(php_sdl_event_ce, Z_OBJ_P(value), ZEND_STRL("type"), event->type);
+
+ switch (event->type)
+ {
+ case SDL_FINGERDOWN:
+ case SDL_FINGERUP:
+ case SDL_FINGERMOTION:
+ {
+ zval tfinger;
+ php_sdl_touchfingerevent_to_zval(&event->tfinger, &tfinger);
+ add_property_zval(value, "tfinger", &tfinger);
+
+ }
+ break;
+ case SDL_MOUSEMOTION:
+ {
+ zval motion;
+ object_init(&motion);
+ add_property_long(&motion, "state", event->motion.state);
+ add_property_long(&motion, "x", event->motion.x);
+ add_property_long(&motion, "y", event->motion.y);
+ add_property_zval(value, "motion", &motion);
+ zval_ptr_dtor(&motion);
+ }
+ break;
+ case SDL_MOUSEBUTTONDOWN:
+ {
+ zval button;
+ object_init(&button);
+ add_property_long(&button, "button", event->button.button);
+ add_property_long(&button, "x", event->button.x);
+ add_property_long(&button, "y", event->button.y);
+ add_property_zval(value, "button", &button);
+ zval_ptr_dtor(&button);
+ }
+ break;
+ case SDL_KEYDOWN:
+ case SDL_KEYUP:
+ {
+ zval keysym;
+ object_init(&keysym);
+ add_property_long(&keysym, "sym", event->key.keysym.sym);
+
+ zval key;
+ object_init(&key);
+ add_property_zval(&key, "keysym", &keysym);
+
+ add_property_zval(value, "key", &key);
+ zval_ptr_dtor(&key);
+ zval_ptr_dtor(&keysym);
+ }
+ break;
+ case SDL_WINDOWEVENT:
+ {
+ zval window;
+ object_init(&window);
+ add_property_long(&window, "event", event->window.event);
+ add_property_long(&window, "timestamp", event->window.timestamp);
+ add_property_long(&window, "windowID", event->window.windowID);
+ add_property_long(&window, "data1", event->window.data1);
+ add_property_long(&window, "data2", event->window.data2);
+ add_property_zval(value, "window", &window);
+ zval_ptr_dtor(&window);
+ }
+ break;
+ case SDL_JOYBUTTONDOWN:
+ case SDL_JOYBUTTONUP:
+ {
+ zval joybutton;
+ object_init(&joybutton);
+ add_property_long(&joybutton, "type", event->jbutton.type);
+ add_property_long(&joybutton, "timestamp", event->jbutton.timestamp);
+ add_property_long(&joybutton, "which", event->jbutton.which);
+ add_property_long(&joybutton, "button", event->jbutton.button);
+ add_property_long(&joybutton, "state", event->jbutton.state);
+ add_property_zval(value, "jbutton", &joybutton);
+ zval_ptr_dtor(&joybutton);
+ }
+ break;
+ case SDL_JOYAXISMOTION:
+ {
+ zval jaxis;
+ object_init(&jaxis);
+ add_property_long(&jaxis, "type", event->jaxis.type);
+ add_property_long(&jaxis, "timestamp", event->jaxis.timestamp);
+ add_property_long(&jaxis, "which", event->jaxis.which);
+ add_property_long(&jaxis, "axis", event->jaxis.axis);
+ add_property_long(&jaxis, "value", event->jaxis.value);
+ add_property_zval(value, "jaxis", &jaxis);
+ zval_ptr_dtor(&jaxis);
+ }
+ break;
}
return 1;
@@ -120,9 +144,10 @@ zend_bool sdl_event_to_zval(SDL_Event *event, zval *value)
zend_bool zval_to_sdl_event(zval *value, SDL_Event *event)
{
zval *val, rv;
-
- if (Z_TYPE_P(value) == IS_OBJECT && Z_OBJCE_P(value) == php_sdl_event_ce) {
- val = zend_read_property(php_sdl_event_ce, value, ZEND_STRL("type"), 0, &rv);
+
+ if (Z_TYPE_P(value) == IS_OBJECT && Z_OBJCE_P(value) == php_sdl_event_ce)
+ {
+ val = zend_read_property(php_sdl_event_ce, Z_OBJ_P(value), ZEND_STRL("type"), 0, &rv);
convert_to_long(val);
Z_LVAL_P(val) = event->type = (int)Z_LVAL_P(val);
@@ -138,7 +163,8 @@ static PHP_METHOD(SDL_Event, __construct)
zend_error_handling error_handling;
zend_replace_error_handling(EH_THROW, NULL, &error_handling);
- if (FAILURE == zend_parse_parameters_none()) {
+ if (FAILURE == zend_parse_parameters_none())
+ {
zend_restore_error_handling(&error_handling);
return;
}
@@ -149,28 +175,29 @@ static PHP_METHOD(SDL_Event, __construct)
static PHP_METHOD(SDL_Event, __toString)
{
char *buf;
- size_t buf_len;
+ size_t buf_len;
SDL_Event event;
- if (zend_parse_parameters_none() == FAILURE) {
+ if (zend_parse_parameters_none() == FAILURE)
+ {
return;
}
zval_to_sdl_event(getThis(), &event);
buf_len = spprintf(&buf, 100, "SDL_Event(type=%d)", event.type);
RETVAL_STRINGL(buf, buf_len);
- efree(buf);
+ efree(buf);
}
/* }}} */
-static HashTable *sdl_event_get_properties(zval *object)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_SDL_Event___toString, 0, 0, IS_STRING, 0)
+ZEND_END_ARG_INFO()
+
+static HashTable *sdl_event_get_properties(zend_object *object)
{
- HashTable *props;
+ HashTable *props;
props = zend_std_get_properties(object);
- zval test;
- zend_string *key = zend_string_init("type", 4, 0);
- ZVAL_LONG(&test, SDL_QUIT);
- zend_hash_update(props, key, &test);
+
return props;
}
@@ -180,7 +207,8 @@ PHP_FUNCTION(SDL_PollEvent)
SDL_Event event;
int ret;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "O/", &object, get_php_sdl_event_ce()) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "O/", &object, get_php_sdl_event_ce()) == FAILURE)
+ {
return;
}
@@ -196,13 +224,14 @@ PHP_FUNCTION(SDL_WaitEvent)
SDL_Event event;
int ret;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "O/", &object, get_php_sdl_event_ce()) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "O/", &object, get_php_sdl_event_ce()) == FAILURE)
+ {
return;
}
ret = SDL_WaitEvent(&event);
sdl_event_to_zval(&event, object);
-
+
RETURN_LONG(ret);
}
@@ -210,13 +239,9 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_none, 0, 0, 0)
ZEND_END_ARG_INFO()
static const zend_function_entry php_sdl_event_methods[] = {
- PHP_ME(SDL_Event, __construct, arginfo_none, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC)
- PHP_ME(SDL_Event, __toString, arginfo_none, ZEND_ACC_PUBLIC)
-
- /* non-static methods */
-// PHP_FALIAS(Empty, SDL_RectEmpty, arginfo_none)
- PHP_FE_END
-};
+ PHP_ME(SDL_Event, __construct, arginfo_none, ZEND_ACC_CTOR | ZEND_ACC_PUBLIC)
+ PHP_ME(SDL_Event, __toString, arginfo_class_SDL_Event___toString, ZEND_ACC_PUBLIC)
+ PHP_FE_END};
/* {{{ MINIT */
PHP_MINIT_FUNCTION(sdl_event)
@@ -225,56 +250,106 @@ PHP_MINIT_FUNCTION(sdl_event)
REGISTER_LONG_CONSTANT("SDL_QUIT", SDL_QUIT, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_APP_TERMINATING", SDL_APP_TERMINATING, CONST_CS|CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_APP_LOWMEMORY", SDL_APP_LOWMEMORY, CONST_CS|CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_APP_WILLENTERBACKGROUND", SDL_APP_WILLENTERBACKGROUND, CONST_CS|CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_APP_DIDENTERBACKGROUND", SDL_APP_DIDENTERBACKGROUND, CONST_CS|CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_APP_WILLENTERFOREGROUND", SDL_APP_WILLENTERFOREGROUND, CONST_CS|CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_APP_DIDENTERFOREGROUND", SDL_APP_DIDENTERFOREGROUND, CONST_CS|CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT", SDL_WINDOWEVENT, CONST_CS|CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_SYSWMEVENT", SDL_SYSWMEVENT, CONST_CS|CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_KEYDOWN", SDL_KEYDOWN, CONST_CS|CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_KEYUP", SDL_KEYUP, CONST_CS|CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_TEXTEDITING", SDL_TEXTEDITING, CONST_CS|CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_TEXTINPUT", SDL_TEXTINPUT, CONST_CS|CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_MOUSEMOTION", SDL_MOUSEMOTION, CONST_CS|CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_MOUSEBUTTONDOWN", SDL_MOUSEBUTTONDOWN, CONST_CS|CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_MOUSEBUTTONUP", SDL_MOUSEBUTTONUP, CONST_CS|CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_MOUSEWHEEL", SDL_MOUSEWHEEL, CONST_CS|CONST_PERSISTENT);
-
+ REGISTER_LONG_CONSTANT("SDL_FINGERDOWN", SDL_FINGERDOWN, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_FINGERUP", SDL_FINGERUP, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_FINGERMOTION", SDL_FINGERMOTION, CONST_CS | CONST_PERSISTENT);
+
+
+ REGISTER_LONG_CONSTANT("SDL_APP_TERMINATING", SDL_APP_TERMINATING, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_APP_LOWMEMORY", SDL_APP_LOWMEMORY, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_APP_WILLENTERBACKGROUND", SDL_APP_WILLENTERBACKGROUND, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_APP_DIDENTERBACKGROUND", SDL_APP_DIDENTERBACKGROUND, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_APP_WILLENTERFOREGROUND", SDL_APP_WILLENTERFOREGROUND, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_APP_DIDENTERFOREGROUND", SDL_APP_DIDENTERFOREGROUND, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT", SDL_WINDOWEVENT, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_SYSWMEVENT", SDL_SYSWMEVENT, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_KEYDOWN", SDL_KEYDOWN, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_KEYUP", SDL_KEYUP, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_TEXTEDITING", SDL_TEXTEDITING, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_TEXTINPUT", SDL_TEXTINPUT, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_MOUSEMOTION", SDL_MOUSEMOTION, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_MOUSEBUTTONDOWN", SDL_MOUSEBUTTONDOWN, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_MOUSEBUTTONUP", SDL_MOUSEBUTTONUP, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_MOUSEWHEEL", SDL_MOUSEWHEEL, CONST_CS | CONST_PERSISTENT);
+
// Joystick
- REGISTER_LONG_CONSTANT("SDL_JOYAXISMOTION", SDL_JOYAXISMOTION, CONST_CS|CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_JOYBUTTONDOWN", SDL_JOYBUTTONDOWN, CONST_CS|CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_JOYBUTTONUP", SDL_JOYBUTTONUP, CONST_CS|CONST_PERSISTENT);
-
- REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_SHOWN", SDL_WINDOWEVENT_SHOWN, CONST_CS|CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_HIDDEN", SDL_WINDOWEVENT_HIDDEN, CONST_CS|CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_EXPOSED", SDL_WINDOWEVENT_EXPOSED, CONST_CS|CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_MOVED", SDL_WINDOWEVENT_MOVED, CONST_CS|CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_RESIZED", SDL_WINDOWEVENT_RESIZED, CONST_CS|CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_SIZE_CHANGED", SDL_WINDOWEVENT_SIZE_CHANGED, CONST_CS|CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_MINIMIZED", SDL_WINDOWEVENT_MINIMIZED, CONST_CS|CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_MAXIMIZED", SDL_WINDOWEVENT_MAXIMIZED, CONST_CS|CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_RESTORED", SDL_WINDOWEVENT_RESTORED, CONST_CS|CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_ENTER", SDL_WINDOWEVENT_ENTER, CONST_CS|CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_LEAVE", SDL_WINDOWEVENT_LEAVE, CONST_CS|CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_FOCUS_GAINED", SDL_WINDOWEVENT_FOCUS_GAINED, CONST_CS|CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_FOCUS_LOST", SDL_WINDOWEVENT_FOCUS_LOST, CONST_CS|CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_CLOSE", SDL_WINDOWEVENT_CLOSE, CONST_CS|CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_TAKE_FOCUS", SDL_WINDOWEVENT_TAKE_FOCUS, CONST_CS|CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_HIT_TEST", SDL_WINDOWEVENT_HIT_TEST, CONST_CS|CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_JOYAXISMOTION", SDL_JOYAXISMOTION, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_JOYBUTTONDOWN", SDL_JOYBUTTONDOWN, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_JOYBUTTONUP", SDL_JOYBUTTONUP, CONST_CS | CONST_PERSISTENT);
+
+ REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_SHOWN", SDL_WINDOWEVENT_SHOWN, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_HIDDEN", SDL_WINDOWEVENT_HIDDEN, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_EXPOSED", SDL_WINDOWEVENT_EXPOSED, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_MOVED", SDL_WINDOWEVENT_MOVED, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_RESIZED", SDL_WINDOWEVENT_RESIZED, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_SIZE_CHANGED", SDL_WINDOWEVENT_SIZE_CHANGED, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_MINIMIZED", SDL_WINDOWEVENT_MINIMIZED, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_MAXIMIZED", SDL_WINDOWEVENT_MAXIMIZED, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_RESTORED", SDL_WINDOWEVENT_RESTORED, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_ENTER", SDL_WINDOWEVENT_ENTER, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_LEAVE", SDL_WINDOWEVENT_LEAVE, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_FOCUS_GAINED", SDL_WINDOWEVENT_FOCUS_GAINED, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_FOCUS_LOST", SDL_WINDOWEVENT_FOCUS_LOST, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_CLOSE", SDL_WINDOWEVENT_CLOSE, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_TAKE_FOCUS", SDL_WINDOWEVENT_TAKE_FOCUS, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_HIT_TEST", SDL_WINDOWEVENT_HIT_TEST, CONST_CS | CONST_PERSISTENT);
INIT_CLASS_ENTRY(ce_event, "SDL_Event", php_sdl_event_methods);
php_sdl_event_ce = zend_register_internal_class(&ce_event);
memcpy(&php_sdl_event_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
php_sdl_event_handlers.get_properties = sdl_event_get_properties;
- php_sdl_event_handlers.offset = XtOffsetOf(struct php_sdl_event, zo);
+ php_sdl_event_handlers.offset = XtOffsetOf(struct php_sdl_event, zo);
zend_declare_property_null(php_sdl_event_ce, ZEND_STRL("type"), ZEND_ACC_PUBLIC);
zend_declare_property_null(php_sdl_event_ce, ZEND_STRL("key"), ZEND_ACC_PUBLIC);
zend_declare_property_null(php_sdl_event_ce, ZEND_STRL("motion"), ZEND_ACC_PUBLIC);
+ zend_declare_property_null(php_sdl_event_ce, ZEND_STRL("window"), ZEND_ACC_PUBLIC);
+ zend_declare_property_null(php_sdl_event_ce, ZEND_STRL("button"), ZEND_ACC_PUBLIC);
+
+
+ // touchpad
+ zend_declare_property_null(php_sdl_event_ce, "tfinger", sizeof("tfinger") - 1, ZEND_ACC_PUBLIC);
+
+ zend_class_entry ce;
+ INIT_CLASS_ENTRY(ce, "SDL_TouchFingerEvent", NULL);
+ sdlTouchFingerEvent_ce = zend_register_internal_class(&ce);
+
+
+ // Déclaration explicite des propriétés publiques
+ zend_declare_property_null(sdlTouchFingerEvent_ce, "type", sizeof("type") - 1, ZEND_ACC_PUBLIC);
+ zend_declare_property_null(sdlTouchFingerEvent_ce, "timestamp", sizeof("timestamp") - 1, ZEND_ACC_PUBLIC);
+ zend_declare_property_null(sdlTouchFingerEvent_ce, "x", sizeof("x") - 1, ZEND_ACC_PUBLIC);
+ zend_declare_property_null(sdlTouchFingerEvent_ce, "y", sizeof("y") - 1, ZEND_ACC_PUBLIC);
+ zend_declare_property_null(sdlTouchFingerEvent_ce, "dx", sizeof("dx") - 1, ZEND_ACC_PUBLIC);
+ zend_declare_property_null(sdlTouchFingerEvent_ce, "dy", sizeof("dy") - 1, ZEND_ACC_PUBLIC);
+ zend_declare_property_null(sdlTouchFingerEvent_ce, "pressure", sizeof("pressure") - 1, ZEND_ACC_PUBLIC);
+ zend_declare_property_null(sdlTouchFingerEvent_ce, "fingerId", sizeof("fingerId") - 1, ZEND_ACC_PUBLIC);
+ zend_declare_property_null(sdlTouchFingerEvent_ce, "touchId", sizeof("touchId") - 1, ZEND_ACC_PUBLIC);
+
return SUCCESS;
}
/* }}} */
+zend_class_entry *sdlTouchFingerEvent_ce;
+
+zend_object* php_sdl_touchfingerevent_new(zend_class_entry *class_type) {
+ zend_object *obj = zend_objects_new(class_type);
+ object_properties_init(obj, class_type);
+ obj->handlers = &std_object_handlers;
+ return obj;
+}
+
+void php_sdl_touchfingerevent_to_zval(SDL_TouchFingerEvent *event, zval *value) {
+ object_init_ex(value, sdlTouchFingerEvent_ce);
+
+ add_property_long(value, "type", event->type);
+ add_property_long(value, "timestamp", event->timestamp);
+ add_property_double(value, "x", event->x);
+ add_property_double(value, "y", event->y);
+ add_property_double(value, "dx", event->dx);
+ add_property_double(value, "dy", event->dy);
+ add_property_double(value, "pressure", event->pressure);
+ add_property_long(value, "fingerId", (zend_long)event->fingerId);
+ add_property_long(value, "touchId", (zend_long)event->touchId);
+}
diff --git a/src/event.h b/src/event.h
index 63cb54a..ba0be5c 100644
--- a/src/event.h
+++ b/src/event.h
@@ -1,6 +1,4 @@
/*
- +----------------------------------------------------------------------+
- | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2018 The PHP Group |
+----------------------------------------------------------------------+
@@ -29,7 +27,8 @@ extern "C" {
zend_class_entry *get_php_sdl_event_ce(void);
zend_bool sdl_event_to_zval(SDL_Event *event, zval *value);
zend_bool zval_to_sdl_event(zval *value, SDL_Event *event);
-
+void php_sdl_touchfingerevent_to_zval(SDL_TouchFingerEvent *event, zval *value);
+extern zend_class_entry *sdlTouchFingerEvent_ce; // déclaration externe
ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_PollEvent, 0, 0, 1)
ZEND_ARG_OBJ_INFO(1, event, SDL_Event, 0)
ZEND_END_ARG_INFO()
@@ -44,7 +43,7 @@ PHP_FUNCTION(SDL_WaitEvent);
PHP_MINIT_FUNCTION(sdl_event);
#ifdef __cplusplus
-} // extern "C"
+} // extern "C"
#endif
#endif /* PHP_SDL_EVENT_H */
diff --git a/src/filesystem.c b/src/filesystem.c
index 3cdc93b..a999771 100644
--- a/src/filesystem.c
+++ b/src/filesystem.c
@@ -1,13 +1,11 @@
/*
- +----------------------------------------------------------------------+
- | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2018 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_01.txt |
+ | https://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
diff --git a/src/filesystem.h b/src/filesystem.h
index 20ca99d..5ff1836 100644
--- a/src/filesystem.h
+++ b/src/filesystem.h
@@ -1,6 +1,4 @@
/*
- +----------------------------------------------------------------------+
- | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2018 The PHP Group |
+----------------------------------------------------------------------+
diff --git a/src/glcontext.c b/src/glcontext.c
index 889bdab..7cb49fe 100644
--- a/src/glcontext.c
+++ b/src/glcontext.c
@@ -1,13 +1,11 @@
/*
- +----------------------------------------------------------------------+
- | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2018 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_01.txt |
+ | https://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
@@ -17,7 +15,6 @@
+----------------------------------------------------------------------+
*/
-
/*
+----------------------------------------------------------------------+
| wrapper for SDL2/SDL_video.h (only SDL_GLContext) |
@@ -39,13 +36,13 @@
static zend_class_entry *php_sdl_glcontext_ce;
static zend_object_handlers php_sdl_glcontext_handlers;
-struct php_sdl_glcontext {
+struct php_sdl_glcontext
+{
SDL_GLContext glcontext;
- Uint32 flags;
- zend_object zo;
+ Uint32 flags;
+ zend_object zo;
};
-
/* {{{ get_php_sdl_glcontext_ce */
zend_class_entry *get_php_sdl_glcontext_ce(void)
{
@@ -53,27 +50,28 @@ zend_class_entry *get_php_sdl_glcontext_ce(void)
}
/* }}} */
-
-#define FETCH_GLCONTEXT(__ptr, __id, __check) \
-{ \
- zend_object* zox = Z_OBJ_P(__id);\
- intern = (struct php_sdl_glcontext*)((char*)zox - zox->handlers->offset);\
- __ptr = intern->glcontext; \
- if (__check && !__ptr) {\
- php_error_docref(NULL, E_WARNING, "Invalid %s object", ZSTR_VAL(intern->zo.ce->name));\
- RETURN_FALSE;\
- }\
-}
+#define FETCH_GLCONTEXT(__ptr, __id, __check) \
+ { \
+ zend_object *zox = Z_OBJ_P(__id); \
+ intern = (struct php_sdl_glcontext *)((char *)zox - zox->handlers->offset); \
+ __ptr = intern->glcontext; \
+ if (__check && !__ptr) \
+ { \
+ php_error_docref(NULL, E_WARNING, "Invalid %s object", ZSTR_VAL(intern->zo.ce->name)); \
+ RETURN_FALSE; \
+ } \
+ }
/* {{{ sdl_glcontext_to_zval */
zend_bool sdl_glcontext_to_zval(SDL_GLContext glcontext, zval *z_val, Uint32 flags)
{
- if (glcontext) {
+ if (glcontext)
+ {
struct php_sdl_glcontext *intern;
object_init_ex(z_val, php_sdl_glcontext_ce);
- zend_object* zo = Z_OBJ_P(z_val);
- intern = (struct php_sdl_glcontext*)((char*)zo - zo->handlers->offset);
+ zend_object *zo = Z_OBJ_P(z_val);
+ intern = (struct php_sdl_glcontext *)((char *)zo - zo->handlers->offset);
intern->glcontext = glcontext;
intern->flags = flags;
@@ -84,30 +82,31 @@ zend_bool sdl_glcontext_to_zval(SDL_GLContext glcontext, zval *z_val, Uint32 fla
}
/* }}} */
-
/* {{{ zval_to_sdl_glcontext */
SDL_GLContext zval_to_sdl_glcontext(zval *z_val)
{
struct php_sdl_glcontext *intern;
- if (Z_TYPE_P(z_val) == IS_OBJECT && Z_OBJCE_P(z_val) == php_sdl_glcontext_ce) {
- zend_object* zo = Z_OBJ_P(z_val);
- intern = (struct php_sdl_glcontext*)((char*)zo - zo->handlers->offset);
+ if (Z_TYPE_P(z_val) == IS_OBJECT && Z_OBJCE_P(z_val) == php_sdl_glcontext_ce)
+ {
+ zend_object *zo = Z_OBJ_P(z_val);
+ intern = (struct php_sdl_glcontext *)((char *)zo - zo->handlers->offset);
return intern->glcontext;
}
return NULL;
}
/* }}} */
-
/* {{{ php_sdl_glcontext_free
- */
+ */
static void php_sdl_glcontext_free(zend_object *zo)
{
- struct php_sdl_glcontext* intern = (struct php_sdl_glcontext*)((char*)zo - zo->handlers->offset);
+ struct php_sdl_glcontext *intern = (struct php_sdl_glcontext *)((char *)zo - zo->handlers->offset);
- if (intern->glcontext) {
- if (!(intern->flags & SDL_DONTFREE)) {
+ if (intern->glcontext)
+ {
+ if (!(intern->flags & SDL_DONTFREE))
+ {
SDL_GL_DeleteContext(intern->glcontext);
}
}
@@ -116,40 +115,39 @@ static void php_sdl_glcontext_free(zend_object *zo)
}
/* }}} */
-
/* {{{ php_sdl_glcontext_new
*/
-static zend_object* php_sdl_glcontext_new(zend_class_entry *class_type)
+static zend_object *php_sdl_glcontext_new(zend_class_entry *class_type)
{
struct php_sdl_glcontext *intern;
- intern = (struct php_sdl_glcontext*)ecalloc(1, sizeof(struct php_sdl_glcontext) + zend_object_properties_size(class_type));
+ intern = (struct php_sdl_glcontext *)ecalloc(1, sizeof(struct php_sdl_glcontext) + zend_object_properties_size(class_type));
zend_object_std_init(&intern->zo, class_type);
object_properties_init(&intern->zo, class_type);
intern->glcontext = NULL;
-
- intern->zo.handlers = (zend_object_handlers*)&php_sdl_glcontext_handlers;
- return &intern->zo;
+ intern->zo.handlers = (zend_object_handlers *)&php_sdl_glcontext_handlers;
+
+ return &intern->zo;
}
/* }}} */
-
/* {{{ proto bool SDL_GL_ExtensionSupported(string extension)
* \brief Return true if an OpenGL extension is supported for the current
* context.
extern DECLSPEC SDL_bool SDLCALL SDL_GL_ExtensionSupported(const char
- *extension);
+ *extension);
*/
PHP_FUNCTION(SDL_GL_ExtensionSupported)
{
char *ext;
size_t ext_len;
- if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "s", &ext, &ext_len)) {
+ if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "s", &ext, &ext_len))
+ {
return;
}
RETVAL_BOOL(SDL_GL_ExtensionSupported(ext) == SDL_TRUE);
@@ -165,14 +163,14 @@ PHP_FUNCTION(SDL_GL_SetAttribute)
{
zend_long attr, value;
- if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "ll", &attr, &value)) {
+ if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "ll", &attr, &value))
+ {
return;
}
RETVAL_LONG(SDL_GL_SetAttribute((SDL_GLattr)attr, (int)value));
}
/* }}} */
-
/* {{{ proto int SDL_GL_GetAttribute(int attr, int &value)
* \brief Get the actual value for an attribute from the current context.
@@ -184,11 +182,13 @@ PHP_FUNCTION(SDL_GL_GetAttribute)
zval *z_value;
int ret, value;
- if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "lz", &attr, &z_value)) {
+ if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "lz", &attr, &z_value))
+ {
return;
}
ret = SDL_GL_GetAttribute((SDL_GLattr)attr, &value);
- if (ret == 0) {
+ if (ret == 0)
+ {
zval_dtor(z_value);
ZVAL_LONG(z_value, value);
}
@@ -196,7 +196,6 @@ PHP_FUNCTION(SDL_GL_GetAttribute)
}
/* }}} */
-
/* {{{ proto SDL_GLContext::__construct(void) */
PHP_METHOD(SDL_GLContext, __construct)
{
@@ -208,47 +207,59 @@ PHP_METHOD(SDL_GLContext, __construct)
intern = (struct php_sdl_glcontext *)Z_OBJ_P(getThis());
zend_replace_error_handling(EH_THROW, NULL, &error_handling);
- if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "O", &z_window, get_php_sdl_window_ce())) {
+ if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "O", &z_window, get_php_sdl_window_ce()))
+ {
zend_restore_error_handling(&error_handling);
return;
}
zend_restore_error_handling(&error_handling);
window = zval_to_sdl_window(z_window);
- if (window) {
+ if (window)
+ {
intern->glcontext = SDL_GL_CreateContext(window);
- if (intern->glcontext) {
+ if (intern->glcontext)
+ {
intern->flags = 0;
- } else {
- zend_throw_exception(zend_exception_get_default(), SDL_GetError(), 0);
}
- } else {
- zend_throw_exception(zend_exception_get_default(), "Invalid SDL_Window object", 0);
+ else
+ {
+ zend_throw_exception(zend_ce_exception, SDL_GetError(), 0);
+ }
+ }
+ else
+ {
+ zend_throw_exception(zend_ce_exception, "Invalid SDL_Window object", 0);
}
}
/* }}} */
-
/* {{{ proto SDL_GLContext::__toString() */
PHP_METHOD(SDL_GLContext, __toString)
{
struct php_sdl_glcontext *intern;
char *buf;
- if (zend_parse_parameters_none() == FAILURE) {
+ if (zend_parse_parameters_none() == FAILURE)
+ {
return;
}
intern = (struct php_sdl_glcontext *)Z_OBJ_P(getThis());
- if (intern->glcontext) {
+ if (intern->glcontext)
+ {
spprintf(&buf, 100, "SDL_GLContext(%lx)", (long)intern->glcontext);
RETVAL_STRING(buf);
- } else {
+ }
+ else
+ {
RETVAL_STRING("SDL_GLContext()");
}
}
/* }}} */
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_SDL_GLContext__toString, 0, 0, IS_STRING, 0)
+ZEND_END_ARG_INFO()
/* {{{ proto SDL_GLContext SDL_GL_CreateContext(SDL_Window window)
@@ -257,7 +268,7 @@ PHP_METHOD(SDL_GLContext, __toString)
*
* \sa SDL_GL_DeleteContext()
extern DECLSPEC SDL_GLContext SDLCALL SDL_GL_CreateContext(SDL_Window *
- window);
+ window);
*/
PHP_FUNCTION(SDL_GL_CreateContext)
{
@@ -265,20 +276,23 @@ PHP_FUNCTION(SDL_GL_CreateContext)
zval *z_window;
SDL_Window *window;
- if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "O", &z_window, get_php_sdl_window_ce())) {
+ if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "O", &z_window, get_php_sdl_window_ce()))
+ {
return;
}
window = zval_to_sdl_window(z_window);
- if (window) {
+ if (window)
+ {
context = SDL_GL_CreateContext(window);
sdl_glcontext_to_zval(context, return_value, SDL_DONTFREE);
- } else {
+ }
+ else
+ {
php_error_docref(NULL, E_WARNING, "Invalid SDL_Window object");
}
}
/* }}} */
-
/* {{{ proto void SDL_GL_DeleteContext(SDL_GLContext context)
* \brief Delete an OpenGL context.
@@ -292,7 +306,8 @@ PHP_FUNCTION(SDL_GL_DeleteContext)
zval *z_context;
SDL_GLContext context;
- if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &z_context, php_sdl_glcontext_ce) == FAILURE) {
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &z_context, php_sdl_glcontext_ce) == FAILURE)
+ {
return;
}
FETCH_GLCONTEXT(context, z_context, 1);
@@ -302,15 +317,14 @@ PHP_FUNCTION(SDL_GL_DeleteContext)
}
/* }}} */
-
-#if SDL_VERSION_ATLEAST(2,0,1)
+#if SDL_VERSION_ATLEAST(2, 0, 1)
/* {{{ proto int SDL_GL_MakeCurrent(SDL_Window window, SDL_GLContext context)
* \brief Set up an OpenGL context for rendering into an OpenGL window.
*
* \note The context must have been created with a compatible window.
extern DECLSPEC int SDLCALL SDL_GL_MakeCurrent(SDL_Window * window,
- SDL_GLContext context);
+ SDL_GLContext context);
*/
PHP_FUNCTION(SDL_GL_MakeCurrent)
{
@@ -319,20 +333,23 @@ PHP_FUNCTION(SDL_GL_MakeCurrent)
SDL_GLContext context;
SDL_Window *window;
- if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OO", &z_window, get_php_sdl_window_ce(), &z_context, php_sdl_glcontext_ce)) {
+ if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OO", &z_window, get_php_sdl_window_ce(), &z_context, php_sdl_glcontext_ce))
+ {
return;
}
FETCH_GLCONTEXT(context, z_context, 1);
window = zval_to_sdl_window(z_window);
- if (window) {
+ if (window)
+ {
RETVAL_LONG(SDL_GL_MakeCurrent(window, context));
- } else {
+ }
+ else
+ {
php_error_docref(NULL, E_WARNING, "Invalid SDL_Window object");
}
}
/* }}} */
-
/* {{{ proto SDL_Window SDL_GL_GetCurrentWindow(void)
* \brief Get the currently active OpenGL window.
@@ -340,13 +357,13 @@ PHP_FUNCTION(SDL_GL_MakeCurrent)
*/
PHP_FUNCTION(SDL_GL_GetCurrentWindow)
{
- if (zend_parse_parameters_none() == FAILURE) {
+ if (zend_parse_parameters_none() == FAILURE)
+ {
return;
}
sdl_window_to_zval(SDL_GL_GetCurrentWindow(), return_value, SDL_DONTFREE);
}
-
/* {{{ proto SDL_GLContext SDL_GL_GetCurrentContext(void)
* \brief Get the currently active OpenGL context.
@@ -354,7 +371,8 @@ PHP_FUNCTION(SDL_GL_GetCurrentWindow)
*/
PHP_FUNCTION(SDL_GL_GetCurrentContext)
{
- if (zend_parse_parameters_none() == FAILURE) {
+ if (zend_parse_parameters_none() == FAILURE)
+ {
return;
}
sdl_glcontext_to_zval(SDL_GL_GetCurrentContext(), return_value, SDL_DONTFREE);
@@ -376,7 +394,7 @@ PHP_FUNCTION(SDL_GL_GetCurrentContext)
* \sa SDL_GetWindowSize()
* \sa SDL_CreateWindow()
extern DECLSPEC void SDLCALL SDL_GL_GetDrawableSize(SDL_Window * window, int *w,
- int *h);
+ int *h);
*/
PHP_FUNCTION(SDL_GL_GetDrawableSize)
{
@@ -384,17 +402,21 @@ PHP_FUNCTION(SDL_GL_GetDrawableSize)
SDL_Window *window;
int w, h;
- if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Ozz", &z_window, get_php_sdl_window_ce(), &z_w, &z_h)) {
+ if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Ozz", &z_window, get_php_sdl_window_ce(), &z_w, &z_h))
+ {
return;
}
window = zval_to_sdl_window(z_window);
- if (window) {
+ if (window)
+ {
SDL_GL_GetDrawableSize(window, &w, &h);
zval_dtor(z_w);
ZVAL_LONG(z_w, w);
zval_dtor(z_h);
ZVAL_LONG(z_h, h);
- } else {
+ }
+ else
+ {
php_error_docref(NULL, E_WARNING, "Invalid SDL_Window object");
}
}
@@ -412,19 +434,22 @@ PHP_FUNCTION(SDL_GL_SwapWindow)
zval *z_window;
SDL_Window *window;
- if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &z_window, get_php_sdl_window_ce())) {
+ if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &z_window, get_php_sdl_window_ce()))
+ {
return;
}
window = zval_to_sdl_window(z_window);
- if (window) {
+ if (window)
+ {
SDL_GL_SwapWindow(window);
- } else {
+ }
+ else
+ {
php_error_docref(NULL, E_WARNING, "Invalid SDL_Window object");
}
}
/* }}} */
-
/* {{{ proto int SDL_GL_SetSwapInterval(int interval)
* \brief Set the swap interval for the current OpenGL context.
@@ -443,14 +468,14 @@ PHP_FUNCTION(SDL_GL_SetSwapInterval)
{
zend_long value;
- if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "l", &value)) {
+ if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "l", &value))
+ {
return;
}
RETVAL_LONG(SDL_GL_SetSwapInterval((int)value));
}
/* }}} */
-
/* {{{ proto int SDL_GL_GetSwapInterval()
* \brief Get the swap interval for the current OpenGL context.
@@ -466,37 +491,35 @@ PHP_FUNCTION(SDL_GL_SetSwapInterval)
*/
PHP_FUNCTION(SDL_GL_GetSwapInterval)
{
- if (zend_parse_parameters_none() == FAILURE) {
+ if (zend_parse_parameters_none() == FAILURE)
+ {
return;
}
RETVAL_LONG(SDL_GL_GetSwapInterval());
}
/* }}} */
-
/* {{{ sdl_glcontext_methods[] */
static const zend_function_entry php_sdl_glcontext_methods[] = {
- PHP_ME(SDL_GLContext, __construct, arginfo_SDL_GLContext__construct, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC)
- PHP_ME(SDL_GLContext, __toString, arginfo_none, ZEND_ACC_PUBLIC)
+ PHP_ME(SDL_GLContext, __construct, arginfo_SDL_GLContext__construct, ZEND_ACC_CTOR | ZEND_ACC_PUBLIC)
+ PHP_ME(SDL_GLContext, __toString, arginfo_class_SDL_GLContext__toString, ZEND_ACC_PUBLIC)
/* non-static method */
- PHP_FALIAS(Delete, SDL_GL_DeleteContext, arginfo_none)
+ PHP_FALIAS(Delete, SDL_GL_DeleteContext, arginfo_none)
/* static functions */
- ZEND_FENTRY(GL_GetCurrent, ZEND_FN(SDL_GL_GetCurrentContext), arginfo_none, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
+ ZEND_FENTRY(GL_GetCurrent, ZEND_FN(SDL_GL_GetCurrentContext), arginfo_none, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
- ZEND_FE_END
-};
+ ZEND_FE_END};
/* }}} */
-#define REGISTER_GL_CLASS_CONST_LONG(const_name, value) \
+#define REGISTER_GL_CLASS_CONST_LONG(const_name, value) \
REGISTER_LONG_CONSTANT("SDL_GL_" const_name, value, CONST_CS | CONST_PERSISTENT); \
- zend_declare_class_constant_long(php_sdl_glcontext_ce, const_name, sizeof(const_name)-1, value)
+ zend_declare_class_constant_long(php_sdl_glcontext_ce, const_name, sizeof(const_name) - 1, value)
-#define REGISTER_GLCONTEXT_CLASS_CONST_LONG(const_name, value) \
+#define REGISTER_GLCONTEXT_CLASS_CONST_LONG(const_name, value) \
REGISTER_LONG_CONSTANT("SDL_GL_CONTEXT_" const_name, value, CONST_CS | CONST_PERSISTENT); \
- zend_declare_class_constant_long(php_sdl_glcontext_ce, const_name, sizeof(const_name)-1, value)
-
+ zend_declare_class_constant_long(php_sdl_glcontext_ce, const_name, sizeof(const_name) - 1, value)
/* {{{ MINIT */
PHP_MINIT_FUNCTION(sdl_glcontext)
@@ -511,44 +534,44 @@ PHP_MINIT_FUNCTION(sdl_glcontext)
php_sdl_glcontext_handlers.offset = XtOffsetOf(struct php_sdl_glcontext, zo);
/* typedef enum SDL_GLattr; */
- REGISTER_GL_CLASS_CONST_LONG("RED_SIZE", SDL_GL_RED_SIZE);
- REGISTER_GL_CLASS_CONST_LONG("GREEN_SIZE", SDL_GL_GREEN_SIZE);
- REGISTER_GL_CLASS_CONST_LONG("BLUE_SIZE", SDL_GL_BLUE_SIZE);
- REGISTER_GL_CLASS_CONST_LONG("ALPHA_SIZE", SDL_GL_ALPHA_SIZE);
- REGISTER_GL_CLASS_CONST_LONG("BUFFER_SIZE", SDL_GL_BUFFER_SIZE),
- REGISTER_GL_CLASS_CONST_LONG("DOUBLEBUFFER", SDL_GL_DOUBLEBUFFER);
- REGISTER_GL_CLASS_CONST_LONG("DEPTH_SIZE", SDL_GL_DEPTH_SIZE);
- REGISTER_GL_CLASS_CONST_LONG("STENCIL_SIZE", SDL_GL_STENCIL_SIZE);
- REGISTER_GL_CLASS_CONST_LONG("ACCUM_RED_SIZE", SDL_GL_ACCUM_RED_SIZE);
- REGISTER_GL_CLASS_CONST_LONG("ACCUM_GREEN_SIZE", SDL_GL_ACCUM_GREEN_SIZE);
- REGISTER_GL_CLASS_CONST_LONG("ACCUM_BLUE_SIZE", SDL_GL_ACCUM_BLUE_SIZE);
- REGISTER_GL_CLASS_CONST_LONG("ACCUM_ALPHA_SIZE", SDL_GL_ACCUM_ALPHA_SIZE);
- REGISTER_GL_CLASS_CONST_LONG("STEREO", SDL_GL_STEREO);
- REGISTER_GL_CLASS_CONST_LONG("MULTISAMPLEBUFFERS", SDL_GL_MULTISAMPLEBUFFERS);
- REGISTER_GL_CLASS_CONST_LONG("MULTISAMPLESAMPLES", SDL_GL_MULTISAMPLESAMPLES),
- REGISTER_GL_CLASS_CONST_LONG("ACCELERATED_VISUAL", SDL_GL_ACCELERATED_VISUAL);
- REGISTER_GL_CLASS_CONST_LONG("RETAINED_BACKING", SDL_GL_RETAINED_BACKING);
- REGISTER_GL_CLASS_CONST_LONG("SHARE_WITH_CURRENT_CONTEXT", SDL_GL_SHARE_WITH_CURRENT_CONTEXT);
-
-#if SDL_VERSION_ATLEAST(2,0,1)
- REGISTER_GL_CLASS_CONST_LONG("FRAMEBUFFER_SRGB_CAPABLE", SDL_GL_FRAMEBUFFER_SRGB_CAPABLE);
+ REGISTER_GL_CLASS_CONST_LONG("RED_SIZE", SDL_GL_RED_SIZE);
+ REGISTER_GL_CLASS_CONST_LONG("GREEN_SIZE", SDL_GL_GREEN_SIZE);
+ REGISTER_GL_CLASS_CONST_LONG("BLUE_SIZE", SDL_GL_BLUE_SIZE);
+ REGISTER_GL_CLASS_CONST_LONG("ALPHA_SIZE", SDL_GL_ALPHA_SIZE);
+ REGISTER_GL_CLASS_CONST_LONG("BUFFER_SIZE", SDL_GL_BUFFER_SIZE),
+ REGISTER_GL_CLASS_CONST_LONG("DOUBLEBUFFER", SDL_GL_DOUBLEBUFFER);
+ REGISTER_GL_CLASS_CONST_LONG("DEPTH_SIZE", SDL_GL_DEPTH_SIZE);
+ REGISTER_GL_CLASS_CONST_LONG("STENCIL_SIZE", SDL_GL_STENCIL_SIZE);
+ REGISTER_GL_CLASS_CONST_LONG("ACCUM_RED_SIZE", SDL_GL_ACCUM_RED_SIZE);
+ REGISTER_GL_CLASS_CONST_LONG("ACCUM_GREEN_SIZE", SDL_GL_ACCUM_GREEN_SIZE);
+ REGISTER_GL_CLASS_CONST_LONG("ACCUM_BLUE_SIZE", SDL_GL_ACCUM_BLUE_SIZE);
+ REGISTER_GL_CLASS_CONST_LONG("ACCUM_ALPHA_SIZE", SDL_GL_ACCUM_ALPHA_SIZE);
+ REGISTER_GL_CLASS_CONST_LONG("STEREO", SDL_GL_STEREO);
+ REGISTER_GL_CLASS_CONST_LONG("MULTISAMPLEBUFFERS", SDL_GL_MULTISAMPLEBUFFERS);
+ REGISTER_GL_CLASS_CONST_LONG("MULTISAMPLESAMPLES", SDL_GL_MULTISAMPLESAMPLES),
+ REGISTER_GL_CLASS_CONST_LONG("ACCELERATED_VISUAL", SDL_GL_ACCELERATED_VISUAL);
+ REGISTER_GL_CLASS_CONST_LONG("RETAINED_BACKING", SDL_GL_RETAINED_BACKING);
+ REGISTER_GL_CLASS_CONST_LONG("SHARE_WITH_CURRENT_CONTEXT", SDL_GL_SHARE_WITH_CURRENT_CONTEXT);
+
+#if SDL_VERSION_ATLEAST(2, 0, 1)
+ REGISTER_GL_CLASS_CONST_LONG("FRAMEBUFFER_SRGB_CAPABLE", SDL_GL_FRAMEBUFFER_SRGB_CAPABLE);
#endif
- REGISTER_GLCONTEXT_CLASS_CONST_LONG("MAJOR_VERSION", SDL_GL_CONTEXT_MAJOR_VERSION);
- REGISTER_GLCONTEXT_CLASS_CONST_LONG("MINOR_VERSION", SDL_GL_CONTEXT_MINOR_VERSION);
- REGISTER_GLCONTEXT_CLASS_CONST_LONG("EGL", SDL_GL_CONTEXT_EGL);
- REGISTER_GLCONTEXT_CLASS_CONST_LONG("FLAGS", SDL_GL_CONTEXT_FLAGS);
- REGISTER_GLCONTEXT_CLASS_CONST_LONG("PROFILE_MASK", SDL_GL_CONTEXT_PROFILE_MASK);
+ REGISTER_GLCONTEXT_CLASS_CONST_LONG("MAJOR_VERSION", SDL_GL_CONTEXT_MAJOR_VERSION);
+ REGISTER_GLCONTEXT_CLASS_CONST_LONG("MINOR_VERSION", SDL_GL_CONTEXT_MINOR_VERSION);
+ REGISTER_GLCONTEXT_CLASS_CONST_LONG("EGL", SDL_GL_CONTEXT_EGL);
+ REGISTER_GLCONTEXT_CLASS_CONST_LONG("FLAGS", SDL_GL_CONTEXT_FLAGS);
+ REGISTER_GLCONTEXT_CLASS_CONST_LONG("PROFILE_MASK", SDL_GL_CONTEXT_PROFILE_MASK);
/* typedef enum SDL_GLprofile; */
- REGISTER_GLCONTEXT_CLASS_CONST_LONG("PROFILE_CORE", SDL_GL_CONTEXT_PROFILE_CORE);
- REGISTER_GLCONTEXT_CLASS_CONST_LONG("PROFILE_COMPATIBILITY", SDL_GL_CONTEXT_PROFILE_COMPATIBILITY);
- REGISTER_GLCONTEXT_CLASS_CONST_LONG("PROFILE_ES", SDL_GL_CONTEXT_PROFILE_ES);
+ REGISTER_GLCONTEXT_CLASS_CONST_LONG("PROFILE_CORE", SDL_GL_CONTEXT_PROFILE_CORE);
+ REGISTER_GLCONTEXT_CLASS_CONST_LONG("PROFILE_COMPATIBILITY", SDL_GL_CONTEXT_PROFILE_COMPATIBILITY);
+ REGISTER_GLCONTEXT_CLASS_CONST_LONG("PROFILE_ES", SDL_GL_CONTEXT_PROFILE_ES);
/* typedef enum SDL_GLcontextFlag; */
- REGISTER_GLCONTEXT_CLASS_CONST_LONG("DEBUG_FLAG", SDL_GL_CONTEXT_DEBUG_FLAG);
+ REGISTER_GLCONTEXT_CLASS_CONST_LONG("DEBUG_FLAG", SDL_GL_CONTEXT_DEBUG_FLAG);
REGISTER_GLCONTEXT_CLASS_CONST_LONG("FORWARD_COMPATIBLE_FLAG", SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG);
- REGISTER_GLCONTEXT_CLASS_CONST_LONG("ROBUST_ACCESS_FLAG", SDL_GL_CONTEXT_ROBUST_ACCESS_FLAG);
- REGISTER_GLCONTEXT_CLASS_CONST_LONG("RESET_ISOLATION_FLAG", SDL_GL_CONTEXT_RESET_ISOLATION_FLAG);
+ REGISTER_GLCONTEXT_CLASS_CONST_LONG("ROBUST_ACCESS_FLAG", SDL_GL_CONTEXT_ROBUST_ACCESS_FLAG);
+ REGISTER_GLCONTEXT_CLASS_CONST_LONG("RESET_ISOLATION_FLAG", SDL_GL_CONTEXT_RESET_ISOLATION_FLAG);
return SUCCESS;
}
diff --git a/src/glcontext.h b/src/glcontext.h
index 237306c..3a73554 100644
--- a/src/glcontext.h
+++ b/src/glcontext.h
@@ -1,6 +1,4 @@
/*
- +----------------------------------------------------------------------+
- | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2018 The PHP Group |
+----------------------------------------------------------------------+
diff --git a/src/joystick.c b/src/joystick.c
index bfa771b..7e55812 100644
--- a/src/joystick.c
+++ b/src/joystick.c
@@ -1,6 +1,4 @@
/*
- +----------------------------------------------------------------------+
- | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
diff --git a/src/joystick.h b/src/joystick.h
index 47c65f5..5dbb44d 100644
--- a/src/joystick.h
+++ b/src/joystick.h
@@ -1,6 +1,4 @@
/*
- +----------------------------------------------------------------------+
- | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
@@ -27,12 +25,6 @@ extern "C"
#include "php_sdl.h"
-#define ARG_PASS_BY_REF 1
-#define ARG_NOT_PASS_BY_REF 0
-
-#define ARG_ALLOW_NULL 1
-#define ARG_NOT_ALLOW_NULL 0
-
ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_NumJoysticks, 0, 0, 0)
ZEND_END_ARG_INFO()
PHP_FUNCTION(SDL_NumJoysticks);
diff --git a/src/keyboard.c b/src/keyboard.c
index 6a76c6a..145c523 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -1,13 +1,11 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) 1997-2022 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_01.txt |
+ | https://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
@@ -28,19 +26,15 @@ extern DECLSPEC SDL_Window * SDLCALL SDL_GetKeyboardFocus(void);
*/
PHP_FUNCTION(SDL_GetKeyboardFocus)
{
- if (zend_parse_parameters_none() == FAILURE) {
+ if (zend_parse_parameters_none() == FAILURE)
+ {
return;
}
sdl_window_to_zval(SDL_GetKeyboardFocus(), return_value, SDL_DONTFREE);
}
/* }}} */
-/* {{{ proto array SDL_GetKeyboardState([int &numkeys [, bool allkeys=true ]])
-
- Standard SDL API
- with allkeys=true return an array of scancode => state array
- PHP Specific, (to reduce memory)
- with allkeys=false return an array of scancode (which are set)
+/* {{{ proto array SDL_GetKeyboardState([int &numkeys])
* \brief Get a snapshot of the current state of the keyboard.
*
@@ -60,32 +54,27 @@ PHP_FUNCTION(SDL_GetKeyboardFocus)
PHP_FUNCTION(SDL_GetKeyboardState)
{
zval *z_numkeys = NULL;
- int i, nb, numkeys;
- zend_bool allkeys=1;
+ int i, numkeys;
const Uint8 *state;
- if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "|zb", &z_numkeys, &allkeys)) {
+ if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "|z", &z_numkeys))
+ {
return;
}
state = SDL_GetKeyboardState(&numkeys);
array_init(return_value);
- for (nb=i=0 ; ir);
- zend_update_property_long(php_sdl_messageboxcolor_ce, value, "g", 1, color->g);
- zend_update_property_long(php_sdl_messageboxcolor_ce, value, "b", 1, color->b);
+ zend_update_property_long(php_sdl_messageboxcolor_ce, Z_OBJ_P(value), "r", 1, color->r);
+ zend_update_property_long(php_sdl_messageboxcolor_ce, Z_OBJ_P(value), "g", 1, color->g);
+ zend_update_property_long(php_sdl_messageboxcolor_ce, Z_OBJ_P(value), "b", 1, color->b);
return 1;
}
@@ -80,11 +82,12 @@ zend_bool sdl_messageboxcolor_to_zval(const SDL_MessageBoxColor *color, zval *va
/* {{{ sdl_messageboxbuttondata_to_zval */
zend_bool sdl_messageboxbuttondata_to_zval(const SDL_MessageBoxButtonData *data, zval *value)
{
- if (data) {
+ if (data)
+ {
object_init_ex(value, php_sdl_messageboxbuttondata_ce);
- zend_update_property_long(php_sdl_messageboxbuttondata_ce, value, ZEND_STRL("flags"), data->flags);
- zend_update_property_long(php_sdl_messageboxbuttondata_ce, value, ZEND_STRL("buttonid"), data->buttonid);
- zend_update_property_string(php_sdl_messageboxbuttondata_ce, value, ZEND_STRL("text"), data->text);
+ zend_update_property_long(php_sdl_messageboxbuttondata_ce, Z_OBJ_P(value), ZEND_STRL("flags"), data->flags);
+ zend_update_property_long(php_sdl_messageboxbuttondata_ce, Z_OBJ_P(value), ZEND_STRL("buttonid"), data->buttonid);
+ zend_update_property_string(php_sdl_messageboxbuttondata_ce, Z_OBJ_P(value), ZEND_STRL("text"), data->text);
return 1;
}
@@ -96,13 +99,14 @@ zend_bool sdl_messageboxbuttondata_to_zval(const SDL_MessageBoxButtonData *data,
/* {{{ sdl_messageboxdata_to_zval */
zend_bool sdl_messageboxdata_to_zval(SDL_MessageBoxData *data, zval *z_val, Uint32 flags)
{
- if (data) {
+ if (data)
+ {
struct php_sdl_messageboxdata *intern;
object_init_ex(z_val, php_sdl_messageboxdata_ce);
intern = (struct php_sdl_messageboxdata *)Z_OBJ_P(z_val);
- intern->data = data;
- intern->flags = flags;
+ intern->data = data;
+ intern->flags = flags;
return 1;
}
@@ -114,20 +118,21 @@ zend_bool sdl_messageboxdata_to_zval(SDL_MessageBoxData *data, zval *z_val, Uint
/* {{{ zval_to_sdl_messageboxcolor( */
zend_bool zval_to_sdl_messageboxcolor(zval *value, SDL_MessageBoxColor *color)
{
- if (Z_TYPE_P(value) == IS_OBJECT && Z_OBJCE_P(value) == php_sdl_messageboxcolor_ce) {
+ if (Z_TYPE_P(value) == IS_OBJECT && Z_OBJCE_P(value) == php_sdl_messageboxcolor_ce)
+ {
zval *val, rv;
/* we convert the properties, without copy: yes ! */
- val = zend_read_property(php_sdl_messageboxcolor_ce, value, "r", 1, 0, &rv);
+ val = zend_read_property(php_sdl_messageboxcolor_ce, Z_OBJ_P(value), "r", 1, 0, &rv);
convert_to_long(val);
Z_LVAL_P(val) = color->r = (Uint8)Z_LVAL_P(val);
- val = zend_read_property(php_sdl_messageboxcolor_ce, value, "g", 1, 0, &rv);
+ val = zend_read_property(php_sdl_messageboxcolor_ce, Z_OBJ_P(value), "g", 1, 0, &rv);
convert_to_long(val);
Z_LVAL_P(val) = color->g = (Uint8)Z_LVAL_P(val);
- val = zend_read_property(php_sdl_messageboxcolor_ce, value, "b", 1, 0, &rv);
+ val = zend_read_property(php_sdl_messageboxcolor_ce, Z_OBJ_P(value), "b", 1, 0, &rv);
convert_to_long(val);
Z_LVAL_P(val) = color->b = (Uint8)Z_LVAL_P(val);
@@ -142,20 +147,21 @@ zend_bool zval_to_sdl_messageboxcolor(zval *value, SDL_MessageBoxColor *color)
/* {{{ zval_to_sdl_messageboxcolor( */
zend_bool zval_to_sdl_messageboxbuttondata(zval *value, SDL_MessageBoxButtonData *data)
{
- if (Z_TYPE_P(value) == IS_OBJECT && Z_OBJCE_P(value) == php_sdl_messageboxbuttondata_ce) {
+ if (Z_TYPE_P(value) == IS_OBJECT && Z_OBJCE_P(value) == php_sdl_messageboxbuttondata_ce)
+ {
zval *val, rv;
/* we convert the properties, without copy: yes ! */
- val = zend_read_property(php_sdl_messageboxbuttondata_ce, value, ZEND_STRL("flags"), 0, &rv);
+ val = zend_read_property(php_sdl_messageboxbuttondata_ce, Z_OBJ_P(value), ZEND_STRL("flags"), 0, &rv);
convert_to_long(val);
Z_LVAL_P(val) = data->flags = (Uint32)Z_LVAL_P(val);
- val = zend_read_property(php_sdl_messageboxbuttondata_ce, value, ZEND_STRL("buttonid"), 0, &rv);
+ val = zend_read_property(php_sdl_messageboxbuttondata_ce, Z_OBJ_P(value), ZEND_STRL("buttonid"), 0, &rv);
convert_to_long(val);
Z_LVAL_P(val) = data->buttonid = (int)Z_LVAL_P(val);
- val = zend_read_property(php_sdl_messageboxbuttondata_ce, value, ZEND_STRL("text"), 0, &rv);
+ val = zend_read_property(php_sdl_messageboxbuttondata_ce, Z_OBJ_P(value), ZEND_STRL("text"), 0, &rv);
convert_to_string(val);
data->text = Z_STRVAL_P(val);
@@ -170,30 +176,35 @@ zend_bool zval_to_sdl_messageboxbuttondata(zval *value, SDL_MessageBoxButtonData
/* {{{ zval_to_sdl_messageboxdata */
SDL_MessageBoxData *zval_to_sdl_messageboxdata(zval *z_val)
{
- if (z_val && Z_TYPE_P(z_val) == IS_OBJECT && Z_OBJCE_P(z_val) == php_sdl_messageboxdata_ce) {
+ if (z_val && Z_TYPE_P(z_val) == IS_OBJECT && Z_OBJCE_P(z_val) == php_sdl_messageboxdata_ce)
+ {
struct php_sdl_messageboxdata *intern;
intern = (struct php_sdl_messageboxdata *)Z_OBJ_P(z_val);
return intern->data;
- }
+ }
return NULL;
}
/* }}} */
/* {{{ php_sdl_messageboxdata_free
- */
+ */
static void php_sdl_messageboxdata_free(zend_object *object)
{
- struct php_sdl_messageboxdata *intern = (struct php_sdl_messageboxdata *) object;
+ struct php_sdl_messageboxdata *intern = (struct php_sdl_messageboxdata *)object;
- if (intern->data) {
- if (!(intern->flags & SDL_DONTFREE)) {
+ if (intern->data)
+ {
+ if (!(intern->flags & SDL_DONTFREE))
+ {
efree((void *)intern->data->title);
efree((void *)intern->data->message);
- if (intern->data->buttons) {
+ if (intern->data->buttons)
+ {
efree((void *)intern->data->buttons);
}
- if (intern->data->colorScheme) {
+ if (intern->data->colorScheme)
+ {
efree((void *)intern->data->colorScheme);
}
efree(intern->data);
@@ -206,7 +217,7 @@ static void php_sdl_messageboxdata_free(zend_object *object)
/* {{{ php_sdl_messageboxdata_new
*/
-static zend_object* php_sdl_messageboxdata_new(zend_class_entry *class_type)
+static zend_object *php_sdl_messageboxdata_new(zend_class_entry *class_type)
{
struct php_sdl_messageboxdata *intern;
@@ -223,11 +234,10 @@ static zend_object* php_sdl_messageboxdata_new(zend_class_entry *class_type)
}
/* }}} */
-
ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_MessageBoxColor__construct, 0, 0, 3)
- ZEND_ARG_INFO(0, r)
- ZEND_ARG_INFO(0, g)
- ZEND_ARG_INFO(0, b)
+ZEND_ARG_INFO(0, r)
+ZEND_ARG_INFO(0, g)
+ZEND_ARG_INFO(0, b)
ZEND_END_ARG_INFO()
/* {{{ proto SDL_MessageBoxColor::__construct(int r, int g, int b, int a)
@@ -235,7 +245,7 @@ ZEND_END_ARG_INFO()
* \brief RGB value used in a message box color scheme
typedef struct
{
- Uint8 r, g, b;
+ Uint8 r, g, b;
} SDL_MessageBoxColor;
*/
static PHP_METHOD(SDL_MessageBoxColor, __construct)
@@ -244,18 +254,21 @@ static PHP_METHOD(SDL_MessageBoxColor, __construct)
zend_error_handling error_handling;
zend_replace_error_handling(EH_THROW, NULL, &error_handling);
- if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "lll", &r, &g, &b)) {
+ if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "lll", &r, &g, &b))
+ {
zend_restore_error_handling(&error_handling);
return;
}
zend_restore_error_handling(&error_handling);
- zend_update_property_long(php_sdl_messageboxcolor_ce, getThis(), "r", 1, r&255);
- zend_update_property_long(php_sdl_messageboxcolor_ce, getThis(), "g", 1, g&255);
- zend_update_property_long(php_sdl_messageboxcolor_ce, getThis(), "b", 1, b&255);
+ zend_update_property_long(php_sdl_messageboxcolor_ce, Z_OBJ_P(getThis()), "r", 1, r & 255);
+ zend_update_property_long(php_sdl_messageboxcolor_ce, Z_OBJ_P(getThis()), "g", 1, g & 255);
+ zend_update_property_long(php_sdl_messageboxcolor_ce, Z_OBJ_P(getThis()), "b", 1, b & 255);
}
/* }}} */
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_SDL_MessageBoxColor__toString, 0, 0, IS_STRING, 0)
+ZEND_END_ARG_INFO()
/* {{{ proto SDL_MessageBoxColor::__toString() */
static PHP_METHOD(SDL_MessageBoxColor, __toString)
@@ -263,8 +276,9 @@ static PHP_METHOD(SDL_MessageBoxColor, __toString)
char *buf;
SDL_MessageBoxColor color;
- //intern = (struct php_sdl_pixelformat *)Z_OBJ_P(__id);
- if (zend_parse_parameters_none() == FAILURE) {
+ // intern = (struct php_sdl_pixelformat *)Z_OBJ_P(__id);
+ if (zend_parse_parameters_none() == FAILURE)
+ {
return;
}
@@ -274,11 +288,10 @@ static PHP_METHOD(SDL_MessageBoxColor, __toString)
}
/* }}} */
-
ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_MessageBoxButtonData__construct, 0, 0, 3)
- ZEND_ARG_INFO(0, flags)
- ZEND_ARG_INFO(0, buttonid)
- ZEND_ARG_INFO(0, text)
+ZEND_ARG_INFO(0, flags)
+ZEND_ARG_INFO(0, buttonid)
+ZEND_ARG_INFO(0, text)
ZEND_END_ARG_INFO()
/* {{{ proto SDL_MessageBoxButtonData::__construct(int r, int g, int b, int a)
@@ -286,9 +299,9 @@ ZEND_END_ARG_INFO()
* \brief Individual button data.
typedef struct
{
- Uint32 flags; *< ::SDL_MessageBoxButtonFlags *
- int buttonid; *< User defined button id (value returned via SDL_ShowMessageBox) *
- const char * text; *< The UTF-8 button text *
+ Uint32 flags; *< ::SDL_MessageBoxButtonFlags *
+ int buttonid; *< User defined button id (value returned via SDL_ShowMessageBox) *
+ const char * text; *< The UTF-8 button text *
} SDL_MessageBoxButtonData;
*/
static PHP_METHOD(SDL_MessageBoxButtonData, __construct)
@@ -299,27 +312,31 @@ static PHP_METHOD(SDL_MessageBoxButtonData, __construct)
zend_error_handling error_handling;
zend_replace_error_handling(EH_THROW, NULL, &error_handling);
- if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "lls", &flags, &id, &text, &text_len)) {
+ if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "lls", &flags, &id, &text, &text_len))
+ {
zend_restore_error_handling(&error_handling);
return;
}
zend_restore_error_handling(&error_handling);
- zend_update_property_long(php_sdl_messageboxbuttondata_ce, getThis(), ZEND_STRL("flags"), flags);
- zend_update_property_long(php_sdl_messageboxbuttondata_ce, getThis(), ZEND_STRL("buttonid"), (int)id);
- zend_update_property_string(php_sdl_messageboxbuttondata_ce, getThis(), ZEND_STRL("text"), text);
+ zend_update_property_long(php_sdl_messageboxbuttondata_ce, Z_OBJ_P(getThis()), ZEND_STRL("flags"), flags);
+ zend_update_property_long(php_sdl_messageboxbuttondata_ce, Z_OBJ_P(getThis()), ZEND_STRL("buttonid"), (int)id);
+ zend_update_property_string(php_sdl_messageboxbuttondata_ce, Z_OBJ_P(getThis()), ZEND_STRL("text"), text);
}
/* }}} */
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_SDL_MessageBoxButtonData___toString, 0, 0, IS_STRING, 0)
+ZEND_END_ARG_INFO()
/* {{{ proto SDL_MessageBoxButtonData::__toString()
-*/
+ */
static PHP_METHOD(SDL_MessageBoxButtonData, __toString)
{
char *buf;
SDL_MessageBoxButtonData data;
- if (zend_parse_parameters_none() == FAILURE) {
+ if (zend_parse_parameters_none() == FAILURE)
+ {
return;
}
zval_to_sdl_messageboxbuttondata(getThis(), &data);
@@ -328,14 +345,13 @@ static PHP_METHOD(SDL_MessageBoxButtonData, __toString)
}
/* }}} */
-
ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_MessageBoxData__construct, 0, 0, 3)
- ZEND_ARG_INFO(0, flags)
- ZEND_ARG_INFO(0, title)
- ZEND_ARG_INFO(0, message)
- ZEND_ARG_ARRAY_INFO(0, buttons, 0)
- ZEND_ARG_ARRAY_INFO(0, colors, 0)
- ZEND_ARG_OBJ_INFO(0, parentwindow, SDL_Window, 0)
+ZEND_ARG_INFO(0, flags)
+ZEND_ARG_INFO(0, title)
+ZEND_ARG_INFO(0, message)
+ZEND_ARG_ARRAY_INFO(0, buttons, 0)
+ZEND_ARG_ARRAY_INFO(0, colors, 0)
+ZEND_ARG_OBJ_INFO(0, parentwindow, SDL_Window, 0)
ZEND_END_ARG_INFO()
/* {{{ proto SDL_MessageBoxData::__construct(int flags, string title, string text [, array buttons [, array colors [, SDL_Window window ]]])
@@ -343,103 +359,126 @@ ZEND_END_ARG_INFO()
* \brief MessageBox structure containing title, text, window, etc.
typedef struct
{
- Uint32 flags; **< ::SDL_MessageBoxFlags *
- SDL_Window *window; **< Parent window, can be NULL *
- const char *title; **< UTF-8 title *
- const char *message; **< UTF-8 message text *
+ Uint32 flags; **< ::SDL_MessageBoxFlags *
+ SDL_Window *window; **< Parent window, can be NULL *
+ const char *title; **< UTF-8 title *
+ const char *message; **< UTF-8 message text *
- int numbuttons;
- const SDL_MessageBoxButtonData *buttons;
+ int numbuttons;
+ const SDL_MessageBoxButtonData *buttons;
- const SDL_MessageBoxColorScheme *colorScheme; **< ::SDL_MessageBoxColorScheme, can be NULL to use system settings *
+ const SDL_MessageBoxColorScheme *colorScheme; **< ::SDL_MessageBoxColorScheme, can be NULL to use system settings *
} SDL_MessageBoxData;
*/
static PHP_METHOD(SDL_MessageBoxData, __construct)
{
struct php_sdl_messageboxdata *intern;
- zval *z_window=NULL, *z_buttons=NULL, *z_colors=NULL;
+ zval *z_window = NULL, *z_buttons = NULL, *z_colors = NULL;
zend_long flags;
char *title, *text;
size_t title_len, text_len;
- int n, nb;
+ int n, nb;
zend_error_handling error_handling;
intern = (struct php_sdl_messageboxdata *)Z_OBJ_P(getThis());
zend_replace_error_handling(EH_THROW, NULL, &error_handling);
- if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "lss|aaO", &flags, &title, &title_len, &text, &text_len, &z_buttons, &z_colors, &z_window, get_php_sdl_window_ce())) {
+ if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "lss|aaO", &flags, &title, &title_len, &text, &text_len, &z_buttons, &z_colors, &z_window, get_php_sdl_window_ce()))
+ {
zend_restore_error_handling(&error_handling);
return;
}
zend_restore_error_handling(&error_handling);
- intern->flags = 0;
+ intern->flags = 0;
intern->data = emalloc(sizeof(SDL_MessageBoxData));
- intern->data->title = estrdup(title);
- intern->data->message = estrdup(text);
- intern->data->flags = (Uint32)flags;
- intern->data->window = zval_to_sdl_window(z_window);
- intern->data->numbuttons = 0;
- intern->data->buttons = NULL;
+ intern->data->title = estrdup(title);
+ intern->data->message = estrdup(text);
+ intern->data->flags = (Uint32)flags;
+ intern->data->window = zval_to_sdl_window(z_window);
+ intern->data->numbuttons = 0;
+ intern->data->buttons = NULL;
intern->data->colorScheme = NULL;
- if (z_buttons) {
+ if (z_buttons)
+ {
zval *ppzval;
SDL_MessageBoxButtonData *buttons;
- n = 0;
+ n = 0;
nb = zend_hash_num_elements(Z_ARRVAL_P(z_buttons));
- if (nb) {
+ if (nb)
+ {
buttons = emalloc(nb * sizeof(SDL_MessageBoxButtonData));
- ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(z_buttons), ppzval) {
- if (zval_to_sdl_messageboxbuttondata(ppzval, buttons+n)) {
- n++;
- } else {
- php_error_docref(NULL, E_NOTICE, "Ignore button, not a SDL_MessageBoxButtonData object");
- }
+ ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(z_buttons), ppzval)
+ {
+ if (zval_to_sdl_messageboxbuttondata(ppzval, buttons + n))
+ {
+ n++;
+ }
+ else
+ {
+ php_error_docref(NULL, E_NOTICE, "Ignore button, not a SDL_MessageBoxButtonData object");
+ }
}
ZEND_HASH_FOREACH_END();
- if (n) {
+ if (n)
+ {
intern->data->numbuttons = n;
- intern->data->buttons = buttons;
- } else {
+ intern->data->buttons = buttons;
+ }
+ else
+ {
efree(buttons);
}
}
}
- if (z_colors) {
+ if (z_colors)
+ {
zval *ppzval = NULL;
SDL_MessageBoxColorScheme *colors;
colors = emalloc(sizeof(SDL_MessageBoxColorScheme));
memset(colors, 0, sizeof(*colors));
- n = 0;
- ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(z_colors), ppzval) {
- if (SDL_MESSAGEBOX_COLOR_MAX == n) {
- php_error_docref(NULL, E_NOTICE, "Ignore button, only %d accepted", SDL_MESSAGEBOX_COLOR_MAX);
- } else if (zval_to_sdl_messageboxcolor(ppzval, &colors->colors[n])) {
- n++;
- } else {
- php_error_docref(NULL, E_NOTICE, "Ignore button, not a SDL_MessageBoxColor object");
- }
+ n = 0;
+ ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(z_colors), ppzval)
+ {
+ if (SDL_MESSAGEBOX_COLOR_MAX == n)
+ {
+ php_error_docref(NULL, E_NOTICE, "Ignore button, only %d accepted", SDL_MESSAGEBOX_COLOR_MAX);
+ }
+ else if (zval_to_sdl_messageboxcolor(ppzval, &colors->colors[n]))
+ {
+ n++;
+ }
+ else
+ {
+ php_error_docref(NULL, E_NOTICE, "Ignore button, not a SDL_MessageBoxColor object");
+ }
}
ZEND_HASH_FOREACH_END();
- if (n) {
- if (SDL_MESSAGEBOX_COLOR_MAX != n) {
+ if (n)
+ {
+ if (SDL_MESSAGEBOX_COLOR_MAX != n)
+ {
php_error_docref(NULL, E_NOTICE, "%d SDL_MessageBoxColors expected", SDL_MESSAGEBOX_COLOR_MAX);
}
intern->data->colorScheme = colors;
- } else {
+ }
+ else
+ {
efree(colors);
}
}
}
/* }}} */
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_SDL_MessageBoxData___toString, 0, 0, IS_STRING, 0)
+ZEND_END_ARG_INFO()
/* {{{ proto SDL_MessageBoxData::__toString() */
static PHP_METHOD(SDL_MessageBoxData, __toString)
@@ -447,33 +486,38 @@ static PHP_METHOD(SDL_MessageBoxData, __toString)
struct php_sdl_messageboxdata *intern;
char *buf;
- if (zend_parse_parameters_none() == FAILURE) {
+ if (zend_parse_parameters_none() == FAILURE)
+ {
return;
}
intern = (struct php_sdl_messageboxdata *)Z_OBJ_P(getThis());
- if (intern->data) {
+ if (intern->data)
+ {
spprintf(&buf, 100, "SDL_MessageBoxData(\"%s\")", intern->data->title);
RETVAL_STRING(buf);
- } else {
+ }
+ else
+ {
RETVAL_STRING("SDL_MessageBoxData()");
}
}
/* }}} */
ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_MessageBoxData_Show, 0, 0, 1)
- ZEND_ARG_INFO(1, buttonid)
+ZEND_ARG_INFO(1, buttonid)
ZEND_END_ARG_INFO()
-#define FETCH_DATA(__ptr, __id, __check) \
-{ \
- intern = (struct php_sdl_messageboxdata *)Z_OBJ_P(__id);\
- __ptr = intern->data; \
- if (__check && !__ptr) {\
- php_error_docref(NULL, E_WARNING, "Invalid %s object", ZSTR_VAL(intern->zo.ce->name));\
- RETURN_FALSE;\
- }\
-}
+#define FETCH_DATA(__ptr, __id, __check) \
+ { \
+ intern = (struct php_sdl_messageboxdata *)Z_OBJ_P(__id); \
+ __ptr = intern->data; \
+ if (__check && !__ptr) \
+ { \
+ php_error_docref(NULL, E_WARNING, "Invalid %s object", ZSTR_VAL(intern->zo.ce->name)); \
+ RETURN_FALSE; \
+ } \
+ }
/* {{{ proto int SDL_ShowMessageBox(SDL_MessageBoxData messageboxdata, int &buttonid)
@@ -498,16 +542,20 @@ PHP_FUNCTION(SDL_ShowMessageBox)
SDL_MessageBoxData *data;
int id, res;
- if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oz/", &z_data, php_sdl_messageboxdata_ce, &z_id) == FAILURE) {
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oz/", &z_data, php_sdl_messageboxdata_ce, &z_id) == FAILURE)
+ {
return;
}
FETCH_DATA(data, z_data, 1);
res = SDL_ShowMessageBox(data, &id);
- if (res==0) {
+ if (res == 0)
+ {
zval_dtor(z_id);
ZVAL_LONG(z_id, (long)id);
}
+
+ RETVAL_LONG(res);
}
/* }}} */
@@ -533,54 +581,49 @@ PHP_FUNCTION(SDL_ShowSimpleMessageBox)
zval *z_window = NULL;
SDL_Window *window = NULL;
- if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "lss|O!", &flags, &title, &title_len, &msg, &msg_len, &z_window, get_php_sdl_window_ce())) {
+ if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "lss|O!", &flags, &title, &title_len, &msg, &msg_len, &z_window, get_php_sdl_window_ce()))
+ {
return;
}
- if( z_window != NULL ) {
+ if (z_window != NULL)
+ {
window = zval_to_sdl_window(z_window);
}
RETVAL_LONG(SDL_ShowSimpleMessageBox(flags, title, msg, window));
}
/* }}} */
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_messagebox_none, 0, 0, 0)
-ZEND_END_ARG_INFO()
-
/* {{{ php_sdl_messageboxcolor_methods[] */
static const zend_function_entry php_sdl_messageboxcolor_methods[] = {
- PHP_ME(SDL_MessageBoxColor, __construct, arginfo_SDL_MessageBoxColor__construct, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC)
- PHP_ME(SDL_MessageBoxColor, __toString, arginfo_messagebox_none, ZEND_ACC_PUBLIC)
+ PHP_ME(SDL_MessageBoxColor, __construct, arginfo_SDL_MessageBoxColor__construct, ZEND_ACC_CTOR | ZEND_ACC_PUBLIC)
+ PHP_ME(SDL_MessageBoxColor, __toString, arginfo_class_SDL_MessageBoxColor__toString, ZEND_ACC_PUBLIC)
- PHP_FE_END
-};
+ PHP_FE_END};
/* }}} */
/* {{{ php_sdl_messageboxbuttondata_methods[] */
static const zend_function_entry php_sdl_messageboxbuttondata_methods[] = {
- PHP_ME(SDL_MessageBoxButtonData, __construct, arginfo_SDL_MessageBoxButtonData__construct, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC)
- PHP_ME(SDL_MessageBoxButtonData, __toString, arginfo_messagebox_none, ZEND_ACC_PUBLIC)
+ PHP_ME(SDL_MessageBoxButtonData, __construct, arginfo_SDL_MessageBoxButtonData__construct, ZEND_ACC_CTOR | ZEND_ACC_PUBLIC)
+ PHP_ME(SDL_MessageBoxButtonData, __toString, arginfo_class_SDL_MessageBoxButtonData___toString, ZEND_ACC_PUBLIC)
- PHP_FE_END
-};
+ PHP_FE_END};
/* }}} */
/* {{{ php_sdl_messageboxdata_methods[] */
static const zend_function_entry php_sdl_messageboxdata_methods[] = {
- PHP_ME(SDL_MessageBoxData, __construct, arginfo_SDL_MessageBoxData__construct, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC)
- PHP_ME(SDL_MessageBoxData, __toString, arginfo_messagebox_none, ZEND_ACC_PUBLIC)
+ PHP_ME(SDL_MessageBoxData, __construct, arginfo_SDL_MessageBoxData__construct, ZEND_ACC_CTOR | ZEND_ACC_PUBLIC)
+ PHP_ME(SDL_MessageBoxData, __toString, arginfo_class_SDL_MessageBoxData___toString, ZEND_ACC_PUBLIC)
/* non-static methods */
- PHP_FALIAS(Show, SDL_ShowMessageBox, arginfo_SDL_MessageBoxData_Show)
+ PHP_FALIAS(Show, SDL_ShowMessageBox, arginfo_SDL_MessageBoxData_Show)
- PHP_FE_END
-};
+ PHP_FE_END};
/* }}} */
-#define REGISTER_MESSAGEBOX_CLASS_CONST_LONG(prefix, const_name, value, ce) \
+#define REGISTER_MESSAGEBOX_CLASS_CONST_LONG(prefix, const_name, value, ce) \
REGISTER_LONG_CONSTANT("SDL_MESSAGEBOX_" prefix const_name, value, CONST_CS | CONST_PERSISTENT); \
- zend_declare_class_constant_long(ce, ZEND_STRL(const_name), value); \
+ zend_declare_class_constant_long(ce, ZEND_STRL(const_name), value);
#define REGISTER_MESSAGEBOXCOLOR_PROP(name) \
zend_declare_property_long(php_sdl_messageboxcolor_ce, ZEND_STRL(name), 0, ZEND_ACC_PUBLIC)
@@ -615,17 +658,17 @@ PHP_MINIT_FUNCTION(sdl_messagebox)
memcpy(&php_sdl_messageboxdata_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
php_sdl_messageboxdata_handlers.free_obj = php_sdl_messageboxdata_free;
- zend_declare_property_long(php_sdl_messageboxdata_ce, ZEND_STRL("flags"), 0, ZEND_ACC_PUBLIC);
- zend_declare_property_null(php_sdl_messageboxdata_ce, ZEND_STRL("title"), ZEND_ACC_PUBLIC);
- zend_declare_property_null(php_sdl_messageboxdata_ce, ZEND_STRL("message"), ZEND_ACC_PUBLIC);
- zend_declare_property_bool(php_sdl_messageboxdata_ce, ZEND_STRL("window"), 0, ZEND_ACC_PUBLIC);
- zend_declare_property_long(php_sdl_messageboxdata_ce, ZEND_STRL("numbuttons"), 0, ZEND_ACC_PUBLIC);
- zend_declare_property_null(php_sdl_messageboxdata_ce, ZEND_STRL("buttons"), ZEND_ACC_PUBLIC);
- zend_declare_property_null(php_sdl_messageboxdata_ce, ZEND_STRL("colors"), ZEND_ACC_PUBLIC);
+ zend_declare_property_long(php_sdl_messageboxdata_ce, ZEND_STRL("flags"), 0, ZEND_ACC_PUBLIC);
+ zend_declare_property_null(php_sdl_messageboxdata_ce, ZEND_STRL("title"), ZEND_ACC_PUBLIC);
+ zend_declare_property_null(php_sdl_messageboxdata_ce, ZEND_STRL("message"), ZEND_ACC_PUBLIC);
+ zend_declare_property_bool(php_sdl_messageboxdata_ce, ZEND_STRL("window"), 0, ZEND_ACC_PUBLIC);
+ zend_declare_property_long(php_sdl_messageboxdata_ce, ZEND_STRL("numbuttons"), 0, ZEND_ACC_PUBLIC);
+ zend_declare_property_null(php_sdl_messageboxdata_ce, ZEND_STRL("buttons"), ZEND_ACC_PUBLIC);
+ zend_declare_property_null(php_sdl_messageboxdata_ce, ZEND_STRL("colors"), ZEND_ACC_PUBLIC);
/* enum SDL_MessageBoxFlags: If supported will display warning icon, etc. */
- REGISTER_MESSAGEBOX_CLASS_CONST_LONG("", "ERROR", SDL_MESSAGEBOX_ERROR, php_sdl_messageboxdata_ce);
- REGISTER_MESSAGEBOX_CLASS_CONST_LONG("", "WARNING", SDL_MESSAGEBOX_WARNING, php_sdl_messageboxdata_ce);
+ REGISTER_MESSAGEBOX_CLASS_CONST_LONG("", "ERROR", SDL_MESSAGEBOX_ERROR, php_sdl_messageboxdata_ce);
+ REGISTER_MESSAGEBOX_CLASS_CONST_LONG("", "WARNING", SDL_MESSAGEBOX_WARNING, php_sdl_messageboxdata_ce);
REGISTER_MESSAGEBOX_CLASS_CONST_LONG("", "INFORMATION", SDL_MESSAGEBOX_INFORMATION, php_sdl_messageboxdata_ce);
/* enum SDL_MessageBoxButtonFlags: Flags for SDL_MessageBoxButtonData. */
@@ -633,12 +676,12 @@ PHP_MINIT_FUNCTION(sdl_messagebox)
REGISTER_MESSAGEBOX_CLASS_CONST_LONG("BUTTON_", "ESCAPEKEY_DEFAULT", SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT, php_sdl_messageboxbuttondata_ce);
/* enum SDL_MessageBoxColorType */
- REGISTER_MESSAGEBOX_CLASS_CONST_LONG("COLOR_", "BACKGROUND", SDL_MESSAGEBOX_COLOR_BACKGROUND, php_sdl_messageboxcolor_ce);
- REGISTER_MESSAGEBOX_CLASS_CONST_LONG("COLOR_", "TEXT", SDL_MESSAGEBOX_COLOR_TEXT, php_sdl_messageboxcolor_ce);
- REGISTER_MESSAGEBOX_CLASS_CONST_LONG("COLOR_", "BUTTON_BORDER", SDL_MESSAGEBOX_COLOR_BUTTON_BORDER, php_sdl_messageboxcolor_ce);
+ REGISTER_MESSAGEBOX_CLASS_CONST_LONG("COLOR_", "BACKGROUND", SDL_MESSAGEBOX_COLOR_BACKGROUND, php_sdl_messageboxcolor_ce);
+ REGISTER_MESSAGEBOX_CLASS_CONST_LONG("COLOR_", "TEXT", SDL_MESSAGEBOX_COLOR_TEXT, php_sdl_messageboxcolor_ce);
+ REGISTER_MESSAGEBOX_CLASS_CONST_LONG("COLOR_", "BUTTON_BORDER", SDL_MESSAGEBOX_COLOR_BUTTON_BORDER, php_sdl_messageboxcolor_ce);
REGISTER_MESSAGEBOX_CLASS_CONST_LONG("COLOR_", "BUTTON_BACKGROUND", SDL_MESSAGEBOX_COLOR_BUTTON_BACKGROUND, php_sdl_messageboxcolor_ce);
- REGISTER_MESSAGEBOX_CLASS_CONST_LONG("COLOR_", "BUTTON_SELECTED", SDL_MESSAGEBOX_COLOR_BUTTON_SELECTED, php_sdl_messageboxcolor_ce);
- REGISTER_MESSAGEBOX_CLASS_CONST_LONG("COLOR_", "MAX", SDL_MESSAGEBOX_COLOR_MAX, php_sdl_messageboxcolor_ce);
+ REGISTER_MESSAGEBOX_CLASS_CONST_LONG("COLOR_", "BUTTON_SELECTED", SDL_MESSAGEBOX_COLOR_BUTTON_SELECTED, php_sdl_messageboxcolor_ce);
+ REGISTER_MESSAGEBOX_CLASS_CONST_LONG("COLOR_", "MAX", SDL_MESSAGEBOX_COLOR_MAX, php_sdl_messageboxcolor_ce);
return SUCCESS;
}
diff --git a/src/messagebox.h b/src/messagebox.h
index b304b0a..c296428 100644
--- a/src/messagebox.h
+++ b/src/messagebox.h
@@ -1,6 +1,4 @@
/*
- +----------------------------------------------------------------------+
- | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2018 The PHP Group |
+----------------------------------------------------------------------+
diff --git a/src/mouse.c b/src/mouse.c
index aa59cd1..23af147 100644
--- a/src/mouse.c
+++ b/src/mouse.c
@@ -1,13 +1,11 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) 1997-2022 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_01.txt |
+ | https://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
@@ -23,10 +21,11 @@
static zend_class_entry *php_sdl_cursor_ce;
static zend_object_handlers php_sdl_cursor_handlers;
-struct php_sdl_cursor {
- SDL_Cursor *cursor;
- Uint32 flags;
- zend_object zo;
+struct php_sdl_cursor
+{
+ SDL_Cursor *cursor;
+ Uint32 flags;
+ zend_object zo;
};
/* {{{ get_php_sdl_cursor_ce */
@@ -36,28 +35,30 @@ zend_class_entry *get_php_sdl_cursor_ce(void)
}
/* }}} */
-#define FETCH_CURSOR(__ptr, __id, __check) \
-{ \
- zend_object* zo = Z_OBJ_P(__id);\
- intern = (struct php_sdl_cursor *)((char*)zo - zo->handlers->offset);\
- __ptr = intern->cursor; \
- if (__check && !__ptr) {\
- php_error_docref(NULL, E_WARNING, "Invalid %s object", ZSTR_VAL(intern->zo.ce->name));\
- RETURN_FALSE;\
- }\
-}
+#define FETCH_CURSOR(__ptr, __id, __check) \
+ { \
+ zend_object *zo = Z_OBJ_P(__id); \
+ intern = (struct php_sdl_cursor *)((char *)zo - zo->handlers->offset); \
+ __ptr = intern->cursor; \
+ if (__check && !__ptr) \
+ { \
+ php_error_docref(NULL, E_WARNING, "Invalid %s object", ZSTR_VAL(intern->zo.ce->name)); \
+ RETURN_FALSE; \
+ } \
+ }
/* {{{ sdl_cursor_to_zval */
zend_bool sdl_cursor_to_zval(SDL_Cursor *cursor, zval *z_val, Uint32 flags)
{
- if (cursor) {
+ if (cursor)
+ {
struct php_sdl_cursor *intern;
object_init_ex(z_val, php_sdl_cursor_ce);
- zend_object* zo = Z_OBJ_P(z_val);
- intern = (struct php_sdl_cursor *)((char*)zo - zo->handlers->offset);
+ zend_object *zo = Z_OBJ_P(z_val);
+ intern = (struct php_sdl_cursor *)((char *)zo - zo->handlers->offset);
intern->cursor = cursor;
- intern->flags = flags;
+ intern->flags = flags;
return 1;
}
@@ -66,28 +67,28 @@ zend_bool sdl_cursor_to_zval(SDL_Cursor *cursor, zval *z_val, Uint32 flags)
}
/* }}} */
-
/* {{{ zval_to_sdl_cursor */
SDL_GLContext zval_to_sdl_cursor(zval *z_val)
{
struct php_sdl_cursor *intern;
- if (Z_TYPE_P(z_val) == IS_OBJECT && Z_OBJCE_P(z_val) == php_sdl_cursor_ce) {
- zend_object* zo = Z_OBJ_P(z_val);
- intern = (struct php_sdl_cursor*)((char*)zo - zo->handlers->offset);
+ if (Z_TYPE_P(z_val) == IS_OBJECT && Z_OBJCE_P(z_val) == php_sdl_cursor_ce)
+ {
+ zend_object *zo = Z_OBJ_P(z_val);
+ intern = (struct php_sdl_cursor *)((char *)zo - zo->handlers->offset);
return intern->cursor;
}
return NULL;
}
/* }}} */
-
/* {{{ php_sdl_cursor_free */
static void php_sdl_cursor_free(zend_object *object)
{
- struct php_sdl_cursor *intern = (struct php_sdl_cursor *)((char*)object - object->handlers->offset);
+ struct php_sdl_cursor *intern = (struct php_sdl_cursor *)((char *)object - object->handlers->offset);
- if (intern->cursor && !(intern->flags & SDL_DONTFREE)) {
+ if (intern->cursor && !(intern->flags & SDL_DONTFREE))
+ {
SDL_FreeCursor(intern->cursor);
}
@@ -95,10 +96,9 @@ static void php_sdl_cursor_free(zend_object *object)
}
/* }}} */
-
/* {{{ php_sdl_cursor_new
*/
-static zend_object* php_sdl_cursor_new(zend_class_entry *class_type)
+static zend_object *php_sdl_cursor_new(zend_class_entry *class_type)
{
struct php_sdl_cursor *intern;
@@ -128,44 +128,51 @@ static PHP_METHOD(SDL_Cursor, __construct)
intern = (struct php_sdl_cursor *)Z_OBJ_P(getThis());
zend_replace_error_handling(EH_THROW, NULL, &error_handling);
- if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "ssllll", &data, &data_len, &mask, &mask_len, &w, &h, &x, &y)) {
+ if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "ssllll", &data, &data_len, &mask, &mask_len, &w, &h, &x, &y))
+ {
zend_restore_error_handling(&error_handling);
return;
}
zend_restore_error_handling(&error_handling);
- if (w<=0 || w&7 || h<=0) {
- zend_throw_exception(zend_exception_get_default(), "Invalid cursor size", 0);
+ if (w <= 0 || w & 7 || h <= 0)
+ {
+ zend_throw_exception(zend_ce_exception, "Invalid cursor size", 0);
return;
}
- size = w/8 * h;
- if (data_len!=size || mask_len!=size) {
- zend_throw_exception_ex(zend_exception_get_default(), 0, "Invalid data or mask, size must be %ld", size);
+ size = w / 8 * h;
+ if (data_len != size || mask_len != size)
+ {
+ zend_throw_exception_ex(zend_ce_exception, 0, "Invalid data or mask, size must be %ld", size);
return;
}
intern->cursor = SDL_CreateCursor((Uint8 *)data, (Uint8 *)mask, (int)w, (int)h, (int)x, (int)y);
- if (intern->cursor) {
+ if (intern->cursor)
+ {
intern->flags = 0;
- } else {
- zend_throw_exception(zend_exception_get_default(), SDL_GetError(), 0);
+ }
+ else
+ {
+ zend_throw_exception(zend_ce_exception, SDL_GetError(), 0);
}
}
/* }}} */
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_SDL_Cursor___toString, 0, 0, IS_STRING, 0)
+ZEND_END_ARG_INFO()
/* {{{ proto SDL_Cursor::__toString()
-*/
+ */
static PHP_METHOD(SDL_Cursor, __toString)
{
- if (zend_parse_parameters_none() == FAILURE) {
+ if (zend_parse_parameters_none() == FAILURE)
+ {
return;
}
RETVAL_STRING("SDL_Cursor()");
}
/* }}} */
-
-
/* {{{ proto SDL_Cursor SDL_CreateCursor(string data, string mask, int w, int h, int hot_x, int hot_y)
* \brief Create a cursor, using the specified bitmap data and
@@ -185,9 +192,9 @@ static PHP_METHOD(SDL_Cursor, __toString)
*
* \sa SDL_FreeCursor()
extern DECLSPEC SDL_Cursor *SDLCALL SDL_CreateCursor(const Uint8 * data,
- const Uint8 * mask,
- int w, int h, int hot_x,
- int hot_y);
+ const Uint8 * mask,
+ int w, int h, int hot_x,
+ int hot_y);
*/
PHP_FUNCTION(SDL_CreateCursor)
{
@@ -197,15 +204,18 @@ PHP_FUNCTION(SDL_CreateCursor)
long size;
SDL_Cursor *cursor;
- if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "ssllll", &data, &data_len, &mask, &mask_len, &w, &h, &x, &y)) {
+ if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "ssllll", &data, &data_len, &mask, &mask_len, &w, &h, &x, &y))
+ {
return;
}
- if (w<=0 || w&7 || h<=0) {
+ if (w <= 0 || w & 7 || h <= 0)
+ {
php_error_docref(NULL, E_WARNING, "Invalid cursor size");
return;
}
- size = w/8 * h;
- if (data_len!=size || mask_len!=size) {
+ size = w / 8 * h;
+ if (data_len != size || mask_len != size)
+ {
php_error_docref(NULL, E_WARNING, "Invalid data or mask, size must be %ld", size);
return;
}
@@ -214,8 +224,6 @@ PHP_FUNCTION(SDL_CreateCursor)
}
/* }}} */
-
-
/* {{{ proto SDL_Cursor SDL_CreateSystemCursor(int id)
* \brief Create a system cursor.
@@ -228,7 +236,8 @@ PHP_FUNCTION(SDL_CreateSystemCursor)
zend_long id;
SDL_Cursor *cursor;
- if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "l", &id)) {
+ if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "l", &id))
+ {
return;
}
cursor = SDL_CreateSystemCursor(id);
@@ -236,15 +245,14 @@ PHP_FUNCTION(SDL_CreateSystemCursor)
}
/* }}} */
-
/* {{{ proto SDL_Cursor SDL_CreateSystemCursor(int id)
* \brief Create a color cursor.
*
* \sa SDL_FreeCursor()
extern DECLSPEC SDL_Cursor *SDLCALL SDL_CreateColorCursor(SDL_Surface *surface,
- int hot_x,
- int hot_y);
+ int hot_x,
+ int hot_y);
*/
PHP_FUNCTION(SDL_CreateColorCursor)
{
@@ -253,20 +261,23 @@ PHP_FUNCTION(SDL_CreateColorCursor)
SDL_Surface *surface;
SDL_Cursor *cursor;
- if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "Oll", &z_surface, get_php_sdl_surface_ce(), &x, &y)) {
+ if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "Oll", &z_surface, get_php_sdl_surface_ce(), &x, &y))
+ {
return;
}
surface = zval_to_sdl_surface(z_surface);
- if (surface) {
+ if (surface)
+ {
cursor = SDL_CreateColorCursor(surface, (int)x, (int)y);
sdl_cursor_to_zval(cursor, return_value, 0);
- } else {
+ }
+ else
+ {
php_error_docref(NULL, E_WARNING, "Invalid SDL_Window object");
}
}
/* }}} */
-
/* {{{ proto void SDL_FreeCursor(SDL_Cursor cursor)
* \brief Frees a cursor created with SDL_CreateCursor().
@@ -280,7 +291,8 @@ PHP_FUNCTION(SDL_FreeCursor)
zval *z_cursor;
SDL_Cursor *cursor;
- if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &z_cursor, php_sdl_cursor_ce) == FAILURE) {
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &z_cursor, php_sdl_cursor_ce) == FAILURE)
+ {
return;
}
FETCH_CURSOR(cursor, z_cursor, 1);
@@ -301,7 +313,8 @@ PHP_FUNCTION(SDL_SetCursor)
zval *z_cursor;
SDL_Cursor *cursor;
- if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &z_cursor, php_sdl_cursor_ce) == FAILURE) {
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &z_cursor, php_sdl_cursor_ce) == FAILURE)
+ {
return;
}
FETCH_CURSOR(cursor, z_cursor, 1);
@@ -310,7 +323,6 @@ PHP_FUNCTION(SDL_SetCursor)
}
/* }}} */
-
/* {{{ proto SDL_Cursor SDL_GetCursor(void)
* \brief Return the active cursor.
@@ -320,7 +332,8 @@ PHP_FUNCTION(SDL_GetCursor)
{
SDL_Cursor *cursor;
- if (zend_parse_parameters_none() == FAILURE) {
+ if (zend_parse_parameters_none() == FAILURE)
+ {
return;
}
cursor = SDL_GetCursor();
@@ -328,7 +341,6 @@ PHP_FUNCTION(SDL_GetCursor)
}
/* }}} */
-
/* {{{ proto SDL_Cursor SDL_GetDefaultCursor(void)
* \brief Return the default cursor.
@@ -338,7 +350,8 @@ PHP_FUNCTION(SDL_GetDefaultCursor)
{
SDL_Cursor *cursor;
- if (zend_parse_parameters_none() == FAILURE) {
+ if (zend_parse_parameters_none() == FAILURE)
+ {
return;
}
cursor = SDL_GetDefaultCursor();
@@ -346,7 +359,6 @@ PHP_FUNCTION(SDL_GetDefaultCursor)
}
/* }}} */
-
/* {{{ proto int SDL_ShowCursor(bool toogle)
* \brief Toggle whether or not the cursor is shown.
@@ -359,16 +371,16 @@ PHP_FUNCTION(SDL_GetDefaultCursor)
*/
PHP_FUNCTION(SDL_ShowCursor)
{
- zend_bool toggle;
+ bool toggle;
- if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "b", &toggle)) {
+ if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "b", &toggle))
+ {
return;
}
RETVAL_BOOL(SDL_ShowCursor(toggle));
}
/* }}} */
-
/* {{{ proto SDL_Window SDL_GetMouseFocus(void)
* \brief Get the window which currently has mouse focus.
@@ -376,13 +388,13 @@ PHP_FUNCTION(SDL_ShowCursor)
*/
PHP_FUNCTION(SDL_GetMouseFocus)
{
- if (zend_parse_parameters_none() == FAILURE) {
+ if (zend_parse_parameters_none() == FAILURE)
+ {
return;
}
sdl_window_to_zval(SDL_GetMouseFocus(), return_value, SDL_DONTFREE);
}
-
/* {{{ proto int SDL_GetMouseState(int &x, int &y)
* \brief Retrieve the current state of the mouse.
@@ -395,19 +407,22 @@ PHP_FUNCTION(SDL_GetMouseFocus)
*/
PHP_FUNCTION(SDL_GetMouseState)
{
- zval *z_x=NULL, *z_y=NULL;
+ zval *z_x = NULL, *z_y = NULL;
int x, y;
Uint32 state;
- if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "|zz", &z_x, &z_y)) {
+ if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "|zz", &z_x, &z_y))
+ {
return;
}
state = SDL_GetMouseState(&x, &y);
- if (z_x) {
+ if (z_x)
+ {
zval_dtor(z_x);
ZVAL_LONG(z_x, x);
}
- if (z_y) {
+ if (z_y)
+ {
zval_dtor(z_y);
ZVAL_LONG(z_y, y);
}
@@ -415,7 +430,6 @@ PHP_FUNCTION(SDL_GetMouseState)
}
/* }}} */
-
/* {{{ proto int SDL_GetRelativeMouseState(int &x, int &y)
* \brief Retrieve the relative state of the mouse.
@@ -427,19 +441,22 @@ PHP_FUNCTION(SDL_GetMouseState)
*/
PHP_FUNCTION(SDL_GetRelativeMouseState)
{
- zval *z_x=NULL, *z_y=NULL;
+ zval *z_x = NULL, *z_y = NULL;
int x, y;
Uint32 state;
- if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "|zz", &z_x, &z_y)) {
+ if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "|zz", &z_x, &z_y))
+ {
return;
}
state = SDL_GetRelativeMouseState(&x, &y);
- if (z_x) {
+ if (z_x)
+ {
zval_dtor(z_x);
ZVAL_LONG(z_x, x);
}
- if (z_y) {
+ if (z_y)
+ {
zval_dtor(z_y);
ZVAL_LONG(z_y, y);
}
@@ -447,7 +464,6 @@ PHP_FUNCTION(SDL_GetRelativeMouseState)
}
/* }}} */
-
/* {{{ proto void SDL_WarpMouseInWindow(SDL_Window window, int x, int y)
* \brief Moves the mouse to the given position within the window.
@@ -458,7 +474,7 @@ PHP_FUNCTION(SDL_GetRelativeMouseState)
*
* \note This function generates a mouse motion event
extern DECLSPEC void SDLCALL SDL_WarpMouseInWindow(SDL_Window * window,
- int x, int y);
+ int x, int y);
*/
PHP_FUNCTION(SDL_WarpMouseInWindow)
{
@@ -466,19 +482,22 @@ PHP_FUNCTION(SDL_WarpMouseInWindow)
SDL_Window *window;
zend_long x, y;
- if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "Oll", &z_window, get_php_sdl_window_ce(), &x, &y)) {
+ if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "Oll", &z_window, get_php_sdl_window_ce(), &x, &y))
+ {
return;
}
window = zval_to_sdl_window(z_window);
- if (window) {
+ if (window)
+ {
SDL_WarpMouseInWindow(window, (int)x, (int)y);
- } else {
+ }
+ else
+ {
php_error_docref(NULL, E_WARNING, "Invalid SDL_Window object");
}
}
/* }}} */
-
/* {{{ proto int SDL_SetRelativeMouseMode(bool enabled)
* \brief Set relative mouse mode.
@@ -499,16 +518,16 @@ PHP_FUNCTION(SDL_WarpMouseInWindow)
*/
PHP_FUNCTION(SDL_SetRelativeMouseMode)
{
- zend_bool enabled;
+ bool enabled;
- if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "b", &enabled)) {
+ if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "b", &enabled))
+ {
return;
}
RETVAL_LONG(SDL_SetRelativeMouseMode(enabled));
}
/* }}} */
-
/* {{{ proto bool SDL_GetRelativeMouseMode(void)
* \brief Query whether relative mouse mode is enabled.
@@ -518,39 +537,37 @@ extern DECLSPEC SDL_bool SDLCALL SDL_GetRelativeMouseMode(void);
*/
PHP_FUNCTION(SDL_GetRelativeMouseMode)
{
- if (zend_parse_parameters_none() == FAILURE) {
+ if (zend_parse_parameters_none() == FAILURE)
+ {
return;
}
RETVAL_BOOL(SDL_GetRelativeMouseMode());
}
-
ZEND_BEGIN_ARG_INFO_EX(arginfo_none, 0, 0, 0)
ZEND_END_ARG_INFO()
-
/* {{{ sdl_cursor_methods[] */
static const zend_function_entry php_sdl_cursor_methods[] = {
- PHP_ME(SDL_Cursor, __construct, arginfo_SDL_Cursor__construct, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC)
- PHP_ME(SDL_Cursor, __toString, arginfo_none, ZEND_ACC_PUBLIC)
+ PHP_ME(SDL_Cursor, __construct, arginfo_SDL_Cursor__construct, ZEND_ACC_CTOR | ZEND_ACC_PUBLIC)
+ PHP_ME(SDL_Cursor, __toString, arginfo_class_SDL_Cursor___toString, ZEND_ACC_PUBLIC)
/* non-static methods */
- PHP_FALIAS(Free, SDL_FreeCursor, arginfo_none)
- PHP_FALIAS(Set, SDL_SetCursor, arginfo_none)
+ PHP_FALIAS(Free, SDL_FreeCursor, arginfo_none)
+ PHP_FALIAS(Set, SDL_SetCursor, arginfo_none)
/* static methods */
- ZEND_FENTRY(Create, ZEND_FN(SDL_CreateCursor), arginfo_SDL_Cursor__construct, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
- ZEND_FENTRY(CreateSystem, ZEND_FN(SDL_CreateSystemCursor), arginfo_SDL_CreateSystemCursor, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
- ZEND_FENTRY(CreateColor, ZEND_FN(SDL_CreateColorCursor), arginfo_SDL_CreateColorCursor, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
- ZEND_FENTRY(Get, ZEND_FN(SDL_GetCursor), arginfo_none, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
- ZEND_FENTRY(GetDefault, ZEND_FN(SDL_GetDefaultCursor), arginfo_none, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
- ZEND_FENTRY(Show, ZEND_FN(SDL_ShowCursor), arginfo_SDL_ShowCursor, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
-
- ZEND_FE_END
-};
+ ZEND_FENTRY(Create, ZEND_FN(SDL_CreateCursor), arginfo_SDL_Cursor__construct, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
+ ZEND_FENTRY(CreateSystem, ZEND_FN(SDL_CreateSystemCursor), arginfo_SDL_CreateSystemCursor, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
+ ZEND_FENTRY(CreateColor, ZEND_FN(SDL_CreateColorCursor), arginfo_SDL_CreateColorCursor, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
+ ZEND_FENTRY(Get, ZEND_FN(SDL_GetCursor), arginfo_none, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
+ ZEND_FENTRY(GetDefault, ZEND_FN(SDL_GetDefaultCursor), arginfo_none, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
+ ZEND_FENTRY(Show, ZEND_FN(SDL_ShowCursor), arginfo_SDL_ShowCursor, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
+
+ ZEND_FE_END};
/* }}} */
-#define REGISTER_CURSOR_CLASS_CONST_LONG(const_name, value) \
+#define REGISTER_CURSOR_CLASS_CONST_LONG(const_name, value) \
REGISTER_LONG_CONSTANT("SDL_SYSTEM_CURSOR_" const_name, value, CONST_CS | CONST_PERSISTENT); \
zend_declare_class_constant_long(php_sdl_cursor_ce, ZEND_STRL(const_name), value)
@@ -563,25 +580,25 @@ PHP_MINIT_FUNCTION(sdl_mouse)
php_sdl_cursor_ce = zend_register_internal_class(&ce);
php_sdl_cursor_ce->create_object = php_sdl_cursor_new;
memcpy(&php_sdl_cursor_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
- php_sdl_cursor_handlers.free_obj = php_sdl_cursor_free;
+ php_sdl_cursor_handlers.free_obj = php_sdl_cursor_free;
php_sdl_cursor_handlers.offset = XtOffsetOf(struct php_sdl_cursor, zo);
/* Cursor types for SDL_CreateSystemCursor.
typedef enum SDL_SystemCursor; */
- REGISTER_CURSOR_CLASS_CONST_LONG("ARROW", SDL_SYSTEM_CURSOR_ARROW);
- REGISTER_CURSOR_CLASS_CONST_LONG("IBEAM", SDL_SYSTEM_CURSOR_IBEAM);
- REGISTER_CURSOR_CLASS_CONST_LONG("WAIT", SDL_SYSTEM_CURSOR_WAIT);
+ REGISTER_CURSOR_CLASS_CONST_LONG("ARROW", SDL_SYSTEM_CURSOR_ARROW);
+ REGISTER_CURSOR_CLASS_CONST_LONG("IBEAM", SDL_SYSTEM_CURSOR_IBEAM);
+ REGISTER_CURSOR_CLASS_CONST_LONG("WAIT", SDL_SYSTEM_CURSOR_WAIT);
REGISTER_CURSOR_CLASS_CONST_LONG("CROSSHAIR", SDL_SYSTEM_CURSOR_CROSSHAIR);
REGISTER_CURSOR_CLASS_CONST_LONG("WAITARROW", SDL_SYSTEM_CURSOR_WAITARROW);
- REGISTER_CURSOR_CLASS_CONST_LONG("SIZENWSE", SDL_SYSTEM_CURSOR_SIZENWSE);
- REGISTER_CURSOR_CLASS_CONST_LONG("SIZENESW", SDL_SYSTEM_CURSOR_SIZENESW);
- REGISTER_CURSOR_CLASS_CONST_LONG("SIZEWE", SDL_SYSTEM_CURSOR_SIZEWE);
- REGISTER_CURSOR_CLASS_CONST_LONG("SIZENS", SDL_SYSTEM_CURSOR_SIZENS);
- REGISTER_CURSOR_CLASS_CONST_LONG("SIZEALL", SDL_SYSTEM_CURSOR_SIZEALL);
- REGISTER_CURSOR_CLASS_CONST_LONG("NO", SDL_SYSTEM_CURSOR_NO);
- REGISTER_CURSOR_CLASS_CONST_LONG("HAND", SDL_SYSTEM_CURSOR_HAND);
-
- REGISTER_LONG_CONSTANT("SDL_NUM_SYSTEM_CURSORS", SDL_NUM_SYSTEM_CURSORS, CONST_CS | CONST_PERSISTENT);
+ REGISTER_CURSOR_CLASS_CONST_LONG("SIZENWSE", SDL_SYSTEM_CURSOR_SIZENWSE);
+ REGISTER_CURSOR_CLASS_CONST_LONG("SIZENESW", SDL_SYSTEM_CURSOR_SIZENESW);
+ REGISTER_CURSOR_CLASS_CONST_LONG("SIZEWE", SDL_SYSTEM_CURSOR_SIZEWE);
+ REGISTER_CURSOR_CLASS_CONST_LONG("SIZENS", SDL_SYSTEM_CURSOR_SIZENS);
+ REGISTER_CURSOR_CLASS_CONST_LONG("SIZEALL", SDL_SYSTEM_CURSOR_SIZEALL);
+ REGISTER_CURSOR_CLASS_CONST_LONG("NO", SDL_SYSTEM_CURSOR_NO);
+ REGISTER_CURSOR_CLASS_CONST_LONG("HAND", SDL_SYSTEM_CURSOR_HAND);
+
+ REGISTER_LONG_CONSTANT("SDL_NUM_SYSTEM_CURSORS", SDL_NUM_SYSTEM_CURSORS, CONST_CS | CONST_PERSISTENT);
zend_declare_class_constant_long(php_sdl_cursor_ce, ZEND_STRL("NUM_SYSTEM"), SDL_NUM_SYSTEM_CURSORS);
/*
@@ -590,16 +607,16 @@ PHP_MINIT_FUNCTION(sdl_mouse)
* - Button 2: Middle mouse button
* - Button 3: Right mouse button
*/
- REGISTER_LONG_CONSTANT("SDL_BUTTON_LEFT", SDL_BUTTON_LEFT, CONST_CS | CONST_PERSISTENT); \
- REGISTER_LONG_CONSTANT("SDL_BUTTON_MIDDLE", SDL_BUTTON_MIDDLE, CONST_CS | CONST_PERSISTENT); \
- REGISTER_LONG_CONSTANT("SDL_BUTTON_RIGHT", SDL_BUTTON_RIGHT, CONST_CS | CONST_PERSISTENT); \
- REGISTER_LONG_CONSTANT("SDL_BUTTON_X1", SDL_BUTTON_X1, CONST_CS | CONST_PERSISTENT); \
- REGISTER_LONG_CONSTANT("SDL_BUTTON_X2", SDL_BUTTON_X2, CONST_CS | CONST_PERSISTENT); \
- REGISTER_LONG_CONSTANT("SDL_BUTTON_LMASK", SDL_BUTTON_LMASK, CONST_CS | CONST_PERSISTENT); \
- REGISTER_LONG_CONSTANT("SDL_BUTTON_MMASK", SDL_BUTTON_MMASK, CONST_CS | CONST_PERSISTENT); \
- REGISTER_LONG_CONSTANT("SDL_BUTTON_RMASK", SDL_BUTTON_RMASK, CONST_CS | CONST_PERSISTENT); \
- REGISTER_LONG_CONSTANT("SDL_BUTTON_X1MASK", SDL_BUTTON_X1MASK, CONST_CS | CONST_PERSISTENT); \
- REGISTER_LONG_CONSTANT("SDL_BUTTON_X2MASK", SDL_BUTTON_X2MASK, CONST_CS | CONST_PERSISTENT); \
+ REGISTER_LONG_CONSTANT("SDL_BUTTON_LEFT", SDL_BUTTON_LEFT, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_BUTTON_MIDDLE", SDL_BUTTON_MIDDLE, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_BUTTON_RIGHT", SDL_BUTTON_RIGHT, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_BUTTON_X1", SDL_BUTTON_X1, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_BUTTON_X2", SDL_BUTTON_X2, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_BUTTON_LMASK", SDL_BUTTON_LMASK, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_BUTTON_MMASK", SDL_BUTTON_MMASK, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_BUTTON_RMASK", SDL_BUTTON_RMASK, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_BUTTON_X1MASK", SDL_BUTTON_X1MASK, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_BUTTON_X2MASK", SDL_BUTTON_X2MASK, CONST_CS | CONST_PERSISTENT);
return SUCCESS;
}
diff --git a/src/mouse.h b/src/mouse.h
index d2468c4..391815a 100644
--- a/src/mouse.h
+++ b/src/mouse.h
@@ -1,6 +1,4 @@
/*
- +----------------------------------------------------------------------+
- | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2018 The PHP Group |
+----------------------------------------------------------------------+
diff --git a/src/mutex.c b/src/mutex.c
index 5bd65c7..f9781d0 100644
--- a/src/mutex.c
+++ b/src/mutex.c
@@ -1,13 +1,11 @@
/*
- +----------------------------------------------------------------------+
- | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2018 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_01.txt |
+ | https://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
@@ -328,11 +326,13 @@ static PHP_METHOD(SDL_mutex, __construct)
if (intern->mutex) {
intern->flags = 0;
} else {
- zend_throw_exception(zend_exception_get_default(), SDL_GetError(), 0);
+ zend_throw_exception(zend_ce_exception, SDL_GetError(), 0);
}
}
/* }}} */
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_SDL_Mutex___toString, 0, 0, IS_STRING, 0)
+ZEND_END_ARG_INFO()
/* {{{ proto SDL_mutex::__toString() */
static PHP_METHOD(SDL_mutex, __toString)
@@ -489,11 +489,13 @@ static PHP_METHOD(SDL_sem, __construct)
if (intern->sem) {
intern->flags = 0;
} else {
- zend_throw_exception(zend_exception_get_default(), SDL_GetError(), 0);
+ zend_throw_exception(zend_ce_exception, SDL_GetError(), 0);
}
}
/* }}} */
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_SDL_Sem___toString, 0, 0, IS_STRING, 0)
+ZEND_END_ARG_INFO()
/* {{{ proto SDL_sem::__toString() */
static PHP_METHOD(SDL_sem, __toString)
@@ -693,11 +695,13 @@ static PHP_METHOD(SDL_cond, __construct)
if (intern->cond) {
intern->flags = 0;
} else {
- zend_throw_exception(zend_exception_get_default(), SDL_GetError(), 0);
+ zend_throw_exception(zend_ce_exception, SDL_GetError(), 0);
}
}
/* }}} */
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_SDL_cond___toString, 0, 0, IS_STRING, 0)
+ZEND_END_ARG_INFO()
/* {{{ proto SDL_cond::__toString() */
static PHP_METHOD(SDL_cond, __toString)
@@ -898,7 +902,7 @@ PHP_FUNCTION(SDL_DestroyCond)
/* {{{ sdl_mutex_methods[] */
static const zend_function_entry php_sdl_mutex_methods[] = {
PHP_ME(SDL_mutex, __construct, arginfo_none, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC)
- PHP_ME(SDL_mutex, __toString, arginfo_none, ZEND_ACC_PUBLIC)
+ PHP_ME(SDL_mutex, __toString, arginfo_class_SDL_Mutex___toString, ZEND_ACC_PUBLIC)
/* non-static method */
PHP_FALIAS(Lock, SDL_LockMutex, arginfo_none)
@@ -914,7 +918,7 @@ static const zend_function_entry php_sdl_mutex_methods[] = {
/* {{{ sdl_sem_methods[] */
static const zend_function_entry php_sdl_sem_methods[] = {
PHP_ME(SDL_sem, __construct, arginfo_SDL_sem__construct, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC)
- PHP_ME(SDL_sem, __toString, arginfo_none, ZEND_ACC_PUBLIC)
+ PHP_ME(SDL_sem, __toString, arginfo_class_SDL_Sem___toString, ZEND_ACC_PUBLIC)
/* non-static method */
PHP_FALIAS(Wait, SDL_SemWait, arginfo_none)
@@ -932,7 +936,7 @@ static const zend_function_entry php_sdl_sem_methods[] = {
/* {{{ sdl_cond_methods[] */
static const zend_function_entry php_sdl_cond_methods[] = {
PHP_ME(SDL_cond, __construct, arginfo_none, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC)
- PHP_ME(SDL_cond, __toString, arginfo_none, ZEND_ACC_PUBLIC)
+ PHP_ME(SDL_cond, __toString, arginfo_class_SDL_cond___toString, ZEND_ACC_PUBLIC)
/* non-static method */
PHP_FALIAS(Wait, SDL_CondWait, arginfo_SDL_Cond_Wait)
diff --git a/src/mutex.h b/src/mutex.h
index 0cc85de..f7e23fe 100644
--- a/src/mutex.h
+++ b/src/mutex.h
@@ -1,6 +1,4 @@
/*
- +----------------------------------------------------------------------+
- | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2018 The PHP Group |
+----------------------------------------------------------------------+
diff --git a/src/php_sdl.c b/src/php_sdl.c
index cb881f1..cadb867 100644
--- a/src/php_sdl.c
+++ b/src/php_sdl.c
@@ -1,13 +1,11 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) 1997-2022 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_01.txt |
+ | https://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
@@ -51,14 +49,18 @@ ZEND_GET_MODULE(sdl)
/* {{{ php_sdl_check_overflow */
zend_bool php_sdl_check_overflow(int a, int b, int silent)
{
- if(a <= 0 || b <= 0) {
- if (!silent) {
+ if (a <= 0 || b <= 0)
+ {
+ if (!silent)
+ {
php_error_docref(NULL, E_WARNING, "one parameter to a memory allocation multiplication is negative or zero, failing operation gracefully");
}
return 1;
}
- if(a > INT_MAX / b) {
- if (!silent) {
+ if (a > INT_MAX / b)
+ {
+ if (!silent)
+ {
php_error_docref(NULL, E_WARNING, "product of memory allocation multiplication would exceed INT_MAX, failing operation gracefully");
}
return 1;
@@ -67,47 +69,25 @@ zend_bool php_sdl_check_overflow(int a, int b, int silent)
}
/* }}} */
-
#define PHP_MINIT_CALL(func) PHP_MINIT(func)(INIT_FUNC_ARGS_PASSTHRU)
+#define PHP_MSHUTDOWN_CALL(func) PHP_MSHUTDOWN(func)(SHUTDOWN_FUNC_ARGS_PASSTHRU)
/* {{{ PHP_MINIT_FUNCTION */
PHP_MINIT_FUNCTION(sdl)
{
- if ( SUCCESS == PHP_MINIT_CALL(sdl_blendmode)
- && SUCCESS == PHP_MINIT_CALL(sdl_cpuinfo)
- && SUCCESS == PHP_MINIT_CALL(sdl_error)
- && SUCCESS == PHP_MINIT_CALL(sdl_event)
- && SUCCESS == PHP_MINIT_CALL(sdl_glcontext)
- && SUCCESS == PHP_MINIT_CALL(sdl_keyboard)
- && SUCCESS == PHP_MINIT_CALL(sdl_messagebox)
- && SUCCESS == PHP_MINIT_CALL(sdl_mouse)
- && SUCCESS == PHP_MINIT_CALL(sdl_mutex)
- && SUCCESS == PHP_MINIT_CALL(sdl_platform)
- && SUCCESS == PHP_MINIT_CALL(sdl_power)
- && SUCCESS == PHP_MINIT_CALL(sdl_filesystem)
- && SUCCESS == PHP_MINIT_CALL(sdl_pixels)
- && SUCCESS == PHP_MINIT_CALL(sdl_rect)
- && SUCCESS == PHP_MINIT_CALL(sdl_render)
- && SUCCESS == PHP_MINIT_CALL(sdl_rwops)
- && SUCCESS == PHP_MINIT_CALL(sdl_sdl)
- && SUCCESS == PHP_MINIT_CALL(sdl_shape)
- && SUCCESS == PHP_MINIT_CALL(sdl_surface)
- && SUCCESS == PHP_MINIT_CALL(sdl_timer)
- && SUCCESS == PHP_MINIT_CALL(sdl_version)
- && SUCCESS == PHP_MINIT_CALL(sdl_video)
- && SUCCESS == PHP_MINIT_CALL(sdl_window)
- && SUCCESS == PHP_MINIT_CALL(sdl_joystick)
- ) {
+ if (SUCCESS == PHP_MINIT_CALL(sdl_blendmode) && SUCCESS == PHP_MINIT_CALL(sdl_cpuinfo) && SUCCESS == PHP_MINIT_CALL(sdl_error) && SUCCESS == PHP_MINIT_CALL(sdl_event) && SUCCESS == PHP_MINIT_CALL(sdl_glcontext) && SUCCESS == PHP_MINIT_CALL(sdl_keyboard) && SUCCESS == PHP_MINIT_CALL(sdl_messagebox) && SUCCESS == PHP_MINIT_CALL(sdl_mouse) && SUCCESS == PHP_MINIT_CALL(sdl_mutex) && SUCCESS == PHP_MINIT_CALL(sdl_platform) && SUCCESS == PHP_MINIT_CALL(sdl_power) && SUCCESS == PHP_MINIT_CALL(sdl_filesystem) && SUCCESS == PHP_MINIT_CALL(sdl_pixels) && SUCCESS == PHP_MINIT_CALL(sdl_rect) && SUCCESS == PHP_MINIT_CALL(sdl_render) && SUCCESS == PHP_MINIT_CALL(sdl_rwops) && SUCCESS == PHP_MINIT_CALL(sdl_sdl) && SUCCESS == PHP_MINIT_CALL(sdl_shape) && SUCCESS == PHP_MINIT_CALL(sdl_surface) && SUCCESS == PHP_MINIT_CALL(sdl_timer) && SUCCESS == PHP_MINIT_CALL(sdl_version) && SUCCESS == PHP_MINIT_CALL(sdl_video) && SUCCESS == PHP_MINIT_CALL(sdl_window) && SUCCESS == PHP_MINIT_CALL(sdl_joystick))
+ {
return SUCCESS;
}
return FAILURE;
}
/* }}} */
-
/* {{{ PHP_MSHUTDOWN_FUNCTION */
PHP_MSHUTDOWN_FUNCTION(sdl)
{
+ PHP_MSHUTDOWN_CALL(sdl_rect);
+
return SUCCESS;
}
/* }}} */
@@ -145,64 +125,68 @@ static zend_function_entry sdl_functions[] = {
ZEND_FE(SDL_Quit, arginfo_SDL_Quit)
ZEND_FE(SDL_QuitSubSystem, arginfo_SDL_QuitSubSystem)
ZEND_FE(SDL_WasInit, arginfo_SDL_WasInit)
+ ZEND_FE(SDL_SetHint, arginfo_SDL_SetHint)
// Window
- ZEND_FE(SDL_CreateWindow, arginfo_SDL_CreateWindow)
- ZEND_FE(SDL_CreateShapedWindow, arginfo_SDL_CreateWindow)
- ZEND_FE(SDL_DestroyWindow, arginfo_SDL_Window)
- ZEND_FE(SDL_UpdateWindowSurface, arginfo_SDL_Window)
- ZEND_FE(SDL_GetWindowTitle, arginfo_SDL_Window)
- ZEND_FE(SDL_SetWindowTitle, arginfo_SDL_SetWindowTitle)
- ZEND_FE(SDL_GetWindowDisplayIndex, arginfo_SDL_Window)
- ZEND_FE(SDL_ShowWindow, arginfo_SDL_Window)
- ZEND_FE(SDL_HideWindow, arginfo_SDL_Window)
- ZEND_FE(SDL_RaiseWindow, arginfo_SDL_Window)
- ZEND_FE(SDL_MaximizeWindow, arginfo_SDL_Window)
- ZEND_FE(SDL_MinimizeWindow, arginfo_SDL_Window)
- ZEND_FE(SDL_RestoreWindow, arginfo_SDL_Window)
- ZEND_FE(SDL_GetWindowSurface, arginfo_SDL_Window)
- ZEND_FE(SDL_SetWindowDisplayMode, arginfo_SDL_SetWindowDisplayMode)
- ZEND_FE(SDL_GetWindowDisplayMode, arginfo_SDL_GetWindowDisplayMode)
- ZEND_FE(SDL_GetWindowPixelFormat, arginfo_SDL_Window)
- ZEND_FE(SDL_GetWindowID, arginfo_SDL_Window)
- ZEND_FE(SDL_GetWindowFlags, arginfo_SDL_Window)
- ZEND_FE(SDL_SetWindowIcon, arginfo_SDL_SetWindowIcon)
- ZEND_FE(SDL_SetWindowPosition, arginfo_SDL_SetWindowPosition)
- ZEND_FE(SDL_GetWindowPosition, arginfo_SDL_GetWindowPosition)
- ZEND_FE(SDL_SetWindowSize, arginfo_SDL_SetWindowPosition)
- ZEND_FE(SDL_GetWindowSize, arginfo_SDL_GetWindowPosition)
- ZEND_FE(SDL_SetWindowMinimumSize, arginfo_SDL_SetWindowPosition)
- ZEND_FE(SDL_GetWindowMinimumSize, arginfo_SDL_GetWindowPosition)
- ZEND_FE(SDL_SetWindowMaximumSize, arginfo_SDL_SetWindowPosition)
- ZEND_FE(SDL_GetWindowMaximumSize, arginfo_SDL_GetWindowPosition)
- ZEND_FE(SDL_SetWindowBordered, arginfo_SDL_SetWindowBordered)
- ZEND_FE(SDL_SetWindowFullscreen, arginfo_SDL_SetWindowFullscreen)
- ZEND_FE(SDL_UpdateWindowSurfaceRects, arginfo_SDL_UpdateWindowSurfaceRects)
- ZEND_FE(SDL_SetWindowGrab, arginfo_SDL_SetWindowGrab)
- ZEND_FE(SDL_GetWindowGrab, arginfo_SDL_Window)
- ZEND_FE(SDL_SetWindowBrightness, arginfo_SDL_SetWindowBrightness)
- ZEND_FE(SDL_GetWindowBrightness, arginfo_SDL_Window)
- ZEND_FE(SDL_GetWindowGammaRamp, arginfo_SDL_GetWindowGammaRamp)
- ZEND_FE(SDL_IsShapedWindow, arginfo_SDL_Window)
- ZEND_FE(SDL_SetWindowShape, arginfo_SDL_SetWindowShape)
- ZEND_FE(SDL_GetShapedWindowMode, arginfo_SDL_GetShapedWindowMode)
-
- ZEND_FE(SDL_WINDOWPOS_UNDEFINED_DISPLAY, arginfo_SDL_WINDOWPOS_DISPLAY)
- ZEND_FE(SDL_WINDOWPOS_CENTERED_DISPLAY, arginfo_SDL_WINDOWPOS_DISPLAY)
+ ZEND_FE(SDL_CreateWindow, arginfo_SDL_CreateWindow)
+ ZEND_FE(SDL_CreateShapedWindow, arginfo_SDL_CreateWindow)
+ ZEND_FE(SDL_DestroyWindow, arginfo_SDL_Window)
+ ZEND_FE(SDL_UpdateWindowSurface, arginfo_SDL_Window)
+ ZEND_FE(SDL_GetWindowTitle, arginfo_SDL_Window)
+ ZEND_FE(SDL_SetWindowTitle, arginfo_SDL_SetWindowTitle)
+ ZEND_FE(SDL_GetWindowDisplayIndex, arginfo_SDL_Window)
+ ZEND_FE(SDL_ShowWindow, arginfo_SDL_Window)
+ ZEND_FE(SDL_HideWindow, arginfo_SDL_Window)
+ ZEND_FE(SDL_RaiseWindow, arginfo_SDL_Window)
+ ZEND_FE(SDL_MaximizeWindow, arginfo_SDL_Window)
+ ZEND_FE(SDL_MinimizeWindow, arginfo_SDL_Window)
+ ZEND_FE(SDL_RestoreWindow, arginfo_SDL_Window)
+ ZEND_FE(SDL_GetWindowSurface, arginfo_SDL_Window)
+ ZEND_FE(SDL_SetWindowDisplayMode, arginfo_SDL_SetWindowDisplayMode)
+ ZEND_FE(SDL_GetWindowDisplayMode, arginfo_SDL_GetWindowDisplayMode)
+ ZEND_FE(SDL_GetWindowPixelFormat, arginfo_SDL_Window)
+ ZEND_FE(SDL_GetWindowID, arginfo_SDL_Window)
+ ZEND_FE(SDL_GetWindowFlags, arginfo_SDL_Window)
+ ZEND_FE(SDL_SetWindowIcon, arginfo_SDL_SetWindowIcon)
+ ZEND_FE(SDL_SetWindowPosition, arginfo_SDL_SetWindowPosition)
+ ZEND_FE(SDL_GetWindowPosition, arginfo_SDL_GetWindowPosition)
+ ZEND_FE(SDL_SetWindowSize, arginfo_SDL_SetWindowPosition)
+ ZEND_FE(SDL_GetWindowSize, arginfo_SDL_GetWindowPosition)
+ ZEND_FE(SDL_SetWindowMinimumSize, arginfo_SDL_SetWindowPosition)
+ ZEND_FE(SDL_GetWindowMinimumSize, arginfo_SDL_GetWindowPosition)
+ ZEND_FE(SDL_SetWindowMaximumSize, arginfo_SDL_SetWindowPosition)
+ ZEND_FE(SDL_GetWindowMaximumSize, arginfo_SDL_GetWindowPosition)
+ ZEND_FE(SDL_SetWindowBordered, arginfo_SDL_SetWindowBordered)
+ ZEND_FE(SDL_SetWindowFullscreen, arginfo_SDL_SetWindowFullscreen)
+ ZEND_FE(SDL_UpdateWindowSurfaceRects, arginfo_SDL_UpdateWindowSurfaceRects)
+ ZEND_FE(SDL_SetWindowGrab, arginfo_SDL_SetWindowGrab)
+ ZEND_FE(SDL_GetWindowGrab, arginfo_SDL_Window)
+ ZEND_FE(SDL_SetWindowBrightness, arginfo_SDL_SetWindowBrightness)
+ ZEND_FE(SDL_GetWindowBrightness, arginfo_SDL_Window)
+ ZEND_FE(SDL_GetWindowGammaRamp, arginfo_SDL_GetWindowGammaRamp)
+ ZEND_FE(SDL_IsShapedWindow, arginfo_SDL_Window)
+ ZEND_FE(SDL_SetWindowShape, arginfo_SDL_SetWindowShape)
+ ZEND_FE(SDL_GetShapedWindowMode, arginfo_SDL_GetShapedWindowMode)
+
+ ZEND_FE(SDL_WINDOWPOS_UNDEFINED_DISPLAY, arginfo_SDL_WINDOWPOS_DISPLAY)
+ ZEND_FE(SDL_WINDOWPOS_CENTERED_DISPLAY, arginfo_SDL_WINDOWPOS_DISPLAY)
// Version
- ZEND_FE(SDL_GetRevision, arginfo_sdl_version_none)
- ZEND_FE(SDL_GetRevisionNumber, arginfo_sdl_version_none)
- ZEND_FE(SDL_GetVersion, arginfo_SDL_GetVersion)
- ZEND_FE(SDL_VERSION, arginfo_SDL_VERSION)
- ZEND_FE(SDL_VERSIONNUM, arginfo_SDL_VERSIONNUM)
- ZEND_FE(SDL_VERSION_ATLEAST, arginfo_SDL_VERSION_ATLEAST)
+ ZEND_FE(SDL_GetRevision, arginfo_sdl_version_none)
+#ifdef HAVE_SDL_GETREVISIONNUMBER
+ ZEND_DEP_FE(SDL_GetRevisionNumber, arginfo_sdl_version_none)
+#endif
+ ZEND_FE(SDL_GetVersion, arginfo_SDL_GetVersion)
+ ZEND_FE(SDL_VERSION, arginfo_SDL_VERSION)
+ ZEND_FE(SDL_VERSIONNUM, arginfo_SDL_VERSIONNUM)
+ ZEND_FE(SDL_VERSION_ATLEAST, arginfo_SDL_VERSION_ATLEAST)
// Timer
ZEND_FE(SDL_Delay, arginfo_SDL_Delay)
// Render
ZEND_FE(SDL_CreateRenderer, arginfo_SDL_CreateRenderer)
+ ZEND_FE(SDL_CreateSoftwareRenderer, arginfo_SDL_CreateSoftwareRenderer)
ZEND_FE(SDL_DestroyRenderer, arginfo_SDL_DestroyRenderer)
ZEND_FE(SDL_DestroyTexture, arginfo_SDL_DestroyTexture)
ZEND_FE(SDL_SetRenderDrawColor, arginfo_SDL_SetRenderDrawColor)
@@ -216,250 +200,247 @@ static zend_function_entry sdl_functions[] = {
ZEND_FE(SDL_RenderPresent, arginfo_SDL_RenderPresent)
ZEND_FE(SDL_CreateTextureFromSurface, arginfo_SDL_CreateTextureFromSurface)
ZEND_FE(SDL_CreateTexture, arginfo_SDL_CreateTexture)
+ ZEND_FE(SDL_UpdateTexture, arginfo_SDL_UpdateTexture)
+ ZEND_FE(SDL_QueryTexture, arginfo_SDL_QueryTexture)
ZEND_FE(SDL_SetRenderTarget, arginfo_SDL_SetRenderTarget)
+ ZEND_FE(SDL_RenderSetLogicalSize, arginfo_SDL_RenderSetLogicalSize)
ZEND_FE(SDL_GetRendererOutputSize, arginfo_SDL_GetRendererOutputSize)
+ ZEND_FE(SDL_RenderDrawPointF, arginfo_SDL_RenderDrawPointF)
+ ZEND_FE(SDL_RenderDrawLineF, arginfo_SDL_RenderDrawLineF)
+ ZEND_FE(SDL_RenderDrawRectF, arginfo_SDL_RenderDrawRectF)
+ ZEND_FE(SDL_RenderFillRectF, arginfo_SDL_RenderFillRectF)
+ ZEND_FE(SDL_RenderCopyF, arginfo_SDL_RenderCopyF)
+ ZEND_FE(SDL_RenderCopyExF, arginfo_SDL_RenderCopyExF)
+
// Surface
- ZEND_FE(SDL_CreateRGBSurface, arginfo_SDL_CreateRGBSurface)
- ZEND_FE(SDL_FreeSurface, arginfo_SDL_Surface)
- ZEND_FE(SDL_FillRect, arginfo_SDL_FillRect)
- ZEND_FE(SDL_FillRects, arginfo_SDL_FillRects)
- ZEND_FE(SDL_MUSTLOCK, arginfo_SDL_Surface)
- ZEND_FE(SDL_LockSurface, arginfo_SDL_Surface)
- ZEND_FE(SDL_UnlockSurface, arginfo_SDL_Surface)
- ZEND_FE(SDL_LoadBMP_RW, arginfo_SDL_LoadBMP_RW)
- ZEND_FE(SDL_LoadBMP, arginfo_SDL_LoadBMP)
- ZEND_FE(SDL_UpperBlit, arginfo_SDL_UpperBlit)
- ZEND_FE(SDL_LowerBlit, arginfo_SDL_LowerBlit)
- ZEND_FE(SDL_UpperBlitScaled, arginfo_SDL_UpperBlit)
- ZEND_FE(SDL_LowerBlitScaled, arginfo_SDL_LowerBlit)
- ZEND_FE(SDL_SoftStretch, arginfo_SDL_UpperBlit)
- ZEND_FE(SDL_SaveBMP_RW, arginfo_SDL_SaveBMP_RW)
- ZEND_FE(SDL_SaveBMP, arginfo_SDL_SaveBMP)
- ZEND_FE(SDL_SetSurfaceRLE, arginfo_SDL_SetSurfaceRLE)
- ZEND_FE(SDL_SetColorKey, arginfo_SDL_SetColorKey)
- ZEND_FE(SDL_GetColorKey, arginfo_SDL_GetColorKey)
- ZEND_FE(SDL_SetSurfaceColorMod, arginfo_SDL_SetSurfaceColorMod)
- ZEND_FE(SDL_GetSurfaceColorMod, arginfo_SDL_GetSurfaceColorMod)
- ZEND_FE(SDL_SetSurfaceAlphaMod, arginfo_SDL_SetSurfaceAlphaMod)
- ZEND_FE(SDL_GetSurfaceAlphaMod, arginfo_SDL_GetSurfaceAlphaMod)
- ZEND_FE(SDL_SetSurfaceBlendMode, arginfo_SDL_SetSurfaceBlendMode)
- ZEND_FE(SDL_GetSurfaceBlendMode, arginfo_SDL_GetSurfaceBlendMode)
- ZEND_FE(SDL_SetClipRect, arginfo_SDL_SetClipRect)
- ZEND_FE(SDL_GetClipRect, arginfo_SDL_GetClipRect)
- ZEND_FE(SDL_ConvertSurface, arginfo_SDL_ConvertSurface)
- ZEND_FE(SDL_ConvertSurfaceFormat, arginfo_SDL_ConvertSurfaceFormat)
- ZEND_FE(SDL_ConvertPixels, arginfo_SDL_ConvertPixels)
- //PHP_FALIAS(SDL_BlitSurface, SDL_UpperBlit, arginfo_SDL_UpperBlit)
- //PHP_FALIAS(SDL_BlitScaled, SDL_UpperBlitScaled, arginfo_SDL_UpperBlit)
-
- // Rect
- ZEND_FE(SDL_RectEmpty, arginfo_SDL_Rect)
- ZEND_FE(SDL_RectEquals, arginfo_SDL_Rect2)
- ZEND_FE(SDL_HasIntersection, arginfo_SDL_Rect2)
- ZEND_FE(SDL_IntersectRect, arginfo_SDL_IntersectRect)
- ZEND_FE(SDL_UnionRect, arginfo_SDL_Rect3)
- ZEND_FE(SDL_IntersectRectAndLine, arginfo_SDL_IntersectRectAndLine)
- ZEND_FE(SDL_EnclosePoints, arginfo_SDL_EnclosePoints)
+ ZEND_FE(SDL_CreateRGBSurface, arginfo_SDL_CreateRGBSurface)
+ ZEND_FE(SDL_FreeSurface, arginfo_SDL_Surface)
+ ZEND_FE(SDL_FillRect, arginfo_SDL_FillRect)
+ ZEND_FE(SDL_FillRects, arginfo_SDL_FillRects)
+ ZEND_FE(SDL_MUSTLOCK, arginfo_SDL_Surface)
+ ZEND_FE(SDL_LockSurface, arginfo_SDL_Surface)
+ ZEND_FE(SDL_UnlockSurface, arginfo_SDL_Surface)
+ ZEND_FE(SDL_LoadBMP_RW, arginfo_SDL_LoadBMP_RW)
+ ZEND_FE(SDL_LoadBMP, arginfo_SDL_LoadBMP)
+ ZEND_FE(SDL_UpperBlit, arginfo_SDL_UpperBlit)
+ ZEND_FE(SDL_LowerBlit, arginfo_SDL_LowerBlit)
+ ZEND_FE(SDL_UpperBlitScaled, arginfo_SDL_UpperBlit)
+ ZEND_FE(SDL_LowerBlitScaled, arginfo_SDL_LowerBlit)
+ ZEND_FE(SDL_SoftStretch, arginfo_SDL_UpperBlit)
+ ZEND_FE(SDL_SaveBMP_RW, arginfo_SDL_SaveBMP_RW)
+ ZEND_FE(SDL_SaveBMP, arginfo_SDL_SaveBMP)
+ ZEND_FE(SDL_SetSurfaceRLE, arginfo_SDL_SetSurfaceRLE)
+ ZEND_FE(SDL_SetColorKey, arginfo_SDL_SetColorKey)
+ ZEND_FE(SDL_GetColorKey, arginfo_SDL_GetColorKey)
+ ZEND_FE(SDL_SetSurfaceColorMod, arginfo_SDL_SetSurfaceColorMod)
+ ZEND_FE(SDL_GetSurfaceColorMod, arginfo_SDL_GetSurfaceColorMod)
+ ZEND_FE(SDL_SetSurfaceAlphaMod, arginfo_SDL_SetSurfaceAlphaMod)
+ ZEND_FE(SDL_GetSurfaceAlphaMod, arginfo_SDL_GetSurfaceAlphaMod)
+ ZEND_FE(SDL_SetSurfaceBlendMode, arginfo_SDL_SetSurfaceBlendMode)
+ ZEND_FE(SDL_GetSurfaceBlendMode, arginfo_SDL_GetSurfaceBlendMode)
+ ZEND_FE(SDL_SetClipRect, arginfo_SDL_SetClipRect)
+ ZEND_FE(SDL_GetClipRect, arginfo_SDL_GetClipRect)
+ ZEND_FE(SDL_ConvertSurface, arginfo_SDL_ConvertSurface)
+ ZEND_FE(SDL_ConvertSurfaceFormat, arginfo_SDL_ConvertSurfaceFormat)
+ ZEND_FE(SDL_ConvertPixels, arginfo_SDL_ConvertPixels)
// Events
ZEND_FE(SDL_WaitEvent, arginfo_SDL_WaitEvent)
- ZEND_FE(SDL_PollEvent, arginfo_SDL_PollEvent)
+ ZEND_FE(SDL_PollEvent, arginfo_SDL_PollEvent)
// Message box
- ZEND_FE(SDL_ShowSimpleMessageBox, arginfo_SDL_ShowSimpleMessageBox)
- ZEND_FE(SDL_ShowMessageBox, arginfo_SDL_ShowMessageBox)
+ ZEND_FE(SDL_ShowSimpleMessageBox, arginfo_SDL_ShowSimpleMessageBox)
+ ZEND_FE(SDL_ShowMessageBox, arginfo_SDL_ShowMessageBox)
// Pixels
- ZEND_FE(SDL_GetPixelFormatName, arginfo_SDL_GetPixelFormatName)
- ZEND_FE(SDL_PixelFormatEnumToMasks, arginfo_SDL_PixelFormatEnumToMasks)
- ZEND_FE(SDL_MasksToPixelFormatEnum, arginfo_SDL_MasksToPixelFormatEnum)
-
- ZEND_FE(SDL_AllocPalette, arginfo_SDL_AllocPalette)
- ZEND_FE(SDL_FreePalette, arginfo_SDL_Palette)
- ZEND_FE(SDL_SetPaletteColors, arginfo_SDL_SetPaletteColors)
-
- ZEND_FE(SDL_AllocFormat, arginfo_SDL_AllocFormat)
- ZEND_FE(SDL_FreeFormat, arginfo_SDL_PixelFormat)
- ZEND_FE(SDL_SetPixelFormatPalette, arginfo_SDL_SetPixelFormatPalette)
- ZEND_FE(SDL_MapRGB, arginfo_SDL_MapRGB)
- ZEND_FE(SDL_MapRGBA, arginfo_SDL_MapRGBA)
- ZEND_FE(SDL_GetRGB, arginfo_SDL_GetRGB)
- ZEND_FE(SDL_GetRGBA, arginfo_SDL_GetRGBA)
- ZEND_FE(SDL_CalculateGammaRamp, arginfo_SDL_CalculateGammaRamp)
+ ZEND_FE(SDL_GetPixelFormatName, arginfo_SDL_GetPixelFormatName)
+ ZEND_FE(SDL_PixelFormatEnumToMasks, arginfo_SDL_PixelFormatEnumToMasks)
+ ZEND_FE(SDL_MasksToPixelFormatEnum, arginfo_SDL_MasksToPixelFormatEnum)
+
+ ZEND_FE(SDL_AllocPalette, arginfo_SDL_AllocPalette)
+ ZEND_FE(SDL_FreePalette, arginfo_SDL_Palette)
+ ZEND_FE(SDL_SetPaletteColors, arginfo_SDL_SetPaletteColors)
+
+ ZEND_FE(SDL_AllocFormat, arginfo_SDL_AllocFormat)
+ ZEND_FE(SDL_FreeFormat, arginfo_SDL_PixelFormat)
+ ZEND_FE(SDL_SetPixelFormatPalette, arginfo_SDL_SetPixelFormatPalette)
+ ZEND_FE(SDL_MapRGB, arginfo_SDL_MapRGB)
+ ZEND_FE(SDL_MapRGBA, arginfo_SDL_MapRGBA)
+ ZEND_FE(SDL_GetRGB, arginfo_SDL_GetRGB)
+ ZEND_FE(SDL_GetRGBA, arginfo_SDL_GetRGBA)
+ ZEND_FE(SDL_CalculateGammaRamp, arginfo_SDL_CalculateGammaRamp)
// Filesystem
ZEND_FE(SDL_GetBasePath, arginfo_SDL_GetBasePath)
- ZEND_FE(SDL_GetPrefPath, arginfo_SDL_GetPrefPath)
+ ZEND_FE(SDL_GetPrefPath, arginfo_SDL_GetPrefPath)
// GL
- ZEND_FE(SDL_GL_ExtensionSupported, arginfo_SDL_GL_ExtensionSupported)
- ZEND_FE(SDL_GL_SetAttribute, arginfo_SDL_GL_SetAttribute)
- ZEND_FE(SDL_GL_GetAttribute, arginfo_SDL_GL_GetAttribute)
- ZEND_FE(SDL_GL_CreateContext, arginfo_SDL_GLContext__construct)
- ZEND_FE(SDL_GL_DeleteContext, arginfo_SDL_GL_DeleteContext)
- ZEND_FE(SDL_GL_MakeCurrent, arginfo_SDL_GL_MakeCurrent)
- ZEND_FE(SDL_GL_GetCurrentWindow, arginfo_none)
- ZEND_FE(SDL_GL_GetCurrentContext, arginfo_none)
-#if SDL_VERSION_ATLEAST(2,0,1)
- ZEND_FE(SDL_GL_GetDrawableSize, arginfo_SDL_GL_GetDrawableSize)
+ ZEND_FE(SDL_GL_ExtensionSupported, arginfo_SDL_GL_ExtensionSupported)
+ ZEND_FE(SDL_GL_SetAttribute, arginfo_SDL_GL_SetAttribute)
+ ZEND_FE(SDL_GL_GetAttribute, arginfo_SDL_GL_GetAttribute)
+ ZEND_FE(SDL_GL_CreateContext, arginfo_SDL_GLContext__construct)
+ ZEND_FE(SDL_GL_DeleteContext, arginfo_SDL_GL_DeleteContext)
+ ZEND_FE(SDL_GL_MakeCurrent, arginfo_SDL_GL_MakeCurrent)
+ ZEND_FE(SDL_GL_GetCurrentWindow, arginfo_none)
+ ZEND_FE(SDL_GL_GetCurrentContext, arginfo_none)
+#if SDL_VERSION_ATLEAST(2, 0, 1)
+ ZEND_FE(SDL_GL_GetDrawableSize, arginfo_SDL_GL_GetDrawableSize)
#endif
- ZEND_FE(SDL_GL_SwapWindow, arginfo_SDL_Window)
- ZEND_FE(SDL_GL_SetSwapInterval, arginfo_SDL_GL_SetSwapInterval)
- ZEND_FE(SDL_GL_GetSwapInterval, arginfo_none)
+ ZEND_FE(SDL_GL_SwapWindow, arginfo_SDL_Window)
+ ZEND_FE(SDL_GL_SetSwapInterval, arginfo_SDL_GL_SetSwapInterval)
+ ZEND_FE(SDL_GL_GetSwapInterval, arginfo_none)
// CPU info
- ZEND_FE(SDL_GetCPUCount, arginfo_cpuinfo_none)
- ZEND_FE(SDL_GetCPUCacheLineSize, arginfo_cpuinfo_none)
- ZEND_FE(SDL_HasRDTSC, arginfo_cpuinfo_none)
- ZEND_FE(SDL_HasAltiVec, arginfo_cpuinfo_none)
- ZEND_FE(SDL_HasMMX, arginfo_cpuinfo_none)
- ZEND_FE(SDL_Has3DNow, arginfo_cpuinfo_none)
- ZEND_FE(SDL_HasSSE, arginfo_cpuinfo_none)
- ZEND_FE(SDL_HasSSE2, arginfo_cpuinfo_none)
- ZEND_FE(SDL_HasSSE3, arginfo_cpuinfo_none)
- ZEND_FE(SDL_HasSSE41, arginfo_cpuinfo_none)
- ZEND_FE(SDL_HasSSE42, arginfo_cpuinfo_none)
+ ZEND_FE(SDL_GetCPUCount, arginfo_cpuinfo_none)
+ ZEND_FE(SDL_GetCPUCacheLineSize, arginfo_cpuinfo_none)
+ ZEND_FE(SDL_HasRDTSC, arginfo_cpuinfo_none)
+ ZEND_FE(SDL_HasAltiVec, arginfo_cpuinfo_none)
+ ZEND_FE(SDL_HasMMX, arginfo_cpuinfo_none)
+ ZEND_FE(SDL_Has3DNow, arginfo_cpuinfo_none)
+ ZEND_FE(SDL_HasSSE, arginfo_cpuinfo_none)
+ ZEND_FE(SDL_HasSSE2, arginfo_cpuinfo_none)
+ ZEND_FE(SDL_HasSSE3, arginfo_cpuinfo_none)
+ ZEND_FE(SDL_HasSSE41, arginfo_cpuinfo_none)
+ ZEND_FE(SDL_HasSSE42, arginfo_cpuinfo_none)
#if SDL_COMPILEDVERSION > 2000
- ZEND_FE(SDL_GetSystemRAM, arginfo_cpuinfo_none)
+ ZEND_FE(SDL_GetSystemRAM, arginfo_cpuinfo_none)
#endif
// Error handling
- ZEND_FE(SDL_SetError, arginfo_SDL_SetError)
- ZEND_FE(SDL_GetError, arginfo_error_none)
- ZEND_FE(SDL_ClearError, arginfo_error_none)
+ ZEND_FE(SDL_SetError, arginfo_SDL_SetError)
+ ZEND_FE(SDL_GetError, arginfo_error_none)
+ ZEND_FE(SDL_ClearError, arginfo_error_none)
// Video
- ZEND_FE(SDL_GetNumVideoDrivers, arginfo_video_none)
- ZEND_FE(SDL_GetVideoDriver, arginfo_SDL_GetVideoDriver)
- ZEND_FE(SDL_VideoInit, arginfo_SDL_VideoInit)
- ZEND_FE(SDL_VideoQuit, arginfo_video_none)
- ZEND_FE(SDL_GetCurrentVideoDriver, arginfo_video_none)
- ZEND_FE(SDL_GetNumVideoDisplays, arginfo_video_none)
- ZEND_FE(SDL_GetDisplayName, arginfo_SDL_dysplayindex)
- ZEND_FE(SDL_GetDisplayBounds, arginfo_SDL_GetDisplayBounds)
- ZEND_FE(SDL_GetNumDisplayModes, arginfo_SDL_dysplayindex)
- ZEND_FE(SDL_GetDisplayMode, arginfo_SDL_GetDisplayMode)
- ZEND_FE(SDL_GetDesktopDisplayMode, arginfo_SDL_dysplayindex)
- ZEND_FE(SDL_GetCurrentDisplayMode, arginfo_SDL_dysplayindex)
- ZEND_FE(SDL_GetClosestDisplayMode, arginfo_SDL_GetClosestDisplayMode)
- ZEND_FE(SDL_IsScreenSaverEnabled, arginfo_video_none)
- ZEND_FE(SDL_EnableScreenSaver, arginfo_video_none)
- ZEND_FE(SDL_DisableScreenSaver, arginfo_video_none)
+ ZEND_FE(SDL_GetNumVideoDrivers, arginfo_video_none)
+ ZEND_FE(SDL_GetVideoDriver, arginfo_SDL_GetVideoDriver)
+ ZEND_FE(SDL_VideoInit, arginfo_SDL_VideoInit)
+ ZEND_FE(SDL_VideoQuit, arginfo_video_none)
+ ZEND_FE(SDL_GetCurrentVideoDriver, arginfo_video_none)
+ ZEND_FE(SDL_GetNumVideoDisplays, arginfo_video_none)
+ ZEND_FE(SDL_GetDisplayName, arginfo_SDL_dysplayindex)
+ ZEND_FE(SDL_GetDisplayBounds, arginfo_SDL_GetDisplayBounds)
+ ZEND_FE(SDL_GetNumDisplayModes, arginfo_SDL_dysplayindex)
+ ZEND_FE(SDL_GetDisplayMode, arginfo_SDL_GetDisplayMode)
+ ZEND_FE(SDL_GetDesktopDisplayMode, arginfo_SDL_dysplayindex)
+ ZEND_FE(SDL_GetCurrentDisplayMode, arginfo_SDL_dysplayindex)
+ ZEND_FE(SDL_GetClosestDisplayMode, arginfo_SDL_GetClosestDisplayMode)
+ ZEND_FE(SDL_IsScreenSaverEnabled, arginfo_video_none)
+ ZEND_FE(SDL_EnableScreenSaver, arginfo_video_none)
+ ZEND_FE(SDL_DisableScreenSaver, arginfo_video_none)
// Power
- ZEND_FE(SDL_GetPowerInfo, arginfo_SDL_GetPowerInfo)
+ ZEND_FE(SDL_GetPowerInfo, arginfo_SDL_GetPowerInfo)
// Platform
- ZEND_FE(SDL_GetPlatform, arginfo_SDL_GetPlatform)
+ ZEND_FE(SDL_GetPlatform, arginfo_SDL_GetPlatform)
// Keyboard
- ZEND_FE(SDL_GetKeyboardFocus, arginfo_none)
- ZEND_FE(SDL_GetKeyboardState, arginfo_SDL_GetKeyboardState)
- ZEND_FE(SDL_GetModState, arginfo_none)
- ZEND_FE(SDL_SetModState, arginfo_SDL_SetModState)
- ZEND_FE(SDL_GetKeyFromScancode, arginfo_scancode)
- ZEND_FE(SDL_GetScancodeFromKey, arginfo_key)
- ZEND_FE(SDL_GetScancodeName, arginfo_scancode)
- ZEND_FE(SDL_GetScancodeFromName, arginfo_name)
- ZEND_FE(SDL_GetKeyName, arginfo_key)
- ZEND_FE(SDL_GetKeyFromName, arginfo_name)
- ZEND_FE(SDL_StartTextInput, arginfo_none)
- ZEND_FE(SDL_IsTextInputActive, arginfo_none)
- ZEND_FE(SDL_StopTextInput, arginfo_none)
- ZEND_FE(SDL_SetTextInputRect, arginfo_SDL_SetTextInputRect)
- ZEND_FE(SDL_HasScreenKeyboardSupport, arginfo_none)
- ZEND_FE(SDL_IsScreenKeyboardShown, arginfo_SDL_IsScreenKeyboardShown)
+ ZEND_FE(SDL_GetKeyboardFocus, arginfo_none)
+ ZEND_FE(SDL_GetKeyboardState, arginfo_SDL_GetKeyboardState)
+ ZEND_FE(SDL_GetModState, arginfo_none)
+ ZEND_FE(SDL_SetModState, arginfo_SDL_SetModState)
+ ZEND_FE(SDL_GetKeyFromScancode, arginfo_scancode)
+ ZEND_FE(SDL_GetScancodeFromKey, arginfo_key)
+ ZEND_FE(SDL_GetScancodeName, arginfo_scancode)
+ ZEND_FE(SDL_GetScancodeFromName, arginfo_name)
+ ZEND_FE(SDL_GetKeyName, arginfo_key)
+ ZEND_FE(SDL_GetKeyFromName, arginfo_name)
+ ZEND_FE(SDL_StartTextInput, arginfo_none)
+ ZEND_FE(SDL_IsTextInputActive, arginfo_none)
+ ZEND_FE(SDL_StopTextInput, arginfo_none)
+ ZEND_FE(SDL_SetTextInputRect, arginfo_SDL_SetTextInputRect)
+ ZEND_FE(SDL_HasScreenKeyboardSupport, arginfo_none)
+ ZEND_FE(SDL_IsScreenKeyboardShown, arginfo_SDL_IsScreenKeyboardShown)
// Mouse/Cursor
- ZEND_FE(SDL_CreateCursor, arginfo_SDL_Cursor__construct)
- ZEND_FE(SDL_CreateSystemCursor, arginfo_SDL_CreateSystemCursor)
- ZEND_FE(SDL_CreateColorCursor, arginfo_SDL_CreateColorCursor)
- ZEND_FE(SDL_FreeCursor, arginfo_SDL_Cursor)
- ZEND_FE(SDL_SetCursor, arginfo_SDL_Cursor)
- ZEND_FE(SDL_GetCursor, arginfo_none)
- ZEND_FE(SDL_GetDefaultCursor, arginfo_none)
- ZEND_FE(SDL_ShowCursor, arginfo_SDL_ShowCursor)
- ZEND_FE(SDL_GetMouseFocus, arginfo_none)
- ZEND_FE(SDL_GetMouseState, arginfo_SDL_GetMouseState)
- ZEND_FE(SDL_GetRelativeMouseState, arginfo_SDL_GetMouseState)
- ZEND_FE(SDL_WarpMouseInWindow, arginfo_SDL_WarpMouseInWindow)
- ZEND_FE(SDL_SetRelativeMouseMode, arginfo_SDL_SetRelativeMouseMode)
- ZEND_FE(SDL_GetRelativeMouseMode, arginfo_none)
+ ZEND_FE(SDL_CreateCursor, arginfo_SDL_Cursor__construct)
+ ZEND_FE(SDL_CreateSystemCursor, arginfo_SDL_CreateSystemCursor)
+ ZEND_FE(SDL_CreateColorCursor, arginfo_SDL_CreateColorCursor)
+ ZEND_FE(SDL_FreeCursor, arginfo_SDL_Cursor)
+ ZEND_FE(SDL_SetCursor, arginfo_SDL_Cursor)
+ ZEND_FE(SDL_GetCursor, arginfo_none)
+ ZEND_FE(SDL_GetDefaultCursor, arginfo_none)
+ ZEND_FE(SDL_ShowCursor, arginfo_SDL_ShowCursor)
+ ZEND_FE(SDL_GetMouseFocus, arginfo_none)
+ ZEND_FE(SDL_GetMouseState, arginfo_SDL_GetMouseState)
+ ZEND_FE(SDL_GetRelativeMouseState, arginfo_SDL_GetMouseState)
+ ZEND_FE(SDL_WarpMouseInWindow, arginfo_SDL_WarpMouseInWindow)
+ ZEND_FE(SDL_SetRelativeMouseMode, arginfo_SDL_SetRelativeMouseMode)
+ ZEND_FE(SDL_GetRelativeMouseMode, arginfo_none)
// Mutex
- ZEND_FE(SDL_CreateMutex, arginfo_none)
- ZEND_FE(SDL_LockMutex, arginfo_SDL_mutex)
- ZEND_FE(SDL_TryLockMutex, arginfo_SDL_mutex)
- ZEND_FE(SDL_UnlockMutex, arginfo_SDL_mutex)
- ZEND_FE(SDL_DestroyMutex, arginfo_SDL_mutex)
+ ZEND_FE(SDL_CreateMutex, arginfo_none)
+ ZEND_FE(SDL_LockMutex, arginfo_SDL_mutex)
+ ZEND_FE(SDL_TryLockMutex, arginfo_SDL_mutex)
+ ZEND_FE(SDL_UnlockMutex, arginfo_SDL_mutex)
+ ZEND_FE(SDL_DestroyMutex, arginfo_SDL_mutex)
/* mutex aliases */
- PHP_FALIAS(SDL_mutexP, SDL_LockMutex, arginfo_SDL_mutex)
- PHP_FALIAS(SDL_mutexV, SDL_UnlockMutex, arginfo_SDL_mutex)
+ PHP_FALIAS(SDL_mutexP, SDL_LockMutex, arginfo_SDL_mutex)
+ PHP_FALIAS(SDL_mutexV, SDL_UnlockMutex, arginfo_SDL_mutex)
/* semaphore functions */
- ZEND_FE(SDL_CreateSemaphore, arginfo_SDL_sem__construct)
- ZEND_FE(SDL_SemWait, arginfo_SDL_sem)
- ZEND_FE(SDL_SemTryWait, arginfo_SDL_sem)
- ZEND_FE(SDL_SemPost, arginfo_SDL_sem)
- ZEND_FE(SDL_SemValue, arginfo_SDL_sem)
- ZEND_FE(SDL_SemWaitTimeout, arginfo_SDL_SemWaitTimeout)
- ZEND_FE(SDL_DestroySemaphore, arginfo_SDL_sem)
+ ZEND_FE(SDL_CreateSemaphore, arginfo_SDL_sem__construct)
+ ZEND_FE(SDL_SemWait, arginfo_SDL_sem)
+ ZEND_FE(SDL_SemTryWait, arginfo_SDL_sem)
+ ZEND_FE(SDL_SemPost, arginfo_SDL_sem)
+ ZEND_FE(SDL_SemValue, arginfo_SDL_sem)
+ ZEND_FE(SDL_SemWaitTimeout, arginfo_SDL_SemWaitTimeout)
+ ZEND_FE(SDL_DestroySemaphore, arginfo_SDL_sem)
/* condition functions */
- ZEND_FE(SDL_CreateCond, arginfo_none)
- ZEND_FE(SDL_CondWait, arginfo_SDL_CondWait)
- ZEND_FE(SDL_CondSignal, arginfo_SDL_cond)
- ZEND_FE(SDL_CondBroadcast, arginfo_SDL_cond)
- ZEND_FE(SDL_CondWaitTimeout, arginfo_SDL_CondWaitTimeout)
- ZEND_FE(SDL_DestroyCond, arginfo_SDL_cond)
+ ZEND_FE(SDL_CreateCond, arginfo_none)
+ ZEND_FE(SDL_CondWait, arginfo_SDL_CondWait)
+ ZEND_FE(SDL_CondSignal, arginfo_SDL_cond)
+ ZEND_FE(SDL_CondBroadcast, arginfo_SDL_cond)
+ ZEND_FE(SDL_CondWaitTimeout, arginfo_SDL_CondWaitTimeout)
+ ZEND_FE(SDL_DestroyCond, arginfo_SDL_cond)
// Joystick
ZEND_FE(SDL_NumJoysticks, arginfo_SDL_NumJoysticks)
- ZEND_FE(SDL_JoystickOpen, arginfo_SDL_JoystickOpen)
- ZEND_FE(SDL_JoystickClose, arginfo_SDL_JoystickClose)
- ZEND_FE(SDL_JoystickNumButtons, arginfo_SDL_JoystickNumButtons)
- ZEND_FE(SDL_JoystickName, arginfo_SDL_JoystickName)
- ZEND_FE(SDL_JoystickGetAxis, arginfo_SDL_JoystickGetAxis)
- ZEND_FE(SDL_JoystickNameForIndex, arginfo_SDL_JoystickNameForIndex)
- ZEND_FE(SDL_IsGameController, arginfo_SDL_IsGameController)
+ ZEND_FE(SDL_JoystickOpen, arginfo_SDL_JoystickOpen)
+ ZEND_FE(SDL_JoystickClose, arginfo_SDL_JoystickClose)
+ ZEND_FE(SDL_JoystickNumButtons, arginfo_SDL_JoystickNumButtons)
+ ZEND_FE(SDL_JoystickName, arginfo_SDL_JoystickName)
+ ZEND_FE(SDL_JoystickGetAxis, arginfo_SDL_JoystickGetAxis)
+ ZEND_FE(SDL_JoystickNameForIndex, arginfo_SDL_JoystickNameForIndex)
+ ZEND_FE(SDL_IsGameController, arginfo_SDL_IsGameController)
// Rwops
- ZEND_FE(SDL_AllocRW, arginfo_none)
- ZEND_FE(SDL_FreeRW, arginfo_SDL_RWops)
- ZEND_FE(SDL_RWFromFile, arginfo_SDL_RWFromFile)
- ZEND_FE(SDL_RWFromFP, arginfo_SDL_RWFromFP)
- ZEND_FE(SDL_RWFromMem, arginfo_SDL_RWFromMem)
- ZEND_FE(SDL_RWFromConstMem, arginfo_SDL_RWFromConstMem)
- ZEND_FE(SDL_RWsize, arginfo_SDL_RWops)
- ZEND_FE(SDL_RWseek, arginfo_SDL_RWseek)
- ZEND_FE(SDL_RWtell, arginfo_SDL_RWops)
- ZEND_FE(SDL_RWread, arginfo_SDL_RWread)
- ZEND_FE(SDL_RWwrite, arginfo_SDL_RWwrite)
- ZEND_FE(SDL_RWclose, arginfo_SDL_RWops)
- ZEND_FE(SDL_ReadU8, arginfo_SDL_RWops)
- ZEND_FE(SDL_ReadLE16, arginfo_SDL_RWops)
- ZEND_FE(SDL_ReadBE16, arginfo_SDL_RWops)
- ZEND_FE(SDL_ReadLE32, arginfo_SDL_RWops)
- ZEND_FE(SDL_ReadBE32, arginfo_SDL_RWops)
+ ZEND_FE(SDL_AllocRW, arginfo_none)
+ ZEND_FE(SDL_FreeRW, arginfo_SDL_RWops)
+ ZEND_FE(SDL_RWFromFile, arginfo_SDL_RWFromFile)
+ ZEND_FE(SDL_RWFromFP, arginfo_SDL_RWFromFP)
+ ZEND_FE(SDL_RWFromMem, arginfo_SDL_RWFromMem)
+ ZEND_FE(SDL_RWFromConstMem, arginfo_SDL_RWFromConstMem)
+ ZEND_FE(SDL_RWsize, arginfo_SDL_RWops)
+ ZEND_FE(SDL_RWseek, arginfo_SDL_RWseek)
+ ZEND_FE(SDL_RWtell, arginfo_SDL_RWops)
+ ZEND_FE(SDL_RWread, arginfo_SDL_RWread)
+ ZEND_FE(SDL_RWwrite, arginfo_SDL_RWwrite)
+ ZEND_FE(SDL_RWclose, arginfo_SDL_RWops)
+ ZEND_FE(SDL_ReadU8, arginfo_SDL_RWops)
+ ZEND_FE(SDL_ReadLE16, arginfo_SDL_RWops)
+ ZEND_FE(SDL_ReadBE16, arginfo_SDL_RWops)
+ ZEND_FE(SDL_ReadLE32, arginfo_SDL_RWops)
+ ZEND_FE(SDL_ReadBE32, arginfo_SDL_RWops)
#if SIZEOF_LONG > 4
- ZEND_FE(SDL_ReadLE64, arginfo_SDL_RWops)
- ZEND_FE(SDL_ReadBE64, arginfo_SDL_RWops)
+ ZEND_FE(SDL_ReadLE64, arginfo_SDL_RWops)
+ ZEND_FE(SDL_ReadBE64, arginfo_SDL_RWops)
#endif
- ZEND_FE(SDL_WriteU8, arginfo_SDL_write)
- ZEND_FE(SDL_WriteLE16, arginfo_SDL_write)
- ZEND_FE(SDL_WriteBE16, arginfo_SDL_write)
- ZEND_FE(SDL_WriteLE32, arginfo_SDL_write)
- ZEND_FE(SDL_WriteBE32, arginfo_SDL_write)
+ ZEND_FE(SDL_WriteU8, arginfo_SDL_write)
+ ZEND_FE(SDL_WriteLE16, arginfo_SDL_write)
+ ZEND_FE(SDL_WriteBE16, arginfo_SDL_write)
+ ZEND_FE(SDL_WriteLE32, arginfo_SDL_write)
+ ZEND_FE(SDL_WriteBE32, arginfo_SDL_write)
#if SIZEOF_LONG > 4
- ZEND_FE(SDL_WriteLE64, arginfo_SDL_write)
- ZEND_FE(SDL_WriteBE64, arginfo_SDL_write)
+ ZEND_FE(SDL_WriteLE64, arginfo_SDL_write)
+ ZEND_FE(SDL_WriteBE64, arginfo_SDL_write)
#endif
-
- ZEND_FE_END
-};
+ ZEND_FE_END};
/* }}} */
/* {{{ sdl_module_entry
@@ -470,14 +451,13 @@ zend_module_entry sdl_module_entry = {
NULL,
"SDL",
sdl_functions,
- PHP_MINIT(sdl), /* Replace with NULL if there is nothing to do at php startup */
+ PHP_MINIT(sdl), /* Replace with NULL if there is nothing to do at php startup */
PHP_MSHUTDOWN(sdl), /* Replace with NULL if there is nothing to do at php shutdown */
- NULL, /* RINIT */
- NULL, /* RSHUTDOWN */
+ NULL, /* RINIT */
+ NULL, /* RSHUTDOWN */
PHP_MINFO(sdl),
PHP_SDL_VERSION,
- STANDARD_MODULE_PROPERTIES
-};
+ STANDARD_MODULE_PROPERTIES};
/* }}} */
/*
diff --git a/src/php_sdl.h b/src/php_sdl.h
index c0cb014..265088b 100644
--- a/src/php_sdl.h
+++ b/src/php_sdl.h
@@ -1,6 +1,4 @@
/*
- +----------------------------------------------------------------------+
- | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2018 The PHP Group |
+----------------------------------------------------------------------+
@@ -17,12 +15,18 @@
+----------------------------------------------------------------------+
*/
-
#ifndef PHP_PHPSDL_H
#define PHP_PHPSDL_H
-#ifdef __cplusplus
-extern "C" {
+#define ARG_PASS_BY_REF 1
+#define ARG_NOT_PASS_BY_REF 0
+
+#define ARG_ALLOW_NULL 1
+#define ARG_NOT_ALLOW_NULL 0
+
+#ifdef __cplusplus
+extern "C"
+{
#endif
#ifdef HAVE_CONFIG_H
@@ -32,7 +36,7 @@ extern "C" {
#include
#include
-#define PHP_SDL_VERSION "2.3.0"
+#define PHP_SDL_VERSION "2.7.0"
#if defined(__APPLE__) && defined(__MACH__)
#include
@@ -44,14 +48,15 @@ extern "C" {
#include
#include
#include
-#ifdef __cplusplus
-} // extern "C"
+#ifdef __cplusplus
+} // extern "C"
#endif
-#ifdef __cplusplus
-extern "C" {
+#ifdef __cplusplus
+extern "C"
+{
#endif
-extern zend_module_entry sdl_module_entry;
+ extern zend_module_entry sdl_module_entry;
#define phpext_sdl_ptr &sdl_module_entry
#ifdef PHP_WIN32
@@ -60,25 +65,20 @@ extern zend_module_entry sdl_module_entry;
#define PHP_SDL_API
#endif
-PHP_MINIT_FUNCTION(sdl);
-PHP_MSHUTDOWN_FUNCTION(sdl);
-PHP_RINIT_FUNCTION(sdl);
-PHP_RSHUTDOWN_FUNCTION(sdl);
-PHP_MINFO_FUNCTION(sdl);
+ PHP_MINIT_FUNCTION(sdl);
+ PHP_MSHUTDOWN_FUNCTION(sdl);
+ PHP_RINIT_FUNCTION(sdl);
+ PHP_RSHUTDOWN_FUNCTION(sdl);
+ PHP_MINFO_FUNCTION(sdl);
-zend_bool php_sdl_check_overflow(int a, int b, int silent);
+ zend_bool php_sdl_check_overflow(int a, int b, int silent);
-#ifdef ZTS
-#include "TSRM.h"
-#endif
-
-#ifdef __cplusplus
-} // extern "C"
+#ifdef __cplusplus
+} // extern "C"
#endif
#endif /* PHP_PHPSDL_H */
-
/*
* Local variables:
* tab-width: 4
diff --git a/src/pixels.c b/src/pixels.c
index e6e0797..7951cb8 100644
--- a/src/pixels.c
+++ b/src/pixels.c
@@ -1,13 +1,11 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) 1997-2022 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_01.txt |
+ | https://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
@@ -17,39 +15,49 @@
+----------------------------------------------------------------------+
*/
-
#include "pixels.h"
#include "zend_interfaces.h"
+#include "zend_operators.h"
+
+/* for PHP 8.0 */
+#ifndef ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX
+#define ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(name, return_reference, required_num_args, type, allow_null) \
+ ZEND_BEGIN_ARG_INFO_EX(name, 0, return_reference, required_num_args)
+#endif
static zend_class_entry *php_sdl_color_ce;
static zend_object_handlers php_sdl_color_handlers;
-struct php_sdl_color {
- zend_object zo;
+struct php_sdl_color
+{
+ zend_object zo;
};
static zend_class_entry *php_sdl_palette_ce;
static zend_object_handlers php_sdl_palette_handlers;
-struct php_sdl_palette {
- zend_object zo;
- SDL_Palette *palette;
- Uint32 flags;
-};
+typedef struct _php_sdl_palette
+{
+ SDL_Palette *palette;
+ Uint32 flags;
+ zend_object zo;
+} php_sdl_palette;
static zend_class_entry *php_sdl_pixelformat_ce;
static zend_object_handlers php_sdl_pixelformat_handlers;
-struct php_sdl_pixelformat {
+typedef struct _php_sdl_pixelformat
+{
SDL_PixelFormat *format;
- Uint32 flags;
- zend_object zo;
-};
+ Uint32 flags;
+ zend_object zo;
+} php_sdl_pixelformat;
static zend_class_entry *php_sdl_pixels_ce;
static zend_object_handlers php_sdl_pixels_handlers;
-struct php_sdl_pixels {
- zend_object zo;
- SDL_Pixels pixels;
- Uint32 flags;
-};
+typedef struct _php_sdl_pixels
+{
+ SDL_Pixels pixels;
+ Uint32 flags;
+ zend_object zo;
+} php_sdl_pixels;
zend_class_entry *get_php_sdl_color_ce(void)
{
@@ -71,35 +79,58 @@ zend_class_entry *get_php_sdl_pixels_ce(void)
return php_sdl_pixels_ce;
}
-#define FETCH_PALETTE(__ptr, __id, __check) \
-{ \
- intern = (struct php_sdl_palette *)Z_OBJ_P(__id);\
- __ptr = intern->palette; \
- if (__check && !__ptr) {\
- php_error_docref(NULL, E_WARNING, "Invalid %s object", ZSTR_VAL(intern->zo.ce->name));\
- RETURN_FALSE;\
- }\
+static inline php_sdl_palette *php_sdl_palette_from_obj(zend_object *obj)
+{
+ return (php_sdl_palette *)((char *)(obj)-XtOffsetOf(php_sdl_palette, zo));
}
-#define FETCH_PIXELFORMAT(__ptr, __id, __check) \
-{ \
- zend_object* zox = Z_OBJ_P(__id);\
- intern = (struct php_sdl_pixelformat *)((char*)zox - zox->handlers->offset);\
- __ptr = intern->format; \
- if (__check && !__ptr) {\
- php_error_docref(NULL, E_WARNING, "Invalid %s object", ZSTR_VAL(intern->zo.ce->name));\
- RETURN_FALSE;\
- }\
+#define FETCH_PALETTE(__ptr, __id, __check) \
+ { \
+ intern = PHP_SDL_PALETTE_P(__id); \
+ __ptr = intern->palette; \
+ if (__check && !__ptr) \
+ { \
+ php_error_docref(NULL, E_WARNING, "Invalid %s object", ZSTR_VAL(intern->zo.ce->name)); \
+ RETURN_FALSE; \
+ } \
+ }
+
+#define PHP_SDL_PALETTE_P(zv) php_sdl_palette_from_obj(Z_OBJ_P((zv)))
+
+static inline php_sdl_pixelformat *php_sdl_pixelformat_from_obj(zend_object *obj)
+{
+ return (php_sdl_pixelformat *)((char *)(obj)-XtOffsetOf(php_sdl_pixelformat, zo));
+}
+
+#define FETCH_PIXELFORMAT(__ptr, __id, __check) \
+ { \
+ intern = PHP_SDL_PIXELFORMAT_P(__id); \
+ __ptr = intern->format; \
+ if (__check && !__ptr) \
+ { \
+ php_error_docref(NULL, E_WARNING, "Invalid %s object", ZSTR_VAL(intern->zo.ce->name)); \
+ RETURN_FALSE; \
+ } \
+ }
+
+#define PHP_SDL_PIXELFORMAT_P(zv) php_sdl_pixelformat_from_obj(Z_OBJ_P((zv)))
+
+static inline php_sdl_pixels *php_sdl_pixels_from_obj(zend_object *obj)
+{
+ return (php_sdl_pixels *)((char *)(obj)-XtOffsetOf(php_sdl_pixels, zo));
}
+#define PHP_SDL_PIXELS_P(zv) php_sdl_pixels_from_obj(Z_OBJ_P((zv)))
+
zend_bool sdl_color_to_zval(SDL_Color *color, zval *value)
{
- if (color) {
+ if (color)
+ {
object_init_ex(value, php_sdl_color_ce);
- zend_update_property_long(php_sdl_color_ce, value, "r", 1, color->r);
- zend_update_property_long(php_sdl_color_ce, value, "g", 1, color->g);
- zend_update_property_long(php_sdl_color_ce, value, "b", 1, color->b);
- zend_update_property_long(php_sdl_color_ce, value, "a", 1, color->a);
+ zend_update_property_long(php_sdl_color_ce, Z_OBJ_P(value), "r", 1, color->r);
+ zend_update_property_long(php_sdl_color_ce, Z_OBJ_P(value), "g", 1, color->g);
+ zend_update_property_long(php_sdl_color_ce, Z_OBJ_P(value), "b", 1, color->b);
+ zend_update_property_long(php_sdl_color_ce, Z_OBJ_P(value), "a", 1, color->a);
return 1;
}
@@ -109,22 +140,23 @@ zend_bool sdl_color_to_zval(SDL_Color *color, zval *value)
zend_bool zval_to_sdl_color(zval *value, SDL_Color *color)
{
- if (Z_TYPE_P(value) == IS_OBJECT && Z_OBJCE_P(value) == php_sdl_color_ce) {
+ if (Z_TYPE_P(value) == IS_OBJECT && Z_OBJCE_P(value) == php_sdl_color_ce)
+ {
zval *val, rv;
- val = zend_read_property(php_sdl_color_ce, value, "r", 1, 0, &rv);
+ val = zend_read_property(php_sdl_color_ce, Z_OBJ_P(value), "r", 1, 0, &rv);
convert_to_long(val);
Z_LVAL_P(val) = color->r = (Uint8)Z_LVAL_P(val);
- val = zend_read_property(php_sdl_color_ce, value, "g", 1, 0, &rv);
+ val = zend_read_property(php_sdl_color_ce, Z_OBJ_P(value), "g", 1, 0, &rv);
convert_to_long(val);
Z_LVAL_P(val) = color->g = (Uint8)Z_LVAL_P(val);
- val = zend_read_property(php_sdl_color_ce, value, "b", 1, 0, &rv);
+ val = zend_read_property(php_sdl_color_ce, Z_OBJ_P(value), "b", 1, 0, &rv);
convert_to_long(val);
Z_LVAL_P(val) = color->b = (Uint8)Z_LVAL_P(val);
- val = zend_read_property(php_sdl_color_ce, value, "a", 1, 0, &rv);
+ val = zend_read_property(php_sdl_color_ce, Z_OBJ_P(value), "a", 1, 0, &rv);
convert_to_long(val);
Z_LVAL_P(val) = color->a = (Uint8)Z_LVAL_P(val);
@@ -135,15 +167,15 @@ zend_bool zval_to_sdl_color(zval *value, SDL_Color *color)
return 0;
}
-
/* {{{ sdl_palette_to_zval */
zend_bool sdl_palette_to_zval(SDL_Palette *palette, zval *z_val, Uint32 flags)
{
- if (palette) {
- struct php_sdl_palette *intern;
+ if (palette)
+ {
+ php_sdl_palette *intern;
object_init_ex(z_val, php_sdl_palette_ce);
- intern = (struct php_sdl_palette *)Z_OBJ_P(z_val);
+ intern = PHP_SDL_PALETTE_P(z_val);
intern->palette = palette;
intern->flags = flags;
@@ -154,16 +186,15 @@ zend_bool sdl_palette_to_zval(SDL_Palette *palette, zval *z_val, Uint32 flags)
}
/* }}} */
-
/* {{{ sdl_pixelformat_to_zval */
zend_bool sdl_pixelformat_to_zval(SDL_PixelFormat *format, zval *z_val, Uint32 flags)
{
- if (format) {
- struct php_sdl_pixelformat *intern;
+ if (format)
+ {
+ php_sdl_pixelformat *intern;
object_init_ex(z_val, php_sdl_pixelformat_ce);
- zend_object *zo = Z_OBJ_P(z_val);
- intern = (struct php_sdl_pixelformat *)((char*)zo - zo->handlers->offset);
+ intern = PHP_SDL_PIXELFORMAT_P(z_val);
intern->format = format;
intern->flags = flags;
@@ -178,13 +209,15 @@ zend_bool sdl_pixelformat_to_zval(SDL_PixelFormat *format, zval *z_val, Uint32 f
/* {{{ sdl_pixels_to_zval */
zend_bool sdl_pixels_to_zval(SDL_Pixels *pixels, zval *z_val, Uint32 flags)
{
- if (pixels) {
- struct php_sdl_pixels *intern;
+ if (pixels)
+ {
+ php_sdl_pixels *intern;
object_init_ex(z_val, php_sdl_pixels_ce);
- intern = (struct php_sdl_pixels *)Z_OBJ_P(z_val);
+ zend_object *zo = Z_OBJ_P(z_val);
+ intern = (php_sdl_pixels*)((char *)zo - zo->handlers->offset);
intern->pixels = *pixels;
- intern->flags = flags;
+ intern->flags = flags;
return 1;
}
@@ -196,13 +229,13 @@ zend_bool sdl_pixels_to_zval(SDL_Pixels *pixels, zval *z_val, Uint32 flags)
/* {{{ zval_to_sdl_pixelformat */
SDL_PixelFormat *zval_to_sdl_pixelformat(zval *z_val)
{
- if (Z_TYPE_P(z_val) == IS_OBJECT && Z_OBJCE_P(z_val) == php_sdl_pixelformat_ce) {
- struct php_sdl_pixelformat *intern;
+ if (Z_TYPE_P(z_val) == IS_OBJECT && Z_OBJCE_P(z_val) == php_sdl_pixelformat_ce)
+ {
+ php_sdl_pixelformat *intern;
- zend_object *zo = Z_OBJ_P(z_val);
- intern = (struct php_sdl_pixelformat*)((char*)zo - zo->handlers->offset);
+ intern = PHP_SDL_PIXELFORMAT_P(z_val);
return intern->format;
- }
+ }
return NULL;
}
/* }}} */
@@ -210,12 +243,14 @@ SDL_PixelFormat *zval_to_sdl_pixelformat(zval *z_val)
/* {{{ zval_to_sdl_pixels */
SDL_Pixels *zval_to_sdl_pixels(zval *z_val)
{
- if (Z_TYPE_P(z_val) == IS_OBJECT && Z_OBJCE_P(z_val) == php_sdl_pixels_ce) {
- struct php_sdl_pixels *intern;
+ php_sdl_pixels *intern;
- intern = (struct php_sdl_pixels *)Z_OBJ_P(z_val);
+ if (Z_TYPE_P(z_val) == IS_OBJECT && Z_OBJCE_P(z_val) == php_sdl_pixels_ce)
+ {
+ zend_object *zo = Z_OBJ_P(z_val);
+ intern = (php_sdl_pixels*)((char *)zo - zo->handlers->offset);
return &intern->pixels;
- }
+ }
return NULL;
}
/* }}} */
@@ -223,21 +258,22 @@ SDL_Pixels *zval_to_sdl_pixels(zval *z_val)
/* {{{ zval_to_sdl_palette */
SDL_Palette *zval_to_sdl_palette(zval *z_val)
{
- if (Z_TYPE_P(z_val) == IS_OBJECT && Z_OBJCE_P(z_val) == php_sdl_palette_ce) {
- struct php_sdl_palette *intern;
+ if (Z_TYPE_P(z_val) == IS_OBJECT && Z_OBJCE_P(z_val) == php_sdl_palette_ce)
+ {
+ php_sdl_palette *intern;
- intern = (struct php_sdl_palette *)Z_OBJ_P(z_val);
+ intern = PHP_SDL_PALETTE_P(z_val);
return intern->palette;
- }
+ }
return NULL;
}
/* }}} */
ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_Color__construct, 0, 0, 4)
- ZEND_ARG_INFO(0, r)
- ZEND_ARG_INFO(0, g)
- ZEND_ARG_INFO(0, b)
- ZEND_ARG_INFO(0, a)
+ZEND_ARG_INFO(0, r)
+ZEND_ARG_INFO(0, g)
+ZEND_ARG_INFO(0, b)
+ZEND_ARG_INFO(0, a)
ZEND_END_ARG_INFO()
/* {{{ proto SDL_Color::__construct(int r, int g, int b, int a) */
@@ -247,19 +283,22 @@ static PHP_METHOD(SDL_Color, __construct)
zend_error_handling error_handling;
zend_replace_error_handling(EH_THROW, NULL, &error_handling);
- if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "llll", &r, &g, &b, &a)) {
+ if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "llll", &r, &g, &b, &a))
+ {
zend_restore_error_handling(&error_handling);
return;
}
zend_restore_error_handling(&error_handling);
- zend_update_property_long(php_sdl_color_ce, getThis(), "r", 1, r&255);
- zend_update_property_long(php_sdl_color_ce, getThis(), "g", 1, g&255);
- zend_update_property_long(php_sdl_color_ce, getThis(), "b", 1, b&255);
- zend_update_property_long(php_sdl_color_ce, getThis(), "a", 1, a&255);
+ zend_update_property_long(php_sdl_color_ce, Z_OBJ_P(getThis()), "r", 1, r & 255);
+ zend_update_property_long(php_sdl_color_ce, Z_OBJ_P(getThis()), "g", 1, g & 255);
+ zend_update_property_long(php_sdl_color_ce, Z_OBJ_P(getThis()), "b", 1, b & 255);
+ zend_update_property_long(php_sdl_color_ce, Z_OBJ_P(getThis()), "a", 1, a & 255);
}
/* }}} */
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_SDL_Color___toString, 0, 0, IS_STRING, 0)
+ZEND_END_ARG_INFO()
/* {{{ proto SDL_Color::__toString() */
static PHP_METHOD(SDL_Color, __toString)
@@ -267,7 +306,8 @@ static PHP_METHOD(SDL_Color, __toString)
char *buf;
SDL_Color color;
- if (zend_parse_parameters_none() == FAILURE) {
+ if (zend_parse_parameters_none() == FAILURE)
+ {
return;
}
@@ -287,11 +327,13 @@ PHP_FUNCTION(SDL_GetPixelFormatName)
zend_long format;
const char *name;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &format) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &format) == FAILURE)
+ {
RETURN_FALSE;
}
name = SDL_GetPixelFormatName((Uint32)format);
- if (!name) {
+ if (!name)
+ {
RETURN_FALSE;
}
RETURN_STRING(name);
@@ -306,11 +348,11 @@ PHP_FUNCTION(SDL_GetPixelFormatName)
*
* \sa SDL_MasksToPixelFormatEnum()
extern DECLSPEC SDL_bool SDLCALL SDL_PixelFormatEnumToMasks(Uint32 format,
- int *bpp,
- Uint32 * Rmask,
- Uint32 * Gmask,
- Uint32 * Bmask,
- Uint32 * Amask);
+ int *bpp,
+ Uint32 * Rmask,
+ Uint32 * Gmask,
+ Uint32 * Bmask,
+ Uint32 * Amask);
*/
PHP_FUNCTION(SDL_PixelFormatEnumToMasks)
{
@@ -319,10 +361,12 @@ PHP_FUNCTION(SDL_PixelFormatEnumToMasks)
int bpp;
Uint32 rmask, gmask, bmask, amask;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "lzzzzz", &format, &z_bpp, &z_rmask, &z_gmask, &z_bmask, &z_amask) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "lz/z/z/z/z/", &format, &z_bpp, &z_rmask, &z_gmask, &z_bmask, &z_amask) == FAILURE)
+ {
RETURN_FALSE;
}
- if (SDL_PixelFormatEnumToMasks((Uint32)format, &bpp, &rmask, &gmask, &bmask, &amask)) {
+ if (SDL_PixelFormatEnumToMasks((Uint32)format, &bpp, &rmask, &gmask, &bmask, &amask))
+ {
zval_dtor(z_bpp);
ZVAL_LONG(z_bpp, bpp);
zval_dtor(z_rmask);
@@ -336,11 +380,10 @@ PHP_FUNCTION(SDL_PixelFormatEnumToMasks)
RETURN_TRUE;
}
- RETURN_FALSE;;
+ RETURN_FALSE;
}
/* }}} */
-
/* {{{ proto bool SDL_MasksToPixelFormatEnum(int format, int bpp, int Rmask, int Gmask, int Bmask, int Amask)
* \brief Convert a bpp and RGBA masks to an enumerated pixel format.
*
@@ -349,16 +392,17 @@ PHP_FUNCTION(SDL_PixelFormatEnumToMasks)
*
* \sa SDL_PixelFormatEnumToMasks()
extern DECLSPEC Uint32 SDLCALL SDL_MasksToPixelFormatEnum(int bpp,
- Uint32 Rmask,
- Uint32 Gmask,
- Uint32 Bmask,
- Uint32 Amask);
+ Uint32 Rmask,
+ Uint32 Gmask,
+ Uint32 Bmask,
+ Uint32 Amask);
*/
PHP_FUNCTION(SDL_MasksToPixelFormatEnum)
{
zend_long bpp, rmask, gmask, bmask, amask;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "lllll", &bpp, &rmask, &gmask, &bmask, &amask) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "lllll", &bpp, &rmask, &gmask, &bmask, &amask) == FAILURE)
+ {
RETURN_FALSE;
}
@@ -376,7 +420,8 @@ PHP_FUNCTION(SDL_AllocFormat)
zend_long index;
SDL_PixelFormat *format;
- if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "l", &index)) {
+ if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "l", &index))
+ {
return;
}
format = SDL_AllocFormat((Uint32)index);
@@ -387,46 +432,52 @@ PHP_FUNCTION(SDL_AllocFormat)
/* {{{ proto SDL_PixelFormat::__construct(format) */
static PHP_METHOD(SDL_PixelFormat, __construct)
{
- struct php_sdl_pixelformat *intern;
+ php_sdl_pixelformat *intern;
zend_long format;
zend_error_handling error_handling;
- intern = (struct php_sdl_pixelformat *)Z_OBJ_P(getThis());
+ intern = PHP_SDL_PIXELFORMAT_P(getThis());
zend_replace_error_handling(EH_THROW, NULL, &error_handling);
- if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "l", &format)) {
+ if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "l", &format))
+ {
zend_restore_error_handling(&error_handling);
return;
}
zend_restore_error_handling(&error_handling);
intern->format = SDL_AllocFormat((Uint32)format);
- if (intern->format) {
+ if (intern->format)
+ {
intern->flags = 0;
- } else {
- zend_throw_exception(zend_exception_get_default(), SDL_GetError(), 0);
+ }
+ else
+ {
+ zend_throw_exception(zend_ce_exception, SDL_GetError(), 0);
}
}
/* }}} */
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_SDL_PixelFormat___toString, 0, 0, IS_STRING, 0)
+ZEND_END_ARG_INFO()
/* {{{ proto SDL_PixelFormat::__toString() */
static PHP_METHOD(SDL_PixelFormat, __toString)
{
- struct php_sdl_pixelformat *intern;
+ php_sdl_pixelformat *intern;
char *buf;
- if (zend_parse_parameters_none() == FAILURE) {
+ if (zend_parse_parameters_none() == FAILURE)
+ {
return;
}
- intern = (struct php_sdl_pixelformat *)Z_OBJ_P(getThis());
+ intern = PHP_SDL_PIXELFORMAT_P(getThis());
spprintf(&buf, 100, "SDL_PixelFormat(%s)", SDL_GetPixelFormatName(intern->format->format));
RETVAL_STRING(buf);
}
/* }}} */
-
/* {{{ proto void SDL_FreeFormat(SDL_PixelFormat format)
* \brief Free an SDL_PixelFormat structure.
@@ -434,11 +485,12 @@ static PHP_METHOD(SDL_PixelFormat, __toString)
*/
PHP_FUNCTION(SDL_FreeFormat)
{
- struct php_sdl_pixelformat *intern;
+ php_sdl_pixelformat *intern;
zval *object;
SDL_PixelFormat *format;
- if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_pixelformat_ce) == FAILURE) {
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_pixelformat_ce) == FAILURE)
+ {
return;
}
FETCH_PIXELFORMAT(format, object, 1);
@@ -448,7 +500,6 @@ PHP_FUNCTION(SDL_FreeFormat)
}
/* }}} */
-
/* {{{ proto SDL_Palette SDL_AllocPalette(int ncolors)
* \brief Create a palette structure with the specified number of color
@@ -466,10 +517,11 @@ PHP_FUNCTION(SDL_AllocPalette)
zend_long ncolors;
SDL_Palette *palette;
- if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "l", &ncolors)) {
+ if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "l", &ncolors))
+ {
return;
}
- palette = SDL_AllocPalette(ncolors);
+ palette = SDL_AllocPalette((int)ncolors);
sdl_palette_to_zval(palette, return_value, 0);
}
/* }}} */
@@ -477,53 +529,60 @@ PHP_FUNCTION(SDL_AllocPalette)
/* {{{ proto SDL_Palette::__construct(ncolors) */
static PHP_METHOD(SDL_Palette, __construct)
{
- struct php_sdl_palette *intern;
+ php_sdl_palette *intern;
zend_long ncolors;
zend_error_handling error_handling;
- intern = (struct php_sdl_palette *)Z_OBJ_P(getThis());
+ intern = PHP_SDL_PALETTE_P(getThis());
zend_replace_error_handling(EH_THROW, NULL, &error_handling);
- if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "l", &ncolors)) {
+ if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "l", &ncolors))
+ {
zend_restore_error_handling(&error_handling);
return;
}
zend_restore_error_handling(&error_handling);
intern->palette = SDL_AllocPalette(ncolors);
- if (intern->palette) {
+ if (intern->palette)
+ {
intern->flags = 0;
- } else {
- zend_throw_exception(zend_exception_get_default(), SDL_GetError(), 0);
+ }
+ else
+ {
+ zend_throw_exception(zend_ce_exception, SDL_GetError(), 0);
}
}
/* }}} */
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_SDL_Palette___toString, 0, 0, IS_STRING, 0)
+ZEND_END_ARG_INFO()
/* {{{ proto SDL_Palette::__toString() */
static PHP_METHOD(SDL_Palette, __toString)
{
- struct php_sdl_palette *intern;
+ php_sdl_palette *intern;
char *buf;
- if (zend_parse_parameters_none() == FAILURE) {
+ if (zend_parse_parameters_none() == FAILURE)
+ {
return;
}
- intern = (struct php_sdl_palette *)Z_OBJ_P(getThis());
+ intern = PHP_SDL_PALETTE_P(getThis());
spprintf(&buf, 100, "SDL_Palette(%d)", intern->palette ? intern->palette->ncolors : 0);
RETVAL_STRING(buf);
}
/* }}} */
-
/* {{{ proto SDL_Palette, count(void) */
static PHP_METHOD(SDL_Palette, count)
{
- struct php_sdl_palette *intern;
+ php_sdl_palette *intern;
- intern = (struct php_sdl_palette *)Z_OBJ_P(getThis());
- if (zend_parse_parameters_none() == FAILURE) {
+ intern = PHP_SDL_PALETTE_P(getThis());
+ if (zend_parse_parameters_none() == FAILURE)
+ {
return;
}
@@ -531,58 +590,72 @@ static PHP_METHOD(SDL_Palette, count)
}
/* }}} */
-ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_Palette_offset, 0, 0, 1)
- ZEND_ARG_INFO(0, offset)
+ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_SDL_Palette_offsetExists, 0, 1, _IS_BOOL, 0)
+ZEND_ARG_INFO(0, offset)
ZEND_END_ARG_INFO()
/* {{{ proto SDL_Palette, offsetExists(int offset) */
PHP_METHOD(SDL_Palette, offsetExists)
{
- struct php_sdl_palette *intern;
+ php_sdl_palette *intern;
zend_long offset;
- intern = (struct php_sdl_palette *)Z_OBJ_P(getThis());
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &offset) == FAILURE) {
+ intern = PHP_SDL_PALETTE_P(getThis());
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &offset) == FAILURE)
+ {
return;
}
- if (!intern->palette || offset < 0 || offset >= (intern->palette->ncolors)) {
+ if (!intern->palette || offset < 0 || offset >= (intern->palette->ncolors))
+ {
RETURN_FALSE;
}
RETURN_TRUE;
}
/* }}} */
+ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_SDL_Palette_offsetGet, 0, 1, IS_MIXED, 1)
+ZEND_ARG_INFO(0, offset)
+ZEND_END_ARG_INFO()
+
/* {{{ proto SDL_Palette, offsetGet(int offset) */
PHP_METHOD(SDL_Palette, offsetGet)
{
- struct php_sdl_palette *intern;
+ php_sdl_palette *intern;
zend_long offset;
- intern = (struct php_sdl_palette *)Z_OBJ_P(getThis());
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &offset) == FAILURE) {
+ intern = PHP_SDL_PALETTE_P(getThis());
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &offset) == FAILURE)
+ {
return;
}
- if (!intern->palette || offset < 0 || offset >= (intern->palette->ncolors)) {
- zend_throw_exception(zend_exception_get_default(), "Invalid offset in SDL_Pixels", 0);
+ if (!intern->palette || offset < 0 || offset >= (intern->palette->ncolors))
+ {
+ zend_throw_exception(zend_ce_exception, "Invalid offset in SDL_Pixels", 0);
RETURN_FALSE;
}
- sdl_color_to_zval(intern->palette->colors+offset, return_value);
+ sdl_color_to_zval(intern->palette->colors + offset, return_value);
}
/* }}} */
+ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_SDL_Palette_offsetUnset, 0, 1, IS_VOID, 0)
+ZEND_ARG_INFO(0, offset)
+ZEND_END_ARG_INFO()
+
/* {{{ proto SDL_Palette, offsetUnset(int offset) */
PHP_METHOD(SDL_Palette, offsetUnset)
{
- struct php_sdl_palette *intern;
+ php_sdl_palette *intern;
zend_long offset;
SDL_Color color;
- intern = (struct php_sdl_palette *)Z_OBJ_P(getThis());
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &offset) == FAILURE) {
+ intern = PHP_SDL_PALETTE_P(getThis());
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &offset) == FAILURE)
+ {
return;
}
- if (!intern->palette || offset < 0 || offset >= (intern->palette->ncolors)) {
- zend_throw_exception(zend_exception_get_default(), "Invalid offset in SDL_Pixels", 0);
+ if (!intern->palette || offset < 0 || offset >= (intern->palette->ncolors))
+ {
+ zend_throw_exception(zend_ce_exception, "Invalid offset in SDL_Pixels", 0);
RETURN_FALSE;
}
memset(&color, 0, sizeof(color));
@@ -590,25 +663,27 @@ PHP_METHOD(SDL_Palette, offsetUnset)
}
/* }}} */
-ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_Palette_offsetSet, 0, 0, 2)
- ZEND_ARG_INFO(0, offset)
- ZEND_ARG_INFO(0, color)
+ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_SDL_Palette_offsetSet, 0, 2, IS_VOID, 0)
+ZEND_ARG_INFO(0, offset)
+ZEND_ARG_INFO(0, color)
ZEND_END_ARG_INFO()
/* {{{ proto SDL_Palette, offsetSet(int offset, int value) */
PHP_METHOD(SDL_Palette, offsetSet)
{
- struct php_sdl_palette *intern;
+ php_sdl_palette *intern;
zend_long offset;
zval *z_color;
SDL_Color color;
- intern = (struct php_sdl_palette *)Z_OBJ_P(getThis());
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "lO", &offset, &z_color, php_sdl_color_ce) == FAILURE) {
+ intern = PHP_SDL_PALETTE_P(getThis());
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "lO", &offset, &z_color, php_sdl_color_ce) == FAILURE)
+ {
return;
}
- if (!intern->palette || offset < 0 || offset >= (intern->palette->ncolors)) {
- zend_throw_exception(zend_exception_get_default(), "Invalid offset in SDL_Pixels", 0);
+ if (!intern->palette || offset < 0 || offset >= (intern->palette->ncolors))
+ {
+ zend_throw_exception(zend_ce_exception, "Invalid offset in SDL_Pixels", 0);
RETURN_FALSE;
}
zval_to_sdl_color(z_color, &color);
@@ -620,16 +695,17 @@ PHP_METHOD(SDL_Palette, offsetSet)
* \brief Set the palette for a pixel format structure.
extern DECLSPEC int SDLCALL SDL_SetPixelFormatPalette(SDL_PixelFormat * format,
- SDL_Palette *palette);
+ SDL_Palette *palette);
*/
PHP_FUNCTION(SDL_SetPixelFormatPalette)
{
- struct php_sdl_palette *intern;
+ php_sdl_palette *intern;
zval *z_format, *z_palette;
SDL_Palette *palette;
SDL_PixelFormat *format;
- if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OO", &z_format, php_sdl_pixelformat_ce, &z_palette, php_sdl_palette_ce) == FAILURE) {
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OO", &z_format, php_sdl_pixelformat_ce, &z_palette, php_sdl_palette_ce) == FAILURE)
+ {
return;
}
FETCH_PALETTE(palette, z_palette, 1);
@@ -639,7 +715,6 @@ PHP_FUNCTION(SDL_SetPixelFormatPalette)
}
/* }}} */
-
/* {{{ proto int SDL_SetPaletteColors(SDL_Palette palette, array colors, int first, int ncolors)
* \brief Set a range of colors in a palette.
@@ -651,54 +726,68 @@ PHP_FUNCTION(SDL_SetPixelFormatPalette)
*
* \return 0 on success, or -1 if not all of the colors could be set.
extern DECLSPEC int SDLCALL SDL_SetPaletteColors(SDL_Palette * palette,
- const SDL_Color * colors,
- int firstcolor, int ncolors);
+ const SDL_Color * colors,
+ int firstcolor, int ncolors);
*/
PHP_FUNCTION(SDL_SetPaletteColors)
{
- struct php_sdl_palette *intern;
+ php_sdl_palette *intern;
zval *object, *z_colors, *z_color;
SDL_Palette *palette;
SDL_Color *colors;
int i, nb;
- zend_long first=0, ncolors=0;
+ zend_long first = 0, ncolors = 0;
long count;
- if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oa|ll", &object, php_sdl_palette_ce, &z_colors, &first, &ncolors) == FAILURE) {
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oa|ll", &object, php_sdl_palette_ce, &z_colors, &first, &ncolors) == FAILURE)
+ {
return;
}
FETCH_PALETTE(palette, object, 1);
count = zend_hash_next_free_element(Z_ARRVAL_P(z_colors));
- if (ncolors <= 0) {
+ if (ncolors <= 0)
+ {
ncolors = count;
- } else if (ncolors > count) {
- php_error_docref(NULL, E_NOTICE, "Invalid color number, %ld will be used instead of %ld", count, ncolors);
+ }
+ else if (ncolors > count)
+ {
+ php_error_docref(NULL, E_NOTICE, "Invalid color number, %ld will be used instead of %ld", count, (long)ncolors);
ncolors = count;
}
- if (first >= intern->palette->ncolors) {
- php_error_docref(NULL, E_WARNING, "Invalid first color index, %ld >= %d", first, intern->palette->ncolors);
+ if (first >= intern->palette->ncolors)
+ {
+ php_error_docref(NULL, E_WARNING, "Invalid first color index, %ld >= %d", (long)first, intern->palette->ncolors);
RETURN_LONG(-1);
}
- if (first+ncolors > intern->palette->ncolors) {
- php_error_docref(NULL, E_WARNING, "Invalid color number, %ld > %d", first+ncolors, intern->palette->ncolors);
+ if (first + ncolors > intern->palette->ncolors)
+ {
+ php_error_docref(NULL, E_WARNING, "Invalid color number, %ld > %d", (long)(first + ncolors), intern->palette->ncolors);
RETURN_LONG(-1);
}
colors = emalloc(sizeof(SDL_Color) * ncolors);
- for (nb=i=0 ; ipixels.pixels = ecalloc(pitch, h);
- intern->pixels.pitch = pitch;
- intern->pixels.h = h;
+ intern->pixels.pixels = ecalloc((int)pitch, (int)h);
}
}
/* }}} */
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_SDL_Pixels___toString, 0, 0, IS_STRING, 0)
+ZEND_END_ARG_INFO()
/* {{{ proto SDL_Pixels::__toString() */
static PHP_METHOD(SDL_Pixels, __toString)
{
- struct php_sdl_pixels *intern;
char *buf;
- if (zend_parse_parameters_none() == FAILURE) {
+ if (zend_parse_parameters_none() == FAILURE)
+ {
return;
}
- intern = (struct php_sdl_pixels *)Z_OBJ_P(getThis());
- spprintf(&buf, 100, "SDL_Pixels(%d,%d)", intern->pixels.pitch, intern->pixels.h);
+ spprintf(&buf, 100, "SDL_Pixels");
RETVAL_STRING(buf);
}
/* }}} */
-
-/* {{{ proto SDL_Pixels, count(void) */
-static PHP_METHOD(SDL_Pixels, count)
+/* {{{ php_sdl_palette_free
+ */
+static void php_sdl_palette_free(zend_object *object)
{
- struct php_sdl_pixels *intern;
+ php_sdl_palette *intern = php_sdl_palette_from_obj(object);
- intern = (struct php_sdl_pixels *)Z_OBJ_P(getThis());
- if (zend_parse_parameters_none() == FAILURE) {
- return;
+ if (intern->palette)
+ {
+ if (!(intern->flags & SDL_DONTFREE))
+ {
+ SDL_FreePalette(intern->palette);
+ }
}
- RETURN_LONG(intern->pixels.h * intern->pixels.pitch);
+ zend_object_std_dtor(&intern->zo);
}
/* }}} */
-ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_Pixels_offset, 0, 0, 1)
- ZEND_ARG_INFO(0, offset)
-ZEND_END_ARG_INFO()
-
-/* {{{ proto SDL_Pixels, offsetExists(int offset) */
-PHP_METHOD(SDL_Pixels, offsetExists)
+/* {{{ php_sdl_palette_new
+ */
+static zend_object *php_sdl_palette_new(zend_class_entry *class_type)
{
- struct php_sdl_pixels *intern;
- zend_long offset;
+ php_sdl_palette *intern = zend_object_alloc(sizeof(php_sdl_palette), class_type);
- intern = (struct php_sdl_pixels *)Z_OBJ_P(getThis());
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &offset) == FAILURE) {
- return;
- }
- if (offset < 0 || offset >= (intern->pixels.h * intern->pixels.pitch)) {
- RETURN_FALSE;
- }
- RETURN_TRUE;
-}
-/* }}} */
+ zend_object_std_init(&intern->zo, class_type);
+ object_properties_init(&intern->zo, class_type);
-/* {{{ proto SDL_Pixels, offsetGet(int offset) */
-PHP_METHOD(SDL_Pixels, offsetGet)
-{
- struct php_sdl_pixels *intern;
- zend_long offset;
+ intern->palette = NULL;
+ intern->zo.handlers = (zend_object_handlers *)&php_sdl_palette_handlers;
- intern = (struct php_sdl_pixels *)Z_OBJ_P(getThis());
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &offset) == FAILURE) {
- return;
- }
- if (offset < 0 || offset >= (intern->pixels.h * intern->pixels.pitch)) {
- zend_throw_exception(zend_exception_get_default(), "Invalid offset in SDL_Pixels", 0);
- RETURN_FALSE;
- }
- RETVAL_LONG(intern->pixels.pixels[offset]);
+ return &intern->zo;
}
/* }}} */
-/* {{{ proto SDL_Pixels, offsetUnset(int offset) */
-PHP_METHOD(SDL_Pixels, offsetUnset)
+/* {{{ sdl_palette_read_property*/
+zval *sdl_palette_read_property(zend_object *object, zend_string *member, int type, void **cache_slot, zval *rv)
{
- struct php_sdl_pixels *intern;
- zend_long offset;
-
- intern = (struct php_sdl_pixels *)Z_OBJ_P(getThis());
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &offset) == FAILURE) {
- return;
- }
- if (offset < 0 || offset >= (intern->pixels.h * intern->pixels.pitch)) {
- zend_throw_exception(zend_exception_get_default(), "Invalid offset in SDL_Pixels", 0);
- RETURN_FALSE;
+ php_sdl_palette *intern = php_sdl_palette_from_obj(object);
+ char *member_val = ZSTR_VAL(member);
+ zval *retval;
+
+ if (!intern->palette)
+ {
+ return zend_std_read_property(object, member, type, cache_slot, rv);
+ }
+
+ retval = rv;
+
+ if (!strcmp(member_val, "ncolors"))
+ {
+ ZVAL_LONG(retval, intern->palette->ncolors);
+ }
+ else if (!strcmp(member_val, "version"))
+ {
+ ZVAL_LONG(retval, intern->palette->version);
+ }
+ else if (!strcmp(member_val, "refcount"))
+ {
+ ZVAL_LONG(retval, intern->palette->refcount);
+ }
+ else if (!strcmp(member_val, "colors"))
+ {
+ int i;
+ zval z_color;
+ array_init(retval);
+ for (i = 0; i < intern->palette->ncolors; i++)
+ {
+ sdl_color_to_zval(&intern->palette->colors[i], &z_color);
+ add_next_index_zval(retval, &z_color);
+ }
}
- intern->pixels.pixels[offset] = 0;
-}
-/* }}} */
+ else
+ {
+ retval = zend_std_read_property(object, member, type, cache_slot, rv);
-ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_Pixels_offsetSet, 0, 0, 2)
- ZEND_ARG_INFO(0, offset)
- ZEND_ARG_INFO(0, value)
-ZEND_END_ARG_INFO()
-
-/* {{{ proto SDL_Pixels, offsetSet(int offset, int value) */
-PHP_METHOD(SDL_Pixels, offsetSet)
-{
- struct php_sdl_pixels *intern;
- zend_long offset, value;
-
- intern = (struct php_sdl_pixels *)Z_OBJ_P(getThis());
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ll", &offset, &value) == FAILURE) {
- return;
- }
- if (offset < 0 || offset >= (intern->pixels.h * intern->pixels.pitch)) {
- zend_throw_exception(zend_exception_get_default(), "Invalid offset in SDL_Pixels", 0);
- RETURN_FALSE;
+ return retval;
}
- intern->pixels.pixels[offset] = (Uint8)value;
+
+ return retval;
}
/* }}} */
+#define SDL_PALETTE_ADD_PROPERTY(n, f) \
+ ZVAL_LONG(&zv, f); \
+ zend_hash_str_update(props, n, sizeof(n) - 1, &zv);
-ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_Pixels_GetByte, 0, 0, 2)
- ZEND_ARG_INFO(0, x)
- ZEND_ARG_INFO(0, y)
-ZEND_END_ARG_INFO()
-
-/* {{{ proto int SDL_Pixels::GetByte(int x, int y) */
-PHP_METHOD(SDL_Pixels, GetByte)
+/* {{{ sdl_palette_get_properties*/
+static HashTable *sdl_palette_get_properties(zend_object *object)
{
- struct php_sdl_pixels *intern;
- zval *z_pixels;
- zend_long x, y;
+ HashTable *props;
+ zval zv, z_color;
+ int i;
+ php_sdl_palette *intern = php_sdl_palette_from_obj(object);
- if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oll", &z_pixels, php_sdl_pixels_ce, &x, &y) == FAILURE) {
- return;
- }
- intern = (struct php_sdl_pixels *)Z_OBJ_P(z_pixels);\
+ props = zend_std_get_properties(object);
- if (x < 0 || x >= intern->pixels.pitch || y < 0 || y >= intern->pixels.h) {
- php_error_docref(NULL, E_NOTICE, "Invalid position (%ld,%ld) in SDL_Pixels (%d,%d)", x, y, intern->pixels.pitch, intern->pixels.h);
- RETURN_FALSE;
+ if (intern->palette)
+ {
+ SDL_PALETTE_ADD_PROPERTY("ncolors", intern->palette->ncolors);
+ SDL_PALETTE_ADD_PROPERTY("version", intern->palette->version);
+ SDL_PALETTE_ADD_PROPERTY("refcount", intern->palette->refcount);
+
+ array_init(&zv);
+ for (i = 0; i < intern->palette->ncolors; i++)
+ {
+ sdl_color_to_zval(&intern->palette->colors[i], &z_color);
+ add_next_index_zval(&zv, &z_color);
+ }
+ zend_hash_str_update(props, "colors", sizeof("colors") - 1, &zv);
}
- RETVAL_LONG(intern->pixels.pixels[y*intern->pixels.pitch+x]);
+ return props;
}
/* }}} */
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_Pixels_SetByte, 0, 0, 3)
- ZEND_ARG_INFO(0, x)
- ZEND_ARG_INFO(0, y)
- ZEND_ARG_INFO(0, byte)
-ZEND_END_ARG_INFO()
-
-/* {{{ proto int SDL_Pixels::SetByte(int x, int y, int byte) */
-PHP_METHOD(SDL_Pixels, SetByte)
+/* {{{ sdl_palette_write_property */
+static zval *sdl_palette_write_property(zend_object *object, zend_string *name, zval *value, void **cache_slot)
{
- struct php_sdl_pixels *intern;
- zval *z_pixels;
- zend_long x, y, v;
-
- if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Olll", &z_pixels, php_sdl_pixels_ce, &x, &y, &v) == FAILURE) {
- return;
- }
- intern = (struct php_sdl_pixels *)Z_OBJ_P(z_pixels);\
-
- if (x < 0 || x >= intern->pixels.pitch || y < 0 || y >= intern->pixels.h) {
- php_error_docref(NULL, E_NOTICE, "Invalid position (%ld,%ld) in SDL_Pixels (%d,%d)", x, y, intern->pixels.pitch, intern->pixels.h);
- RETURN_FALSE;
- }
- RETVAL_LONG(intern->pixels.pixels[y*intern->pixels.pitch+x]);
- intern->pixels.pixels[y*intern->pixels.pitch+x] = (Uint8)v;
+ php_error_docref(NULL, E_ERROR, "Not supported, use SDL_SetPaletteColors() or SDL_Palette::SetColors()");
+ return value;
}
/* }}} */
-
-
-/* {{{ php_sdl_palette_free
- */
-static void php_sdl_palette_free(zend_object *object)
+/* {{{ php_sdl_pixelformat_free
+ */
+static void php_sdl_pixelformat_free(zend_object *object)
{
- struct php_sdl_palette *intern = (struct php_sdl_palette *) object;
+ php_sdl_pixelformat *intern = php_sdl_pixelformat_from_obj(object);
- if (intern->palette) {
- if (!(intern->flags & SDL_DONTFREE)) {
- SDL_FreePalette(intern->palette);
+ if (intern->format)
+ {
+ if (!(intern->flags & SDL_DONTFREE))
+ {
+ SDL_FreeFormat(intern->format);
}
}
@@ -1156,66 +1222,167 @@ static void php_sdl_palette_free(zend_object *object)
}
/* }}} */
-/* {{{ php_sdl_palette_new
+/* {{{ php_sdl_pixelformat_new
*/
-static zend_object* php_sdl_palette_new(zend_class_entry *class_type)
+static zend_object *php_sdl_pixelformat_new(zend_class_entry *class_type)
{
- struct php_sdl_palette *intern;
-
- intern = ecalloc(1, sizeof(*intern));
+ php_sdl_pixelformat *intern = zend_object_alloc(sizeof(php_sdl_pixelformat), class_type);
zend_object_std_init(&intern->zo, class_type);
object_properties_init(&intern->zo, class_type);
- intern->palette = NULL;
- intern->zo.handlers = (zend_object_handlers *) &php_sdl_palette_handlers;
+ intern->format = NULL;
+ intern->zo.handlers = (zend_object_handlers *)&php_sdl_pixelformat_handlers;
return &intern->zo;
}
/* }}} */
-/* {{{ php_sdl_pixelformat_free
- */
-static void php_sdl_pixelformat_free(zend_object *object)
+/* {{{ sdl_pixelformat_read_property*/
+zval *sdl_pixelformat_read_property(zend_object *object, zend_string *member, int type, void **cache_slot, zval *rv)
{
- struct php_sdl_pixelformat *intern = (struct php_sdl_pixelformat*)((char*)object - object->handlers->offset);
+ php_sdl_pixelformat *intern = php_sdl_pixelformat_from_obj(object);
+ char *member_val = ZSTR_VAL(member);
+ zval *retval;
- if (intern->format) {
- if (!(intern->flags & SDL_DONTFREE)) {
- SDL_FreeFormat(intern->format);
- }
+ if (!intern->format)
+ {
+ return zend_std_read_property(object, member, type, cache_slot, rv);
}
- zend_object_std_dtor(&intern->zo);
-}
-/* }}} */
+ retval = rv;
-/* {{{ php_sdl_pixelformat_new
- */
-static zend_object* php_sdl_pixelformat_new(zend_class_entry *class_type)
-{
- struct php_sdl_pixelformat *intern;
+ if (!strcmp(member_val, "format"))
+ {
+ ZVAL_LONG(retval, intern->format->format);
+ }
+ else if (!strcmp(member_val, "BitsPerPixel"))
+ {
+ ZVAL_LONG(retval, intern->format->BitsPerPixel);
+ }
+ else if (!strcmp(member_val, "BytesPerPixel"))
+ {
+ ZVAL_LONG(retval, intern->format->BytesPerPixel);
+ }
+ else if (!strcmp(member_val, "Rmask"))
+ {
+ ZVAL_LONG(retval, intern->format->Rmask);
+ }
+ else if (!strcmp(member_val, "Gmask"))
+ {
+ ZVAL_LONG(retval, intern->format->Gmask);
+ }
+ else if (!strcmp(member_val, "Bmask"))
+ {
+ ZVAL_LONG(retval, intern->format->Bmask);
+ }
+ else if (!strcmp(member_val, "Amask"))
+ {
+ ZVAL_LONG(retval, intern->format->Amask);
+ }
+ else if (!strcmp(member_val, "Rloss"))
+ {
+ ZVAL_LONG(retval, intern->format->Rloss);
+ }
+ else if (!strcmp(member_val, "Gloss"))
+ {
+ ZVAL_LONG(retval, intern->format->Gloss);
+ }
+ else if (!strcmp(member_val, "Bloss"))
+ {
+ ZVAL_LONG(retval, intern->format->Bloss);
+ }
+ else if (!strcmp(member_val, "Aloss"))
+ {
+ ZVAL_LONG(retval, intern->format->Aloss);
+ }
+ else if (!strcmp(member_val, "Rshift"))
+ {
+ ZVAL_LONG(retval, intern->format->Rshift);
+ }
+ else if (!strcmp(member_val, "Gshift"))
+ {
+ ZVAL_LONG(retval, intern->format->Gshift);
+ }
+ else if (!strcmp(member_val, "Bshift"))
+ {
+ ZVAL_LONG(retval, intern->format->Bshift);
+ }
+ else if (!strcmp(member_val, "Ashift"))
+ {
+ ZVAL_LONG(retval, intern->format->Ashift);
+ }
+ else if (!strcmp(member_val, "palette"))
+ {
+ sdl_palette_to_zval(intern->format->palette, retval, SDL_DONTFREE);
+ }
+ else
+ {
+ retval = zend_std_read_property(object, member, type, cache_slot, rv);
- intern = (struct php_sdl_pixelformat*)ecalloc(1, sizeof(struct php_sdl_pixelformat) + zend_object_properties_size(class_type));
+ return retval;
+ }
- zend_object_std_init(&intern->zo, class_type);
- object_properties_init(&intern->zo, class_type);
+ return retval;
+}
+/* }}} */
- intern->format = NULL;
- intern->zo.handlers = (zend_object_handlers *) &php_sdl_pixelformat_handlers;
+#define SDL_PIXELFORMAT_ADD_PROPERTY(n, f) \
+ ZVAL_LONG(&zv, f); \
+ zend_hash_str_update(props, n, sizeof(n) - 1, &zv);
- return &intern->zo;
+/* {{{ sdl_pixelformat_read_property*/
+static HashTable *sdl_pixelformat_get_properties(zend_object *object)
+{
+ HashTable *props;
+ zval zv;
+ php_sdl_pixelformat *intern;
+ intern = php_sdl_pixelformat_from_obj(object);
+ props = zend_std_get_properties(object);
+
+ if (intern->format)
+ {
+ SDL_PIXELFORMAT_ADD_PROPERTY("format", intern->format->format);
+ SDL_PIXELFORMAT_ADD_PROPERTY("BitsPerPixel", intern->format->BitsPerPixel);
+ SDL_PIXELFORMAT_ADD_PROPERTY("BytesPerPixel", intern->format->BytesPerPixel);
+ SDL_PIXELFORMAT_ADD_PROPERTY("Rmask", intern->format->Rmask);
+ SDL_PIXELFORMAT_ADD_PROPERTY("Gmask", intern->format->Gmask);
+ SDL_PIXELFORMAT_ADD_PROPERTY("Bmask", intern->format->Bmask);
+ SDL_PIXELFORMAT_ADD_PROPERTY("Amask", intern->format->Amask);
+ SDL_PIXELFORMAT_ADD_PROPERTY("Rloss", intern->format->Rloss);
+ SDL_PIXELFORMAT_ADD_PROPERTY("Gloss", intern->format->Gloss);
+ SDL_PIXELFORMAT_ADD_PROPERTY("Bloss", intern->format->Bloss);
+ SDL_PIXELFORMAT_ADD_PROPERTY("Aloss", intern->format->Aloss);
+ SDL_PIXELFORMAT_ADD_PROPERTY("Rshift", intern->format->Rshift);
+ SDL_PIXELFORMAT_ADD_PROPERTY("Gshift", intern->format->Gshift);
+ SDL_PIXELFORMAT_ADD_PROPERTY("Bshift", intern->format->Bshift);
+ SDL_PIXELFORMAT_ADD_PROPERTY("Ashift", intern->format->Ashift);
+
+ sdl_palette_to_zval(intern->format->palette, &zv, SDL_DONTFREE);
+ zend_hash_str_update(props, "palette", sizeof("palette") - 1, &zv);
+ }
+ return props;
+}
+/* }}} */
+
+/* {{{ sdl_pixelformat_write_property */
+static zval *sdl_pixelformat_write_property(zend_object *object, zend_string *name, zval *value, void **cache_slot)
+{
+ php_error_docref(NULL, E_ERROR, "Not supported, SDL_PixelFormat is read-only");
+ return value;
}
/* }}} */
/* {{{ php_sdl_pixels_free
- */
+ */
static void php_sdl_pixels_free(zend_object *object)
{
- struct php_sdl_pixels *intern = (struct php_sdl_pixels *) object;
+ php_sdl_pixels *intern = php_sdl_pixels_from_obj(object);
- if (intern->pixels.pixels) {
- if (!(intern->flags & SDL_DONTFREE)) {
+ if (intern->pixels.pixels)
+ {
+ if (!(intern->flags & SDL_DONTFREE))
+ {
efree(intern->pixels.pixels);
}
}
@@ -1226,78 +1393,96 @@ static void php_sdl_pixels_free(zend_object *object)
/* {{{ php_sdl_pixels_new
*/
-static zend_object* php_sdl_pixels_new(zend_class_entry *class_type)
+static zend_object *php_sdl_pixels_new(zend_class_entry *class_type)
{
- struct php_sdl_pixels *intern;
-
- intern = ecalloc(1, sizeof(*intern));
+ php_sdl_pixels *intern = zend_object_alloc(sizeof(php_sdl_pixels), class_type);
zend_object_std_init(&intern->zo, class_type);
object_properties_init(&intern->zo, class_type);
- intern->zo.handlers = (zend_object_handlers *) &php_sdl_pixels_handlers;
+ intern->zo.handlers = (zend_object_handlers *)&php_sdl_pixels_handlers;
return &intern->zo;
}
/* }}} */
+/* {{{ sdl_pixels_read_property*/
+zval *sdl_pixels_read_property(zend_object *object, zend_string *member, int type, void **cache_slot, zval *rv)
+{
+ php_sdl_pixels *intern;
+ intern = php_sdl_pixels_from_obj(object);
+ char *member_val = ZSTR_VAL(member);
+
+ zval *retval;
+
+ retval = rv;
+
+ if (!strcmp(member_val, "pixels"))
+ {
+ if (!intern->pixels.pixels)
+ {
+ return zend_std_read_property(object, member, type, cache_slot, rv);
+ }
+ }
+ else
+ {
+ retval = zend_std_read_property(object, member, type, cache_slot, rv);
+ }
+
+ return retval;
+}
+/* }}} */
+
+#define SDL_PIXELS_ADD_PROPERTY(n, f) \
+ ZVAL_LONG(&zv, f); \
+ zend_hash_str_update(props, n, sizeof(n) - 1, &zv);
+
/* {{{ php_sdl_color_methods[] */
static const zend_function_entry php_sdl_color_methods[] = {
- PHP_ME(SDL_Color, __construct, arginfo_SDL_Color__construct, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC)
- PHP_ME(SDL_Color, __toString, arginfo_palette_none, ZEND_ACC_PUBLIC)
+ PHP_ME(SDL_Color, __construct, arginfo_SDL_Color__construct, ZEND_ACC_CTOR | ZEND_ACC_PUBLIC)
+ PHP_ME(SDL_Color, __toString, arginfo_class_SDL_Color___toString, ZEND_ACC_PUBLIC)
- PHP_FE_END
-};
+ PHP_FE_END};
/* }}} */
/* {{{ php_sdl_palette_methods[] */
static const zend_function_entry php_sdl_palette_methods[] = {
- PHP_ME(SDL_Palette, __construct, arginfo_SDL_AllocPalette, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC)
- PHP_ME(SDL_Palette, __toString, arginfo_palette_none, ZEND_ACC_PUBLIC)
- PHP_ME(SDL_Palette, count, arginfo_palette_none, ZEND_ACC_PUBLIC)
- PHP_ME(SDL_Palette, offsetExists, arginfo_SDL_Palette_offset, ZEND_ACC_PUBLIC)
- PHP_ME(SDL_Palette, offsetGet, arginfo_SDL_Palette_offset, ZEND_ACC_PUBLIC)
- PHP_ME(SDL_Palette, offsetSet, arginfo_SDL_Palette_offsetSet, ZEND_ACC_PUBLIC)
- PHP_ME(SDL_Palette, offsetUnset, arginfo_SDL_Palette_offset, ZEND_ACC_PUBLIC)
+ PHP_ME(SDL_Palette, __construct, arginfo_SDL_AllocPalette, ZEND_ACC_PUBLIC)
+ PHP_ME(SDL_Palette, __toString, arginfo_class_SDL_Palette___toString, ZEND_ACC_PUBLIC)
+ PHP_ME(SDL_Palette, count, arginfo_palette_none, ZEND_ACC_PUBLIC)
+ PHP_ME(SDL_Palette, offsetExists, arginfo_SDL_Palette_offsetExists, ZEND_ACC_PUBLIC)
+ PHP_ME(SDL_Palette, offsetGet, arginfo_SDL_Palette_offsetGet, ZEND_ACC_PUBLIC)
+ PHP_ME(SDL_Palette, offsetSet, arginfo_SDL_Palette_offsetSet, ZEND_ACC_PUBLIC)
+ PHP_ME(SDL_Palette, offsetUnset, arginfo_SDL_Palette_offsetUnset, ZEND_ACC_PUBLIC)
/* non-static methods */
- PHP_FALIAS(Free, SDL_FreePalette, arginfo_palette_none)
- PHP_FALIAS(SetColors, SDL_SetPaletteColors, arginfo_SDL_Palette_SetColors)
+ PHP_FALIAS(Free, SDL_FreePalette, arginfo_palette_none)
+ PHP_FALIAS(SetColors, SDL_SetPaletteColors, arginfo_SDL_Palette_SetColors)
- PHP_FE_END
-};
+ PHP_FE_END};
/* }}} */
/* {{{ php_sdl_pixelformat_methods[] */
static const zend_function_entry php_sdl_pixelformat_methods[] = {
- PHP_ME(SDL_PixelFormat, __construct, arginfo_SDL_AllocFormat, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC)
- PHP_ME(SDL_PixelFormat, __toString, arginfo_palette_none, ZEND_ACC_PUBLIC)
- PHP_ME(SDL_PixelFormat, GetRGB, arginfo_SDL_PixelFormat_GetRGB, ZEND_ACC_PUBLIC)
- PHP_ME(SDL_PixelFormat, GetRGBA, arginfo_SDL_PixelFormat_GetRGBA, ZEND_ACC_PUBLIC)
+ PHP_ME(SDL_PixelFormat, __construct, arginfo_SDL_AllocFormat, ZEND_ACC_PUBLIC)
+ PHP_ME(SDL_PixelFormat, __toString, arginfo_class_SDL_PixelFormat___toString, ZEND_ACC_PUBLIC)
+ PHP_ME(SDL_PixelFormat, GetRGB, arginfo_SDL_PixelFormat_GetRGB, ZEND_ACC_PUBLIC)
+ PHP_ME(SDL_PixelFormat, GetRGBA, arginfo_SDL_PixelFormat_GetRGBA, ZEND_ACC_PUBLIC)
/* non-static methods */
- PHP_FALIAS(Free, SDL_FreeFormat, arginfo_format_none)
- PHP_FALIAS(SetPalette, SDL_SetPixelFormatPalette, arginfo_SDL_PixelFormat_SetPalette)
- PHP_FALIAS(MapRGB, SDL_MapRGB, arginfo_SDL_PixelFormat_MapRGB)
- PHP_FALIAS(MapRGBA, SDL_MapRGBA, arginfo_SDL_PixelFormat_MapRGBA)
+ PHP_FALIAS(Free, SDL_FreeFormat, arginfo_format_none)
+ PHP_FALIAS(SetPalette, SDL_SetPixelFormatPalette, arginfo_SDL_PixelFormat_SetPalette)
+ PHP_FALIAS(MapRGB, SDL_MapRGB, arginfo_SDL_PixelFormat_MapRGB)
+ PHP_FALIAS(MapRGBA, SDL_MapRGBA, arginfo_SDL_PixelFormat_MapRGBA)
- PHP_FE_END
-};
+ PHP_FE_END};
/* }}} */
/* {{{ php_sdl_pixels_methods[] */
static const zend_function_entry php_sdl_pixels_methods[] = {
- PHP_ME(SDL_Pixels, __construct, arginfo_SDL_Pixels__construct, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC)
- PHP_ME(SDL_Pixels, __toString, arginfo_format_none, ZEND_ACC_PUBLIC)
- PHP_ME(SDL_Pixels, count, arginfo_format_none, ZEND_ACC_PUBLIC)
- PHP_ME(SDL_Pixels, offsetExists, arginfo_SDL_Pixels_offset, ZEND_ACC_PUBLIC)
- PHP_ME(SDL_Pixels, offsetGet, arginfo_SDL_Pixels_offset, ZEND_ACC_PUBLIC)
- PHP_ME(SDL_Pixels, offsetSet, arginfo_SDL_Pixels_offsetSet, ZEND_ACC_PUBLIC)
- PHP_ME(SDL_Pixels, offsetUnset, arginfo_SDL_Pixels_offset, ZEND_ACC_PUBLIC)
- PHP_ME(SDL_Pixels, GetByte, arginfo_SDL_Pixels_GetByte, ZEND_ACC_PUBLIC)
- PHP_ME(SDL_Pixels, SetByte, arginfo_SDL_Pixels_SetByte, ZEND_ACC_PUBLIC)
- PHP_FE_END
-};
+ PHP_ME(SDL_Pixels, __construct, arginfo_SDL_Pixels__construct, ZEND_ACC_PUBLIC)
+ PHP_ME(SDL_Pixels, __toString, arginfo_class_SDL_Pixels___toString, ZEND_ACC_PUBLIC)
+ PHP_FE_END};
/* }}} */
#define REGISTER_COLOR_PROP(name) \
@@ -1331,7 +1516,11 @@ PHP_MINIT_FUNCTION(sdl_pixels)
php_sdl_palette_ce->create_object = php_sdl_palette_new;
zend_class_implements(php_sdl_palette_ce, 1, zend_ce_arrayaccess);
memcpy(&php_sdl_palette_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
+ php_sdl_palette_handlers.read_property = sdl_palette_read_property;
+ php_sdl_palette_handlers.get_properties = sdl_palette_get_properties;
+ php_sdl_palette_handlers.write_property = sdl_palette_write_property;
php_sdl_palette_handlers.free_obj = php_sdl_palette_free;
+ php_sdl_palette_handlers.offset = XtOffsetOf(php_sdl_palette, zo);
REGISTER_PALETTE_PROP("ncolors");
REGISTER_PALETTE_PROP("version");
@@ -1342,8 +1531,11 @@ PHP_MINIT_FUNCTION(sdl_pixels)
php_sdl_pixelformat_ce = zend_register_internal_class(&ce_pixelformat);
php_sdl_pixelformat_ce->create_object = php_sdl_pixelformat_new;
memcpy(&php_sdl_pixelformat_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
+ php_sdl_pixelformat_handlers.read_property = sdl_pixelformat_read_property;
+ php_sdl_pixelformat_handlers.get_properties = sdl_pixelformat_get_properties;
+ php_sdl_pixelformat_handlers.write_property = sdl_pixelformat_write_property;
php_sdl_pixelformat_handlers.free_obj = php_sdl_pixelformat_free;
- php_sdl_pixelformat_handlers.offset = XtOffsetOf(struct php_sdl_pixelformat, zo);
+ php_sdl_pixelformat_handlers.offset = XtOffsetOf(php_sdl_pixelformat, zo);
REGISTER_FORMAT_PROP("format");
REGISTER_FORMAT_PROP("BitsPerPixel");
@@ -1365,92 +1557,89 @@ PHP_MINIT_FUNCTION(sdl_pixels)
INIT_CLASS_ENTRY(ce_pixels, "SDL_Pixels", php_sdl_pixels_methods);
php_sdl_pixels_ce = zend_register_internal_class(&ce_pixels);
php_sdl_pixels_ce->create_object = php_sdl_pixels_new;
- zend_class_implements(php_sdl_pixels_ce, 1, zend_ce_arrayaccess);
memcpy(&php_sdl_pixels_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
+ php_sdl_pixels_handlers.read_property = sdl_pixels_read_property;
php_sdl_pixels_handlers.free_obj = php_sdl_pixels_free;
-
- REGISTER_PIXELS_PROP("pitch");
- REGISTER_PIXELS_PROP("h");
- REGISTER_PIXELS_PROP("count");
+ php_sdl_pixels_handlers.offset = XtOffsetOf(php_sdl_pixels, zo);
/* Pixel type. */
- REGISTER_LONG_CONSTANT("SDL_PIXELTYPE_UNKNOWN", SDL_PIXELTYPE_UNKNOWN, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_PIXELTYPE_INDEX1", SDL_PIXELTYPE_INDEX1, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_PIXELTYPE_INDEX4", SDL_PIXELTYPE_INDEX4, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_PIXELTYPE_INDEX8", SDL_PIXELTYPE_INDEX8, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_PIXELTYPE_PACKED8", SDL_PIXELTYPE_PACKED8, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_PIXELTYPE_PACKED16", SDL_PIXELTYPE_PACKED16, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_PIXELTYPE_PACKED32", SDL_PIXELTYPE_PACKED32, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_PIXELTYPE_ARRAYU8", SDL_PIXELTYPE_ARRAYU8, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_PIXELTYPE_ARRAYU16", SDL_PIXELTYPE_ARRAYU16, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_PIXELTYPE_ARRAYU32", SDL_PIXELTYPE_ARRAYU32, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_PIXELTYPE_ARRAYF16", SDL_PIXELTYPE_ARRAYF16, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_PIXELTYPE_ARRAYF32", SDL_PIXELTYPE_ARRAYF32, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_PIXELTYPE_UNKNOWN", SDL_PIXELTYPE_UNKNOWN, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_PIXELTYPE_INDEX1", SDL_PIXELTYPE_INDEX1, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_PIXELTYPE_INDEX4", SDL_PIXELTYPE_INDEX4, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_PIXELTYPE_INDEX8", SDL_PIXELTYPE_INDEX8, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_PIXELTYPE_PACKED8", SDL_PIXELTYPE_PACKED8, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_PIXELTYPE_PACKED16", SDL_PIXELTYPE_PACKED16, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_PIXELTYPE_PACKED32", SDL_PIXELTYPE_PACKED32, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_PIXELTYPE_ARRAYU8", SDL_PIXELTYPE_ARRAYU8, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_PIXELTYPE_ARRAYU16", SDL_PIXELTYPE_ARRAYU16, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_PIXELTYPE_ARRAYU32", SDL_PIXELTYPE_ARRAYU32, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_PIXELTYPE_ARRAYF16", SDL_PIXELTYPE_ARRAYF16, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_PIXELTYPE_ARRAYF32", SDL_PIXELTYPE_ARRAYF32, CONST_CS | CONST_PERSISTENT);
/* Bitmap pixel order, high bit -> low bit. */
- REGISTER_LONG_CONSTANT("SDL_BITMAPORDER_NONE", SDL_BITMAPORDER_NONE, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_BITMAPORDER_4321", SDL_BITMAPORDER_4321, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_BITMAPORDER_1234", SDL_BITMAPORDER_1234, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_BITMAPORDER_NONE", SDL_BITMAPORDER_NONE, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_BITMAPORDER_4321", SDL_BITMAPORDER_4321, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_BITMAPORDER_1234", SDL_BITMAPORDER_1234, CONST_CS | CONST_PERSISTENT);
/* Packed component order, high bit -> low bit. */
- REGISTER_LONG_CONSTANT("SDL_PACKEDORDER_NONE", SDL_PACKEDORDER_NONE, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_PACKEDORDER_XRGB", SDL_PACKEDORDER_XRGB, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_PACKEDORDER_RGBX", SDL_PACKEDORDER_RGBX, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_PACKEDORDER_ARGB", SDL_PACKEDORDER_ARGB, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_PACKEDORDER_RGBA", SDL_PACKEDORDER_RGBA, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_PACKEDORDER_XBGR", SDL_PACKEDORDER_XBGR, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_PACKEDORDER_BGRX", SDL_PACKEDORDER_BGRX, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_PACKEDORDER_ABGR", SDL_PACKEDORDER_ABGR, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_PACKEDORDER_BGRA", SDL_PACKEDORDER_BGRA, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_PACKEDORDER_NONE", SDL_PACKEDORDER_NONE, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_PACKEDORDER_XRGB", SDL_PACKEDORDER_XRGB, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_PACKEDORDER_RGBX", SDL_PACKEDORDER_RGBX, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_PACKEDORDER_ARGB", SDL_PACKEDORDER_ARGB, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_PACKEDORDER_RGBA", SDL_PACKEDORDER_RGBA, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_PACKEDORDER_XBGR", SDL_PACKEDORDER_XBGR, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_PACKEDORDER_BGRX", SDL_PACKEDORDER_BGRX, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_PACKEDORDER_ABGR", SDL_PACKEDORDER_ABGR, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_PACKEDORDER_BGRA", SDL_PACKEDORDER_BGRA, CONST_CS | CONST_PERSISTENT);
/* Packed component layout. */
- REGISTER_LONG_CONSTANT("SDL_PACKEDLAYOUT_NONE", SDL_PACKEDLAYOUT_NONE, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_PACKEDLAYOUT_332", SDL_PACKEDLAYOUT_332, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_PACKEDLAYOUT_4444", SDL_PACKEDLAYOUT_4444, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_PACKEDLAYOUT_1555", SDL_PACKEDLAYOUT_1555, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_PACKEDLAYOUT_5551", SDL_PACKEDLAYOUT_5551, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_PACKEDLAYOUT_565", SDL_PACKEDLAYOUT_565, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_PACKEDLAYOUT_8888", SDL_PACKEDLAYOUT_8888, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_PACKEDLAYOUT_2101010", SDL_PACKEDLAYOUT_2101010, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_PACKEDLAYOUT_1010102", SDL_PACKEDLAYOUT_1010102, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_PACKEDLAYOUT_NONE", SDL_PACKEDLAYOUT_NONE, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_PACKEDLAYOUT_332", SDL_PACKEDLAYOUT_332, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_PACKEDLAYOUT_4444", SDL_PACKEDLAYOUT_4444, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_PACKEDLAYOUT_1555", SDL_PACKEDLAYOUT_1555, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_PACKEDLAYOUT_5551", SDL_PACKEDLAYOUT_5551, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_PACKEDLAYOUT_565", SDL_PACKEDLAYOUT_565, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_PACKEDLAYOUT_8888", SDL_PACKEDLAYOUT_8888, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_PACKEDLAYOUT_2101010", SDL_PACKEDLAYOUT_2101010, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_PACKEDLAYOUT_1010102", SDL_PACKEDLAYOUT_1010102, CONST_CS | CONST_PERSISTENT);
/* Pixel format */
- REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_UNKNOWN", SDL_PIXELFORMAT_UNKNOWN, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_INDEX1LSB", SDL_PIXELFORMAT_INDEX1LSB, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_INDEX1MSB", SDL_PIXELFORMAT_INDEX1MSB, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_INDEX4LSB", SDL_PIXELFORMAT_INDEX4LSB, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_INDEX4MSB", SDL_PIXELFORMAT_INDEX4MSB, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_INDEX8", SDL_PIXELFORMAT_INDEX8, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_RGB332", SDL_PIXELFORMAT_RGB332, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_RGB444", SDL_PIXELFORMAT_RGB444, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_RGB555", SDL_PIXELFORMAT_RGB555, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_BGR555", SDL_PIXELFORMAT_BGR555, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_ARGB4444", SDL_PIXELFORMAT_ARGB4444, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_RGBA4444", SDL_PIXELFORMAT_RGBA4444, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_ABGR4444", SDL_PIXELFORMAT_ABGR4444, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_BGRA4444", SDL_PIXELFORMAT_BGRA4444, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_ARGB1555", SDL_PIXELFORMAT_ARGB1555, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_RGBA5551", SDL_PIXELFORMAT_RGBA5551, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_ABGR1555", SDL_PIXELFORMAT_ABGR1555, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_BGRA5551", SDL_PIXELFORMAT_BGRA5551, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_RGB565", SDL_PIXELFORMAT_RGB565, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_BGR565", SDL_PIXELFORMAT_BGR565, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_RGB24", SDL_PIXELFORMAT_RGB24, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_BGR24", SDL_PIXELFORMAT_BGR24, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_RGB888", SDL_PIXELFORMAT_RGB888, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_RGBX8888", SDL_PIXELFORMAT_RGBX8888, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_BGR888", SDL_PIXELFORMAT_BGR888, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_BGRX8888", SDL_PIXELFORMAT_BGRX8888, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_ARGB8888", SDL_PIXELFORMAT_ARGB8888, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_RGBA8888", SDL_PIXELFORMAT_RGBA8888, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_ABGR8888", SDL_PIXELFORMAT_ABGR8888, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_BGRA8888", SDL_PIXELFORMAT_BGRA8888, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_ARGB2101010", SDL_PIXELFORMAT_ARGB2101010, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_YV12", SDL_PIXELFORMAT_YV12, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_IYUV", SDL_PIXELFORMAT_IYUV, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_YUY2", SDL_PIXELFORMAT_YUY2, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_UYVY", SDL_PIXELFORMAT_UYVY, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_YVYU", SDL_PIXELFORMAT_YVYU, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_UNKNOWN", SDL_PIXELFORMAT_UNKNOWN, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_INDEX1LSB", SDL_PIXELFORMAT_INDEX1LSB, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_INDEX1MSB", SDL_PIXELFORMAT_INDEX1MSB, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_INDEX4LSB", SDL_PIXELFORMAT_INDEX4LSB, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_INDEX4MSB", SDL_PIXELFORMAT_INDEX4MSB, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_INDEX8", SDL_PIXELFORMAT_INDEX8, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_RGB332", SDL_PIXELFORMAT_RGB332, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_RGB444", SDL_PIXELFORMAT_RGB444, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_RGB555", SDL_PIXELFORMAT_RGB555, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_BGR555", SDL_PIXELFORMAT_BGR555, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_ARGB4444", SDL_PIXELFORMAT_ARGB4444, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_RGBA4444", SDL_PIXELFORMAT_RGBA4444, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_ABGR4444", SDL_PIXELFORMAT_ABGR4444, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_BGRA4444", SDL_PIXELFORMAT_BGRA4444, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_ARGB1555", SDL_PIXELFORMAT_ARGB1555, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_RGBA5551", SDL_PIXELFORMAT_RGBA5551, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_ABGR1555", SDL_PIXELFORMAT_ABGR1555, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_BGRA5551", SDL_PIXELFORMAT_BGRA5551, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_RGB565", SDL_PIXELFORMAT_RGB565, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_BGR565", SDL_PIXELFORMAT_BGR565, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_RGB24", SDL_PIXELFORMAT_RGB24, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_BGR24", SDL_PIXELFORMAT_BGR24, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_RGB888", SDL_PIXELFORMAT_RGB888, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_RGBX8888", SDL_PIXELFORMAT_RGBX8888, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_BGR888", SDL_PIXELFORMAT_BGR888, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_BGRX8888", SDL_PIXELFORMAT_BGRX8888, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_ARGB8888", SDL_PIXELFORMAT_ARGB8888, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_RGBA8888", SDL_PIXELFORMAT_RGBA8888, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_ABGR8888", SDL_PIXELFORMAT_ABGR8888, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_BGRA8888", SDL_PIXELFORMAT_BGRA8888, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_ARGB2101010", SDL_PIXELFORMAT_ARGB2101010, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_YV12", SDL_PIXELFORMAT_YV12, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_IYUV", SDL_PIXELFORMAT_IYUV, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_YUY2", SDL_PIXELFORMAT_YUY2, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_UYVY", SDL_PIXELFORMAT_UYVY, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_YVYU", SDL_PIXELFORMAT_YVYU, CONST_CS | CONST_PERSISTENT);
return SUCCESS;
}
diff --git a/src/pixels.h b/src/pixels.h
index 2501cd2..d6b32af 100644
--- a/src/pixels.h
+++ b/src/pixels.h
@@ -1,6 +1,4 @@
/*
- +----------------------------------------------------------------------+
- | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2018 The PHP Group |
+----------------------------------------------------------------------+
@@ -30,8 +28,6 @@ extern "C" {
/* PHP specific struct to manage memory access */
typedef struct SDL_Pixels
{
- int h;
- int pitch;
Uint8 *pixels;
} SDL_Pixels;
diff --git a/src/platform.c b/src/platform.c
index 40d1268..dada1e7 100644
--- a/src/platform.c
+++ b/src/platform.c
@@ -1,13 +1,11 @@
/*
- +----------------------------------------------------------------------+
- | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2018 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_01.txt |
+ | https://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
diff --git a/src/platform.h b/src/platform.h
index f7917a6..ee823ef 100644
--- a/src/platform.h
+++ b/src/platform.h
@@ -1,6 +1,4 @@
/*
- +----------------------------------------------------------------------+
- | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2018 The PHP Group |
+----------------------------------------------------------------------+
diff --git a/src/power.c b/src/power.c
index c9a7c44..42a4670 100644
--- a/src/power.c
+++ b/src/power.c
@@ -1,13 +1,11 @@
/*
- +----------------------------------------------------------------------+
- | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2018 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_01.txt |
+ | https://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
@@ -40,7 +38,7 @@ PHP_FUNCTION(SDL_GetPowerInfo)
zval *z_secs = NULL, *z_pct = NULL;
zend_bool has_secs, has_pct;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "|zz", &z_secs, &z_pct) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|z/z/", &z_secs, &z_pct) == FAILURE) {
RETURN_FALSE;
}
diff --git a/src/power.h b/src/power.h
index f889a62..c7b1e8c 100644
--- a/src/power.h
+++ b/src/power.h
@@ -1,6 +1,4 @@
/*
- +----------------------------------------------------------------------+
- | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2018 The PHP Group |
+----------------------------------------------------------------------+
diff --git a/src/rect.c b/src/rect.c
index 4e303e8..7a0a39d 100644
--- a/src/rect.c
+++ b/src/rect.c
@@ -1,13 +1,11 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) 1997-2022 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_01.txt |
+ | https://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
@@ -18,37 +16,81 @@
*/
#include "rect.h"
+#include "rect_arginfo.h"
static zend_class_entry *php_sdl_rect_ce;
static zend_object_handlers php_sdl_rect_handlers;
-struct php_sdl_rect {
- zend_object zo;
+struct php_sdl_rect
+{
+ zend_object zo;
+};
+
+static zend_class_entry *php_sdl_frect_ce;
+static zend_object_handlers php_sdl_frect_handlers;
+struct php_sdl_frect
+{
+ zend_object zo;
};
static zend_class_entry *php_sdl_point_ce;
static zend_object_handlers php_sdl_point_handlers;
-struct php_sdl_point {
- zend_object zo;
+struct php_sdl_point
+{
+ zend_object zo;
};
+static zend_class_entry *php_sdl_fpoint_ce;
+static zend_object_handlers php_sdl_fpoint_handlers;
+struct php_sdl_fpoint
+{
+ zend_object zo;
+};
+
+zend_class_entry *get_php_sdl_rect_ce(void)
+{
+ return php_sdl_rect_ce;
+}
+
+zend_class_entry *get_php_sdl_frect_ce(void)
+{
+ return php_sdl_frect_ce;
+}
+
zend_class_entry *get_php_sdl_point_ce(void)
{
return php_sdl_point_ce;
}
-zend_class_entry *get_php_sdl_rect_ce(void)
+zend_class_entry *get_php_sdl_fpoint_ce(void)
{
- return php_sdl_rect_ce;
+ return php_sdl_fpoint_ce;
}
zend_bool sdl_rect_to_zval(SDL_Rect *rect, zval *value)
{
- if (rect) {
+ if (rect)
+ {
object_init_ex(value, php_sdl_rect_ce);
- zend_update_property_long(php_sdl_rect_ce, value, "x", 1, rect->x);
- zend_update_property_long(php_sdl_rect_ce, value, "y", 1, rect->y);
- zend_update_property_long(php_sdl_rect_ce, value, "w", 1, rect->w);
- zend_update_property_long(php_sdl_rect_ce, value, "h", 1, rect->h);
+ zend_update_property_long(php_sdl_rect_ce, Z_OBJ_P(value), "x", 1, rect->x);
+ zend_update_property_long(php_sdl_rect_ce, Z_OBJ_P(value), "y", 1, rect->y);
+ zend_update_property_long(php_sdl_rect_ce, Z_OBJ_P(value), "w", 1, rect->w);
+ zend_update_property_long(php_sdl_rect_ce, Z_OBJ_P(value), "h", 1, rect->h);
+
+ return 1;
+ }
+ ZVAL_NULL(value);
+ return 0;
+}
+
+zend_bool sdl_frect_to_zval(SDL_FRect *rect, zval *value)
+{
+ if (rect)
+ {
+ object_init_ex(value, php_sdl_frect_ce);
+ zend_update_property_double(php_sdl_frect_ce, Z_OBJ_P(value), "x", 1, rect->x);
+ zend_update_property_double(php_sdl_frect_ce, Z_OBJ_P(value), "y", 1, rect->y);
+ zend_update_property_double(php_sdl_frect_ce, Z_OBJ_P(value), "w", 1, rect->w);
+ zend_update_property_double(php_sdl_frect_ce, Z_OBJ_P(value), "h", 1, rect->h);
return 1;
}
@@ -58,10 +100,25 @@ zend_bool sdl_rect_to_zval(SDL_Rect *rect, zval *value)
zend_bool sdl_point_to_zval(SDL_Point *pt, zval *value)
{
- if (pt) {
- object_init_ex(value, php_sdl_rect_ce);
- zend_update_property_long(php_sdl_rect_ce, value, "x", 1, pt->x);
- zend_update_property_long(php_sdl_rect_ce, value, "y", 1, pt->y);
+ if (pt)
+ {
+ object_init_ex(value, php_sdl_point_ce);
+ zend_update_property_long(php_sdl_point_ce, Z_OBJ_P(value), "x", 1, pt->x);
+ zend_update_property_long(php_sdl_point_ce, Z_OBJ_P(value), "y", 1, pt->y);
+
+ return 1;
+ }
+ ZVAL_NULL(value);
+ return 0;
+}
+
+zend_bool sdl_fpoint_to_zval(SDL_FPoint *pt, zval *value)
+{
+ if (pt)
+ {
+ object_init_ex(value, php_sdl_fpoint_ce);
+ zend_update_property_double(php_sdl_fpoint_ce, Z_OBJ_P(value), "x", 1, pt->x);
+ zend_update_property_double(php_sdl_fpoint_ce, Z_OBJ_P(value), "y", 1, pt->y);
return 1;
}
@@ -71,22 +128,23 @@ zend_bool sdl_point_to_zval(SDL_Point *pt, zval *value)
zend_bool zval_to_sdl_rect(zval *value, SDL_Rect *rect)
{
- if (Z_TYPE(*value) == IS_OBJECT && Z_OBJCE_P(value) == php_sdl_rect_ce) {
+ if (instanceof_function(Z_OBJCE_P(value), php_sdl_rect_ce))
+ {
zval *val, rv;
- val = zend_read_property(php_sdl_rect_ce, value, "x", 1, 0, &rv);
+ val = zend_read_property(php_sdl_rect_ce, Z_OBJ_P(value), "x", 1, 0, &rv);
convert_to_long(val);
Z_LVAL_P(val) = rect->x = (int)Z_LVAL_P(val);
- val = zend_read_property(php_sdl_rect_ce, value, "y", 1, 0, &rv);
+ val = zend_read_property(php_sdl_rect_ce, Z_OBJ_P(value), "y", 1, 0, &rv);
convert_to_long(val);
Z_LVAL_P(val) = rect->y = (int)Z_LVAL_P(val);
- val = zend_read_property(php_sdl_rect_ce, value, "w", 1, 0, &rv);
+ val = zend_read_property(php_sdl_rect_ce, Z_OBJ_P(value), "w", 1, 0, &rv);
convert_to_long(val);
Z_LVAL_P(val) = rect->w = (int)Z_LVAL_P(val);
- val = zend_read_property(php_sdl_rect_ce, value, "h", 1, 0, &rv);
+ val = zend_read_property(php_sdl_rect_ce, Z_OBJ_P(value), "h", 1, 0, &rv);
convert_to_long(val);
Z_LVAL_P(val) = rect->h = (int)Z_LVAL_P(val);
@@ -97,16 +155,46 @@ zend_bool zval_to_sdl_rect(zval *value, SDL_Rect *rect)
return 0;
}
+zend_bool zval_to_sdl_frect(zval *value, SDL_FRect *rect)
+{
+ if (instanceof_function(Z_OBJCE_P(value), php_sdl_frect_ce))
+ {
+ zval *val, rv;
+
+ val = zend_read_property(php_sdl_frect_ce, Z_OBJ_P(value), "x", 1, 0, &rv);
+ convert_to_double(val);
+ Z_DVAL_P(val) = rect->x = (float)Z_DVAL_P(val);
+
+ val = zend_read_property(php_sdl_frect_ce, Z_OBJ_P(value), "y", 1, 0, &rv);
+ convert_to_double(val);
+ Z_DVAL_P(val) = rect->y = (float)Z_DVAL_P(val);
+
+ val = zend_read_property(php_sdl_frect_ce, Z_OBJ_P(value), "w", 1, 0, &rv);
+ convert_to_double(val);
+ Z_DVAL_P(val) = rect->w = (float)Z_DVAL_P(val);
+
+ val = zend_read_property(php_sdl_frect_ce, Z_OBJ_P(value), "h", 1, 0, &rv);
+ convert_to_double(val);
+ Z_DVAL_P(val) = rect->h = (float)Z_DVAL_P(val);
+
+ return 1;
+ }
+ /* create an empty rect */
+ memset(rect, 0, sizeof(SDL_FRect));
+ return 0;
+}
+
zend_bool zval_to_sdl_point(zval *value, SDL_Point *pt)
{
- if (Z_TYPE(*value) == IS_OBJECT && Z_OBJCE_P(value) == php_sdl_point_ce) {
+ if (instanceof_function(Z_OBJCE_P(value), php_sdl_point_ce))
+ {
zval *val, rv;
- val = zend_read_property(php_sdl_rect_ce, value, "x", 1, 0, &rv);
+ val = zend_read_property(php_sdl_point_ce, Z_OBJ_P(value), "x", 1, 0, &rv);
convert_to_long(val);
Z_LVAL_P(val) = pt->x = (int)Z_LVAL_P(val);
- val = zend_read_property(php_sdl_rect_ce, value, "y", 1, 0, &rv);
+ val = zend_read_property(php_sdl_point_ce, Z_OBJ_P(value), "y", 1, 0, &rv);
convert_to_long(val);
Z_LVAL_P(val) = pt->y = (int)Z_LVAL_P(val);
@@ -117,33 +205,55 @@ zend_bool zval_to_sdl_point(zval *value, SDL_Point *pt)
return 0;
}
+zend_bool zval_to_sdl_fpoint(zval *value, SDL_FPoint *pt)
+{
+ if (instanceof_function(Z_OBJCE_P(value), php_sdl_fpoint_ce))
+ {
+ zval *val, rv;
+
+ val = zend_read_property(php_sdl_fpoint_ce, Z_OBJ_P(value), "x", 1, 0, &rv);
+ convert_to_double(val);
+ Z_DVAL_P(val) = pt->x = (float)Z_DVAL_P(val);
+
+ val = zend_read_property(php_sdl_fpoint_ce, Z_OBJ_P(value), "y", 1, 0, &rv);
+ convert_to_double(val);
+ Z_DVAL_P(val) = pt->y = (float)Z_DVAL_P(val);
+
+ return 1;
+ }
+ /* create an empty point */
+ memset(pt, 0, sizeof(SDL_FPoint));
+ return 0;
+}
+
/* {{{ proto SDL_Rect::__construct(, int x, int y, int w, int h)
* \brief A rectangle, with the origin at the upper left.
*/
-static PHP_METHOD(SDL_Rect, __construct)
+PHP_METHOD(SDL_Rect, __construct)
{
zend_long x = 0, y = 0, w = 0, h = 0;
- if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "|llll", &x, &y, &w, &h)) {
+ if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "|llll", &x, &y, &w, &h))
+ {
return;
}
- zend_update_property_long(php_sdl_rect_ce, getThis(), "x", 1, x);
- zend_update_property_long(php_sdl_rect_ce, getThis(), "y", 1, y);
- zend_update_property_long(php_sdl_rect_ce, getThis(), "w", 1, w);
- zend_update_property_long(php_sdl_rect_ce, getThis(), "h", 1, h);
+ zend_update_property_long(php_sdl_rect_ce, Z_OBJ_P(getThis()), "x", 1, x);
+ zend_update_property_long(php_sdl_rect_ce, Z_OBJ_P(getThis()), "y", 1, y);
+ zend_update_property_long(php_sdl_rect_ce, Z_OBJ_P(getThis()), "w", 1, w);
+ zend_update_property_long(php_sdl_rect_ce, Z_OBJ_P(getThis()), "h", 1, h);
}
/* }}} */
-
/* {{{ proto SDL_Rect::__toString() */
-static PHP_METHOD(SDL_Rect, __toString)
+PHP_METHOD(SDL_Rect, __toString)
{
zend_string *buf;
SDL_Rect rect;
- if (zend_parse_parameters_none() == FAILURE) {
+ if (zend_parse_parameters_none() == FAILURE)
+ {
return;
}
@@ -153,35 +263,68 @@ static PHP_METHOD(SDL_Rect, __toString)
}
/* }}} */
+PHP_METHOD(SDL_FRect, __construct)
+{
+ double x = 0, y = 0, w = 0, h = 0;
+
+ ZEND_PARSE_PARAMETERS_START(4, 4)
+ Z_PARAM_DOUBLE(x)
+ Z_PARAM_DOUBLE(y)
+ Z_PARAM_DOUBLE(w)
+ Z_PARAM_DOUBLE(h)
+ ZEND_PARSE_PARAMETERS_END();
+
+ zend_update_property_double(php_sdl_frect_ce, Z_OBJ_P(getThis()), "x", 1, x);
+ zend_update_property_double(php_sdl_frect_ce, Z_OBJ_P(getThis()), "y", 1, y);
+ zend_update_property_double(php_sdl_frect_ce, Z_OBJ_P(getThis()), "w", 1, w);
+ zend_update_property_double(php_sdl_frect_ce, Z_OBJ_P(getThis()), "h", 1, h);
+}
+
+PHP_METHOD(SDL_FRect, __toString)
+{
+ zend_string *buf;
+ SDL_FRect rect;
+
+ if (zend_parse_parameters_none() == FAILURE)
+ {
+ return;
+ }
+
+ zval_to_sdl_frect(getThis(), &rect);
+ buf = strpprintf(0, "SDL_FRect(%f,%f,%f,%f)", rect.x, rect.y, rect.w, rect.h);
+ RETVAL_STR(buf);
+}
+
/* {{{ proto SDL_Point::__construct(, int x, int y)
* \brief A rectangle, with the origin at the upper left.
*/
-static PHP_METHOD(SDL_Point, __construct)
+PHP_METHOD(SDL_Point, __construct)
{
zend_long x, y;
zend_error_handling error_handling;
zend_replace_error_handling(EH_THROW, NULL, &error_handling);
- if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "ll", &x, &y)) {
+ if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "ll", &x, &y))
+ {
zend_restore_error_handling(&error_handling);
return;
}
zend_restore_error_handling(&error_handling);
- zend_update_property_long(php_sdl_rect_ce, getThis(), "x", 1, x);
- zend_update_property_long(php_sdl_rect_ce, getThis(), "y", 1, y);
+ zend_update_property_long(php_sdl_point_ce, Z_OBJ_P(getThis()), "x", 1, x);
+ zend_update_property_long(php_sdl_point_ce, Z_OBJ_P(getThis()), "y", 1, y);
}
/* }}} */
-
/* {{{ proto SDL_Point::__toString() */
-static PHP_METHOD(SDL_Point, __toString)
+PHP_METHOD(SDL_Point, __toString)
{
zend_string *buf;
SDL_Point point;
- if (zend_parse_parameters_none() == FAILURE) {
+ if (zend_parse_parameters_none() == FAILURE)
+ {
return;
}
@@ -191,6 +334,33 @@ static PHP_METHOD(SDL_Point, __toString)
}
/* }}} */
+PHP_METHOD(SDL_FPoint, __construct)
+{
+ double x = 0, y = 0;
+
+ ZEND_PARSE_PARAMETERS_START(2, 2)
+ Z_PARAM_DOUBLE(x)
+ Z_PARAM_DOUBLE(y)
+ ZEND_PARSE_PARAMETERS_END();
+
+ zend_update_property_double(php_sdl_fpoint_ce, Z_OBJ_P(getThis()), "x", 1, x);
+ zend_update_property_double(php_sdl_fpoint_ce, Z_OBJ_P(getThis()), "y", 1, y);
+}
+
+PHP_METHOD(SDL_FPoint, __toString)
+{
+ zend_string *buf;
+ SDL_FPoint point;
+
+ if (zend_parse_parameters_none() == FAILURE)
+ {
+ return;
+ }
+
+ zval_to_sdl_fpoint(getThis(), &point);
+ buf = strpprintf(0, "SDL_FPoint(%f,%f)", point.x, point.y);
+ RETVAL_STR(buf);
+}
/* {{{ proto bool SDL_RectEmpty(SDL_Rect rect)
@@ -202,15 +372,29 @@ PHP_FUNCTION(SDL_RectEmpty)
zval *object;
SDL_Rect rect;
- if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_rect_ce) == FAILURE) {
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_rect_ce) == FAILURE)
+ {
return;
}
zval_to_sdl_rect(object, &rect);
-
+
RETURN_BOOL(SDL_RectEmpty(&rect));
}
/* }}} */
+PHP_FUNCTION(SDL_FRectEmpty)
+{
+ zval *object;
+ SDL_FRect rect;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_frect_ce) == FAILURE)
+ {
+ return;
+ }
+ zval_to_sdl_frect(object, &rect);
+
+ RETURN_BOOL((rect.w <= 0.0f) || (rect.h <= 0.0f));
+}
/* {{{ proto bool SDL_RectEquals(SDL_Rect a, SDL_Rect b)
@@ -222,61 +406,118 @@ PHP_FUNCTION(SDL_RectEquals)
zval *obj1, *obj2;
SDL_Rect rect1, rect2;
- if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OO", &obj1, php_sdl_rect_ce, &obj2, php_sdl_rect_ce) == FAILURE) {
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OO", &obj1, php_sdl_rect_ce, &obj2, php_sdl_rect_ce) == FAILURE)
+ {
return;
}
zval_to_sdl_rect(obj1, &rect1);
zval_to_sdl_rect(obj2, &rect2);
-
+
RETURN_BOOL(SDL_RectEquals(&rect1, &rect2));
}
/* }}} */
-
/* {{{ proto bool SDL_HasIntersection(SDL_Rect a, SDL_Rect b)
* \brief Determine whether two rectangles intersect.
*
* \return SDL_TRUE if there is an intersection, SDL_FALSE otherwise.
extern DECLSPEC SDL_bool SDLCALL SDL_HasIntersection(const SDL_Rect * A,
- const SDL_Rect * B);
+ const SDL_Rect * B);
*/
PHP_FUNCTION(SDL_HasIntersection)
{
zval *obj1, *obj2;
SDL_Rect rect1, rect2;
- if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OO", &obj1, php_sdl_rect_ce, &obj2, php_sdl_rect_ce) == FAILURE) {
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OO", &obj1, php_sdl_rect_ce, &obj2, php_sdl_rect_ce) == FAILURE)
+ {
return;
}
zval_to_sdl_rect(obj1, &rect1);
zval_to_sdl_rect(obj2, &rect2);
-
+
RETURN_BOOL(SDL_HasIntersection(&rect1, &rect2));
}
/* }}} */
+PHP_FUNCTION(SDL_HasIntersectionF)
+{
+ zval *obj1, *obj2;
+ SDL_FRect A, B;
+ float Amin, Amax, Bmin, Bmax;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OO", &obj1, php_sdl_frect_ce, &obj2, php_sdl_frect_ce) == FAILURE)
+ {
+ return;
+ }
+ zval_to_sdl_frect(obj1, &A);
+ zval_to_sdl_frect(obj2, &B);
+
+ /** SDL_HasIntersectionF not yet available as public API (SDL <= 2.0.20) */
+ /* Horizontal intersection */
+ Amin = A.x;
+ Amax = Amin + A.w;
+ Bmin = B.x;
+ Bmax = Bmin + B.w;
+ if (Bmin > Amin)
+ {
+ Amin = Bmin;
+ }
+ if (Bmax < Amax)
+ {
+ Amax = Bmax;
+ }
+ if (Amax <= Amin)
+ {
+ RETURN_FALSE;
+ }
+
+ /* Vertical intersection */
+ Amin = A.y;
+ Amax = Amin + A.h;
+ Bmin = B.y;
+ Bmax = Bmin + B.h;
+ if (Bmin > Amin)
+ {
+ Amin = Bmin;
+ }
+ if (Bmax < Amax)
+ {
+ Amax = Bmax;
+ }
+ if (Amax <= Amin)
+ {
+ RETURN_FALSE;
+ }
+
+ RETURN_TRUE;
+ // RETURN_BOOL(SDL_HasIntersectionF(&rect1, &rect2));
+}
+
/* {{{ proto bool SDL_IntersectRect(SDL_Rect a, SDL_Rect b, SDL_Rect &result)
* \brief Calculate the intersection of two rectangles.
*
* \return SDL_TRUE if there is an intersection, SDL_FALSE otherwise.
extern DECLSPEC SDL_bool SDLCALL SDL_IntersectRect(const SDL_Rect * A,
- const SDL_Rect * B,
- SDL_Rect * result);
+ const SDL_Rect * B,
+ SDL_Rect * result);
*/
PHP_FUNCTION(SDL_IntersectRect)
{
zval *obj1, *obj2, *result;
SDL_Rect rect1, rect2, rect3;
- if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OOz", &obj1, php_sdl_rect_ce, &obj2, php_sdl_rect_ce, &result) == FAILURE) {
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OOz/", &obj1, php_sdl_rect_ce, &obj2, php_sdl_rect_ce, &result) == FAILURE)
+ {
return;
}
zval_to_sdl_rect(obj1, &rect1);
zval_to_sdl_rect(obj2, &rect2);
- if (SDL_IntersectRect(&rect1, &rect2, &rect3)) {
- zval_dtor(result);
+ if (SDL_IntersectRect(&rect1, &rect2, &rect3))
+ {
+ zval_ptr_dtor(result);
sdl_rect_to_zval(&rect3, result);
RETURN_TRUE;
}
@@ -284,40 +525,100 @@ PHP_FUNCTION(SDL_IntersectRect)
}
/* }}} */
+PHP_FUNCTION(SDL_IntersectFRect)
+{
+ zval *obj1, *obj2, *result;
+ SDL_FRect A, B, resultRect;
+ float Amin, Amax, Bmin, Bmax;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OOz/", &obj1, php_sdl_frect_ce, &obj2, php_sdl_frect_ce, &result) == FAILURE)
+ {
+ return;
+ }
+ zval_to_sdl_frect(obj1, &A);
+ zval_to_sdl_frect(obj2, &B);
+
+ /** SDL_IntersectFRect does not exists (SDL <= 2.0.20) */
+ /* Special cases for empty rects */
+ if ((A.w <= 0.0f) || (A.h <= 0.0f) || (B.w <= 0.0f) || (B.h <= 0.0f))
+ {
+ resultRect.w = 0;
+ resultRect.h = 0;
+
+ zval_ptr_dtor(result);
+ sdl_frect_to_zval(&resultRect, result);
+
+ RETURN_FALSE;
+ }
+
+ /* Horizontal intersection */
+ Amin = A.x;
+ Amax = Amin + A.w;
+ Bmin = B.x;
+ Bmax = Bmin + B.w;
+ if (Bmin > Amin)
+ Amin = Bmin;
+ resultRect.x = Amin;
+ if (Bmax < Amax)
+ Amax = Bmax;
+ resultRect.w = Amax - Amin;
+
+ /* Vertical intersection */
+ Amin = A.y;
+ Amax = Amin + A.h;
+ Bmin = B.y;
+ Bmax = Bmin + B.h;
+ if (Bmin > Amin)
+ Amin = Bmin;
+ resultRect.y = Amin;
+ if (Bmax < Amax)
+ Amax = Bmax;
+ resultRect.h = Amax - Amin;
+
+ if (!((resultRect.w <= 0.0f) || (resultRect.h <= 0.0f)))
+ { // !SDL_FRectEmpty
+ zval_ptr_dtor(result);
+ sdl_frect_to_zval(&resultRect, result);
+
+ RETURN_TRUE;
+ }
+
+ RETURN_FALSE;
+}
+
/* {{{ proto bool SDL_UnionRect(SDL_Rect a, SDL_Rect b, SDL_Rect &result)
* \brief Calculate the union of two rectangles.
extern DECLSPEC void SDLCALL SDL_UnionRect(const SDL_Rect * A,
- const SDL_Rect * B,
- SDL_Rect * result);
+ const SDL_Rect * B,
+ SDL_Rect * result);
*/
PHP_FUNCTION(SDL_UnionRect)
{
zval *obj1, *obj2, *result;
SDL_Rect rect1, rect2, rect3;
- if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OOz", &obj1, php_sdl_rect_ce, &obj2, php_sdl_rect_ce, &result) == FAILURE) {
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OOz/", &obj1, php_sdl_rect_ce, &obj2, php_sdl_rect_ce, &result) == FAILURE)
+ {
return;
}
zval_to_sdl_rect(obj1, &rect1);
zval_to_sdl_rect(obj2, &rect2);
SDL_UnionRect(&rect1, &rect2, &rect3);
- zval_dtor(result);
+ zval_ptr_dtor(result);
sdl_rect_to_zval(&rect3, result);
}
/* }}} */
-
-
/* {{{ proto bool SDL_EnclosePoints(array points, int count, SDL_Rect clip, SDL_Rect &result)
* \brief Calculate a minimal rectangle enclosing a set of points
*
* \return SDL_TRUE if any points were within the clipping rect
extern DECLSPEC SDL_bool SDLCALL SDL_EnclosePoints(const SDL_Point * points,
- int count,
- const SDL_Rect * clip,
- SDL_Rect * result);
+ int count,
+ const SDL_Rect * clip,
+ SDL_Rect * result);
*/
PHP_FUNCTION(SDL_EnclosePoints)
{
@@ -328,35 +629,43 @@ PHP_FUNCTION(SDL_EnclosePoints)
SDL_Rect clip, result;
SDL_Point *points;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "alOz", &z_points, &count, &z_clip, php_sdl_rect_ce, &z_result) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "alOz/", &z_points, &count, &z_clip, php_sdl_rect_ce, &z_result) == FAILURE)
+ {
return;
}
RETVAL_FALSE;
- if (count<=0) {
+ if (count <= 0)
+ {
count = zend_hash_next_free_element(Z_ARRVAL_P(z_points));
}
- points = emalloc(sizeof(SDL_Point)*count);
+ points = emalloc(sizeof(SDL_Point) * count);
zval_to_sdl_rect(z_clip, &clip);
- for (i=0, nb=0 ; ipixels, pitch));
+ }
+}
+
PHP_FUNCTION(SDL_SetRenderTarget)
{
zval *z_renderer, *z_texture;
@@ -223,9 +261,20 @@ PHP_FUNCTION(SDL_SetRenderTarget)
}
renderer = (SDL_Renderer*)zend_fetch_resource(Z_RES_P(z_renderer), SDL_RENDERER_RES_NAME, le_sdl_renderer);
- texture = (SDL_Texture*)zend_fetch_resource(Z_RES_P(z_texture), SDL_TEXTURE_RES_NAME, le_sdl_texture);
+ // texture = (SDL_Texture*)zend_fetch_resource(Z_RES_P(z_texture), SDL_TEXTURE_RES_NAME, le_sdl_texture);
+ if (Z_TYPE_P(z_texture) == IS_NULL) {
+ // SDL accepte NULL pour reset la target vers le default render target
+ texture = NULL;
+ } else {
+ texture = (SDL_Texture*)zend_fetch_resource(Z_RES_P(z_texture), SDL_TEXTURE_RES_NAME, le_sdl_texture);
+ if (!texture) {
+ php_error_docref(NULL, E_WARNING, "Invalid SDL_Texture resource");
+ RETURN_FALSE;
+ }
+ }
- if( renderer && texture ) {
+ if (renderer)
+ {
RETURN_LONG(SDL_SetRenderTarget(renderer, texture));
}
}
@@ -249,6 +298,24 @@ PHP_FUNCTION(SDL_CreateRenderer)
RETURN_RES(zend_register_resource(renderer, le_sdl_renderer));
}
+PHP_FUNCTION(SDL_CreateSoftwareRenderer)
+{
+ zval *z_surface;
+ SDL_Surface *surface = NULL;
+ SDL_Renderer *renderer = NULL;
+
+ if( zend_parse_parameters(ZEND_NUM_ARGS(), "O", &z_surface, get_php_sdl_surface_ce()) == FAILURE ) {
+ WRONG_PARAM_COUNT;
+ }
+
+ if( z_surface != NULL ) {
+ surface = zval_to_sdl_surface(z_surface);
+ }
+
+ renderer = SDL_CreateSoftwareRenderer(surface);
+ RETURN_RES(zend_register_resource(renderer, le_sdl_renderer));
+}
+
PHP_FUNCTION(SDL_RenderCopy)
{
zval *z_renderer, *z_texture;
@@ -258,9 +325,12 @@ PHP_FUNCTION(SDL_RenderCopy)
SDL_Rect *srcrect = NULL, *dstrect = NULL;
SDL_Rect def_srcrect, def_dstrect;
- if( zend_parse_parameters(ZEND_NUM_ARGS(), "zzO!O!", &z_renderer, &z_texture, &z_srcrect, get_php_sdl_rect_ce(), &z_dstrect, get_php_sdl_rect_ce()) == FAILURE ) {
- WRONG_PARAM_COUNT;
- }
+ ZEND_PARSE_PARAMETERS_START(4, 4)
+ Z_PARAM_ZVAL(z_renderer)
+ Z_PARAM_ZVAL(z_texture)
+ Z_PARAM_OBJECT_OF_CLASS_OR_NULL(z_srcrect, get_php_sdl_rect_ce())
+ Z_PARAM_OBJECT_OF_CLASS_OR_NULL(z_dstrect, get_php_sdl_rect_ce())
+ ZEND_PARSE_PARAMETERS_END();
renderer = (SDL_Renderer*)zend_fetch_resource(Z_RES_P(z_renderer), SDL_RENDERER_RES_NAME, le_sdl_renderer);
texture = (SDL_Texture*)zend_fetch_resource(Z_RES_P(z_texture), SDL_TEXTURE_RES_NAME, le_sdl_texture);
@@ -314,6 +384,21 @@ PHP_FUNCTION(SDL_RenderCopyEx)
RETURN_LONG(SDL_RenderCopyEx(renderer, texture, srcrect, dstrect, angle, center, (Uint32)flip));
}
+PHP_FUNCTION(SDL_RenderSetLogicalSize)
+{
+ zval *z_renderer;
+ zend_long w, h;
+ SDL_Renderer *renderer;
+
+ if( zend_parse_parameters(ZEND_NUM_ARGS(), "zll", &z_renderer, &w, &h) == FAILURE ) {
+ WRONG_PARAM_COUNT;
+ }
+
+ renderer = (SDL_Renderer*)zend_fetch_resource(Z_RES_P(z_renderer), SDL_RENDERER_RES_NAME, le_sdl_renderer);
+
+ RETURN_LONG(SDL_RenderSetLogicalSize(renderer, w, h));
+}
+
PHP_FUNCTION(SDL_GetRendererOutputSize)
{
zval *z_renderer, *z_width=NULL, *z_height=NULL;
@@ -334,6 +419,190 @@ PHP_FUNCTION(SDL_GetRendererOutputSize)
ZVAL_LONG(z_height, h);
}
+PHP_FUNCTION(SDL_QueryTexture)
+{
+ zval *z_texture, *z_format = NULL, *z_access = NULL, *z_width = NULL, *z_height = NULL;
+ SDL_Texture *texture;
+ int w, h, access, result;
+ Uint32 format;
+
+ if( zend_parse_parameters(ZEND_NUM_ARGS(), "z|zzzz", &z_texture, &z_format, &z_access, &z_width, &z_height) == FAILURE ) {
+ return;
+ }
+
+ texture = (SDL_Texture*)zend_fetch_resource(Z_RES_P(z_texture), SDL_TEXTURE_RES_NAME, le_sdl_texture);
+
+ result = SDL_QueryTexture(texture, &format, &access, &w, &h);
+
+ if(z_format)
+ ZEND_TRY_ASSIGN_REF_LONG(z_format, format);
+ if(z_access)
+ ZEND_TRY_ASSIGN_REF_LONG(z_access, access);
+ if(z_width)
+ ZEND_TRY_ASSIGN_REF_LONG(z_width, w);
+ if(z_height)
+ ZEND_TRY_ASSIGN_REF_LONG(z_height, h);
+
+ RETURN_LONG(result);
+}
+
+PHP_FUNCTION(SDL_RenderDrawPointF)
+{
+ zval *RENDERER;
+ SDL_Renderer *renderer;
+ double x, y;
+
+ ZEND_PARSE_PARAMETERS_START(3, 3);
+ Z_PARAM_ZVAL(RENDERER)
+ Z_PARAM_DOUBLE(x)
+ Z_PARAM_DOUBLE(y)
+ ZEND_PARSE_PARAMETERS_END();
+ renderer = (SDL_Renderer*)zend_fetch_resource(Z_RES_P(RENDERER), SDL_RENDERER_RES_NAME, le_sdl_renderer);
+
+ int result = SDL_RenderDrawPointF(renderer, (float) x, (float) y);
+
+ RETURN_LONG(result);
+}
+
+PHP_FUNCTION(SDL_RenderDrawLineF)
+{
+ zval *RENDERER;
+ SDL_Renderer *renderer;
+ double x1, y1, x2, y2;
+
+ ZEND_PARSE_PARAMETERS_START(5, 5);
+ Z_PARAM_ZVAL(RENDERER)
+ Z_PARAM_DOUBLE(x1)
+ Z_PARAM_DOUBLE(y1)
+ Z_PARAM_DOUBLE(x2)
+ Z_PARAM_DOUBLE(y2)
+ ZEND_PARSE_PARAMETERS_END();
+
+ renderer = (SDL_Renderer*)zend_fetch_resource(Z_RES_P(RENDERER), SDL_RENDERER_RES_NAME, le_sdl_renderer);
+
+ int result = SDL_RenderDrawLineF(renderer, (float) x1, (float) y1, (float) x2, (float) y2);
+
+ RETURN_LONG(result);
+}
+
+PHP_FUNCTION(SDL_RenderDrawRectF)
+{
+ zval *RENDERER;
+ SDL_Renderer *renderer;
+ zval *RECT;
+ SDL_FRect rect;
+
+ ZEND_PARSE_PARAMETERS_START(2, 2);
+ Z_PARAM_ZVAL(RENDERER)
+ Z_PARAM_OBJECT_OF_CLASS(RECT, get_php_sdl_frect_ce())
+ ZEND_PARSE_PARAMETERS_END();
+
+ renderer = (SDL_Renderer*)zend_fetch_resource(Z_RES_P(RENDERER), SDL_RENDERER_RES_NAME, le_sdl_renderer);
+ zval_to_sdl_frect(RECT, &rect);
+ int result = SDL_RenderDrawRectF(renderer, (const SDL_FRect*) &rect);
+
+ RETURN_LONG(result);
+}
+
+PHP_FUNCTION(SDL_RenderFillRectF)
+{
+ zval *RENDERER, *RECT;
+ SDL_Renderer *renderer;
+ SDL_FRect rect;
+
+ ZEND_PARSE_PARAMETERS_START(2, 2);
+ Z_PARAM_ZVAL(RENDERER)
+ Z_PARAM_OBJECT_OF_CLASS(RECT, get_php_sdl_frect_ce())
+ ZEND_PARSE_PARAMETERS_END();
+ renderer = (SDL_Renderer*)zend_fetch_resource(Z_RES_P(RENDERER), SDL_RENDERER_RES_NAME, le_sdl_renderer);
+ zval_to_sdl_frect(RECT, &rect);
+ int result = SDL_RenderFillRectF(renderer, (const SDL_FRect*) &rect);
+
+ RETURN_LONG(result);
+}
+
+PHP_FUNCTION(SDL_RenderCopyF)
+{
+ zval *RENDERER, *TEXTURE, *SRCRECT, *DSTRECT;
+ SDL_Renderer *renderer;
+ SDL_Texture *texture;
+ SDL_Rect *srcrect = NULL;
+ SDL_Rect def_srcrect;
+ SDL_FRect *dstrect = NULL;
+ SDL_FRect def_dstrect;
+
+ ZEND_PARSE_PARAMETERS_START(4, 4);
+ Z_PARAM_ZVAL(RENDERER)
+ Z_PARAM_ZVAL(TEXTURE)
+ Z_PARAM_OBJECT_OF_CLASS_OR_NULL(SRCRECT, get_php_sdl_rect_ce())
+ Z_PARAM_OBJECT_OF_CLASS_OR_NULL(DSTRECT, get_php_sdl_frect_ce())
+ ZEND_PARSE_PARAMETERS_END();
+
+ renderer = (SDL_Renderer*)zend_fetch_resource(Z_RES_P(RENDERER), SDL_RENDERER_RES_NAME, le_sdl_renderer);
+ texture = (SDL_Texture*)zend_fetch_resource(Z_RES_P(TEXTURE), SDL_TEXTURE_RES_NAME, le_sdl_texture);
+
+ if(SRCRECT != NULL && Z_TYPE_P(SRCRECT) != IS_NULL) {
+ srcrect = &def_srcrect;
+ zval_to_sdl_rect(SRCRECT, srcrect);
+ }
+ if(DSTRECT != NULL && Z_TYPE_P(DSTRECT) != IS_NULL) {
+ dstrect = &def_dstrect;
+ zval_to_sdl_frect(DSTRECT, dstrect);
+ }
+
+ int result = SDL_RenderCopyF(renderer, texture, (const SDL_Rect*) srcrect, (const SDL_FRect*) dstrect);
+
+ RETURN_LONG(result);
+}
+
+PHP_FUNCTION(SDL_RenderCopyExF)
+{
+ zval *RENDERER, *TEXTURE, *SRCRECT, *DSTRECT, *CENTER;
+ SDL_Renderer *renderer;
+ SDL_Texture *texture;
+ SDL_Rect *srcrect = NULL;
+ SDL_Rect def_srcrect;
+ SDL_FRect *dstrect = NULL;;
+ SDL_FRect def_dstrect;
+ SDL_FPoint *center = NULL;;
+ SDL_FPoint def_center;
+ // @todo SDL_RendererFlip
+ zend_long flip;
+ double angle;
+
+ ZEND_PARSE_PARAMETERS_START(7, 7);
+ //Z_PARAM_OBJECT_OF_CLASS(RENDERER, sdl_renderer_ce)
+ Z_PARAM_ZVAL(RENDERER)
+ // Z_PARAM_OBJECT_OF_CLASS(TEXTURE, sdl_texture_ce)
+ Z_PARAM_ZVAL(TEXTURE)
+ Z_PARAM_OBJECT_OF_CLASS_OR_NULL(SRCRECT, get_php_sdl_rect_ce())
+ Z_PARAM_OBJECT_OF_CLASS_OR_NULL(DSTRECT, get_php_sdl_frect_ce())
+ Z_PARAM_DOUBLE(angle)
+ Z_PARAM_OBJECT_OF_CLASS_OR_NULL(CENTER, get_php_sdl_fpoint_ce())
+ Z_PARAM_LONG(flip)
+ ZEND_PARSE_PARAMETERS_END();
+ //renderer = php_sdl_renderer_from_zval_p(RENDERER);
+ renderer = (SDL_Renderer*)zend_fetch_resource(Z_RES_P(RENDERER), SDL_RENDERER_RES_NAME, le_sdl_renderer);
+ texture = (SDL_Texture*)zend_fetch_resource(Z_RES_P(TEXTURE), SDL_TEXTURE_RES_NAME, le_sdl_texture);
+
+ if (SRCRECT != NULL && Z_TYPE_P(SRCRECT) != IS_NULL) {
+ srcrect = &def_srcrect;
+ zval_to_sdl_rect(SRCRECT, srcrect);
+ }
+ if (DSTRECT != NULL && Z_TYPE_P(DSTRECT) != IS_NULL) {
+ dstrect = &def_dstrect;
+ zval_to_sdl_frect(DSTRECT, dstrect);
+ }
+ if (CENTER != NULL && Z_TYPE_P(CENTER) != IS_NULL) {
+ center = &def_center;
+ zval_to_sdl_fpoint(CENTER, center);
+ }
+
+ int result = SDL_RenderCopyExF(renderer, texture, (const SDL_Rect*)srcrect, (const SDL_FRect*)dstrect, angle, (const SDL_FPoint*)center, flip);
+
+ RETURN_LONG(result);
+}
+
/* {{{ MINIT */
PHP_MINIT_FUNCTION(sdl_render)
{
diff --git a/src/render.h b/src/render.h
index 85bf2c3..a67673f 100644
--- a/src/render.h
+++ b/src/render.h
@@ -1,8 +1,6 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) 1997-2022 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -27,7 +25,6 @@ extern "C" {
#include "php_sdl.h"
ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_SetRenderDrawColor, 0, 0, 5)
- //ZEND_ARG_OBJ_INFO(0, renderer, SDL_Renderer, 0)
ZEND_ARG_INFO(0, renderer)
ZEND_ARG_INFO(0, r)
ZEND_ARG_INFO(0, g)
@@ -36,12 +33,10 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_SetRenderDrawColor, 0, 0, 5)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_RenderClear, 0, 0, 1)
- //ZEND_ARG_OBJ_INFO(0, renderer, SDL_Renderer, 0)
ZEND_ARG_INFO(0, renderer)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_DestroyRenderer, 0, 0, 1)
- //ZEND_ARG_OBJ_INFO(0, renderer, SDL_Renderer, 0)
ZEND_ARG_INFO(0, renderer)
ZEND_END_ARG_INFO()
@@ -50,10 +45,8 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_DestroyTexture, 0, 0, 1)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_RenderFillRect, 0, 0, 2)
- //ZEND_ARG_OBJ_INFO(0, renderer, SDL_Renderer, 0)
ZEND_ARG_INFO(0, renderer)
ZEND_ARG_OBJ_INFO(0, rect, SDL_Rect, 0)
- //ZEND_ARG_INFO(0, rect)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_RenderDrawRect, 0, 0, 2)
@@ -70,7 +63,6 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_RenderDrawLine, 0, 0, 4)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_RenderPresent, 0, 0, 1)
- //ZEND_ARG_OBJ_INFO(0, renderer, SDL_Renderer, 0)
ZEND_ARG_INFO(0, renderer)
ZEND_END_ARG_INFO()
@@ -81,7 +73,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_RenderDrawPoint, 0, 0, 3)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_CreateTextureFromSurface, 0, 0, 2)
- ZEND_ARG_INFO(0, renderer)//ZEND_ARG_OBJ_INFO(0, renderer, SDL_Renderer, 0)
+ ZEND_ARG_INFO(0, renderer)
ZEND_ARG_OBJ_INFO(0, surface, SDL_Surface, 0)
ZEND_END_ARG_INFO()
@@ -93,6 +85,21 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_CreateTexture, 0, 0, 5)
ZEND_ARG_INFO(0, h)
ZEND_END_ARG_INFO()
+ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_UpdateTexture, 0, 0, 4)
+ ZEND_ARG_OBJ_INFO(0, texture, SDL_Texture, 0)
+ ZEND_ARG_OBJ_INFO(0, rect, SDL_Rect, 1)
+ ZEND_ARG_OBJ_INFO(0, pixels, SDL_Pixels, 0)
+ ZEND_ARG_TYPE_INFO(0, pitch, IS_LONG, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_QueryTexture, 0, 0, 1)
+ ZEND_ARG_OBJ_INFO(0, texture, SDL_Texture, 0)
+ ZEND_ARG_TYPE_INFO(1, format, IS_LONG, 1)
+ ZEND_ARG_TYPE_INFO(1, access, IS_LONG, 1)
+ ZEND_ARG_TYPE_INFO(1, w, IS_LONG, 1)
+ ZEND_ARG_TYPE_INFO(1, h, IS_LONG, 1)
+ZEND_END_ARG_INFO()
+
ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_SetRenderTarget, 0, 0, 2)
ZEND_ARG_INFO(0, renderer)
ZEND_ARG_INFO(0, texture)
@@ -104,6 +111,10 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_CreateRenderer, 0, 0, 3)
ZEND_ARG_INFO(0, flags)
ZEND_END_ARG_INFO()
+ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_CreateSoftwareRenderer, 0, 0, 1)
+ ZEND_ARG_OBJ_INFO(0, surface, SDL_Surface, 0)
+ZEND_END_ARG_INFO()
+
ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_RenderCopy, 0, 0, 4)
ZEND_ARG_INFO(0, renderer)
ZEND_ARG_INFO(0, texture)
@@ -121,12 +132,56 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_RenderCopyEx, 0, 0, 7)
ZEND_ARG_INFO(0, flip)
ZEND_END_ARG_INFO()
+ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_RenderSetLogicalSize, 0, 0, 3)
+ ZEND_ARG_OBJ_INFO(0, renderer, SDL_Renderer, 0)
+ ZEND_ARG_TYPE_INFO(0, w, IS_LONG, 0)
+ ZEND_ARG_TYPE_INFO(0, h, IS_LONG, 0)
+ZEND_END_ARG_INFO()
+
ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_GetRendererOutputSize, 0, 0, 3)
ZEND_ARG_INFO(0, renderer)
ZEND_ARG_INFO(1, w)
ZEND_ARG_INFO(1, h)
ZEND_END_ARG_INFO()
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_SDL_RenderDrawPointF, 0, 3, IS_LONG, 0)
+ ZEND_ARG_INFO(0, renderer)
+ ZEND_ARG_TYPE_INFO(0, x, IS_DOUBLE, 0)
+ ZEND_ARG_TYPE_INFO(0, y, IS_DOUBLE, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_SDL_RenderDrawLineF, 0, 5, IS_LONG, 0)
+ ZEND_ARG_INFO(0, renderer)
+ ZEND_ARG_TYPE_INFO(0, x1, IS_DOUBLE, 0)
+ ZEND_ARG_TYPE_INFO(0, y1, IS_DOUBLE, 0)
+ ZEND_ARG_TYPE_INFO(0, x2, IS_DOUBLE, 0)
+ ZEND_ARG_TYPE_INFO(0, y2, IS_DOUBLE, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_SDL_RenderDrawRectF, 0, 2, IS_LONG, 0)
+ ZEND_ARG_INFO(0, renderer)
+ ZEND_ARG_OBJ_INFO(0, rect, SDL_FRect, 0)
+ZEND_END_ARG_INFO()
+
+#define arginfo_SDL_RenderFillRectF arginfo_SDL_RenderDrawRectF
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_SDL_RenderCopyF, 0, 4, IS_LONG, 0)
+ ZEND_ARG_INFO(0, renderer)
+ ZEND_ARG_OBJ_INFO(0, texture, SDL_Texture, 0)
+ ZEND_ARG_OBJ_INFO(0, srcrect, SDL_Rect, 1)
+ ZEND_ARG_OBJ_INFO(0, dstrect, SDL_FRect, 1)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_SDL_RenderCopyExF, 0, 7, IS_LONG, 0)
+ ZEND_ARG_INFO(0, renderer)
+ ZEND_ARG_OBJ_INFO(0, texture, SDL_Texture, 0)
+ ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, srcrect, SDL_Rect, 1, "null")
+ ZEND_ARG_OBJ_INFO(0, dstrect, SDL_FRect, 1)
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, angle, IS_DOUBLE, 0, "0.0")
+ ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, center, SDL_FPoint, 1, "null")
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, flip, IS_LONG, 0, "SDL_FLIP_NONE")
+ZEND_END_ARG_INFO()
+
PHP_FUNCTION(SDL_SetRenderDrawColor);
PHP_FUNCTION(SDL_RenderClear);
PHP_FUNCTION(SDL_DestroyRenderer);
@@ -138,11 +193,21 @@ PHP_FUNCTION(SDL_RenderPresent);
PHP_FUNCTION(SDL_RenderDrawPoint);
PHP_FUNCTION(SDL_CreateTextureFromSurface);
PHP_FUNCTION(SDL_CreateTexture);
+PHP_FUNCTION(SDL_UpdateTexture);
+PHP_FUNCTION(SDL_QueryTexture);
PHP_FUNCTION(SDL_SetRenderTarget);
PHP_FUNCTION(SDL_CreateRenderer);
+PHP_FUNCTION(SDL_CreateSoftwareRenderer);
PHP_FUNCTION(SDL_RenderCopy);
PHP_FUNCTION(SDL_RenderCopyEx);
+PHP_FUNCTION(SDL_RenderSetLogicalSize);
PHP_FUNCTION(SDL_GetRendererOutputSize);
+ZEND_FUNCTION(SDL_RenderDrawPointF);
+ZEND_FUNCTION(SDL_RenderDrawLineF);
+ZEND_FUNCTION(SDL_RenderDrawRectF);
+ZEND_FUNCTION(SDL_RenderFillRectF);
+ZEND_FUNCTION(SDL_RenderCopyF);
+ZEND_FUNCTION(SDL_RenderCopyExF);
PHP_MINIT_FUNCTION(sdl_render);
diff --git a/src/rwops.c b/src/rwops.c
index 290830d..1a1a3a0 100644
--- a/src/rwops.c
+++ b/src/rwops.c
@@ -1,13 +1,11 @@
/*
- +----------------------------------------------------------------------+
- | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2018 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_01.txt |
+ | https://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
@@ -139,11 +137,14 @@ static PHP_METHOD(SDL_RWops, __construct)
if (intern->rwops) {
intern->flags = 0;
} else {
- zend_throw_exception(zend_exception_get_default(), SDL_GetError(), 0);
+ zend_throw_exception(zend_ce_exception, SDL_GetError(), 0);
}
}
/* }}} */
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_SDL_RWops___toString, 0, 0, IS_STRING, 0)
+ZEND_END_ARG_INFO()
+
/* {{{ proto SDL_RWops::__toString() */
static PHP_METHOD(SDL_RWops, __toString)
{
@@ -814,7 +815,7 @@ ZEND_END_ARG_INFO()
/* {{{ sdl_rwops_methods[] */
static const zend_function_entry php_sdl_rwops_methods[] = {
PHP_ME(SDL_RWops, __construct, arginfo_rwops_none, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC)
- PHP_ME(SDL_RWops, __toString, arginfo_rwops_none, ZEND_ACC_PUBLIC)
+ PHP_ME(SDL_RWops, __toString, arginfo_class_SDL_RWops___toString, ZEND_ACC_PUBLIC)
/* non-static methods */
PHP_FALIAS(Free, SDL_FreeRW, arginfo_rwops_none)
diff --git a/src/rwops.h b/src/rwops.h
index 3bde6ec..f1aec7a 100644
--- a/src/rwops.h
+++ b/src/rwops.h
@@ -1,6 +1,4 @@
/*
- +----------------------------------------------------------------------+
- | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2018 The PHP Group |
+----------------------------------------------------------------------+
diff --git a/src/sdl.c b/src/sdl.c
index 2f4eabf..cde630a 100644
--- a/src/sdl.c
+++ b/src/sdl.c
@@ -1,13 +1,11 @@
/*
- +----------------------------------------------------------------------+
- | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2018 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_01.txt |
+ | https://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
@@ -114,6 +112,25 @@ PHP_FUNCTION(SDL_WasInit) {
}
/* }}} */
+/* {{{ proto int SDL_SetHint(string hint, string value)
+
+extern DECLSPEC Uint32 SDLCALL SDL_SetHint(char *hint, char *value);
+*/
+PHP_FUNCTION(SDL_SetHint) {
+ char *hint;
+ size_t hint_len;
+ char *value;
+ size_t value_len;
+
+ ZEND_PARSE_PARAMETERS_START(2, 2)
+ Z_PARAM_STRING(hint, hint_len)
+ Z_PARAM_STRING(value, value_len)
+ ZEND_PARSE_PARAMETERS_END();
+
+ RETURN_LONG(SDL_SetHint(hint, value) == SDL_TRUE);
+}
+/* }}} */
+
/* {{{ PHP_MINIT_FUNCTION */
PHP_MINIT_FUNCTION(sdl_sdl)
{
@@ -131,6 +148,8 @@ PHP_MINIT_FUNCTION(sdl_sdl)
REGISTER_LONG_CONSTANT("SDL_INIT_NOPARACHUTE", SDL_INIT_NOPARACHUTE, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SDL_INIT_EVERYTHING", SDL_INIT_EVERYTHING, CONST_CS | CONST_PERSISTENT);
+ REGISTER_STRING_CONSTANT("SDL_HINT_RENDER_SCALE_QUALITY", SDL_HINT_RENDER_SCALE_QUALITY, CONST_CS | CONST_PERSISTENT);
+
return SUCCESS;
}
/* }}} */
diff --git a/src/sdl.h b/src/sdl.h
index 3396c11..93e51ae 100644
--- a/src/sdl.h
+++ b/src/sdl.h
@@ -1,6 +1,4 @@
/*
- +----------------------------------------------------------------------+
- | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2018 The PHP Group |
+----------------------------------------------------------------------+
@@ -56,6 +54,14 @@ ZEND_END_ARG_INFO()
PHP_FUNCTION(SDL_Quit);
+ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_SetHint, 0, 0, 2)
+ ZEND_ARG_TYPE_INFO(0, name, IS_STRING, 0)
+ ZEND_ARG_TYPE_INFO(0, value, IS_STRING, 0)
+ZEND_END_ARG_INFO()
+
+PHP_FUNCTION(SDL_SetHint);
+
+
PHP_MINIT_FUNCTION(sdl_sdl);
#ifdef __cplusplus
diff --git a/src/shape.c b/src/shape.c
index 185e739..756bc19 100644
--- a/src/shape.c
+++ b/src/shape.c
@@ -1,13 +1,11 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) 1997-2022 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_01.txt |
+ | https://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
@@ -130,16 +128,18 @@ static PHP_METHOD(SDL_WindowShapeMode, __construct)
intern->mode.mode = ShapeModeColorKey;
zval_to_sdl_color(z_param, &intern->mode.parameters.colorKey);
} else {
- zend_throw_exception(zend_exception_get_default(), "Invalid parameter for mode=ShapeModeColorKey, SDL_Color object expected", 0);
+ zend_throw_exception(zend_ce_exception, "Invalid parameter for mode=ShapeModeColorKey, SDL_Color object expected", 0);
}
} else {
- zend_throw_exception(zend_exception_get_default(), "Invalid mode for SDL_WindowShapeMode", 0);
+ zend_throw_exception(zend_ce_exception, "Invalid mode for SDL_WindowShapeMode", 0);
}
}
/* }}} */
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_SDL_WindowShapeMode___toString, 0, 0, IS_STRING, 0)
+ZEND_END_ARG_INFO()
/* {{{ proto SDL_WindowShapeMode::__toString() */
static PHP_METHOD(SDL_WindowShapeMode, __toString)
@@ -174,14 +174,10 @@ static PHP_METHOD(SDL_WindowShapeMode, __toString)
}
/* }}} */
-/* generic arginfo */
-ZEND_BEGIN_ARG_INFO_EX(arginfo_none, 0, 0, 0)
-ZEND_END_ARG_INFO()
-
/* {{{ php_sdl_windowshapemode_methods[] */
static const zend_function_entry php_sdl_windowshapemode_methods[] = {
PHP_ME(SDL_WindowShapeMode, __construct, arginfo_SDL_WindowShapeMode__construct, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC)
- PHP_ME(SDL_WindowShapeMode, __toString, arginfo_none, ZEND_ACC_PUBLIC)
+ PHP_ME(SDL_WindowShapeMode, __toString, arginfo_class_SDL_WindowShapeMode___toString, ZEND_ACC_PUBLIC)
PHP_FE_END
};
@@ -189,7 +185,7 @@ static const zend_function_entry php_sdl_windowshapemode_methods[] = {
#define REGISTER_CLASS_CONST_LONG(const_name, value) \
REGISTER_LONG_CONSTANT("ShapeMode" const_name, value, CONST_CS | CONST_PERSISTENT); \
- zend_declare_class_constant_long(php_sdl_windowshapemode_ce, ZEND_STRL(const_name), value); \
+ zend_declare_class_constant_long(php_sdl_windowshapemode_ce, const_name, sizeof(const_name)-1, value); \
/* {{{ MINIT */
PHP_MINIT_FUNCTION(sdl_shape)
diff --git a/src/shape.h b/src/shape.h
index 5f85548..9c5f85a 100644
--- a/src/shape.h
+++ b/src/shape.h
@@ -1,6 +1,4 @@
/*
- +----------------------------------------------------------------------+
- | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2018 The PHP Group |
+----------------------------------------------------------------------+
diff --git a/src/surface.c b/src/surface.c
index 486ce7b..3215f4d 100644
--- a/src/surface.c
+++ b/src/surface.c
@@ -1,13 +1,11 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) 1997-2022 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_01.txt |
+ | https://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
@@ -25,10 +23,11 @@
static zend_class_entry *php_sdl_surface_ce;
static zend_object_handlers php_sdl_surface_handlers;
-struct php_sdl_surface {
- SDL_Surface *surface;
- Uint32 flags;
- zend_object zo;
+struct php_sdl_surface
+{
+ SDL_Surface *surface;
+ Uint32 flags;
+ zend_object zo;
};
zend_class_entry *get_php_sdl_surface_ce(void)
@@ -36,26 +35,28 @@ zend_class_entry *get_php_sdl_surface_ce(void)
return php_sdl_surface_ce;
}
-#define FETCH_SURFACE(__ptr, __id, __check) \
-{ \
- zend_object* zox = Z_OBJ_P(__id);\
- intern = (struct php_sdl_surface*)((char*)zox - zox->handlers->offset);\
- __ptr = intern->surface; \
- if (__check && !__ptr) {\
- php_error_docref(NULL, E_WARNING, "Invalid %s object", ZSTR_VAL(intern->zo.ce->name));\
- RETURN_FALSE;\
- }\
-}
+#define FETCH_SURFACE(__ptr, __id, __check) \
+ { \
+ zend_object *zox = Z_OBJ_P(__id); \
+ intern = (struct php_sdl_surface *)((char *)zox - zox->handlers->offset); \
+ __ptr = intern->surface; \
+ if (__check && !__ptr) \
+ { \
+ php_error_docref(NULL, E_WARNING, "Invalid %s object", ZSTR_VAL(intern->zo.ce->name)); \
+ RETURN_FALSE; \
+ } \
+ }
/* {{{ sdl_surface_to_zval */
zend_bool sdl_surface_to_zval(SDL_Surface *surface, zval *z_val)
{
- if (surface) {
+ if (surface)
+ {
struct php_sdl_surface *intern;
object_init_ex(z_val, php_sdl_surface_ce);
- zend_object* zo = Z_OBJ_P(z_val);
- intern = (struct php_sdl_surface*)((char*)zo - zo->handlers->offset);
+ zend_object *zo = Z_OBJ_P(z_val);
+ intern = (struct php_sdl_surface *)((char *)zo - zo->handlers->offset);
intern->surface = surface;
/* copy flags to be able to check before access to surface */
intern->flags = surface->flags;
@@ -72,17 +73,16 @@ SDL_Surface *zval_to_sdl_surface(zval *z_val)
{
struct php_sdl_surface *intern;
- if (Z_TYPE_P(z_val) == IS_OBJECT && Z_OBJCE_P(z_val) == php_sdl_surface_ce) {
- zend_object* zo = Z_OBJ_P(z_val);
- intern = (struct php_sdl_surface*)((char*)zo - zo->handlers->offset);
+ if (Z_TYPE_P(z_val) == IS_OBJECT && Z_OBJCE_P(z_val) == php_sdl_surface_ce)
+ {
+ zend_object *zo = Z_OBJ_P(z_val);
+ intern = (struct php_sdl_surface *)((char *)zo - zo->handlers->offset);
return intern->surface;
- }
+ }
return NULL;
}
/* }}} */
-
-
/* {{{ proto SDL_Surface SDL_CreateRGBSurface(int flags, int width, int height, int depth, int Rmask, int Gmask, int Bmask, int Amask)
* Allocate and free an RGB surface.
@@ -102,18 +102,19 @@ SDL_Surface *zval_to_sdl_surface(zval *z_val)
* \param Bmask The blue mask of the surface to create.
* \param Amask The alpha mask of the surface to create.
extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurface
- (Uint32 flags, int width, int height, int depth,
- Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask);
+ (Uint32 flags, int width, int height, int depth,
+ Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask);
*/
PHP_FUNCTION(SDL_CreateRGBSurface)
{
zend_long flags, width, height, depth, rmask, gmask, bmask, amask;
SDL_Surface *surface;
- if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "llllllll", &flags, &width, &height, &depth, &rmask, &gmask, &bmask, &amask)) {
+ if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "llllllll", &flags, &width, &height, &depth, &rmask, &gmask, &bmask, &amask))
+ {
return;
}
- surface = SDL_CreateRGBSurface(flags, width, height, depth, rmask, gmask, bmask, amask);
+ surface = SDL_CreateRGBSurface((Uint32)flags, (int)width, (int)height, (int)depth, (Uint32)rmask, (Uint32)gmask, (Uint32)bmask, (Uint32)amask);
sdl_surface_to_zval(surface, return_value);
}
/* }}} */
@@ -128,7 +129,7 @@ PHP_FUNCTION(SDL_CreateRGBSurface)
*
* \return the new surface, or NULL if there was an error.
extern DECLSPEC SDL_Surface *SDLCALL SDL_LoadBMP_RW(SDL_RWops * src,
- int freesrc);
+ int freesrc);
*/
PHP_FUNCTION(SDL_LoadBMP_RW)
{
@@ -137,12 +138,14 @@ PHP_FUNCTION(SDL_LoadBMP_RW)
SDL_Surface *surface;
SDL_RWops *rwops;
- if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "Ol", &z_rwops, get_php_sdl_rwops_ce(), &freesrc)) {
+ if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "Ol", &z_rwops, get_php_sdl_rwops_ce(), &freesrc))
+ {
return;
}
rwops = zval_to_sdl_rwops(z_rwops);
surface = SDL_LoadBMP_RW(rwops, 0);
- if (freesrc) {
+ if (freesrc)
+ {
/* we close the SDL_RWops ourself, to free the PHP object */
zval_dtor(z_rwops);
ZVAL_NULL(z_rwops);
@@ -151,8 +154,6 @@ PHP_FUNCTION(SDL_LoadBMP_RW)
}
/* }}} */
-
-
/* {{{ proto SDL_Surface SDL_LoadBMP(string file)
PHP note: stream are supported
@@ -168,7 +169,8 @@ PHP_FUNCTION(SDL_LoadBMP)
size_t path_len;
SDL_Surface *surface = NULL;
- if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "s", &path, &path_len)) {
+ if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "s", &path, &path_len))
+ {
return;
}
@@ -178,7 +180,6 @@ PHP_FUNCTION(SDL_LoadBMP)
}
/* }}} */
-
/* {{{ proto SDL_Surface::__construct(int flags, int width, int height, int depth, int Rmask, int Gmask, int Bmask, int Amask) */
static PHP_METHOD(SDL_Surface, __construct)
{
@@ -186,53 +187,64 @@ static PHP_METHOD(SDL_Surface, __construct)
zend_long flags, width, height, depth, rmask, gmask, bmask, amask;
zend_error_handling error_handling;
- intern = (struct php_sdl_surface *)Z_OBJ_P(getThis());
+ zend_object *zo = Z_OBJ_P(getThis());
+ intern = (struct php_sdl_surface *)((char *)zo - zo->handlers->offset);
zend_replace_error_handling(EH_THROW, NULL, &error_handling);
- if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "llllllll", &flags, &width, &height, &depth, &rmask, &gmask, &bmask, &amask)) {
+ if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "llllllll", &flags, &width, &height, &depth, &rmask, &gmask, &bmask, &amask))
+ {
zend_restore_error_handling(&error_handling);
return;
}
zend_restore_error_handling(&error_handling);
- intern->surface = SDL_CreateRGBSurface(flags, width, height, depth, rmask, gmask, bmask, amask);
- if (intern->surface) {
+ intern->surface = SDL_CreateRGBSurface(flags, (int)width, (int)height, (int)depth, rmask, gmask, bmask, amask);
+ if (intern->surface)
+ {
/* copy flags to be able to check before access to surface */
intern->flags = intern->surface->flags;
- } else {
- zend_throw_exception(zend_exception_get_default(), SDL_GetError(), 0);
+ }
+ else
+ {
+ zend_throw_exception(zend_ce_exception, SDL_GetError(), 0);
}
}
/* }}} */
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_SDL_Surface___toString, 0, 0, IS_STRING, 0)
+ZEND_END_ARG_INFO()
/* {{{ proto SDL_Surface::__toString() */
static PHP_METHOD(SDL_Surface, __toString)
{
struct php_sdl_surface *intern;
char *buf;
- size_t buf_len;
+ size_t buf_len;
- if (zend_parse_parameters_none() == FAILURE) {
+ if (zend_parse_parameters_none() == FAILURE)
+ {
return;
}
- intern = (struct php_sdl_surface *)Z_OBJ_P(getThis());
- if (intern->surface) {
+ zend_object *zo = Z_OBJ_P(getThis());
+ intern = (struct php_sdl_surface *)((char *)zo - zo->handlers->offset);
+
+ if (intern->surface)
+ {
buf_len = spprintf(&buf, 100, "SDL_Surface(%u,%d,%d,%u,0x%x,0x%x,0x%x,0x%x)",
- intern->surface->flags, intern->surface->w, intern->surface->h,
- intern->surface->format->BitsPerPixel, intern->surface->format->Rmask,
- intern->surface->format->Gmask, intern->surface->format->Bmask, intern->surface->format->Amask);
+ intern->surface->flags, intern->surface->w, intern->surface->h,
+ intern->surface->format->BitsPerPixel, intern->surface->format->Rmask,
+ intern->surface->format->Gmask, intern->surface->format->Bmask, intern->surface->format->Amask);
RETVAL_STRINGL(buf, buf_len);
- efree(buf);
- } else {
+ efree(buf);
+ }
+ else
+ {
RETVAL_STRING("SDL_Surface()");
}
}
/* }}} */
-
-
/* {{{ proto int SDL_SaveBMP_RW(SDL_Surface surface, SDL_RWops &dst, int freedst)
* Save a surface to a seekable SDL data stream (memory or file).
@@ -241,7 +253,7 @@ static PHP_METHOD(SDL_Surface, __toString)
*
* \return 0 if successful or -1 if there was an error.
extern DECLSPEC int SDLCALL SDL_SaveBMP_RW
- (SDL_Surface * surface, SDL_RWops * dst, int freedst);
+ (SDL_Surface * surface, SDL_RWops * dst, int freedst);
*/
PHP_FUNCTION(SDL_SaveBMP_RW)
{
@@ -252,20 +264,23 @@ PHP_FUNCTION(SDL_SaveBMP_RW)
SDL_RWops *rwops;
int result;
- if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OO|l", &z_surface, php_sdl_surface_ce, &z_rwops, get_php_sdl_rwops_ce(), &freedst) == FAILURE) {
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OO|l", &z_surface, php_sdl_surface_ce, &z_rwops, get_php_sdl_rwops_ce(), &freedst) == FAILURE)
+ {
return;
}
FETCH_SURFACE(surface, z_surface, 1);
rwops = zval_to_sdl_rwops(z_rwops);
- if (!rwops) {
+ if (!rwops)
+ {
php_error_docref(NULL, E_WARNING, "Invalid SDL_RWops object");
RETURN_LONG(-1);
}
result = SDLCALL SDL_SaveBMP_RW(surface, rwops, 0);
- if (freedst) {
+ if (freedst)
+ {
/* we close the SDL_RWops ourself, to free the PHP object */
zval_dtor(z_rwops);
ZVAL_NULL(z_rwops);
@@ -274,14 +289,12 @@ PHP_FUNCTION(SDL_SaveBMP_RW)
}
/* }}} */
-
-
/* {{{ proto int SDL_SaveBMP(SDL_Surface surface, string path)
PHP note: stream are "partially" supported (only when PHP_STREAM_AS_STDIO)
define SDL_SaveBMP(surface, file) \
- SDL_SaveBMP_RW(surface, SDL_RWFromFile(file, "wb"), 1)
+ SDL_SaveBMP_RW(surface, SDL_RWFromFile(file, "wb"), 1)
*/
PHP_FUNCTION(SDL_SaveBMP)
@@ -295,7 +308,8 @@ PHP_FUNCTION(SDL_SaveBMP)
int result = -1;
php_stream *stream;
- if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Os", &z_surface, php_sdl_surface_ce, &path, &path_len) == FAILURE) {
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Os", &z_surface, php_sdl_surface_ce, &path, &path_len) == FAILURE)
+ {
return;
}
FETCH_SURFACE(surface, z_surface, 1);
@@ -304,7 +318,8 @@ PHP_FUNCTION(SDL_SaveBMP)
php_stream_to_zval_rwops(stream, &z_rwops, 0);
rwops = zval_to_sdl_rwops(&z_rwops);
- if (rwops) {
+ if (rwops)
+ {
result = SDLCALL SDL_SaveBMP_RW(surface, rwops, 0);
}
zval_dtor(&z_rwops);
@@ -313,7 +328,6 @@ PHP_FUNCTION(SDL_SaveBMP)
}
/* }}} */
-
/* {{{ proto void SDL_FreeSurface(SDL_Surface surface)
* \brief Destroy a window.
@@ -325,7 +339,8 @@ PHP_FUNCTION(SDL_FreeSurface)
zval *object;
SDL_Surface *surface;
- if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_surface_ce) == FAILURE) {
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_surface_ce) == FAILURE)
+ {
return;
}
FETCH_SURFACE(surface, object, 1);
@@ -335,8 +350,6 @@ PHP_FUNCTION(SDL_FreeSurface)
}
/* }}} */
-
-
/* {{{ proto SDL_FillRect(SDL_Surface surface, SDL_Rect rect, int color)
* Performs a fast fill of the given rectangle with \c color.
@@ -348,7 +361,7 @@ PHP_FUNCTION(SDL_FreeSurface)
*
* \return 0 on success, or -1 on error.
extern DECLSPEC int SDLCALL SDL_FillRect
- (SDL_Surface * dst, const SDL_Rect * rect, Uint32 color);
+ (SDL_Surface * dst, const SDL_Rect * rect, Uint32 color);
*/
PHP_FUNCTION(SDL_FillRect)
{
@@ -358,7 +371,8 @@ PHP_FUNCTION(SDL_FillRect)
SDL_Rect rect;
SDL_Surface *surface;
- if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OOl", &z_surface, php_sdl_surface_ce, &z_rect, get_php_sdl_rect_ce(), &color) == FAILURE) {
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OOl", &z_surface, php_sdl_surface_ce, &z_rect, get_php_sdl_rect_ce(), &color) == FAILURE)
+ {
return;
}
FETCH_SURFACE(surface, z_surface, 1);
@@ -368,11 +382,10 @@ PHP_FUNCTION(SDL_FillRect)
}
/* }}} */
-
/* {{{ proto int SDL_FillRects(SDL_Surface surface, SDL_Rect rect, int count, int color)
extern DECLSPEC int SDLCALL SDL_FillRects
- (SDL_Surface * dst, const SDL_Rect * rects, int count, Uint32 color);
+ (SDL_Surface * dst, const SDL_Rect * rects, int count, Uint32 color);
*/
PHP_FUNCTION(SDL_FillRects)
{
@@ -383,32 +396,40 @@ PHP_FUNCTION(SDL_FillRects)
SDL_Rect *rects;
SDL_Surface *surface;
- if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oall", &z_surface, php_sdl_surface_ce, &z_rects, &count, &color) == FAILURE) {
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oall", &z_surface, php_sdl_surface_ce, &z_rects, &count, &color) == FAILURE)
+ {
return;
}
FETCH_SURFACE(surface, z_surface, 1);
- if (count<=0) {
+ if (count <= 0)
+ {
count = zend_hash_next_free_element(Z_ARRVAL_P(z_rects));
}
- rects = emalloc(sizeof(SDL_Rect)*count);
+ rects = emalloc(sizeof(SDL_Rect) * count);
- for (i=nb=0 ; iRGB:
- Source surface blend mode set to SDL_BLENDMODE_BLEND:
- alpha-blend (using the source alpha-channel and per-surface alpha)
- SDL_SRCCOLORKEY ignored.
- Source surface blend mode set to SDL_BLENDMODE_NONE:
- copy RGB.
- if SDL_SRCCOLORKEY set, only copy the pixels matching the
- RGB values of the source color key, ignoring alpha in the
- comparison.
-
- RGB->RGBA:
- Source surface blend mode set to SDL_BLENDMODE_BLEND:
- alpha-blend (using the source per-surface alpha)
- Source surface blend mode set to SDL_BLENDMODE_NONE:
- copy RGB, set destination alpha to source per-surface alpha value.
- both:
- if SDL_SRCCOLORKEY set, only copy the pixels matching the
- source color key.
-
- RGBA->RGBA:
- Source surface blend mode set to SDL_BLENDMODE_BLEND:
- alpha-blend (using the source alpha-channel and per-surface alpha)
- SDL_SRCCOLORKEY ignored.
- Source surface blend mode set to SDL_BLENDMODE_NONE:
- copy all of RGBA to the destination.
- if SDL_SRCCOLORKEY set, only copy the pixels matching the
- RGB values of the source color key, ignoring alpha in the
- comparison.
-
- RGB->RGB:
- Source surface blend mode set to SDL_BLENDMODE_BLEND:
- alpha-blend (using the source per-surface alpha)
- Source surface blend mode set to SDL_BLENDMODE_NONE:
- copy RGB.
- both:
- if SDL_SRCCOLORKEY set, only copy the pixels matching the
- source color key.
- \endverbatim
+ RGBA->RGB:
+ Source surface blend mode set to SDL_BLENDMODE_BLEND:
+ alpha-blend (using the source alpha-channel and per-surface alpha)
+ SDL_SRCCOLORKEY ignored.
+ Source surface blend mode set to SDL_BLENDMODE_NONE:
+ copy RGB.
+ if SDL_SRCCOLORKEY set, only copy the pixels matching the
+ RGB values of the source color key, ignoring alpha in the
+ comparison.
+
+ RGB->RGBA:
+ Source surface blend mode set to SDL_BLENDMODE_BLEND:
+ alpha-blend (using the source per-surface alpha)
+ Source surface blend mode set to SDL_BLENDMODE_NONE:
+ copy RGB, set destination alpha to source per-surface alpha value.
+ both:
+ if SDL_SRCCOLORKEY set, only copy the pixels matching the
+ source color key.
+
+ RGBA->RGBA:
+ Source surface blend mode set to SDL_BLENDMODE_BLEND:
+ alpha-blend (using the source alpha-channel and per-surface alpha)
+ SDL_SRCCOLORKEY ignored.
+ Source surface blend mode set to SDL_BLENDMODE_NONE:
+ copy all of RGBA to the destination.
+ if SDL_SRCCOLORKEY set, only copy the pixels matching the
+ RGB values of the source color key, ignoring alpha in the
+ comparison.
+
+ RGB->RGB:
+ Source surface blend mode set to SDL_BLENDMODE_BLEND:
+ alpha-blend (using the source per-surface alpha)
+ Source surface blend mode set to SDL_BLENDMODE_NONE:
+ copy RGB.
+ both:
+ if SDL_SRCCOLORKEY set, only copy the pixels matching the
+ source color key.
+ \endverbatim
*
* You should call SDL_BlitSurface() unless you know exactly how SDL
@@ -558,8 +578,8 @@ PHP_FUNCTION(SDL_UnlockSurface)
* This is the public blit function, SDL_BlitSurface(), and it performs
* rectangle validation and clipping before passing it to SDL_LowerBlit()
extern DECLSPEC int SDLCALL SDL_UpperBlit
- (SDL_Surface * src, const SDL_Rect * srcrect,
- SDL_Surface * dst, SDL_Rect * dstrect);
+ (SDL_Surface * src, const SDL_Rect * srcrect,
+ SDL_Surface * dst, SDL_Rect * dstrect);
*/
PHP_FUNCTION(SDL_UpperBlit)
{
@@ -569,42 +589,44 @@ PHP_FUNCTION(SDL_UpperBlit)
SDL_Rect srect, drect;
int result;
- if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OzO|z", &z_src, php_sdl_surface_ce, &z_srect, &z_dst, php_sdl_surface_ce, &z_drect)) {
+ if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OzO|z", &z_src, php_sdl_surface_ce, &z_srect, &z_dst, php_sdl_surface_ce, &z_drect))
+ {
return;
}
FETCH_SURFACE(src, z_src, 1);
FETCH_SURFACE(dst, z_dst, 1);
- if (!(Z_TYPE_P(z_srect)==IS_NULL || zval_to_sdl_rect(z_srect, &srect))) {
+ if (!(Z_TYPE_P(z_srect) == IS_NULL || zval_to_sdl_rect(z_srect, &srect)))
+ {
php_error_docref(NULL, E_ERROR, "srcrect is not a SDL_Rect object");
return;
}
- /*
- if (z_drect && !(Z_TYPE_P(z_drect)==IS_NULL || zval_to_sdl_rect(z_drect, &drect))) {
- php_error_docref(NULL, E_ERROR, "dstrect is not a SDL_Rect object");
- return;
- } else if (z_drect && Z_TYPE_P(z_drect)==IS_NULL) {
- php_error_docref(NULL, E_NOTICE, "dstrect is not a SDL_Rect object, so is ignored");
- }
- * */
+ /*
+if (z_drect && !(Z_TYPE_P(z_drect)==IS_NULL || zval_to_sdl_rect(z_drect, &drect))) {
+ php_error_docref(NULL, E_ERROR, "dstrect is not a SDL_Rect object");
+ return;
+} else if (z_drect && Z_TYPE_P(z_drect)==IS_NULL) {
+ php_error_docref(NULL, E_NOTICE, "dstrect is not a SDL_Rect object, so is ignored");
+}
+ * */
- result = SDL_UpperBlit(src, (Z_TYPE_P(z_srect)==IS_NULL ? NULL : &srect),
- dst, (z_drect==NULL || Z_TYPE_P(z_drect)==IS_NULL ? NULL : &drect));
+ result = SDL_UpperBlit(src, (Z_TYPE_P(z_srect) == IS_NULL ? NULL : &srect),
+ dst, (z_drect == NULL || Z_TYPE_P(z_drect) == IS_NULL ? NULL : &drect));
- if (result==0 && z_drect && Z_TYPE_P(z_drect)==IS_OBJECT) {
+ if (result == 0 && z_drect && Z_TYPE_P(z_drect) == IS_OBJECT)
+ {
sdl_rect_to_zval(&drect, z_drect);
}
RETURN_LONG(result);
}
/* }}} */
-
/* {{{ proto void SDL_LowerBlit(SDL_Surface src, SDL_rect &srcrect, SDL_Surface dst , SDL_rect &dstrect)
* This is a semi-private blit function and it performs low-level surface
* blitting only.
extern DECLSPEC int SDLCALL SDL_LowerBlit
- (SDL_Surface * src, SDL_Rect * srcrect,
- SDL_Surface * dst, SDL_Rect * dstrect);
+ (SDL_Surface * src, SDL_Rect * srcrect,
+ SDL_Surface * dst, SDL_Rect * dstrect);
*/
PHP_FUNCTION(SDL_LowerBlit)
{
@@ -614,7 +636,8 @@ PHP_FUNCTION(SDL_LowerBlit)
SDL_Rect srect, drect;
int result;
- if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OOOO", &z_src, php_sdl_surface_ce, &z_srect, get_php_sdl_rect_ce(), &z_dst, php_sdl_surface_ce, &z_drect, get_php_sdl_rect_ce())) {
+ if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OOOO", &z_src, php_sdl_surface_ce, &z_srect, get_php_sdl_rect_ce(), &z_dst, php_sdl_surface_ce, &z_drect, get_php_sdl_rect_ce()))
+ {
return;
}
FETCH_SURFACE(src, z_src, 1);
@@ -624,7 +647,8 @@ PHP_FUNCTION(SDL_LowerBlit)
result = SDL_LowerBlit(src, &srect, dst, &drect);
- if (result==0) {
+ if (result == 0)
+ {
zval_dtor(z_srect);
sdl_rect_to_zval(&srect, z_srect);
zval_dtor(z_drect);
@@ -634,14 +658,13 @@ PHP_FUNCTION(SDL_LowerBlit)
}
/* }}} */
-
/* {{{ proto void SDL_UpperBlitScaled(SDL_Surface src, SDL_rect &srcrect, SDL_Surface dst [, SDL_rect &dstrect])
* This is the public scaled blit function, SDL_BlitScaled(), and it performs
* rectangle validation and clipping before passing it to SDL_LowerBlitScaled()
extern DECLSPEC int SDLCALL SDL_UpperBlitScaled
- (SDL_Surface * src, const SDL_Rect * srcrect,
- SDL_Surface * dst, SDL_Rect * dstrect);
+ (SDL_Surface * src, const SDL_Rect * srcrect,
+ SDL_Surface * dst, SDL_Rect * dstrect);
define SDL_BlitScaled SDL_UpperBlitScaled
*/
PHP_FUNCTION(SDL_UpperBlitScaled)
@@ -652,42 +675,44 @@ PHP_FUNCTION(SDL_UpperBlitScaled)
SDL_Rect srect, drect;
int result;
- if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OzO|z", &z_src, php_sdl_surface_ce, &z_srect, &z_dst, php_sdl_surface_ce, &z_drect)) {
+ if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OzO|z", &z_src, php_sdl_surface_ce, &z_srect, &z_dst, php_sdl_surface_ce, &z_drect))
+ {
return;
}
FETCH_SURFACE(src, z_src, 1);
FETCH_SURFACE(dst, z_dst, 1);
- if (!(Z_TYPE_P(z_srect)==IS_NULL || zval_to_sdl_rect(z_srect, &srect))) {
+ if (!(Z_TYPE_P(z_srect) == IS_NULL || zval_to_sdl_rect(z_srect, &srect)))
+ {
php_error_docref(NULL, E_ERROR, "srcrect is not a SDL_Rect object");
return;
}
- /*
- if (z_drect && !(Z_TYPE_P(z_drect)==IS_NULL || zval_to_sdl_rect(z_drect, &drect))) {
- php_error_docref(NULL, E_ERROR, "dstrect is not a SDL_Rect object");
- return;
- } else if (z_drect && Z_TYPE_P(z_drect)==IS_NULL) {
- php_error_docref(NULL, E_NOTICE, "dstrect is not a SDL_Rect object, so is ignored");
- }
- * */
+ /*
+if (z_drect && !(Z_TYPE_P(z_drect)==IS_NULL || zval_to_sdl_rect(z_drect, &drect))) {
+ php_error_docref(NULL, E_ERROR, "dstrect is not a SDL_Rect object");
+ return;
+} else if (z_drect && Z_TYPE_P(z_drect)==IS_NULL) {
+ php_error_docref(NULL, E_NOTICE, "dstrect is not a SDL_Rect object, so is ignored");
+}
+ * */
- result = SDL_UpperBlitScaled(src, (Z_TYPE_P(z_srect)==IS_NULL ? NULL : &srect),
- dst, (z_drect==NULL || Z_TYPE_P(z_drect)==IS_NULL ? NULL : &drect));
+ result = SDL_UpperBlitScaled(src, (Z_TYPE_P(z_srect) == IS_NULL ? NULL : &srect),
+ dst, (z_drect == NULL || Z_TYPE_P(z_drect) == IS_NULL ? NULL : &drect));
- if (result==0 && z_drect && Z_TYPE_P(z_drect)==IS_OBJECT) {
+ if (result == 0 && z_drect && Z_TYPE_P(z_drect) == IS_OBJECT)
+ {
sdl_rect_to_zval(&drect, z_drect);
}
RETURN_LONG(result);
}
/* }}} */
-
/* {{{ proto void SDL_LowerBlitScaled(SDL_Surface src, SDL_rect &srcrect, SDL_Surface dst , SDL_rect &dstrect)
* This is a semi-private blit function and it performs low-level surface
* scaled blitting only.
extern DECLSPEC int SDLCALL SDL_LowerBlitScaled
- (SDL_Surface * src, SDL_Rect * srcrect,
- SDL_Surface * dst, SDL_Rect * dstrect);
+ (SDL_Surface * src, SDL_Rect * srcrect,
+ SDL_Surface * dst, SDL_Rect * dstrect);
*/
PHP_FUNCTION(SDL_LowerBlitScaled)
{
@@ -697,7 +722,8 @@ PHP_FUNCTION(SDL_LowerBlitScaled)
SDL_Rect srect, drect;
int result;
- if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OOOO", &z_src, php_sdl_surface_ce, &z_srect, get_php_sdl_rect_ce(), &z_dst, php_sdl_surface_ce, &z_drect, get_php_sdl_rect_ce())) {
+ if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OOOO", &z_src, php_sdl_surface_ce, &z_srect, get_php_sdl_rect_ce(), &z_dst, php_sdl_surface_ce, &z_drect, get_php_sdl_rect_ce()))
+ {
return;
}
FETCH_SURFACE(src, z_src, 1);
@@ -707,7 +733,8 @@ PHP_FUNCTION(SDL_LowerBlitScaled)
result = SDL_LowerBlitScaled(src, &srect, dst, &drect);
- if (result==0) {
+ if (result == 0)
+ {
zval_dtor(z_srect);
sdl_rect_to_zval(&srect, z_srect);
zval_dtor(z_drect);
@@ -717,7 +744,6 @@ PHP_FUNCTION(SDL_LowerBlitScaled)
}
/* }}} */
-
/* {{{ proto void SDL_SoftStretch(SDL_Surface src, SDL_rect srcrect, SDL_Surface dst [, SDL_rect dstrect])
* \brief Perform a fast, low quality, stretch blit between two surfaces of the
@@ -725,9 +751,9 @@ PHP_FUNCTION(SDL_LowerBlitScaled)
*
* \note This function uses a static buffer, and is not thread-safe.
extern DECLSPEC int SDLCALL SDL_SoftStretch(SDL_Surface * src,
- const SDL_Rect * srcrect,
- SDL_Surface * dst,
- const SDL_Rect * dstrect);
+ const SDL_Rect * srcrect,
+ SDL_Surface * dst,
+ const SDL_Rect * dstrect);
*/
PHP_FUNCTION(SDL_SoftStretch)
@@ -738,30 +764,34 @@ PHP_FUNCTION(SDL_SoftStretch)
SDL_Rect srect, drect;
int result;
- if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OzO|z", &z_src, php_sdl_surface_ce, &z_srect, &z_dst, php_sdl_surface_ce, &z_drect)) {
+ if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OzO|z", &z_src, php_sdl_surface_ce, &z_srect, &z_dst, php_sdl_surface_ce, &z_drect))
+ {
return;
}
FETCH_SURFACE(src, z_src, 1);
FETCH_SURFACE(dst, z_dst, 1);
- if (!(Z_TYPE_P(z_srect)==IS_NULL || zval_to_sdl_rect(z_srect, &srect))) {
+ if (!(Z_TYPE_P(z_srect) == IS_NULL || zval_to_sdl_rect(z_srect, &srect)))
+ {
php_error_docref(NULL, E_ERROR, "srcrect is not a SDL_Rect object");
return;
}
- if (z_drect && !(Z_TYPE_P(z_drect)==IS_NULL || zval_to_sdl_rect(z_drect, &drect))) {
+ if (z_drect && !(Z_TYPE_P(z_drect) == IS_NULL || zval_to_sdl_rect(z_drect, &drect)))
+ {
php_error_docref(NULL, E_ERROR, "dstrect is not a SDL_Rect object");
return;
- } else if (z_drect && Z_TYPE_P(z_drect)==IS_NULL) {
+ }
+ else if (z_drect && Z_TYPE_P(z_drect) == IS_NULL)
+ {
php_error_docref(NULL, E_NOTICE, "dstrect is not a SDL_Rect object, so is ignored");
}
- result = SDL_SoftStretch(src, (Z_TYPE_P(z_srect)==IS_NULL ? NULL : &srect),
- dst, (z_drect==NULL || Z_TYPE_P(z_drect)==IS_NULL ? NULL : &drect));
+ result = SDL_SoftStretch(src, (Z_TYPE_P(z_srect) == IS_NULL ? NULL : &srect),
+ dst, (z_drect == NULL || Z_TYPE_P(z_drect) == IS_NULL ? NULL : &drect));
RETURN_LONG(result);
}
/* }}} */
-
/* {{{ proto void SDL_SetSurfaceRLE(SDL_Surface src, int flag)
* \brief Sets the RLE acceleration hint for a surface.
@@ -771,7 +801,7 @@ PHP_FUNCTION(SDL_SoftStretch)
* \note If RLE is enabled, colorkey and alpha blending blits are much faster,
* but the surface must be locked before directly accessing the pixels.
extern DECLSPEC int SDLCALL SDL_SetSurfaceRLE(SDL_Surface * surface,
- int flag);
+ int flag);
*/
PHP_FUNCTION(SDL_SetSurfaceRLE)
{
@@ -780,7 +810,8 @@ PHP_FUNCTION(SDL_SetSurfaceRLE)
zend_long flag;
SDL_Surface *surface;
- if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Ol", &z_surface, php_sdl_surface_ce, &flag)) {
+ if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Ol", &z_surface, php_sdl_surface_ce, &flag))
+ {
return;
}
FETCH_SURFACE(surface, z_surface, 1);
@@ -800,20 +831,22 @@ PHP_FUNCTION(SDL_SetSurfaceRLE)
*
* You can pass SDL_RLEACCEL to enable RLE accelerated blits.
extern DECLSPEC int SDLCALL SDL_SetColorKey(SDL_Surface * surface,
- int flag, Uint32 key);
+ int flag, Uint32 key);
*/
PHP_FUNCTION(SDL_SetColorKey)
{
struct php_sdl_surface *intern;
zval *z_surface;
- zend_long flag, key = 0;
+ bool flag;
+ zend_long key = 0;
SDL_Surface *surface;
- if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Ol|l", &z_surface, php_sdl_surface_ce, &flag, &key)) {
+ if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Ob|l", &z_surface, php_sdl_surface_ce, &flag, &key))
+ {
return;
}
FETCH_SURFACE(surface, z_surface, 1);
- RETURN_LONG(SDL_SetColorKey(surface, (int)flag, (Uint32)key));
+ RETURN_LONG(SDL_SetColorKey(surface, flag ? SDL_TRUE : SDL_FALSE, (Uint32)key));
}
/* }}} */
@@ -828,7 +861,7 @@ PHP_FUNCTION(SDL_SetColorKey)
* \return 0 on success, or -1 if the surface is not valid or colorkey is not
* enabled.
extern DECLSPEC int SDLCALL SDL_GetColorKey(SDL_Surface * surface,
- Uint32 * key);
+ Uint32 * key);
*/
PHP_FUNCTION(SDL_GetColorKey)
{
@@ -838,12 +871,14 @@ PHP_FUNCTION(SDL_GetColorKey)
SDL_Surface *surface;
int result;
- if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oz", &z_surface, php_sdl_surface_ce, &z_key)) {
+ if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oz/", &z_surface, php_sdl_surface_ce, &z_key))
+ {
return;
}
FETCH_SURFACE(surface, z_surface, 1);
result = SDL_GetColorKey(surface, &key);
- if (result == 0) {
+ if (result == 0)
+ {
zval_dtor(z_key);
ZVAL_LONG(z_key, (long)key);
}
@@ -864,7 +899,7 @@ PHP_FUNCTION(SDL_GetColorKey)
*
* \sa SDL_GetSurfaceColorMod()
extern DECLSPEC int SDLCALL SDL_SetSurfaceColorMod(SDL_Surface * surface,
- Uint8 r, Uint8 g, Uint8 b);
+ Uint8 r, Uint8 g, Uint8 b);
*/
PHP_FUNCTION(SDL_SetSurfaceColorMod)
{
@@ -873,7 +908,8 @@ PHP_FUNCTION(SDL_SetSurfaceColorMod)
zend_long r, g, b;
SDL_Surface *surface;
- if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Olll", &z_surface, php_sdl_surface_ce, &r, &g, &b)) {
+ if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Olll", &z_surface, php_sdl_surface_ce, &r, &g, &b))
+ {
return;
}
FETCH_SURFACE(surface, z_surface, 1);
@@ -894,8 +930,8 @@ PHP_FUNCTION(SDL_SetSurfaceColorMod)
*
* \sa SDL_SetSurfaceColorMod()
extern DECLSPEC int SDLCALL SDL_GetSurfaceColorMod(SDL_Surface * surface,
- Uint8 * r, Uint8 * g,
- Uint8 * b);
+ Uint8 * r, Uint8 * g,
+ Uint8 * b);
*/
PHP_FUNCTION(SDL_GetSurfaceColorMod)
{
@@ -905,12 +941,14 @@ PHP_FUNCTION(SDL_GetSurfaceColorMod)
SDL_Surface *surface;
int result;
- if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Ozzz", &z_surface, php_sdl_surface_ce, &z_r, &z_g, &z_b)) {
+ if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oz/z/z/", &z_surface, php_sdl_surface_ce, &z_r, &z_g, &z_b))
+ {
return;
}
FETCH_SURFACE(surface, z_surface, 1);
result = SDL_GetSurfaceColorMod(surface, &r, &g, &b);
- if (result == 0) {
+ if (result == 0)
+ {
zval_dtor(z_r);
ZVAL_LONG(z_r, (long)r);
zval_dtor(z_g);
@@ -933,7 +971,7 @@ PHP_FUNCTION(SDL_GetSurfaceColorMod)
*
* \sa SDL_GetSurfaceAlphaMod()
extern DECLSPEC int SDLCALL SDL_SetSurfaceAlphaMod(SDL_Surface * surface,
- Uint8 alpha);
+ Uint8 alpha);
*/
PHP_FUNCTION(SDL_SetSurfaceAlphaMod)
{
@@ -942,7 +980,8 @@ PHP_FUNCTION(SDL_SetSurfaceAlphaMod)
zend_long a;
SDL_Surface *surface;
- if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Ol", &z_surface, php_sdl_surface_ce, &a)) {
+ if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Ol", &z_surface, php_sdl_surface_ce, &a))
+ {
return;
}
FETCH_SURFACE(surface, z_surface, 1);
@@ -961,7 +1000,7 @@ PHP_FUNCTION(SDL_SetSurfaceAlphaMod)
*
* \sa SDL_SetSurfaceAlphaMod()
extern DECLSPEC int SDLCALL SDL_GetSurfaceAlphaMod(SDL_Surface * surface,
- Uint8 * alpha);
+ Uint8 * alpha);
*/
PHP_FUNCTION(SDL_GetSurfaceAlphaMod)
{
@@ -971,12 +1010,14 @@ PHP_FUNCTION(SDL_GetSurfaceAlphaMod)
SDL_Surface *surface;
int result;
- if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oz", &z_surface, php_sdl_surface_ce, &z_a)) {
+ if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oz/", &z_surface, php_sdl_surface_ce, &z_a))
+ {
return;
}
FETCH_SURFACE(surface, z_surface, 1);
result = SDL_GetSurfaceAlphaMod(surface, &a);
- if (result == 0) {
+ if (result == 0)
+ {
zval_dtor(z_a);
ZVAL_LONG(z_a, (long)a);
}
@@ -984,7 +1025,6 @@ PHP_FUNCTION(SDL_GetSurfaceAlphaMod)
}
/* }}} */
-
/* {{{ proto int SDL_SetSurfaceBlendMode(SDL_Surface src, int blendmode)
* \brief Set the blend mode used for blit operations.
*
@@ -995,7 +1035,7 @@ PHP_FUNCTION(SDL_GetSurfaceAlphaMod)
*
* \sa SDL_GetSurfaceBlendMode()
extern DECLSPEC int SDLCALL SDL_SetSurfaceBlendMode(SDL_Surface * surface,
- SDL_BlendMode blendMode);
+ SDL_BlendMode blendMode);
*/
PHP_FUNCTION(SDL_SetSurfaceBlendMode)
{
@@ -1004,7 +1044,8 @@ PHP_FUNCTION(SDL_SetSurfaceBlendMode)
zend_long mode;
SDL_Surface *surface;
- if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Ol", &z_surface, php_sdl_surface_ce, &mode)) {
+ if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Ol", &z_surface, php_sdl_surface_ce, &mode))
+ {
return;
}
FETCH_SURFACE(surface, z_surface, 1);
@@ -1023,7 +1064,7 @@ PHP_FUNCTION(SDL_SetSurfaceBlendMode)
*
* \sa SDL_SetSurfaceBlendMode()
extern DECLSPEC int SDLCALL SDL_GetSurfaceBlendMode(SDL_Surface * surface,
- SDL_BlendMode *blendMode);
+ SDL_BlendMode *blendMode);
*/
PHP_FUNCTION(SDL_GetSurfaceBlendMode)
{
@@ -1033,12 +1074,14 @@ PHP_FUNCTION(SDL_GetSurfaceBlendMode)
SDL_Surface *surface;
int result;
- if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oz", &z_surface, php_sdl_surface_ce, &z_mode)) {
+ if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oz/", &z_surface, php_sdl_surface_ce, &z_mode))
+ {
return;
}
FETCH_SURFACE(surface, z_surface, 1);
result = SDL_GetSurfaceBlendMode(surface, &mode);
- if (result == 0) {
+ if (result == 0)
+ {
zval_dtor(z_mode);
ZVAL_LONG(z_mode, (long)mode);
}
@@ -1060,7 +1103,7 @@ PHP_FUNCTION(SDL_GetSurfaceBlendMode)
* Note that blits are automatically clipped to the edges of the source
* and destination surfaces.
extern DECLSPEC SDL_bool SDLCALL SDL_SetClipRect(SDL_Surface * surface,
- const SDL_Rect * rect);
+ const SDL_Rect * rect);
*/
PHP_FUNCTION(SDL_SetClipRect)
{
@@ -1069,11 +1112,13 @@ PHP_FUNCTION(SDL_SetClipRect)
SDL_Rect rect;
SDL_Surface *surface;
- if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OO", &z_surface, php_sdl_surface_ce, &z_rect, get_php_sdl_rect_ce())) {
+ if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OO", &z_surface, php_sdl_surface_ce, &z_rect, get_php_sdl_rect_ce()))
+ {
return;
}
FETCH_SURFACE(surface, z_surface, 1);
- if (zval_to_sdl_rect(z_rect, &rect)) {
+ if (zval_to_sdl_rect(z_rect, &rect))
+ {
RETURN_BOOL(SDL_SetClipRect(surface, &rect));
}
php_error_docref(NULL, E_WARNING, "Invalid SDL_Rect object");
@@ -1088,7 +1133,7 @@ PHP_FUNCTION(SDL_SetClipRect)
* \c rect must be a pointer to a valid rectangle which will be filled
* with the correct values.
extern DECLSPEC void SDLCALL SDL_GetClipRect(SDL_Surface * surface,
- SDL_Rect * rect);
+ SDL_Rect * rect);
*/
PHP_FUNCTION(SDL_GetClipRect)
{
@@ -1097,7 +1142,8 @@ PHP_FUNCTION(SDL_GetClipRect)
SDL_Rect rect;
SDL_Surface *surface;
- if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oz", &z_surface, php_sdl_surface_ce, &z_rect)) {
+ if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oz/", &z_surface, php_sdl_surface_ce, &z_rect))
+ {
return;
}
FETCH_SURFACE(surface, z_surface, 1);
@@ -1118,7 +1164,7 @@ PHP_FUNCTION(SDL_GetClipRect)
* SDL will try to RLE accelerate colorkey and alpha blits in the resulting
* surface.
extern DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurface
- (SDL_Surface * src, const SDL_PixelFormat * fmt, Uint32 flags);
+ (SDL_Surface * src, const SDL_PixelFormat * fmt, Uint32 flags);
*/
PHP_FUNCTION(SDL_ConvertSurface)
{
@@ -1128,15 +1174,19 @@ PHP_FUNCTION(SDL_ConvertSurface)
SDL_Surface *src, *dst;
SDL_PixelFormat *format;
- if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OO|l", &z_src, php_sdl_surface_ce, &z_format, get_php_sdl_pixelformat_ce(), &flags)) {
+ if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OO|l", &z_src, php_sdl_surface_ce, &z_format, get_php_sdl_pixelformat_ce(), &flags))
+ {
return;
}
FETCH_SURFACE(src, z_src, 1);
format = zval_to_sdl_pixelformat(z_format);
- if (format) {
+ if (format)
+ {
dst = SDL_ConvertSurface(src, format, (Uint32)flags);
sdl_surface_to_zval(dst, return_value);
- } else {
+ }
+ else
+ {
RETVAL_NULL();
}
}
@@ -1145,7 +1195,7 @@ PHP_FUNCTION(SDL_ConvertSurface)
/* {{{ proto void SDL_ConvertSurfaceFormat(SDL_Surface src, int format [, int flags])
extern DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurfaceFormat
- (SDL_Surface * src, Uint32 pixel_format, Uint32 flags);
+ (SDL_Surface * src, Uint32 pixel_format, Uint32 flags);
*/
PHP_FUNCTION(SDL_ConvertSurfaceFormat)
{
@@ -1154,7 +1204,8 @@ PHP_FUNCTION(SDL_ConvertSurfaceFormat)
zend_long format, flags = 0;
SDL_Surface *src, *dst;
- if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Ol|l", &z_src, php_sdl_surface_ce, &format, &flags)) {
+ if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Ol|l", &z_src, php_sdl_surface_ce, &format, &flags))
+ {
return;
}
FETCH_SURFACE(src, z_src, 1);
@@ -1169,39 +1220,31 @@ PHP_FUNCTION(SDL_ConvertSurfaceFormat)
*
* \return 0 on success, or -1 if there was an error
extern DECLSPEC int SDLCALL SDL_ConvertPixels(int width, int height,
- Uint32 src_format,
- const void * src, int src_pitch,
- Uint32 dst_format,
- void * dst, int dst_pitch);
+ Uint32 src_format,
+ const void * src, int src_pitch,
+ Uint32 dst_format,
+ void * dst, int dst_pitch);
*/
PHP_FUNCTION(SDL_ConvertPixels)
{
zval *z_src, *z_dst;
- zend_long w, h, sf, sp, df, dp;
+ zend_long w, h, src_format, src_pitch, dst_format, dst_pitch;
SDL_Pixels *src, *dst;
- if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "lllOllOl", &w, &h, &sf, &z_src, get_php_sdl_pixels_ce(), &sp, &df, &z_dst, get_php_sdl_pixels_ce(), &dp)) {
+ if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "lllOllOl", &w, &h, &src_format, &z_src, get_php_sdl_pixels_ce(), &src_pitch, &dst_format, &z_dst, get_php_sdl_pixels_ce(), &dst_pitch))
+ {
return;
}
- if (!(src = zval_to_sdl_pixels(z_src))) {
+ if (!(src = zval_to_sdl_pixels(z_src)))
+ {
php_error_docref(NULL, E_WARNING, "Invalid source SDL_Pixels object");
}
- if (!(dst = zval_to_sdl_pixels(z_dst))) {
+ if (!(dst = zval_to_sdl_pixels(z_dst)))
+ {
php_error_docref(NULL, E_WARNING, "Invalid destination SDL_Pixels object");
}
- if (h < 0 || h > src->h || h > dst->h) {
- h = (src->h > dst->h ? dst->h : src->h);
- php_error_docref(NULL, E_NOTICE, "Bad value for height, will use %ld", h);\
- }
- if (sp != src->pitch) {
- sp = src->pitch;
- php_error_docref(NULL, E_NOTICE, "Bad value for source pitch, will use %ld", sp);\
- }
- if (dp != dst->pitch) {
- dp = dst->pitch;
- php_error_docref(NULL, E_NOTICE, "Bad value for destination pitch, will use %ld", dp);\
- }
- RETVAL_LONG(SDL_ConvertPixels(w, h, sf, src->pixels, sp, df, src->pixels, dp));
+
+ RETVAL_LONG(SDL_ConvertPixels(w, h, src_format, src->pixels, src_pitch, dst_format, dst->pixels, dst_pitch));
}
/* }}} */
@@ -1210,53 +1253,54 @@ PHP_FUNCTION(SDL_ConvertPixels)
#undef SDL_BlitScaled
static const zend_function_entry php_sdl_surface_methods[] = {
- PHP_ME(SDL_Surface, __construct, arginfo_SDL_CreateRGBSurface, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC)
- PHP_ME(SDL_Surface, __toString, arginfo_surface_none, ZEND_ACC_PUBLIC)
+ PHP_ME(SDL_Surface, __construct, arginfo_SDL_CreateRGBSurface, ZEND_ACC_CTOR | ZEND_ACC_PUBLIC)
+ PHP_ME(SDL_Surface, __toString, arginfo_class_SDL_Surface___toString, ZEND_ACC_PUBLIC)
/* non-static methods */
- PHP_FALIAS(Free, SDL_FreeSurface, arginfo_surface_none)
- PHP_FALIAS(FillRect, SDL_FillRect, arginfo_SDL_Surface_FillRect)
- PHP_FALIAS(FillRects, SDL_FillRects, arginfo_SDL_Surface_FillRects)
- PHP_FALIAS(MustLock, SDL_MUSTLOCK, arginfo_surface_none)
- PHP_FALIAS(Lock, SDL_LockSurface, arginfo_surface_none)
- PHP_FALIAS(Unlock, SDL_UnlockSurface, arginfo_surface_none)
- PHP_FALIAS(Blit, SDL_UpperBlit, arginfo_SDL_Surface_UpperBlit)
- PHP_FALIAS(UpperBlit, SDL_UpperBlit, arginfo_SDL_Surface_UpperBlit)
- PHP_FALIAS(LowerBlit, SDL_LowerBlit, arginfo_SDL_Surface_LowerBlit)
- PHP_FALIAS(BlitScaled, SDL_UpperBlitScaled, arginfo_SDL_Surface_UpperBlit)
- PHP_FALIAS(UpperBlitScaled, SDL_UpperBlitScaled, arginfo_SDL_Surface_UpperBlit)
- PHP_FALIAS(LowerBlitScaled, SDL_LowerBlitScaled, arginfo_SDL_Surface_LowerBlit)
- PHP_FALIAS(SoftStretch, SDL_SoftStretch, arginfo_SDL_Surface_UpperBlit)
- PHP_FALIAS(SaveBMP_RW, SDL_SaveBMP_RW, arginfo_SDL_Surface_SaveBMP_RW)
- PHP_FALIAS(SaveBMP, SDL_SaveBMP, arginfo_SDL_Surface_SaveBMP)
- PHP_FALIAS(SetRLE, SDL_SetSurfaceRLE, arginfo_SDL_Surface_SetRLE)
- PHP_FALIAS(SetColorKey, SDL_SetColorKey, arginfo_SDL_Surface_SetColorKey)
- PHP_FALIAS(GetColorKey, SDL_GetColorKey, arginfo_SDL_Surface_GetColorKey)
- PHP_FALIAS(SetColorMod, SDL_SetSurfaceColorMod, arginfo_SDL_Surface_SetColorMod)
- PHP_FALIAS(GetColorMod, SDL_GetSurfaceColorMod, arginfo_SDL_Surface_GetColorMod)
- PHP_FALIAS(SetAlphaMod, SDL_SetSurfaceAlphaMod, arginfo_SDL_Surface_SetAlphaMod)
- PHP_FALIAS(GetAlphaMod, SDL_GetSurfaceAlphaMod, arginfo_SDL_Surface_GetAlphaMod)
- PHP_FALIAS(SetBlendMode, SDL_SetSurfaceBlendMode, arginfo_SDL_Surface_SetBlendMode)
- PHP_FALIAS(GetBlendMode, SDL_GetSurfaceBlendMode, arginfo_SDL_Surface_GetBlendMode)
- PHP_FALIAS(SetClipRect, SDL_SetClipRect, arginfo_SDL_Surface_SetClipRect)
- PHP_FALIAS(GetClipRect, SDL_GetClipRect, arginfo_SDL_Surface_GetClipRect)
- PHP_FALIAS(Convert, SDL_ConvertSurface, arginfo_SDL_Surface_Convert)
- PHP_FALIAS(ConvertFormat, SDL_ConvertSurfaceFormat, arginfo_SDL_Surface_ConvertFormat)
+ PHP_FALIAS(Free, SDL_FreeSurface, arginfo_surface_none)
+ PHP_FALIAS(FillRect, SDL_FillRect, arginfo_SDL_Surface_FillRect)
+ PHP_FALIAS(FillRects, SDL_FillRects, arginfo_SDL_Surface_FillRects)
+ PHP_FALIAS(MustLock, SDL_MUSTLOCK, arginfo_surface_none)
+ PHP_FALIAS(Lock, SDL_LockSurface, arginfo_surface_none)
+ PHP_FALIAS(Unlock, SDL_UnlockSurface, arginfo_surface_none)
+ PHP_FALIAS(Blit, SDL_UpperBlit, arginfo_SDL_Surface_UpperBlit)
+ PHP_FALIAS(UpperBlit, SDL_UpperBlit, arginfo_SDL_Surface_UpperBlit)
+ PHP_FALIAS(LowerBlit, SDL_LowerBlit, arginfo_SDL_Surface_LowerBlit)
+ PHP_FALIAS(BlitScaled, SDL_UpperBlitScaled, arginfo_SDL_Surface_UpperBlit)
+ PHP_FALIAS(UpperBlitScaled, SDL_UpperBlitScaled, arginfo_SDL_Surface_UpperBlit)
+ PHP_FALIAS(LowerBlitScaled, SDL_LowerBlitScaled, arginfo_SDL_Surface_LowerBlit)
+ PHP_FALIAS(SoftStretch, SDL_SoftStretch, arginfo_SDL_Surface_UpperBlit)
+ PHP_FALIAS(SaveBMP_RW, SDL_SaveBMP_RW, arginfo_SDL_Surface_SaveBMP_RW)
+ PHP_FALIAS(SaveBMP, SDL_SaveBMP, arginfo_SDL_Surface_SaveBMP)
+ PHP_FALIAS(SetRLE, SDL_SetSurfaceRLE, arginfo_SDL_Surface_SetRLE)
+ PHP_FALIAS(SetColorKey, SDL_SetColorKey, arginfo_SDL_Surface_SetColorKey)
+ PHP_FALIAS(GetColorKey, SDL_GetColorKey, arginfo_SDL_Surface_GetColorKey)
+ PHP_FALIAS(SetColorMod, SDL_SetSurfaceColorMod, arginfo_SDL_Surface_SetColorMod)
+ PHP_FALIAS(GetColorMod, SDL_GetSurfaceColorMod, arginfo_SDL_Surface_GetColorMod)
+ PHP_FALIAS(SetAlphaMod, SDL_SetSurfaceAlphaMod, arginfo_SDL_Surface_SetAlphaMod)
+ PHP_FALIAS(GetAlphaMod, SDL_GetSurfaceAlphaMod, arginfo_SDL_Surface_GetAlphaMod)
+ PHP_FALIAS(SetBlendMode, SDL_SetSurfaceBlendMode, arginfo_SDL_Surface_SetBlendMode)
+ PHP_FALIAS(GetBlendMode, SDL_GetSurfaceBlendMode, arginfo_SDL_Surface_GetBlendMode)
+ PHP_FALIAS(SetClipRect, SDL_SetClipRect, arginfo_SDL_Surface_SetClipRect)
+ PHP_FALIAS(GetClipRect, SDL_GetClipRect, arginfo_SDL_Surface_GetClipRect)
+ PHP_FALIAS(Convert, SDL_ConvertSurface, arginfo_SDL_Surface_Convert)
+ PHP_FALIAS(ConvertFormat, SDL_ConvertSurfaceFormat, arginfo_SDL_Surface_ConvertFormat)
/* static methods */
- ZEND_FENTRY(LoadRW, ZEND_FN(SDL_LoadBMP_RW), arginfo_SDL_LoadBMP_RW, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
- ZEND_FENTRY(LoadBMP, ZEND_FN(SDL_LoadBMP), arginfo_SDL_LoadBMP, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
+ ZEND_FENTRY(LoadRW, ZEND_FN(SDL_LoadBMP_RW), arginfo_SDL_LoadBMP_RW, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
+ ZEND_FENTRY(LoadBMP, ZEND_FN(SDL_LoadBMP), arginfo_SDL_LoadBMP, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
- PHP_FE_END
-};
+ PHP_FE_END};
/* {{{ php_sdl_surface_free
- */
+ */
static void php_sdl_surface_free(zend_object *object)
{
- struct php_sdl_surface *intern = (struct php_sdl_surface*)((char*)object - object->handlers->offset);
- if (intern->surface) {
- if (!(intern->flags & SDL_DONTFREE)) {
+ struct php_sdl_surface *intern = (struct php_sdl_surface *)((char *)object - object->handlers->offset);
+ if (intern->surface)
+ {
+ if (!(intern->flags & SDL_DONTFREE))
+ {
SDL_FreeSurface(intern->surface);
}
}
@@ -1267,72 +1311,87 @@ static void php_sdl_surface_free(zend_object *object)
/* {{{ php_sdl_surface_new
*/
-static zend_object* php_sdl_surface_new(zend_class_entry *class_type)
+static zend_object *php_sdl_surface_new(zend_class_entry *class_type)
{
struct php_sdl_surface *intern;
- intern = (struct php_sdl_surface*)ecalloc(1, sizeof(struct php_sdl_surface) + zend_object_properties_size(class_type));
+ intern = (struct php_sdl_surface *)zend_object_alloc(sizeof(struct php_sdl_surface), class_type);
zend_object_std_init(&intern->zo, class_type);
object_properties_init(&intern->zo, class_type);
intern->surface = NULL;
- intern->zo.handlers = (zend_object_handlers *) &php_sdl_surface_handlers;
+ intern->zo.handlers = (zend_object_handlers *)&php_sdl_surface_handlers;
return &intern->zo;
}
/* }}} */
+static inline struct php_sdl_surface *php_sdl_surface_from_obj(zend_object *obj)
+{
+ return (struct php_sdl_surface *)((char *)(obj)-obj->handlers->offset);
+}
+
/* {{{ sdl_surface_read_property*/
-zval *sdl_surface_read_property(zval *object, zval *member, int type, void** cache_slot, zval *retval)
+zval *sdl_surface_read_property(zend_object *object, zend_string *member, int type, void **cache_slot, zval *retval)
{
- zval tmp_member;
- zend_object* zobject = Z_OBJ_P(object);
- struct php_sdl_surface *intern = (struct php_sdl_surface *)((char*)zobject - zobject->handlers->offset);
+ struct php_sdl_surface *intern;
+ char *member_val;
- if (!intern->surface) {
- ZVAL_NULL(retval);
- return retval;
- }
+ intern = php_sdl_surface_from_obj(object);
+ member_val = ZSTR_VAL(member);
- if (Z_TYPE_P(member) != IS_STRING) {
- tmp_member = *member;
- zval_copy_ctor(&tmp_member);
- convert_to_string(&tmp_member);
- member = &tmp_member;
+ if (!intern->surface)
+ {
+ retval = zend_std_read_property(object, member, type, cache_slot, retval);
+ return retval;
}
- if (!strcmp(Z_STRVAL_P(member), "flags")) {
+ if (!strcmp(member_val, "flags"))
+ {
ZVAL_LONG(retval, intern->surface->flags);
- } else if (!strcmp(Z_STRVAL_P(member), "w")) {
+ }
+ else if (!strcmp(member_val, "w"))
+ {
ZVAL_LONG(retval, intern->surface->w);
- } else if (!strcmp(Z_STRVAL_P(member), "h")) {
+ }
+ else if (!strcmp(member_val, "h"))
+ {
ZVAL_LONG(retval, intern->surface->h);
- } else if (!strcmp(Z_STRVAL_P(member), "pitch")) {
+ }
+ else if (!strcmp(member_val, "pitch"))
+ {
ZVAL_LONG(retval, intern->surface->pitch);
- } else if (!strcmp(Z_STRVAL_P(member), "locked")) {
+ }
+ else if (!strcmp(member_val, "locked"))
+ {
ZVAL_LONG(retval, intern->surface->locked);
- } else if (!strcmp(Z_STRVAL_P(member), "format")) {
+ }
+ else if (!strcmp(member_val, "format"))
+ {
sdl_pixelformat_to_zval(intern->surface->format, retval, SDL_DONTFREE);
- } else if (!strcmp(Z_STRVAL_P(member), "clip_rect")) {
+ }
+ else if (!strcmp(member_val, "clip_rect"))
+ {
sdl_rect_to_zval(&intern->surface->clip_rect, retval);
- } else if (!strcmp(Z_STRVAL_P(member), "pixels")) {
+ }
+ else if (!strcmp(member_val, "pixels"))
+ {
SDL_Pixels pix;
- pix.pitch = intern->surface->pitch;
- pix.h = intern->surface->h;
pix.pixels = (Uint8 *)intern->surface->pixels;
sdl_pixels_to_zval(&pix, retval, SDL_DONTFREE);
- } else {
- return retval;
}
- if (member == &tmp_member) {
- zval_dtor(member);
+ else
+ {
+ retval = zend_std_read_property(object, member, type, cache_slot, retval);
+ return retval;
}
+
return retval;
}
/* }}} */
-#define REGISTER_SURFACE_CLASS_CONST_LONG(const_name, value) \
+#define REGISTER_SURFACE_CLASS_CONST_LONG(const_name, value) \
REGISTER_LONG_CONSTANT("SDL_" const_name, value, CONST_CS | CONST_PERSISTENT); \
zend_declare_class_constant_long(php_sdl_surface_ce, ZEND_STRL(const_name), value)
@@ -1356,14 +1415,14 @@ PHP_MINIT_FUNCTION(sdl_surface)
REGISTER_SURFACE_PROP("w");
REGISTER_SURFACE_PROP("h");
REGISTER_SURFACE_PROP("pitch");
- zend_declare_property_null(get_php_sdl_pixelformat_ce(), ZEND_STRL("format"), ZEND_ACC_PUBLIC);
- zend_declare_property_null(get_php_sdl_rect_ce(), ZEND_STRL("clip_rect"), ZEND_ACC_PUBLIC);
- zend_declare_property_null(get_php_sdl_pixels_ce(), ZEND_STRL("pixels"), ZEND_ACC_PUBLIC);
-
- REGISTER_SURFACE_CLASS_CONST_LONG("SWSURFACE", SDL_SWSURFACE);
- REGISTER_SURFACE_CLASS_CONST_LONG("PREALLOC", SDL_PREALLOC);
- REGISTER_SURFACE_CLASS_CONST_LONG("RLEACCEL", SDL_RLEACCEL);
- REGISTER_SURFACE_CLASS_CONST_LONG("DONTFREE", SDL_DONTFREE);
+ zend_declare_property_null(php_sdl_surface_ce, ZEND_STRL("format"), ZEND_ACC_PUBLIC);
+ zend_declare_property_null(php_sdl_surface_ce, ZEND_STRL("clip_rect"), ZEND_ACC_PUBLIC);
+ zend_declare_property_null(php_sdl_surface_ce, ZEND_STRL("pixels"), ZEND_ACC_PUBLIC);
+
+ REGISTER_SURFACE_CLASS_CONST_LONG("SWSURFACE", SDL_SWSURFACE);
+ REGISTER_SURFACE_CLASS_CONST_LONG("PREALLOC", SDL_PREALLOC);
+ REGISTER_SURFACE_CLASS_CONST_LONG("RLEACCEL", SDL_RLEACCEL);
+ REGISTER_SURFACE_CLASS_CONST_LONG("DONTFREE", SDL_DONTFREE);
return SUCCESS;
}
diff --git a/src/surface.h b/src/surface.h
index 94f98f2..6506f0f 100644
--- a/src/surface.h
+++ b/src/surface.h
@@ -1,6 +1,4 @@
/*
- +----------------------------------------------------------------------+
- | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2018 The PHP Group |
+----------------------------------------------------------------------+
diff --git a/src/timer.c b/src/timer.c
index 67c0af9..9a05500 100644
--- a/src/timer.c
+++ b/src/timer.c
@@ -1,13 +1,11 @@
/*
- +----------------------------------------------------------------------+
- | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2018 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_01.txt |
+ | https://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
diff --git a/src/timer.h b/src/timer.h
index 9babd80..4aecfed 100644
--- a/src/timer.h
+++ b/src/timer.h
@@ -1,6 +1,4 @@
/*
- +----------------------------------------------------------------------+
- | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2018 The PHP Group |
+----------------------------------------------------------------------+
diff --git a/src/version.c b/src/version.c
index 55e8d07..a889e79 100644
--- a/src/version.c
+++ b/src/version.c
@@ -1,13 +1,11 @@
/*
- +----------------------------------------------------------------------+
- | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2016 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_01.txt |
+ | https://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
@@ -61,6 +59,7 @@ PHP_FUNCTION(SDL_GetRevision)
}
/* }}} */
+#ifdef HAVE_SDL_GETREVISIONNUMBER
/* {{{ proto int SDL_GetRevisionNumber()
* \brief Get the revision number of SDL that is linked against your program.
@@ -78,6 +77,7 @@ PHP_FUNCTION(SDL_GetRevisionNumber)
RETURN_LONG(SDL_GetRevisionNumber());
}
/* }}} */
+#endif
/* {{{ proto void SDL_GetVersion(array &version)
@@ -144,7 +144,7 @@ PHP_FUNCTION(SDL_VERSION)
SDL_version version;
zval *version_array;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &version_array) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "z/", &version_array) == FAILURE) {
RETURN_FALSE;
}
SDL_VERSION(&version);
diff --git a/src/version.h b/src/version.h
index 238c4a7..4b08737 100644
--- a/src/version.h
+++ b/src/version.h
@@ -1,6 +1,4 @@
/*
- +----------------------------------------------------------------------+
- | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2018 The PHP Group |
+----------------------------------------------------------------------+
@@ -51,7 +49,9 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_VERSION_ATLEAST, 0, 0, 3)
ZEND_END_ARG_INFO()
PHP_FUNCTION(SDL_GetRevision);
+#ifdef HAVE_SDL_GETREVISIONNUMBER
PHP_FUNCTION(SDL_GetRevisionNumber);
+#endif
PHP_FUNCTION(SDL_GetVersion);
PHP_FUNCTION(SDL_VERSION);
PHP_FUNCTION(SDL_VERSIONNUM);
diff --git a/src/video.c b/src/video.c
index 9b059e5..c77e508 100644
--- a/src/video.c
+++ b/src/video.c
@@ -1,13 +1,11 @@
/*
- +----------------------------------------------------------------------+
- | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2018 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_01.txt |
+ | https://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
@@ -41,7 +39,7 @@ zend_class_entry *get_php_sdl_displaymode_ce(void)
}
#define update_displaymode_prop(z_value, name, value) \
- zend_update_property_long(php_sdl_displaymode_ce, z_value, ZEND_STRL(name), value)
+ zend_update_property_long(php_sdl_displaymode_ce, Z_OBJ_P(z_value), ZEND_STRL(name), value)
zend_bool sdl_displaymode_to_zval(SDL_DisplayMode *display, zval *value)
{
@@ -61,9 +59,9 @@ zend_bool sdl_displaymode_to_zval(SDL_DisplayMode *display, zval *value)
#define read_displaymode_prop(z_value, name, value) \
{ \
zval *val, rv; \
- val = zend_read_property(php_sdl_displaymode_ce, z_value, ZEND_STRL(name), 0, &rv); \
+ val = zend_read_property(php_sdl_displaymode_ce, Z_OBJ_P(z_value), ZEND_STRL(name), 0, &rv); \
convert_to_long(val); \
- Z_LVAL_P(val) = value = (int)Z_LVAL_P(val); \
+ Z_LVAL_P(val) = (value) = (int)Z_LVAL_P(val); \
}
zend_bool zval_to_sdl_displaymode(zval *value, SDL_DisplayMode *display)
@@ -111,6 +109,9 @@ static PHP_METHOD(SDL_DisplayMode, __construct)
}
/* }}} */
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_SDL_DisplayMode___toString, 0, 0, IS_STRING, 0)
+ZEND_END_ARG_INFO()
+
/* {{{ proto SDL_DisplayMode::__toString() */
static PHP_METHOD(SDL_DisplayMode, __toString)
{
@@ -316,7 +317,7 @@ PHP_FUNCTION(SDL_GetDisplayBounds)
SDL_Rect rect;
zval *result;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "lz", &display, &result) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "lz/", &display, &result) == FAILURE) {
RETURN_FALSE;
}
err = SDL_GetDisplayBounds((int)display, &rect);
@@ -526,8 +527,8 @@ PHP_FUNCTION(SDL_DisableScreenSaver)
/* {{{ php_sdl_displaymode_methods[] */
static const zend_function_entry php_sdl_displaymode_methods[] = {
- PHP_ME(SDL_DisplayMode, __construct, arginfo_SDL_DisplayMode__construct, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC)
- PHP_ME(SDL_DisplayMode, __toString, arginfo_video_none, ZEND_ACC_PUBLIC)
+ PHP_ME(SDL_DisplayMode, __construct, arginfo_SDL_DisplayMode__construct, ZEND_ACC_PUBLIC)
+ PHP_ME(SDL_DisplayMode, __toString, arginfo_class_SDL_DisplayMode___toString, ZEND_ACC_PUBLIC)
PHP_FE_END
};
@@ -543,8 +544,8 @@ PHP_MINIT_FUNCTION(sdl_video)
memcpy(&php_sdl_displaymode_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
zend_declare_property_long(php_sdl_displaymode_ce, ZEND_STRL("format"), 0, ZEND_ACC_PUBLIC);
- zend_declare_property_long(php_sdl_displaymode_ce, ZEND_STRL("w"), 0, ZEND_ACC_PUBLIC);
- zend_declare_property_long(php_sdl_displaymode_ce, ZEND_STRL("h"), 0, ZEND_ACC_PUBLIC);
+ zend_declare_property_long(php_sdl_displaymode_ce, ZEND_STRL("w"), 0, ZEND_ACC_PUBLIC);
+ zend_declare_property_long(php_sdl_displaymode_ce, ZEND_STRL("h"), 0, ZEND_ACC_PUBLIC);
zend_declare_property_long(php_sdl_displaymode_ce, ZEND_STRL("refresh_rate"), 0, ZEND_ACC_PUBLIC);
return SUCCESS;
diff --git a/src/video.h b/src/video.h
index 658f166..a158a54 100644
--- a/src/video.h
+++ b/src/video.h
@@ -1,6 +1,4 @@
/*
- +----------------------------------------------------------------------+
- | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2018 The PHP Group |
+----------------------------------------------------------------------+
diff --git a/src/window.c b/src/window.c
index 0cfdfc6..61edf2b 100644
--- a/src/window.c
+++ b/src/window.c
@@ -1,13 +1,11 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) 1997-2022 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_01.txt |
+ | https://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
@@ -30,15 +28,16 @@
static zend_class_entry *php_sdl_window_ce;
static zend_object_handlers php_sdl_window_handlers;
-struct php_sdl_window {
- SDL_Window *window;
+struct php_sdl_window
+{
+ SDL_Window *window;
int flags;
- zend_object zo;
+ zend_object zo;
};
typedef struct php_sdl_window php_sdl_window_t;
-static inline php_sdl_window_t* php_sdl_window_fetch_object(zend_object* obj);
+static inline php_sdl_window_t *php_sdl_window_fetch_object(zend_object *obj);
zend_class_entry *get_php_sdl_window_ce(void)
{
@@ -48,11 +47,12 @@ zend_class_entry *get_php_sdl_window_ce(void)
/* {{{ zval_to_sdl_window */
SDL_Window *zval_to_sdl_window(zval *z_val)
{
- if (z_val && Z_TYPE_P(z_val) == IS_OBJECT && Z_OBJCE_P(z_val) == php_sdl_window_ce) {
- zend_object* zo = Z_OBJ_P(z_val);
+ if (z_val && Z_TYPE_P(z_val) == IS_OBJECT && Z_OBJCE_P(z_val) == php_sdl_window_ce)
+ {
+ zend_object *zo = Z_OBJ_P(z_val);
struct php_sdl_window *intern;
- intern = (struct php_sdl_window*)((char*)zo - zo->handlers->offset);
+ intern = (struct php_sdl_window *)((char *)zo - zo->handlers->offset);
return intern->window;
}
return NULL;
@@ -62,23 +62,24 @@ SDL_Window *zval_to_sdl_window(zval *z_val)
static inline void sdl_window_add_long_property(HashTable *props, const char *name, zend_long value)
{
zval zvalue;
- zend_string *zname = zend_string_init(name, strlen(name), 0);
+ zend_string *zname = zend_string_init(name, strlen(name), 0);
ZVAL_LONG(&zvalue, value);
zend_hash_update(props, zname, &zvalue);
zend_string_release(zname);
}
/* {{{ sdl_window_read_property*/
-static HashTable *sdl_window_get_properties(zval *object)
+static HashTable *sdl_window_get_properties(zend_object *object)
{
HashTable *props;
- zend_string* z_string;
+ zend_string *z_string;
zval zv;
- struct php_sdl_window* intern = php_sdl_window_fetch_object(Z_OBJ_P(object));
+ struct php_sdl_window *intern = php_sdl_window_fetch_object(object);
props = zend_std_get_properties(object);
- if (intern->window) {
+ if (intern->window)
+ {
int w, h, x, y;
SDL_GetWindowSize(intern->window, &w, &h);
@@ -90,7 +91,7 @@ static HashTable *sdl_window_get_properties(zval *object)
sdl_window_add_long_property(props, "w", w);
sdl_window_add_long_property(props, "h", h);
ZVAL_STRING(&zv, SDL_GetWindowTitle(intern->window));
- z_string = zend_string_init("title", 6, 0);
+ z_string = zend_string_init("title", 6, 0);
zend_hash_update(props, z_string, &zv);
zend_string_release(z_string);
}
@@ -98,22 +99,22 @@ static HashTable *sdl_window_get_properties(zval *object)
}
/* }}} */
-static inline php_sdl_window_t* php_sdl_window_fetch_object(zend_object* obj)
+static inline php_sdl_window_t *php_sdl_window_fetch_object(zend_object *obj)
{
- return (php_sdl_window_t*) ((char*) obj - XtOffsetOf(php_sdl_window_t, zo));
-}
-
-#define FETCH_WINDOW(__ptr, __id, __check) \
-{ \
- zend_object* zox = Z_OBJ_P(__id);\
- intern = (struct php_sdl_window*)((char*)zox - zox->handlers->offset);\
- __ptr = intern->window; \
- if (__check && !__ptr) {\
- php_error_docref(NULL, E_WARNING, "Invalid %s object", ZSTR_VAL(intern->zo.ce->name));\
- RETURN_FALSE;\
- }\
+ return (php_sdl_window_t *)((char *)obj - XtOffsetOf(php_sdl_window_t, zo));
}
+#define FETCH_WINDOW(__ptr, __id, __check) \
+ { \
+ zend_object *zox = Z_OBJ_P(__id); \
+ intern = (struct php_sdl_window *)((char *)zox - zox->handlers->offset); \
+ __ptr = intern->window; \
+ if (__check && !__ptr) \
+ { \
+ php_error_docref(NULL, E_WARNING, "Invalid %s object", ZSTR_VAL(intern->zo.ce->name)); \
+ RETURN_FALSE; \
+ } \
+ }
/* {{{ proto void SDL_GetWindowDisplayIndex(SDL_Window window)
@@ -129,7 +130,8 @@ PHP_FUNCTION(SDL_GetWindowDisplayIndex)
zval *object;
SDL_Window *window;
- if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_window_ce) == FAILURE) {
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_window_ce) == FAILURE)
+ {
return;
}
FETCH_WINDOW(window, object, 1);
@@ -153,8 +155,8 @@ PHP_FUNCTION(SDL_GetWindowDisplayIndex)
* \sa SDL_GetWindowDisplayMode()
* \sa SDL_SetWindowFullscreen()
extern DECLSPEC int SDLCALL SDL_SetWindowDisplayMode(SDL_Window * window,
- const SDL_DisplayMode
- * mode);
+ const SDL_DisplayMode
+ * mode);
*/
PHP_FUNCTION(SDL_SetWindowDisplayMode)
{
@@ -163,11 +165,13 @@ PHP_FUNCTION(SDL_SetWindowDisplayMode)
SDL_Window *window;
SDL_DisplayMode mode;
- if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OO", &z_window, php_sdl_window_ce, &z_mode, get_php_sdl_displaymode_ce()) == FAILURE) {
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OO", &z_window, php_sdl_window_ce, &z_mode, get_php_sdl_displaymode_ce()) == FAILURE)
+ {
return;
}
FETCH_WINDOW(window, z_window, 1);
- if (zval_to_sdl_displaymode(z_mode, &mode)) {
+ if (zval_to_sdl_displaymode(z_mode, &mode))
+ {
RETVAL_LONG(SDL_SetWindowDisplayMode(window, &mode));
}
}
@@ -181,7 +185,7 @@ PHP_FUNCTION(SDL_SetWindowDisplayMode)
* \sa SDL_SetWindowDisplayMode()
* \sa SDL_SetWindowFullscreen()
extern DECLSPEC int SDLCALL SDL_GetWindowDisplayMode(SDL_Window * window,
- SDL_DisplayMode * mode);
+ SDL_DisplayMode * mode);
*/
PHP_FUNCTION(SDL_GetWindowDisplayMode)
{
@@ -191,12 +195,14 @@ PHP_FUNCTION(SDL_GetWindowDisplayMode)
SDL_DisplayMode mode;
int res;
- if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oz", &z_window, php_sdl_window_ce, &z_mode) == FAILURE) {
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oz", &z_window, php_sdl_window_ce, &z_mode) == FAILURE)
+ {
return;
}
FETCH_WINDOW(window, z_window, 1);
res = SDL_GetWindowDisplayMode(window, &mode);
- if (0==res) {
+ if (0 == res)
+ {
zval_dtor(z_mode);
sdl_displaymode_to_zval(&mode, z_mode);
}
@@ -204,7 +210,6 @@ PHP_FUNCTION(SDL_GetWindowDisplayMode)
}
/* }}} */
-
/* {{{ proto int SDL_GetWindowPixelFormat(SDL_Window window)
* \brief Get the pixel format associated with the window.
@@ -216,7 +221,8 @@ PHP_FUNCTION(SDL_GetWindowPixelFormat)
zval *z_window;
SDL_Window *window;
- if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &z_window, php_sdl_window_ce)) {
+ if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &z_window, php_sdl_window_ce))
+ {
return;
}
FETCH_WINDOW(window, z_window, 1);
@@ -224,7 +230,6 @@ PHP_FUNCTION(SDL_GetWindowPixelFormat)
}
/* }}} */
-
/* {{{ proto int SDL_GetWindowID(SDL_Window window)
* \brief Get the numeric ID of a window, for logging purposes.
@@ -236,7 +241,8 @@ PHP_FUNCTION(SDL_GetWindowID)
zval *z_window;
SDL_Window *window;
- if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &z_window, php_sdl_window_ce)) {
+ if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &z_window, php_sdl_window_ce))
+ {
return;
}
FETCH_WINDOW(window, z_window, 1);
@@ -255,7 +261,8 @@ PHP_FUNCTION(SDL_GetWindowFlags)
zval *z_window;
SDL_Window *window;
- if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &z_window, php_sdl_window_ce)) {
+ if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &z_window, php_sdl_window_ce))
+ {
return;
}
FETCH_WINDOW(window, z_window, 1);
@@ -270,7 +277,7 @@ PHP_FUNCTION(SDL_GetWindowFlags)
* \param window The window for which the icon should be set.
* \param icon The icon for the window.
extern DECLSPEC void SDLCALL SDL_SetWindowIcon(SDL_Window * window,
- SDL_Surface * icon);
+ SDL_Surface * icon);
*/
PHP_FUNCTION(SDL_SetWindowIcon)
{
@@ -279,15 +286,19 @@ PHP_FUNCTION(SDL_SetWindowIcon)
SDL_Window *window;
SDL_Surface *icon;
- if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OO", &z_window, php_sdl_window_ce, &z_icon, get_php_sdl_surface_ce())) {
+ if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OO", &z_window, php_sdl_window_ce, &z_icon, get_php_sdl_surface_ce()))
+ {
return;
}
FETCH_WINDOW(window, z_window, 1);
icon = zval_to_sdl_surface(z_icon);
- if (icon) {
+ if (icon)
+ {
SDL_SetWindowIcon(window, icon);
- } else {
+ }
+ else
+ {
php_error_docref(NULL, E_WARNING, "Invalid SDL_Surface object");
}
}
@@ -299,15 +310,15 @@ PHP_FUNCTION(SDL_SetWindowIcon)
*
* \param window The window to reposition.
* \param x The x coordinate of the window, ::SDL_WINDOWPOS_CENTERED, or
- ::SDL_WINDOWPOS_UNDEFINED.
+ ::SDL_WINDOWPOS_UNDEFINED.
* \param y The y coordinate of the window, ::SDL_WINDOWPOS_CENTERED, or
- ::SDL_WINDOWPOS_UNDEFINED.
+ ::SDL_WINDOWPOS_UNDEFINED.
*
* \note The window coordinate origin is the upper left of the display.
*
* \sa SDL_GetWindowPosition()
extern DECLSPEC void SDLCALL SDL_SetWindowPosition(SDL_Window * window,
- int x, int y);
+ int x, int y);
*/
PHP_FUNCTION(SDL_SetWindowPosition)
{
@@ -316,7 +327,8 @@ PHP_FUNCTION(SDL_SetWindowPosition)
zend_long x, y;
SDL_Window *window;
- if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oll", &z_window, php_sdl_window_ce, &x, &y)) {
+ if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oll", &z_window, php_sdl_window_ce, &x, &y))
+ {
return;
}
FETCH_WINDOW(window, z_window, 1);
@@ -332,14 +344,14 @@ PHP_FUNCTION(SDL_WINDOWPOS_CENTERED_DISPLAY)
{
zend_long display;
- if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "l", &display)) {
+ if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "l", &display))
+ {
return;
}
RETVAL_LONG(SDL_WINDOWPOS_CENTERED_DISPLAY(display));
}
/* }}} */
-
/* {{{ proto int SDL_WINDOWPOS_UNDEFINED_DISPLAY(int)
define SDL_WINDOWPOS_UNDEFINED_DISPLAY(X) (SDL_WINDOWPOS_UNDEFINED_MASK|(X))
@@ -348,7 +360,8 @@ PHP_FUNCTION(SDL_WINDOWPOS_UNDEFINED_DISPLAY)
{
zend_long display;
- if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "l", &display)) {
+ if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "l", &display))
+ {
return;
}
RETVAL_LONG(SDL_WINDOWPOS_UNDEFINED_DISPLAY(display));
@@ -365,32 +378,34 @@ PHP_FUNCTION(SDL_WINDOWPOS_UNDEFINED_DISPLAY)
*
* \sa SDL_SetWindowPosition()
extern DECLSPEC void SDLCALL SDL_GetWindowPosition(SDL_Window * window,
- int *x, int *y);
+ int *x, int *y);
*/
PHP_FUNCTION(SDL_GetWindowPosition)
{
struct php_sdl_window *intern;
- zval *z_window, *z_x=NULL, *z_y=NULL;
+ zval *z_window, *z_x = NULL, *z_y = NULL;
int x, y;
SDL_Window *window;
- if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oz/z/", &z_window, php_sdl_window_ce, &z_x, &z_y)) {
+ if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oz/z/", &z_window, php_sdl_window_ce, &z_x, &z_y))
+ {
return;
}
FETCH_WINDOW(window, z_window, 1);
SDL_GetWindowPosition(window, &x, &y);
- if (z_x) {
+ if (z_x)
+ {
zval_dtor(z_x);
ZVAL_LONG(z_x, x);
}
- if (z_y) {
+ if (z_y)
+ {
zval_dtor(z_y);
ZVAL_LONG(z_y, y);
}
}
/* }}} */
-
/* {{{ proto void SDL_SetWindowSize(SDL Window window, int x, int y)
* \brief Set the size of a window's client area.
@@ -404,7 +419,7 @@ PHP_FUNCTION(SDL_GetWindowPosition)
*
* \sa SDL_GetWindowSize()
extern DECLSPEC void SDLCALL SDL_SetWindowSize(SDL_Window * window, int w,
- int h);
+ int h);
*/
PHP_FUNCTION(SDL_SetWindowSize)
{
@@ -413,7 +428,8 @@ PHP_FUNCTION(SDL_SetWindowSize)
zend_long x, y;
SDL_Window *window;
- if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oll", &z_window, php_sdl_window_ce, &x, &y)) {
+ if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oll", &z_window, php_sdl_window_ce, &x, &y))
+ {
return;
}
FETCH_WINDOW(window, z_window, 1);
@@ -431,32 +447,34 @@ PHP_FUNCTION(SDL_SetWindowSize)
*
* \sa SDL_SetWindowSize()
extern DECLSPEC void SDLCALL SDL_GetWindowSize(SDL_Window * window, int *w,
- int *h);
+ int *h);
*/
PHP_FUNCTION(SDL_GetWindowSize)
{
struct php_sdl_window *intern;
- zval *z_window, *z_x=NULL, *z_y=NULL;
+ zval *z_window, *z_x = NULL, *z_y = NULL;
int x, y;
SDL_Window *window;
- if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oz/z/", &z_window, php_sdl_window_ce, &z_x, &z_y)) {
+ if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oz/z/", &z_window, php_sdl_window_ce, &z_x, &z_y))
+ {
return;
}
FETCH_WINDOW(window, z_window, 1);
SDL_GetWindowSize(window, &x, &y);
- if (z_x) {
+ if (z_x)
+ {
zval_dtor(z_x);
ZVAL_LONG(z_x, x);
}
- if (z_y) {
+ if (z_y)
+ {
zval_dtor(z_y);
ZVAL_LONG(z_y, y);
}
}
/* }}} */
-
/* {{{ proto void SDL_SetWindowMinimumSize(SDL Window window, int x, int y)
* \brief Set the minimum size of a window's client area.
@@ -471,7 +489,7 @@ PHP_FUNCTION(SDL_GetWindowSize)
* \sa SDL_GetWindowMinimumSize()
* \sa SDL_SetWindowMaximumSize()
extern DECLSPEC void SDLCALL SDL_SetWindowMinimumSize(SDL_Window * window,
- int min_w, int min_h);
+ int min_w, int min_h);
*/
PHP_FUNCTION(SDL_SetWindowMinimumSize)
{
@@ -480,7 +498,8 @@ PHP_FUNCTION(SDL_SetWindowMinimumSize)
zend_long x, y;
SDL_Window *window;
- if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oll", &z_window, php_sdl_window_ce, &x, &y)) {
+ if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oll", &z_window, php_sdl_window_ce, &x, &y))
+ {
return;
}
FETCH_WINDOW(window, z_window, 1);
@@ -499,32 +518,34 @@ PHP_FUNCTION(SDL_SetWindowMinimumSize)
* \sa SDL_GetWindowMaximumSize()
* \sa SDL_SetWindowMinimumSize()
extern DECLSPEC void SDLCALL SDL_GetWindowMinimumSize(SDL_Window * window,
- int *w, int *h);
+ int *w, int *h);
*/
PHP_FUNCTION(SDL_GetWindowMinimumSize)
{
struct php_sdl_window *intern;
- zval *z_window, *z_x=NULL, *z_y=NULL;
+ zval *z_window, *z_x = NULL, *z_y = NULL;
int x, y;
SDL_Window *window;
- if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O|zz", &z_window, php_sdl_window_ce, &z_x, &z_y)) {
+ if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O|zz", &z_window, php_sdl_window_ce, &z_x, &z_y))
+ {
return;
}
FETCH_WINDOW(window, z_window, 1);
SDL_GetWindowMinimumSize(window, &x, &y);
- if (z_x) {
+ if (z_x)
+ {
zval_dtor(z_x);
ZVAL_LONG(z_x, x);
}
- if (z_y) {
+ if (z_y)
+ {
zval_dtor(z_y);
ZVAL_LONG(z_y, y);
}
}
/* }}} */
-
/* {{{ proto void SDL_SetWindowMaximumSize(SDL Window window, int x, int y)
* \brief Set the maximum size of a window's client area.
@@ -539,7 +560,7 @@ PHP_FUNCTION(SDL_GetWindowMinimumSize)
* \sa SDL_GetWindowMaximumSize()
* \sa SDL_SetWindowMinimumSize()
extern DECLSPEC void SDLCALL SDL_SetWindowMaximumSize(SDL_Window * window,
- int max_w, int max_h);
+ int max_w, int max_h);
*/
PHP_FUNCTION(SDL_SetWindowMaximumSize)
{
@@ -548,7 +569,8 @@ PHP_FUNCTION(SDL_SetWindowMaximumSize)
zend_long x, y;
SDL_Window *window;
- if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oll", &z_window, php_sdl_window_ce, &x, &y)) {
+ if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oll", &z_window, php_sdl_window_ce, &x, &y))
+ {
return;
}
FETCH_WINDOW(window, z_window, 1);
@@ -567,25 +589,28 @@ PHP_FUNCTION(SDL_SetWindowMaximumSize)
* \sa SDL_GetWindowMinimumSize()
* \sa SDL_SetWindowMaximumSize()
extern DECLSPEC void SDLCALL SDL_GetWindowMaximumSize(SDL_Window * window,
- int *w, int *h);
+ int *w, int *h);
*/
PHP_FUNCTION(SDL_GetWindowMaximumSize)
{
struct php_sdl_window *intern;
- zval *z_window, *z_x=NULL, *z_y=NULL;
+ zval *z_window, *z_x = NULL, *z_y = NULL;
int x, y;
SDL_Window *window;
- if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O|zz", &z_window, php_sdl_window_ce, &z_x, &z_y)) {
+ if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O|zz", &z_window, php_sdl_window_ce, &z_x, &z_y))
+ {
return;
}
FETCH_WINDOW(window, z_window, 1);
SDL_GetWindowMaximumSize(window, &x, &y);
- if (z_x) {
+ if (z_x)
+ {
zval_dtor(z_x);
ZVAL_LONG(z_x, x);
}
- if (z_y) {
+ if (z_y)
+ {
zval_dtor(z_y);
ZVAL_LONG(z_y, y);
}
@@ -607,16 +632,17 @@ PHP_FUNCTION(SDL_GetWindowMaximumSize)
*
* \sa SDL_GetWindowFlags()
extern DECLSPEC void SDLCALL SDL_SetWindowBordered(SDL_Window * window,
- SDL_bool bordered);
+ SDL_bool bordered);
*/
PHP_FUNCTION(SDL_SetWindowBordered)
{
struct php_sdl_window *intern;
zval *z_window;
- zend_bool bordered;
+ bool bordered;
SDL_Window *window;
- if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Ob", &z_window, php_sdl_window_ce, &bordered)) {
+ if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Ob", &z_window, php_sdl_window_ce, &bordered))
+ {
return;
}
FETCH_WINDOW(window, z_window, 1);
@@ -624,7 +650,6 @@ PHP_FUNCTION(SDL_SetWindowBordered)
}
/* }}} */
-
/* {{{ proto void SDL_ShowWindow(SDL_Window window)
* \brief Show a window.
@@ -638,7 +663,8 @@ PHP_FUNCTION(SDL_ShowWindow)
zval *object;
SDL_Window *window;
- if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_window_ce) == FAILURE) {
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_window_ce) == FAILURE)
+ {
return;
}
FETCH_WINDOW(window, object, 1);
@@ -647,7 +673,6 @@ PHP_FUNCTION(SDL_ShowWindow)
}
/* }}} */
-
/* {{{ proto void SDL_HideWindow(SDL_Window window)
* \brief Hide a window.
@@ -661,7 +686,8 @@ PHP_FUNCTION(SDL_HideWindow)
zval *object;
SDL_Window *window;
- if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_window_ce) == FAILURE) {
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_window_ce) == FAILURE)
+ {
return;
}
FETCH_WINDOW(window, object, 1);
@@ -670,7 +696,6 @@ PHP_FUNCTION(SDL_HideWindow)
}
/* }}} */
-
/* {{{ proto void SDL_RaiseWindow(SDL_Window window)
* \brief Raise a window above other windows and set the input focus.
@@ -682,7 +707,8 @@ PHP_FUNCTION(SDL_RaiseWindow)
zval *object;
SDL_Window *window;
- if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_window_ce) == FAILURE) {
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_window_ce) == FAILURE)
+ {
return;
}
FETCH_WINDOW(window, object, 1);
@@ -691,7 +717,6 @@ PHP_FUNCTION(SDL_RaiseWindow)
}
/* }}} */
-
/* {{{ proto void SDL_MaximizeWindow(SDL_Window window)
* \brief Make a window as large as possible.
@@ -705,7 +730,8 @@ PHP_FUNCTION(SDL_MaximizeWindow)
zval *object;
SDL_Window *window;
- if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_window_ce) == FAILURE) {
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_window_ce) == FAILURE)
+ {
return;
}
FETCH_WINDOW(window, object, 1);
@@ -714,7 +740,6 @@ PHP_FUNCTION(SDL_MaximizeWindow)
}
/* }}} */
-
/* {{{ proto void SDL_MinimizeWindow(SDL_Window window)
* \brief Minimize a window to an iconic representation.
@@ -728,7 +753,8 @@ PHP_FUNCTION(SDL_MinimizeWindow)
zval *object;
SDL_Window *window;
- if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_window_ce) == FAILURE) {
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_window_ce) == FAILURE)
+ {
return;
}
FETCH_WINDOW(window, object, 1);
@@ -737,7 +763,6 @@ PHP_FUNCTION(SDL_MinimizeWindow)
}
/* }}} */
-
/* {{{ proto void SDL_RestoreWindow(SDL_Window window)
* \brief Restore the size and position of a minimized or maximized window.
@@ -752,7 +777,8 @@ PHP_FUNCTION(SDL_RestoreWindow)
zval *object;
SDL_Window *window;
- if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_window_ce) == FAILURE) {
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_window_ce) == FAILURE)
+ {
return;
}
FETCH_WINDOW(window, object, 1);
@@ -770,7 +796,7 @@ PHP_FUNCTION(SDL_RestoreWindow)
* \sa SDL_SetWindowDisplayMode()
* \sa SDL_GetWindowDisplayMode()
extern DECLSPEC int SDLCALL SDL_SetWindowFullscreen(SDL_Window * window,
- Uint32 flags);
+ Uint32 flags);
*/
PHP_FUNCTION(SDL_SetWindowFullscreen)
{
@@ -779,7 +805,8 @@ PHP_FUNCTION(SDL_SetWindowFullscreen)
SDL_Window *window;
zend_long flags;
- if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Ol", &object, php_sdl_window_ce, &flags) == FAILURE) {
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Ol", &object, php_sdl_window_ce, &flags) == FAILURE)
+ {
return;
}
FETCH_WINDOW(window, object, 1);
@@ -788,7 +815,6 @@ PHP_FUNCTION(SDL_SetWindowFullscreen)
}
/* }}} */
-
/* {{{ proto void SDL_GetWindowSurface(SDL_Window window)
* \brief Get the SDL surface associated with the window.
@@ -811,7 +837,8 @@ PHP_FUNCTION(SDL_GetWindowSurface)
SDL_Window *window = NULL;
SDL_Surface *surface = NULL;
- if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_window_ce) == FAILURE) {
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_window_ce) == FAILURE)
+ {
return;
}
FETCH_WINDOW(window, object, 1);
@@ -830,8 +857,8 @@ PHP_FUNCTION(SDL_GetWindowSurface)
* \sa SDL_GetWindowSurface()
* \sa SDL_UpdateWindowSurfaceRect()
extern DECLSPEC int SDLCALL SDL_UpdateWindowSurfaceRects(SDL_Window * window,
- const SDL_Rect * rects,
- int numrects);
+ const SDL_Rect * rects,
+ int numrects);
*/
PHP_FUNCTION(SDL_UpdateWindowSurfaceRects)
{
@@ -842,35 +869,46 @@ PHP_FUNCTION(SDL_UpdateWindowSurfaceRects)
SDL_Window *window;
SDL_Rect *rects;
- if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oa|l", &z_window, php_sdl_window_ce, &z_array, &num)) {
+ if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oa|l", &z_window, php_sdl_window_ce, &z_array, &num))
+ {
return;
}
FETCH_WINDOW(window, z_window, 1);
- nb = 0;
+ nb = 0;
max = (int)(num ? num : zend_hash_num_elements(Z_ARRVAL_P(z_array)));
- if (max) {
+ if (max)
+ {
zval *ppzval;
rects = emalloc(max * sizeof(SDL_Rect));
- ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(z_array), ppzval) {
- if (zval_to_sdl_rect(ppzval, rects+nb)) {
- nb++;
- } else {
- php_error_docref(NULL, E_NOTICE, "Ignore rect, not a SDL_Rect object");
- }
+ ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(z_array), ppzval)
+ {
+ if (zval_to_sdl_rect(ppzval, rects + nb))
+ {
+ nb++;
+ }
+ else
+ {
+ php_error_docref(NULL, E_NOTICE, "Ignore rect, not a SDL_Rect object");
+ }
}
ZEND_HASH_FOREACH_END();
}
- if (!nb) {
+ if (!nb)
+ {
php_error_docref(NULL, E_WARNING, "No SDL_Rect provided");
- } else {
- if (num && nbwindow = window;
@@ -1103,8 +1149,8 @@ PHP_FUNCTION(SDL_CreateShapedWindow)
*
* \sa SDL_DestroyWindow()
extern DECLSPEC SDL_Window * SDLCALL SDL_CreateWindow(const char *title,
- int x, int y, int w,
- int h, Uint32 flags);
+ int x, int y, int w,
+ int h, Uint32 flags);
*/
PHP_FUNCTION(SDL_CreateWindow)
{
@@ -1124,7 +1170,8 @@ static PHP_METHOD(SDL_Window, __construct)
intern = php_sdl_window_fetch_object(Z_OBJ_P(getThis()));
zend_replace_error_handling(EH_THROW, NULL, &error_handling);
- if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "slllll", &title, &title_len, &x, &y, &w, &h, &flags)) {
+ if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "slllll", &title, &title_len, &x, &y, &w, &h, &flags))
+ {
zend_restore_error_handling(&error_handling);
return;
}
@@ -1132,41 +1179,49 @@ static PHP_METHOD(SDL_Window, __construct)
intern->window = SDL_CreateWindow(title, x, y, w, h, flags);
intern->flags = 0;
- if (intern->window) {
+ if (intern->window)
+ {
SDL_SetWindowData(intern->window, PHP_SDL_MAGICDATA, (void *)(unsigned long)Z_OBJ_HANDLE_P(getThis()));
- } else {
- zend_throw_exception(zend_exception_get_default(), "Can't create window", 0);
+ }
+ else
+ {
+ zend_throw_exception(zend_ce_exception, "Can't create window", 0);
}
}
/* }}} */
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_SDL_Window___toString, 0, 0, IS_STRING, 0)
+ZEND_END_ARG_INFO()
/* {{{ proto SDL_Window::__toString() */
static PHP_METHOD(SDL_Window, __toString)
{
struct php_sdl_window *intern;
char *buf = NULL;
- int buf_len;
+ int buf_len;
- if (zend_parse_parameters_none() == FAILURE) {
+ if (zend_parse_parameters_none() == FAILURE)
+ {
return;
}
intern = php_sdl_window_fetch_object(Z_OBJ_P(getThis()));
- if (0 && intern->window) {
+ if (0 && intern->window)
+ {
int x, y, w, h;
SDL_GetWindowPosition(intern->window, &x, &y);
SDL_GetWindowSize(intern->window, &w, &h);
buf_len = spprintf(&buf, 0, "SDL_Window(\"%s\",%d,%d,%d,%d,%u)", SDL_GetWindowTitle(intern->window), x, y, w, h, SDL_GetWindowFlags(intern->window));
RETURN_STRINGL(buf, buf_len);
- } else {
+ }
+ else
+ {
RETURN_STRING("SDL_Window()");
}
}
/* }}} */
-
/* {{{ proto SDL_UpdateWindowSurface(SDL_Window window)
* \brief Copy the window surface to the screen.
@@ -1183,7 +1238,8 @@ PHP_FUNCTION(SDL_UpdateWindowSurface)
zval *z_window;
SDL_Window *window;
- if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &z_window, php_sdl_window_ce) == FAILURE) {
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &z_window, php_sdl_window_ce) == FAILURE)
+ {
return;
}
FETCH_WINDOW(window, z_window, 1);
@@ -1191,7 +1247,6 @@ PHP_FUNCTION(SDL_UpdateWindowSurface)
}
/* }}} */
-
/* {{{ proto SDL_DestroyWindow(SDL_Window window)
* \brief Destroy a window.
@@ -1203,7 +1258,8 @@ PHP_FUNCTION(SDL_DestroyWindow)
zval *object;
SDL_Window *window;
- if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_window_ce) == FAILURE) {
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_window_ce) == FAILURE)
+ {
return;
}
FETCH_WINDOW(window, object, 1);
@@ -1213,7 +1269,6 @@ PHP_FUNCTION(SDL_DestroyWindow)
}
/* }}} */
-
/* {{{ proto string SDL_GetWindowTitle(SDL_Window window)
* \brief Get the title of a window, in UTF-8 format.
@@ -1227,7 +1282,8 @@ PHP_FUNCTION(SDL_GetWindowTitle)
zval *object;
SDL_Window *window;
- if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_window_ce) == FAILURE) {
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_window_ce) == FAILURE)
+ {
return;
}
FETCH_WINDOW(window, object, 1);
@@ -1242,7 +1298,7 @@ PHP_FUNCTION(SDL_GetWindowTitle)
*
* \sa SDL_GetWindowTitle()
extern DECLSPEC void SDLCALL SDL_SetWindowTitle(SDL_Window * window,
- const char *title);
+ const char *title);
*/
PHP_FUNCTION(SDL_SetWindowTitle)
{
@@ -1252,7 +1308,8 @@ PHP_FUNCTION(SDL_SetWindowTitle)
char *title;
size_t title_len;
- if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Os", &object, php_sdl_window_ce, &title, &title_len) == FAILURE) {
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Os", &object, php_sdl_window_ce, &title, &title_len) == FAILURE)
+ {
return;
}
FETCH_WINDOW(window, object, 1);
@@ -1261,7 +1318,6 @@ PHP_FUNCTION(SDL_SetWindowTitle)
}
/* }}} */
-
/* {{{ proto bool SDL_IsShapedWindow(SDL_Window window)
* \brief Return whether the given window is a shaped window.
@@ -1278,7 +1334,8 @@ PHP_FUNCTION(SDL_IsShapedWindow)
zval *object;
SDL_Window *window;
- if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_window_ce) == FAILURE) {
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_window_ce) == FAILURE)
+ {
return;
}
FETCH_WINDOW(window, object, 1);
@@ -1310,20 +1367,24 @@ PHP_FUNCTION(SDL_SetWindowShape)
SDL_WindowShapeMode *mode;
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OOO", &z_window, php_sdl_window_ce,
- &z_surface, get_php_sdl_surface_ce(), &z_mode, get_php_sdl_windowshapemode_ce()) == FAILURE) {
+ &z_surface, get_php_sdl_surface_ce(), &z_mode, get_php_sdl_windowshapemode_ce()) == FAILURE)
+ {
return;
}
FETCH_WINDOW(window, z_window, 1);
surface = zval_to_sdl_surface(z_surface);
- mode = zval_to_sdl_windowshapemode(z_mode);
- if (!surface) {
+ mode = zval_to_sdl_windowshapemode(z_mode);
+ if (!surface)
+ {
php_error_docref(NULL, E_WARNING, "Invalid SDL_Surface object");
-
- } else if (!mode) {
+ }
+ else if (!mode)
+ {
php_error_docref(NULL, E_WARNING, "Invalid SDL_WindowShapeMode object");
-
- } else {
- RETVAL_LONG(SDL_SetWindowShape(window, surface, mode));
+ }
+ else
+ {
+ RETVAL_LONG(SDL_SetWindowShape(window, surface, mode));
}
}
/* }}} */
@@ -1351,12 +1412,14 @@ PHP_FUNCTION(SDL_GetShapedWindowMode)
SDL_WindowShapeMode mode;
int ret;
- if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &z_window, php_sdl_window_ce, &z_mode) == FAILURE) {
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &z_window, php_sdl_window_ce, &z_mode) == FAILURE)
+ {
return;
}
FETCH_WINDOW(window, z_window, 1);
ret = SDL_GetShapedWindowMode(window, &mode);
- if (ret==0) {
+ if (ret == 0)
+ {
zval_dtor(z_mode);
sdl_windowshapemode_to_zval(&mode, z_mode);
}
@@ -1365,69 +1428,70 @@ PHP_FUNCTION(SDL_GetShapedWindowMode)
/* }}} */
static const zend_function_entry php_sdl_window_methods[] = {
- PHP_ME(SDL_Window, __construct, arginfo_SDL_CreateWindow, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC)
- PHP_ME(SDL_Window, __toString, arginfo_window_none, ZEND_ACC_PUBLIC)
+ PHP_ME(SDL_Window, __construct, arginfo_SDL_CreateWindow, ZEND_ACC_CTOR | ZEND_ACC_PUBLIC)
+ PHP_ME(SDL_Window, __toString, arginfo_class_SDL_Window___toString, ZEND_ACC_PUBLIC)
/* non-static functions */
- PHP_FALIAS(UpdateSurface, SDL_UpdateWindowSurface, arginfo_window_none)
- PHP_FALIAS(Destroy, SDL_DestroyWindow, arginfo_window_none)
- PHP_FALIAS(GetTitle, SDL_GetWindowTitle, arginfo_window_none)
- PHP_FALIAS(SetTitle, SDL_SetWindowTitle, arginfo_SDL_Window_SetTitle)
- PHP_FALIAS(GetDisplayIndex, SDL_GetWindowDisplayIndex, arginfo_window_none)
- PHP_FALIAS(Show, SDL_ShowWindow, arginfo_window_none)
- PHP_FALIAS(Hide, SDL_HideWindow, arginfo_window_none)
- PHP_FALIAS(Raise, SDL_RaiseWindow, arginfo_window_none)
- PHP_FALIAS(Maximize, SDL_MaximizeWindow, arginfo_window_none)
- PHP_FALIAS(Minimize, SDL_MinimizeWindow, arginfo_window_none)
- PHP_FALIAS(Restore, SDL_RestoreWindow, arginfo_window_none)
- PHP_FALIAS(GetSurface, SDL_GetWindowSurface, arginfo_window_none)
- PHP_FALIAS(SetDisplayMode, SDL_SetWindowDisplayMode, arginfo_SDL_Window_SetDisplayMode)
- PHP_FALIAS(GetDisplayMode, SDL_GetWindowDisplayMode, arginfo_SDL_Window_GetDisplayMode)
- PHP_FALIAS(GetPixelFormat, SDL_GetWindowPixelFormat, arginfo_window_none)
- PHP_FALIAS(GetID, SDL_GetWindowID, arginfo_window_none)
- PHP_FALIAS(GetFlags, SDL_GetWindowFlags, arginfo_window_none)
- PHP_FALIAS(SetIcon, SDL_SetWindowIcon, arginfo_SDL_Window_SetIcon)
- PHP_FALIAS(SetPosition, SDL_SetWindowPosition, arginfo_SDL_Window_SetPosition)
- PHP_FALIAS(GetPosition, SDL_GetWindowPosition, arginfo_SDL_Window_GetPosition)
- PHP_FALIAS(SetSize, SDL_SetWindowSize, arginfo_SDL_Window_SetSize)
- PHP_FALIAS(GetSize, SDL_GetWindowSize, arginfo_SDL_Window_GetSize)
- PHP_FALIAS(SetMinimumSize, SDL_SetWindowMinimumSize, arginfo_SDL_Window_SetPosition)
- PHP_FALIAS(GetMinimumSize, SDL_GetWindowMinimumSize, arginfo_SDL_Window_GetPosition)
- PHP_FALIAS(SetMaximumSize, SDL_SetWindowMaximumSize, arginfo_SDL_Window_SetPosition)
- PHP_FALIAS(GetMaximumSize, SDL_GetWindowMaximumSize, arginfo_SDL_Window_GetPosition)
- PHP_FALIAS(SetBordered, SDL_SetWindowBordered, arginfo_SDL_Window_SetBordered)
- PHP_FALIAS(SetFullscreen, SDL_SetWindowFullscreen, arginfo_SDL_Window_SetFullscreen)
- PHP_FALIAS(UpdateSurfaceRects, SDL_UpdateWindowSurfaceRects, arginfo_SDL_Window_UpdateSurfaceRects)
- PHP_FALIAS(SetGrab, SDL_SetWindowGrab, arginfo_SDL_Window_SetGrab)
- PHP_FALIAS(GetGrab, SDL_GetWindowGrab, arginfo_window_none)
- PHP_FALIAS(SetBrightness, SDL_SetWindowBrightness, arginfo_SDL_Window_SetBrightness)
- PHP_FALIAS(GetBrightness, SDL_GetWindowBrightness, arginfo_window_none)
- PHP_FALIAS(GetGammaRamp, SDL_GetWindowGammaRamp, arginfo_SDL_Window_GetGammaRamp)
- PHP_FALIAS(GL_CreateContext, SDL_GL_CreateContext, arginfo_window_none)
- PHP_FALIAS(GL_MakeCurrent, SDL_GL_MakeCurrent, arginfo_SDL_GLContext)
-#if SDL_VERSION_ATLEAST(2,0,1)
- PHP_FALIAS(GL_GetDrawableSize, SDL_GL_GetDrawableSize, arginfo_SDL_Window_GetPosition)
+ PHP_FALIAS(UpdateSurface, SDL_UpdateWindowSurface, arginfo_window_none)
+ PHP_FALIAS(Destroy, SDL_DestroyWindow, arginfo_window_none)
+ PHP_FALIAS(GetTitle, SDL_GetWindowTitle, arginfo_window_none)
+ PHP_FALIAS(SetTitle, SDL_SetWindowTitle, arginfo_SDL_Window_SetTitle)
+ PHP_FALIAS(GetDisplayIndex, SDL_GetWindowDisplayIndex, arginfo_window_none)
+ PHP_FALIAS(Show, SDL_ShowWindow, arginfo_window_none)
+ PHP_FALIAS(Hide, SDL_HideWindow, arginfo_window_none)
+ PHP_FALIAS(Raise, SDL_RaiseWindow, arginfo_window_none)
+ PHP_FALIAS(Maximize, SDL_MaximizeWindow, arginfo_window_none)
+ PHP_FALIAS(Minimize, SDL_MinimizeWindow, arginfo_window_none)
+ PHP_FALIAS(Restore, SDL_RestoreWindow, arginfo_window_none)
+ PHP_FALIAS(GetSurface, SDL_GetWindowSurface, arginfo_window_none)
+ PHP_FALIAS(SetDisplayMode, SDL_SetWindowDisplayMode, arginfo_SDL_Window_SetDisplayMode)
+ PHP_FALIAS(GetDisplayMode, SDL_GetWindowDisplayMode, arginfo_SDL_Window_GetDisplayMode)
+ PHP_FALIAS(GetPixelFormat, SDL_GetWindowPixelFormat, arginfo_window_none)
+ PHP_FALIAS(GetID, SDL_GetWindowID, arginfo_window_none)
+ PHP_FALIAS(GetFlags, SDL_GetWindowFlags, arginfo_window_none)
+ PHP_FALIAS(SetIcon, SDL_SetWindowIcon, arginfo_SDL_Window_SetIcon)
+ PHP_FALIAS(SetPosition, SDL_SetWindowPosition, arginfo_SDL_Window_SetPosition)
+ PHP_FALIAS(GetPosition, SDL_GetWindowPosition, arginfo_SDL_Window_GetPosition)
+ PHP_FALIAS(SetSize, SDL_SetWindowSize, arginfo_SDL_Window_SetSize)
+ PHP_FALIAS(GetSize, SDL_GetWindowSize, arginfo_SDL_Window_GetSize)
+ PHP_FALIAS(SetMinimumSize, SDL_SetWindowMinimumSize, arginfo_SDL_Window_SetPosition)
+ PHP_FALIAS(GetMinimumSize, SDL_GetWindowMinimumSize, arginfo_SDL_Window_GetPosition)
+ PHP_FALIAS(SetMaximumSize, SDL_SetWindowMaximumSize, arginfo_SDL_Window_SetPosition)
+ PHP_FALIAS(GetMaximumSize, SDL_GetWindowMaximumSize, arginfo_SDL_Window_GetPosition)
+ PHP_FALIAS(SetBordered, SDL_SetWindowBordered, arginfo_SDL_Window_SetBordered)
+ PHP_FALIAS(SetFullscreen, SDL_SetWindowFullscreen, arginfo_SDL_Window_SetFullscreen)
+ PHP_FALIAS(UpdateSurfaceRects, SDL_UpdateWindowSurfaceRects, arginfo_SDL_Window_UpdateSurfaceRects)
+ PHP_FALIAS(SetGrab, SDL_SetWindowGrab, arginfo_SDL_Window_SetGrab)
+ PHP_FALIAS(GetGrab, SDL_GetWindowGrab, arginfo_window_none)
+ PHP_FALIAS(SetBrightness, SDL_SetWindowBrightness, arginfo_SDL_Window_SetBrightness)
+ PHP_FALIAS(GetBrightness, SDL_GetWindowBrightness, arginfo_window_none)
+ PHP_FALIAS(GetGammaRamp, SDL_GetWindowGammaRamp, arginfo_SDL_Window_GetGammaRamp)
+ PHP_FALIAS(GL_CreateContext, SDL_GL_CreateContext, arginfo_window_none)
+ PHP_FALIAS(GL_MakeCurrent, SDL_GL_MakeCurrent, arginfo_SDL_GLContext)
+#if SDL_VERSION_ATLEAST(2, 0, 1)
+ PHP_FALIAS(GL_GetDrawableSize, SDL_GL_GetDrawableSize, arginfo_SDL_Window_GetPosition)
#endif
- PHP_FALIAS(GL_Swap, SDL_GL_SwapWindow, arginfo_window_none)
- PHP_FALIAS(WarpMouse, SDL_WarpMouseInWindow, arginfo_SDL_Window_SetPosition)
- PHP_FALIAS(IsShaped, SDL_IsShapedWindow, arginfo_window_none)
- PHP_FALIAS(SetShape, SDL_SetWindowShape, arginfo_SDL_Window_SetShape)
- PHP_FALIAS(GetShapedMode, SDL_GetShapedWindowMode, arginfo_SDL_Window_GetShapedMode)
+ PHP_FALIAS(GL_Swap, SDL_GL_SwapWindow, arginfo_window_none)
+ PHP_FALIAS(WarpMouse, SDL_WarpMouseInWindow, arginfo_SDL_Window_SetPosition)
+ PHP_FALIAS(IsShaped, SDL_IsShapedWindow, arginfo_window_none)
+ PHP_FALIAS(SetShape, SDL_SetWindowShape, arginfo_SDL_Window_SetShape)
+ PHP_FALIAS(GetShapedMode, SDL_GetShapedWindowMode, arginfo_SDL_Window_GetShapedMode)
/* static methods */
- ZEND_FENTRY(GL_GetCurrent, ZEND_FN(SDL_GL_GetCurrentWindow), arginfo_window_none, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
- ZEND_FENTRY(GetMouseFocus, ZEND_FN(SDL_GetMouseFocus), arginfo_window_none, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
+ ZEND_FENTRY(GL_GetCurrent, ZEND_FN(SDL_GL_GetCurrentWindow), arginfo_window_none, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
+ ZEND_FENTRY(GetMouseFocus, ZEND_FN(SDL_GetMouseFocus), arginfo_window_none, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
- PHP_FE_END
-};
+ PHP_FE_END};
/* {{{ php_sdl_window_free
- */
-static void php_sdl_window_free(zend_object* zo)
+ */
+static void php_sdl_window_free(zend_object *zo)
{
- struct php_sdl_window *intern = (struct php_sdl_window*)((char*)zo - zo->handlers->offset);
- if (intern->window) {
- if(!(intern->flags & SDL_DONTFREE)) {
+ struct php_sdl_window *intern = (struct php_sdl_window *)((char *)zo - zo->handlers->offset);
+ if (intern->window)
+ {
+ if (!(intern->flags & SDL_DONTFREE))
+ {
SDL_DestroyWindow(intern->window);
}
}
@@ -1438,19 +1502,19 @@ static void php_sdl_window_free(zend_object* zo)
/* {{{ php_sdl_window_new
*/
-static zend_object* php_sdl_window_new(zend_class_entry *class_type)
+static zend_object *php_sdl_window_new(zend_class_entry *class_type)
{
struct php_sdl_window *intern;
- intern = (struct php_sdl_window*)ecalloc(1, sizeof(struct php_sdl_window) + zend_object_properties_size(class_type));
+ intern = (struct php_sdl_window *)ecalloc(1, sizeof(struct php_sdl_window) + zend_object_properties_size(class_type));
zend_object_std_init(&intern->zo, class_type);
object_properties_init(&intern->zo, class_type);
- intern->window = NULL;
+ intern->window = NULL;
php_sdl_window_handlers.offset = XtOffsetOf(struct php_sdl_window, zo);
- php_sdl_window_handlers.free_obj = php_sdl_window_free;
+ php_sdl_window_handlers.free_obj = php_sdl_window_free;
intern->zo.handlers = &php_sdl_window_handlers;
return &intern->zo;
@@ -1460,12 +1524,13 @@ static zend_object* php_sdl_window_new(zend_class_entry *class_type)
/* {{{ sdl_window_to_zval */
zend_bool sdl_window_to_zval(SDL_Window *window, zval *z_val, int flags)
{
- if (window) {
+ if (window)
+ {
struct php_sdl_window *intern;
object_init_ex(z_val, php_sdl_window_ce);
- zend_object* zo = Z_OBJ_P(z_val);
- intern = (struct php_sdl_window*)((char*)zo - zo->handlers->offset);
+ zend_object *zo = Z_OBJ_P(z_val);
+ intern = (struct php_sdl_window *)((char *)zo - zo->handlers->offset);
intern->window = window;
intern->flags = flags;
@@ -1476,13 +1541,13 @@ zend_bool sdl_window_to_zval(SDL_Window *window, zval *z_val, int flags)
}
/* }}} */
-#define REGISTER_WINDOW_CLASS_CONST_LONG(const_name, value) \
+#define REGISTER_WINDOW_CLASS_CONST_LONG(const_name, value) \
REGISTER_LONG_CONSTANT("SDL_WINDOW_" const_name, value, CONST_CS | CONST_PERSISTENT); \
- zend_declare_class_constant_long(php_sdl_window_ce, ZEND_STRL(const_name), value); \
+ zend_declare_class_constant_long(php_sdl_window_ce, ZEND_STRL(const_name), value);
-#define REGISTER_WINDOWPOS_CLASS_CONST_LONG(const_name, value) \
+#define REGISTER_WINDOWPOS_CLASS_CONST_LONG(const_name, value) \
REGISTER_LONG_CONSTANT("SDL_WINDOWPOS_" const_name, value, CONST_CS | CONST_PERSISTENT); \
- zend_declare_class_constant_long(php_sdl_window_ce, ZEND_STRL("POS_" const_name), value); \
+ zend_declare_class_constant_long(php_sdl_window_ce, ZEND_STRL("POS_" const_name), value);
#define REGISTER_WINDOW_PROP(name) \
zend_declare_property_long(php_sdl_window_ce, ZEND_STRL(name), 0, ZEND_ACC_PUBLIC)
@@ -1507,28 +1572,28 @@ PHP_MINIT_FUNCTION(sdl_window)
REGISTER_WINDOW_PROP("w");
REGISTER_WINDOW_PROP("h");
- zend_declare_property_null(php_sdl_window_ce, ZEND_STRL("title"), ZEND_ACC_PUBLIC);
-
- REGISTER_WINDOW_CLASS_CONST_LONG("FULLSCREEN", SDL_WINDOW_FULLSCREEN);
- REGISTER_WINDOW_CLASS_CONST_LONG("OPENGL", SDL_WINDOW_OPENGL);
- REGISTER_WINDOW_CLASS_CONST_LONG("SHOWN", SDL_WINDOW_SHOWN);
- REGISTER_WINDOW_CLASS_CONST_LONG("HIDDEN", SDL_WINDOW_HIDDEN);
- REGISTER_WINDOW_CLASS_CONST_LONG("BORDERLESS", SDL_WINDOW_BORDERLESS);
- REGISTER_WINDOW_CLASS_CONST_LONG("RESIZABLE", SDL_WINDOW_RESIZABLE);
- REGISTER_WINDOW_CLASS_CONST_LONG("MINIMIZED", SDL_WINDOW_MINIMIZED);
- REGISTER_WINDOW_CLASS_CONST_LONG("MAXIMIZED", SDL_WINDOW_MAXIMIZED);
- REGISTER_WINDOW_CLASS_CONST_LONG("INPUT_GRABBED", SDL_WINDOW_INPUT_GRABBED);
- REGISTER_WINDOW_CLASS_CONST_LONG("INPUT_FOCUS", SDL_WINDOW_INPUT_FOCUS);
- REGISTER_WINDOW_CLASS_CONST_LONG("MOUSE_FOCUS", SDL_WINDOW_MOUSE_FOCUS);
+ zend_declare_property_null(php_sdl_window_ce, ZEND_STRL("title"), ZEND_ACC_PUBLIC);
+
+ REGISTER_WINDOW_CLASS_CONST_LONG("FULLSCREEN", SDL_WINDOW_FULLSCREEN);
+ REGISTER_WINDOW_CLASS_CONST_LONG("OPENGL", SDL_WINDOW_OPENGL);
+ REGISTER_WINDOW_CLASS_CONST_LONG("SHOWN", SDL_WINDOW_SHOWN);
+ REGISTER_WINDOW_CLASS_CONST_LONG("HIDDEN", SDL_WINDOW_HIDDEN);
+ REGISTER_WINDOW_CLASS_CONST_LONG("BORDERLESS", SDL_WINDOW_BORDERLESS);
+ REGISTER_WINDOW_CLASS_CONST_LONG("RESIZABLE", SDL_WINDOW_RESIZABLE);
+ REGISTER_WINDOW_CLASS_CONST_LONG("MINIMIZED", SDL_WINDOW_MINIMIZED);
+ REGISTER_WINDOW_CLASS_CONST_LONG("MAXIMIZED", SDL_WINDOW_MAXIMIZED);
+ REGISTER_WINDOW_CLASS_CONST_LONG("INPUT_GRABBED", SDL_WINDOW_INPUT_GRABBED);
+ REGISTER_WINDOW_CLASS_CONST_LONG("INPUT_FOCUS", SDL_WINDOW_INPUT_FOCUS);
+ REGISTER_WINDOW_CLASS_CONST_LONG("MOUSE_FOCUS", SDL_WINDOW_MOUSE_FOCUS);
REGISTER_WINDOW_CLASS_CONST_LONG("FULLSCREEN_DESKTOP", SDL_WINDOW_FULLSCREEN_DESKTOP);
- REGISTER_WINDOW_CLASS_CONST_LONG("FOREIGN", SDL_WINDOW_FOREIGN);
+ REGISTER_WINDOW_CLASS_CONST_LONG("FOREIGN", SDL_WINDOW_FOREIGN);
#if SDL_COMPILEDVERSION > 2000
- REGISTER_WINDOW_CLASS_CONST_LONG("ALLOW_HIGHDPI", SDL_WINDOW_ALLOW_HIGHDPI);
+ REGISTER_WINDOW_CLASS_CONST_LONG("ALLOW_HIGHDPI", SDL_WINDOW_ALLOW_HIGHDPI);
#endif
- REGISTER_WINDOWPOS_CLASS_CONST_LONG("UNDEFINED_MASK", SDL_WINDOWPOS_UNDEFINED_MASK);
- REGISTER_WINDOWPOS_CLASS_CONST_LONG("UNDEFINED", SDL_WINDOWPOS_UNDEFINED);
- REGISTER_WINDOWPOS_CLASS_CONST_LONG("CENTERED_MASK", SDL_WINDOWPOS_CENTERED_MASK);
- REGISTER_WINDOWPOS_CLASS_CONST_LONG("CENTERED", SDL_WINDOWPOS_CENTERED);
+ REGISTER_WINDOWPOS_CLASS_CONST_LONG("UNDEFINED_MASK", SDL_WINDOWPOS_UNDEFINED_MASK);
+ REGISTER_WINDOWPOS_CLASS_CONST_LONG("UNDEFINED", SDL_WINDOWPOS_UNDEFINED);
+ REGISTER_WINDOWPOS_CLASS_CONST_LONG("CENTERED_MASK", SDL_WINDOWPOS_CENTERED_MASK);
+ REGISTER_WINDOWPOS_CLASS_CONST_LONG("CENTERED", SDL_WINDOWPOS_CENTERED);
return SUCCESS;
}
diff --git a/src/window.h b/src/window.h
index a3d263d..95abb4c 100644
--- a/src/window.h
+++ b/src/window.h
@@ -1,6 +1,4 @@
/*
- +----------------------------------------------------------------------+
- | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2018 The PHP Group |
+----------------------------------------------------------------------+
diff --git a/tests/003-init-and-quit-subsystems.phpt b/tests/003-init-and-quit-subsystems.phpt
index 07976bd..afa0a18 100644
--- a/tests/003-init-and-quit-subsystems.phpt
+++ b/tests/003-init-and-quit-subsystems.phpt
@@ -9,13 +9,13 @@ require 'test-functions.php';
assertEquals(SDL_WasInit(), 0, 'before calling SDL_Init nothing is initialised');
SDL_InitSubSystem(SDL_INIT_AUDIO);
-assertEquals(SDL_WasInit(), SDL_INIT_AUDIO, 'init first subsystem works');
+assertEquals(SDL_WasInit() & ~SDL_INIT_EVENTS, SDL_INIT_AUDIO, 'init first subsystem works');
SDL_InitSubSystem(SDL_INIT_TIMER);
-assertEquals(SDL_WasInit(), SDL_INIT_AUDIO + SDL_INIT_TIMER, 'init two subsystems works');
+assertEquals(SDL_WasInit() & ~SDL_INIT_EVENTS, SDL_INIT_AUDIO + SDL_INIT_TIMER, 'init two subsystems works');
SDL_QuitSubSystem(SDL_INIT_AUDIO);
-assertEquals(SDL_WasInit(), SDL_INIT_TIMER, 'quitting one subsystem works');
+assertEquals(SDL_WasInit() & ~SDL_INIT_EVENTS, SDL_INIT_TIMER, 'quitting one subsystem works');
SDL_Quit();
assertEquals(SDL_WasInit(), 0, 'quitting everything works');
diff --git a/tests/005-video.phpt b/tests/005-video.phpt
index 59e378e..5ed8f2e 100644
--- a/tests/005-video.phpt
+++ b/tests/005-video.phpt
@@ -3,8 +3,6 @@ video group test
--SKIPIF--
--FILE--
@@ -52,9 +50,9 @@ object(SDL_Rect)#1 (4) {
["y"]=>
int(0)
["w"]=>
- int(1680)
+ int(%d)
["h"]=>
- int(1050)
+ int(%d)
}
SDL_GetNumDisplayModes(0):int(%d)
SDL_GetDisplayMode(0,0):object(SDL_DisplayMode)#2 (4) {
diff --git a/tests/006-rect.phpt b/tests/006-rect.phpt
index 151113a..858a4d2 100644
--- a/tests/006-rect.phpt
+++ b/tests/006-rect.phpt
@@ -3,25 +3,38 @@ rect group test, procedural mode
--SKIPIF--
--FILE--
IntersectLine($x1, $y1, $x2, $y2));
+var_dump(SDL_IntersectRectAndLine($r1, $x1, $y1, $x2, $y2));
echo "+++ EnclosePoints\n";
$pts = array(
@@ -63,11 +84,21 @@ var_dump($pts[0]." ".$pts[1]." ".$pts[2]." ".$pts[3]);
var_dump(SDL_EnclosePoints($pts, 0, $r1, $res1), $res1);
$pts[]="foo";
var_dump(SDL_EnclosePoints($pts, 6, $r4, $res2), $res2);
+
+echo "+++ SDL_FRect\n";
+$r = new SDL_FRect(1.1, 2.2, 3.3, 4.4);
+var_dump($r);
+
+echo "+++ SDL_FPoint\n";
+$r = new SDL_FPoint(1.1, 2.2);
+var_dump($r);
+
?>
Done
--EXPECTF--
+++ Empty (true)
-object(SDL_Rect)#1 (4) {
+SDL_Rect(0,0,0,0)
+object(SDL_Rect)#%d (4) {
["x"]=>
int(0)
["y"]=>
@@ -78,8 +109,19 @@ object(SDL_Rect)#1 (4) {
int(0)
}
bool(true)
+object(SDL_FRect)#%d (4) {
+ ["x"]=>
+ float(0)
+ ["y"]=>
+ float(0)
+ ["w"]=>
+ float(0)
+ ["h"]=>
+ float(0)
+}
+bool(true)
+++ Empty (false)
-object(SDL_Rect)#2 (4) {
+object(SDL_Rect)#%d (4) {
["x"]=>
int(1)
["y"]=>
@@ -90,6 +132,17 @@ object(SDL_Rect)#2 (4) {
int(4)
}
bool(false)
+object(SDL_FRect)#%d (4) {
+ ["x"]=>
+ float(1)
+ ["y"]=>
+ float(2)
+ ["w"]=>
+ float(3)
+ ["h"]=>
+ float(4)
+}
+bool(false)
+++ Equal (true)
bool(true)
bool(true)
@@ -99,7 +152,7 @@ bool(false)
+++ Inter (true)
bool(true)
bool(true)
-object(SDL_Rect)#6 (4) {
+object(SDL_Rect)#%d (4) {
["x"]=>
int(16)
["y"]=>
@@ -109,13 +162,28 @@ object(SDL_Rect)#6 (4) {
["h"]=>
int(13)
}
+bool(true)
+bool(true)
+object(SDL_FRect)#%d (4) {
+ ["x"]=>
+ float(16.100000381469727)
+ ["y"]=>
+ float(17.100000381469727)
+ ["w"]=>
+ float(14.100000381469727)
+ ["h"]=>
+ float(13.100000381469727)
+}
+++ Inter (false)
bool(false)
bool(false)
NULL
+bool(false)
+bool(false)
+NULL
+++ Union
NULL
-object(SDL_Rect)#6 (4) {
+object(SDL_Rect)#%d (4) {
["x"]=>
int(10)
["y"]=>
@@ -162,5 +230,23 @@ Warning: SDL_EnclosePoints(): point #4 is not a SDL_Point object in %s/006-rect.
Warning: SDL_EnclosePoints(): point #5 missing in %s/006-rect.php on line %d
bool(false)
NULL
++++ SDL_FRect
+object(SDL_FRect)#%d (4) {
+ ["x"]=>
+ float(1.1)
+ ["y"]=>
+ float(2.2)
+ ["w"]=>
+ float(3.3)
+ ["h"]=>
+ float(4.4)
+}
++++ SDL_FPoint
+object(SDL_FPoint)#%d (2) {
+ ["x"]=>
+ float(1.1)
+ ["y"]=>
+ float(2.2)
+}
Done
diff --git a/tests/007-rect-oo.phpt b/tests/007-rect-oo.phpt
index 61e60b8..3a453ee 100644
--- a/tests/007-rect-oo.phpt
+++ b/tests/007-rect-oo.phpt
@@ -3,25 +3,35 @@ rect group test, object mode
--SKIPIF--
--FILE--
Empty());
+
+$r = new SDL_FRect(.0,.0,.0,.0);
+var_dump($r);
+var_dump($r->Empty());
echo "+++ Empty (false)\n";
$r = new SDL_Rect(1,2,3,4);
var_dump($r, "$r");
var_dump($r->Empty());
+$r = new SDL_FRect(1.1, 2.2, 3.3, 4.4);
+var_dump($r, "$r");
+var_dump($r->Empty());
+
$r1 = new SDL_Rect(10,10,20,20);
$r2 = new SDL_Rect(10,10,20,20);
$r3 = new SDL_Rect(16,17,22,24);
$r4 = new SDL_Rect(100,10,20,20);
+$fr2 = new SDL_FRect(10.1, 10.1, 20.1, 20.1);
+$fr3 = new SDL_FRect(16.1, 17.1, 22.1, 24.1);
+$fr4 = new SDL_FRect(100.1, 10.1, 20.1, 20.1);
+
echo "+++ Equal (true)\n";
var_dump($r1->Equal($r1));
var_dump($r1->Equal($r2));
@@ -34,12 +44,20 @@ var_dump($r2->HasIntersection($r3));
var_dump($r2->Intersect($r3, $x));
var_dump($x); unset($x);
+var_dump($fr2->HasIntersection($fr3));
+var_dump($fr2->Intersect($fr3, $x));
+var_dump($x); unset($x);
+
echo "+++ Inter (false)\n";
var_dump($r2->HasIntersection($r4));
var_dump($r2->Intersect($r4, $x));
var_dump($x); unset($x);
-echo "+++ Uninon\n";
+var_dump($fr2->HasIntersection($fr4));
+var_dump($fr2->Intersect($fr4, $x));
+var_dump($x); unset($x);
+
+echo "+++ Union\n";
var_dump($r2->Union($r3, $x));
var_dump($x); unset($x);
var_dump($r2->Union($r4, $x));
@@ -51,11 +69,16 @@ var_dump($r1->IntersectLine($x1, $y1, $x2, $y2));
var_dump($x1, $y1, $x2, $y2);
$x1=0; $y1=2; $x2=40; $y2=6;
var_dump($r1->IntersectLine($x1, $y1, $x2, $y2));
+
+echo '+++ Test subclasses of SDL_Rect can be passed to SDL functions', PHP_EOL;
+class CustomRect extends \SDL_Rect {}
+$customRect = new CustomRect(10, 20, 30, 40);
+var_dump(SDL_RectEmpty($customRect));
?>
Done
--EXPECTF--
+++ Empty (true)
-object(SDL_Rect)#1 (4) {
+object(SDL_Rect)#%d (4) {
["x"]=>
int(0)
["y"]=>
@@ -67,8 +90,19 @@ object(SDL_Rect)#1 (4) {
}
string(17) "SDL_Rect(0,0,0,0)"
bool(true)
+object(SDL_FRect)#%d (4) {
+ ["x"]=>
+ float(0)
+ ["y"]=>
+ float(0)
+ ["w"]=>
+ float(0)
+ ["h"]=>
+ float(0)
+}
+bool(true)
+++ Empty (false)
-object(SDL_Rect)#2 (4) {
+object(SDL_Rect)#%d (4) {
["x"]=>
int(1)
["y"]=>
@@ -80,6 +114,18 @@ object(SDL_Rect)#2 (4) {
}
string(17) "SDL_Rect(1,2,3,4)"
bool(false)
+object(SDL_FRect)#%d (4) {
+ ["x"]=>
+ float(1.100000023841858)
+ ["y"]=>
+ float(2.200000047683716)
+ ["w"]=>
+ float(3.299999952316284)
+ ["h"]=>
+ float(4.400000095367432)
+}
+string(46) "SDL_FRect(1.100000,2.200000,3.300000,4.400000)"
+bool(false)
+++ Equal (true)
bool(true)
bool(true)
@@ -89,7 +135,7 @@ bool(false)
+++ Inter (true)
bool(true)
bool(true)
-object(SDL_Rect)#6 (4) {
+object(SDL_Rect)#%d (4) {
["x"]=>
int(16)
["y"]=>
@@ -99,13 +145,28 @@ object(SDL_Rect)#6 (4) {
["h"]=>
int(13)
}
+bool(true)
+bool(true)
+object(SDL_FRect)#%d (4) {
+ ["x"]=>
+ float(16.100000381469727)
+ ["y"]=>
+ float(17.100000381469727)
+ ["w"]=>
+ float(14.100000381469727)
+ ["h"]=>
+ float(13.100000381469727)
+}
+++ Inter (false)
bool(false)
bool(false)
NULL
-+++ Uninon
+bool(false)
+bool(false)
+NULL
++++ Union
NULL
-object(SDL_Rect)#6 (4) {
+object(SDL_Rect)#%d (4) {
["x"]=>
int(10)
["y"]=>
@@ -116,7 +177,7 @@ object(SDL_Rect)#6 (4) {
int(31)
}
NULL
-object(SDL_Rect)#6 (4) {
+object(SDL_Rect)#%d (4) {
["x"]=>
int(10)
["y"]=>
@@ -133,5 +194,6 @@ int(15)
int(29)
int(24)
bool(false)
++++ Test subclasses of SDL_Rect can be passed to SDL functions
+bool(false)
Done
-
diff --git a/tests/009-color.phpt b/tests/009-color.phpt
index 12f99cf..3759648 100644
--- a/tests/009-color.phpt
+++ b/tests/009-color.phpt
@@ -3,8 +3,6 @@ SDL_Color test
--SKIPIF--
--FILE--
--FILE--
--FILE--
--FILE--
--FILE--
--INI--
-error_reporting = 32767;
+error_reporting = E_ALL & ~E_DEPRECATED;
--FILE--
@@ -48,7 +46,6 @@ bool(true)
bool(true)
bool(true)
bool(true)
-bool(false)
bool(true)
bool(true)
= Done
diff --git a/tests/017-rwops-stream.phpt b/tests/017-rwops-stream.phpt
index 0d64901..0e89a77 100644
--- a/tests/017-rwops-stream.phpt
+++ b/tests/017-rwops-stream.phpt
@@ -3,13 +3,12 @@ SDL_RWops test, stream mode
--SKIPIF--
--FILE--
size());
echo "read:"; var_dump($ro->read($buf, $size)==$size, strlen($buf)==$size);
diff --git a/tests/018-power.phpt b/tests/018-power.phpt
index 97e9c25..571e426 100644
--- a/tests/018-power.phpt
+++ b/tests/018-power.phpt
@@ -3,7 +3,6 @@ SDL_power test suite
--SKIPIF--
--FILE--
--FILE--
locked);
var_dump(SDL_UnlockSurface($spal), $spal->locked);
echo "= ColorKey\n";
-var_dump(SDL_SetColorKey($spal, 1, 127));
+var_dump(SDL_SetColorKey($spal, true, 127));
var_dump(SDL_GetColorKey($spal, $key), $key);
-var_dump(SDL_SetColorKey($spal, 0));
+var_dump(SDL_SetColorKey($spal, false));
var_dump(SDL_GetColorKey($spal, $key));
-
+var_dump(SDL_GetError());
+SDL_ClearError();
echo "= ColorMod\n";
var_dump(SDL_SetSurfaceColorMod($scol, 1, 2, 3));
var_dump(SDL_GetSurfaceColorMod($scol, $r, $g, $b), $r, $g, $b);
@@ -81,6 +81,7 @@ int(0)
int(127)
int(0)
int(-1)
+string(31) "Surface doesn't have a colorkey"
= ColorMod
int(0)
int(0)
diff --git a/tests/021-surface-oo.phpt b/tests/021-surface-oo.phpt
index fbe91ec..f2b74e6 100644
--- a/tests/021-surface-oo.phpt
+++ b/tests/021-surface-oo.phpt
@@ -3,11 +3,11 @@ SDL_Surface test, procedural mode
--SKIPIF--
--FILE--
w, $spal->h, $spal->format->palette->ncolors, $spal->pixels);
@@ -57,30 +57,18 @@ $scol->Free()
= Done
--EXPECTF--
= Create Palette
-string(40) "SDL_Surface(0,150,100,8,0x0,0x0,0x0,0x0)"
+string(40) "SDL_Surface(%d,150,100,8,0x0,0x0,0x0,0x0)"
int(150)
int(100)
int(256)
-object(SDL_Pixels)#%d (3) {
- ["pitch"]=>
- int(152)
- ["h"]=>
- int(100)
- ["count"]=>
- int(15200)
+object(SDL_Pixels)#%d (0) {
}
= Create True colors
-string(57) "SDL_Surface(0,150,100,32,0xff000000,0xff0000,0xff00,0xff)"
+string(57) "SDL_Surface(%d,150,100,32,0xff000000,0xff0000,0xff00,0xff)"
int(150)
int(100)
NULL
-object(SDL_Pixels)#%d (3) {
- ["pitch"]=>
- int(600)
- ["h"]=>
- int(100)
- ["count"]=>
- int(60000)
+object(SDL_Pixels)#%d (0) {
}
= Lock
bool(false)
diff --git a/tests/022-pixels.phpt b/tests/022-pixels.phpt
index da36f1b..fd0aa8e 100644
--- a/tests/022-pixels.phpt
+++ b/tests/022-pixels.phpt
@@ -3,8 +3,6 @@ SDL_Pixels test
--SKIPIF--
--INI--
error_reporting = 32767;
--FILE--
@@ -16,19 +14,6 @@ try {
echo "Exception: " . $e->getMessage() . "\n";
}
var_dump($pix = new SDL_Pixels(10, 10), "$pix");
-echo "= Get/Set\n";
-var_dump($pix->GetByte(15,15));
-var_dump($pix->SetByte(0,0,1));
-var_dump($pix->GetByte(0,0));
-var_dump($pix->SetByte(1,1,255));
-var_dump($pix->GetByte(1,1));
-
-echo "= Array\n";
-var_dump($pix[20], isset($pix[20]), isset($pix[1000]));
-var_dump($pix[20]=127);
-var_dump($pix[20]);
-unset($pix[20]);
-var_dump($pix[20]);
?>
= Done
--EXPECTF--
@@ -36,28 +21,7 @@ var_dump($pix[20]);
Exception: Invalid size
Notice: SDL_Pixels::__construct(): Pitch set to 12 in %s%e022-pixels.php on line 8
-object(SDL_Pixels)#%d (3) {
- ["pitch"]=>
- int(12)
- ["h"]=>
- int(10)
- ["count"]=>
- int(120)
+object(SDL_Pixels)#%d (0) {
}
-string(17) "SDL_Pixels(12,10)"
-= Get/Set
-
-Notice: SDL_Pixels::GetByte(): Invalid position (15,15) in SDL_Pixels (12,10) in %s%e022-pixels.php on line 10
-bool(false)
-int(0)
-int(1)
-int(0)
-int(255)
-= Array
-int(0)
-bool(true)
-bool(false)
-int(127)
-int(127)
-int(0)
+string(10) "SDL_Pixels"
= Done
diff --git a/tests/028-point.phpt b/tests/028-point.phpt
new file mode 100644
index 0000000..2713cf0
--- /dev/null
+++ b/tests/028-point.phpt
@@ -0,0 +1,25 @@
+--TEST--
+SDL_Point test suite
+--SKIPIF--
+
+SUITE: End
+--EXPECTF--
+SUITE: Start
+TEST: Subclasses of SDL_Point can be converted properly
+SDL_Point(10,20)
+TEST: SDL_FPoint to string
+SDL_FPoint(22.230000,42.430000)
+SUITE: End
diff --git a/tests/029-point-in-rect.phpt b/tests/029-point-in-rect.phpt
new file mode 100644
index 0000000..4fba04c
--- /dev/null
+++ b/tests/029-point-in-rect.phpt
@@ -0,0 +1,17 @@
+--TEST--
+SDL_PointInRect test suite
+--SKIPIF--
+
+SUITE: End
+--EXPECTF--
+SUITE: Start
+bool(false)
+bool(true)
+SUITE: End
diff --git a/tests/test-functions.php b/tests/test-functions.php
index bd93d90..ad0aeea 100644
--- a/tests/test-functions.php
+++ b/tests/test-functions.php
@@ -1,8 +1,10 @@