Skip to content

Some stubs #71

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 100 additions & 0 deletions src/cpuinfo.stub.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<?php

/**
* This function returns the number of CPU cores available.
* @return int
*/
function SDL_GetCPUCount():int {
return 0;
}

/**
* This function returns the L1 cache line size of the CPU
*
* This is useful for determining multi-threaded structure padding or SIMD prefetch sizes.
* @return int
*/
function SDL_GetCPUCacheLineSize():int {
return 0;
}


/**
* This function returns true if the CPU has the RDTSC instruction.
* @return int
*/
function SDL_HasRDTSC():int {
return 0;
}

/**
* This function returns true if the CPU has AltiVec features.
* @return int
*/
function SDL_HasAltiVec():int {
return 0;
}

/**
* This function returns true if the CPU has MMX features.
* @return int
*/
function SDL_HasMMX():int {
return 0;
}

/**
* This function returns true if the CPU has 3DNow! features.
* @return int
*/
function SDL_Has3DNow():int {
return 0;
}

/**
* This function returns true if the CPU has SSE features.
* @return int
*/
function SDL_HasSSE():int {
return 0;
}

/**
* This function returns true if the CPU has HasSSE2 features.
* @return int
*/
function SDL_HasSSE2():int {
return 0;
}

/**
* This function returns true if the CPU has SSE3 features.
* @return int
*/
function SDL_HasSSE3():int {
return 0;
}

/**
* This function returns true if the CPU has SSE4.1 features.
* @return int
*/
function SDL_HasSSE41():int {
return 0;
}

/**
* This function returns true if the CPU has SSE4.2 features.
* @return int
*/
function SDL_HasSSE42():int {
return 0;
}

/**
* This function returns the amount of RAM configured in the system, in MB.
* @return int
*/
function SDL_GetSystemRAM():int {
return 0;
}
26 changes: 26 additions & 0 deletions src/error.stub.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

/**
*
* @param string $error
* @return int unconditionally returns -1.
*/
function SDL_SetError(string $error):int {
return 0;
}

/**
*
* @return string
*/
function SDL_GetError():string {
return '';
}

/**
*
* @return string
*/
function SDL_ClearError():string {
return '';
}
32 changes: 32 additions & 0 deletions src/event.stub.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

class SDL_Event implements Stringable {
public SDL_Window $window;

public function __construct() {
}

public function __toString(): string {
return '';
}
}

/**
* Polls for currently pending events.
* @param null|resource If not NULL, the next event is removed from the queue and stored in that area.
* @return int 1 if there are any pending events, or 0 if there are none available.
*/
function SDL_PollEvent(
mixed $event
):int {
return 0;
}

/**
*
* @param SDL_Event $event
* @return int
*/
function SDL_WaitEvent(SDL_Event $event):int {
return 0;
}
64 changes: 64 additions & 0 deletions src/filesystem.stub.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php


/**
* Get the path where the application resides.
*
* Get the "base path". This is the directory where the application was run from, which is probably the installation directory, and may or may not be the process's current working directory.
*
* This returns an absolute path in UTF-8 encoding, and is guaranteed to end with a path separator ('\\' on Windows, '/' most other places).
*
* The pointer returned by this function is owned by you. Please call SDL_free() on the pointer when you are done with it, or it will be a memory leak. This is not necessarily a fast call, though, so you should call this once near startup and save the string if you need it.
*
* Some platforms can't determine the application's path, and on other platforms, this might be meaningless. In such cases, this function will return NULL.
*
* @param string $org
* @param string $app
* @return null|false|string String of base dir in UTF-8 encoding, or NULL on error.
*/
function SDL_GetPrefPath(
string $org,
string $app,
):null|false|string {
return null;
}

/**
* Get the user-and-app-specific path where files can be written.
*
* Get the "pref dir". This is meant to be where users can write personal files (preferences and save games, etc) that are specific to your application. This directory is unique per user, per application.
*
* This function will decide the appropriate location in the native filesystem, create the directory if necessary, and return a string of the absolute path to the directory in UTF-8 encoding.
*
* On Windows, the string might look like: "C:\\Users\\bob\\AppData\\Roaming\\My Company\\My Program Name\\"
*
* On Linux, the string might look like: "/home/bob/.local/share/My Program Name/"
*
* On Mac OS X, the string might look like: "/Users/bob/Library/Application Support/My Program Name/"
*
* (etc.)
*
* You specify the name of your organization (if it's not a real organization, your name or an Internet domain you own might do) and the name of your application. These should be untranslated proper names.
*
* Both the org and app strings may become part of a directory name, so please follow these rules:
*
* - Try to use the same org string (including case-sensitivity) for
* all your applications that use this function.
* - Always use a unique app string for each one, and make sure it never
* changes for an app once you've decided on it.
* - Unicode characters are legal, as long as it's UTF-8 encoded, but...
* - ...only use letters, numbers, and spaces. Avoid punctuation like
* "Game Name 2: Bad Guy's Revenge!" ... "Game Name 2" is sufficient.
*
* This returns an absolute path in UTF-8 encoding, and is guaranteed to end with a path separator ('\\' on Windows, '/' most other places).
*
* The pointer returned by this function is owned by you. Please call SDL_free() on the pointer when you are done with it, or it will be a memory leak. This is not necessarily a fast call, though, so you should call this once near startup and save the string if you need it.
*
* You should assume the path returned by this function is the only safe place to write files (and that SDL_GetBasePath(), while it might be writable, or even the parent of the returned path, aren't where you should be writing things).
*
* Some platforms can't determine the pref path, and on other platforms, this might be meaningless. In such cases, this function will return NULL.
* @return null|string UTF-8 string of user dir in platform-dependent notation. NULL if there's a problem (creating directory failed, etc).
*/
function SDL_GetBasePath():null|string {
return null;
}
141 changes: 141 additions & 0 deletions src/glcontext.stub.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
<?php

class SDL_GLContext implements Stringable {
public function __construct(
public SDL_Window $window,
) {
}

public function __toString(): string {
return '';
}
}

/**
* Return true if an OpenGL extension is supported for the current context.
* @param string $ext
* @return bool
*/
function SDL_GL_ExtensionSupported(string $ext):bool {
return true;
}

/**
* Set an OpenGL window attribute before window creation.
* @param int $attr
* @param int $value
* @return int
*/
function SDL_GL_SetAttribute(
int $attr,
int $value,
):int {
return 0;
}

/**
* Get the actual value for an attribute from the current context.
* @param int $attr
* @param int &$value
* @return int
*/
function SDL_GL_GetAttribute(
int $attr,
int &$value,
):int {
return 0;
}

/**
* Create an OpenGL context for use with an OpenGL window, and make it current.
* @param SDL_Window $window
* @return void
*/
function SDL_GL_CreateContext(SDL_Window $window):void {
}

/**
* Delete an OpenGL context.
* @param SDL_GLContext $context
* @return void
*/
function SDL_GL_DeleteContext(
SDL_GLContext $context
):void {
}

/**
* Set up an OpenGL context for rendering into an OpenGL window.
*
* The context must have been created with a compatible window.
* @param SDL_Window $window
* @param SDL_GLContext $context
* @return null|int
*/
function SDL_GL_MakeCurrent(
SDL_Window $window,
SDL_GLContext $context,
):null|int {
return null;
}

/**
* Get the currently active OpenGL window.
* @return SDL_Window
*/
function SDL_GL_GetCurrentWindow():SDL_Window {
/** @var SDL_Window $o */
return $o;
}

/**
* Get the currently active OpenGL context.
* @return SDL_GLContext
*/
function SDL_GL_GetCurrentContext():SDL_GLContext {
/** @var SDL_GLContext $o */
return $o;
}

/**
* Get the size of a window's underlying drawable (for use with glViewport).
*
* This may differ from SDL_GetWindowSize if we're rendering to a high-DPI drawable, i.e. the window was created with SDL_WINDOW_ALLOW_HIGHDPI on a platform with high-DPI support (Apple calls this "Retina"), and not disabled by the SDL_HINT_VIDEO_HIGHDPI_DISABLED hint.
* @param SDL_Window $window Window from which the drawable size should be queried
* @param int $w Pointer to variable for storing the width, may be NULL
* @param int $h Pointer to variable for storing the height, may be NULL
* @return void
*/
function SDL_GL_GetDrawableSize(
SDL_Window $window,
int &$w,
int &$h,
):void {
}

/**
* Swap the OpenGL buffers for a window, if double-buffering is supported.
* @param SDL_Window $window
* @return void
*/
function SDL_GL_SwapWindow(
SDL_Window $window
):void {
}

/**
* Set the swap interval for the current OpenGL context.
* @param int $interval 0 for immediate updates, 1 for updates synchronized with the vertical retrace. If the system supports it, you may specify -1 to allow late swaps to happen immediately instead of waiting for the next retrace.
* @return int 0 on success, or -1 if setting the swap interval is not supported.
*/
function SDL_GL_SetSwapInterval(int $interval):int {
return 0;
}

/**
* Get the swap interval for the current OpenGL context.
* @return int 0 if there is no vertical retrace synchronization, 1 if the buffer swap is synchronized with the vertical retrace, and -1 if late swaps happen immediately instead of waiting for the next retrace. If the system can't determine the swap interval, or there isn't a valid current context, this will return 0 as a safe default.
*/
function SDL_GL_GetSwapInterval():int {
return 0;
}
Loading