Compare commits
1 Commits
master
...
1.2.1-supp
Author | SHA1 | Date |
---|---|---|
|
a3a93708d9 |
|
@ -4,5 +4,7 @@ go 1.13
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/ImVexed/muon v0.0.0-20191017043257-ae2a6637f296
|
github.com/ImVexed/muon v0.0.0-20191017043257-ae2a6637f296
|
||||||
golang.org/x/net v0.0.0-20190930134127-c5a3c61f89f3
|
golang.org/x/net v0.0.0-20221002022538-bcab6841153b
|
||||||
)
|
)
|
||||||
|
|
||||||
|
replace github.com/ImVexed/muon v0.0.0-20191017043257-ae2a6637f296 => ../../
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Binary file not shown.
|
@ -0,0 +1 @@
|
||||||
|
.DS_Store
|
|
@ -0,0 +1,182 @@
|
||||||
|
///
|
||||||
|
/// @file App.h
|
||||||
|
///
|
||||||
|
/// @brief The header for the App class.
|
||||||
|
///
|
||||||
|
/// @author
|
||||||
|
///
|
||||||
|
/// This file is a part of Ultralight, a fast, lightweight, HTML UI engine
|
||||||
|
///
|
||||||
|
/// Website: <http://ultralig.ht>
|
||||||
|
///
|
||||||
|
/// Copyright (C) 2019 Ultralight, Inc. All rights reserved.
|
||||||
|
///
|
||||||
|
#pragma once
|
||||||
|
#include "Defines.h"
|
||||||
|
#include <Ultralight/RefPtr.h>
|
||||||
|
#include <Ultralight/Renderer.h>
|
||||||
|
#include <Ultralight/platform/Config.h>
|
||||||
|
|
||||||
|
namespace ultralight {
|
||||||
|
|
||||||
|
class Monitor;
|
||||||
|
class Window;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Interface for all App-related events. @see App::set_listener
|
||||||
|
///
|
||||||
|
class AExport AppListener {
|
||||||
|
public:
|
||||||
|
virtual ~AppListener() {}
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Called whenever the App updates. You should update all app logic here.
|
||||||
|
///
|
||||||
|
/// @note This event is fired right before the run loop calls
|
||||||
|
/// Renderer::Update and Renderer::Render.
|
||||||
|
///
|
||||||
|
virtual void OnUpdate() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
///
|
||||||
|
/// App-specific settings.
|
||||||
|
///
|
||||||
|
struct AExport Settings {
|
||||||
|
///
|
||||||
|
/// The name of the developer of this app.
|
||||||
|
///
|
||||||
|
/// This is used to generate a unique path to store local application data
|
||||||
|
/// on the user's machine.
|
||||||
|
///
|
||||||
|
String developer_name = "MyCompany";
|
||||||
|
|
||||||
|
///
|
||||||
|
/// The name of this app.
|
||||||
|
///
|
||||||
|
/// This is used to generate a unique path to store local application data
|
||||||
|
/// on the user's machine.
|
||||||
|
///
|
||||||
|
String app_name = "MyApp";
|
||||||
|
|
||||||
|
///
|
||||||
|
/// The root file path for our file system. You should set this to the
|
||||||
|
/// relative path where all of your app data is.
|
||||||
|
///
|
||||||
|
/// This will be used to resolve all file URLs, eg file:///page.html
|
||||||
|
///
|
||||||
|
/// @note This relative path is resolved using the following logic:
|
||||||
|
/// - Windows: relative to the executable path
|
||||||
|
/// - Linux: relative to the executable path
|
||||||
|
/// - macOS: relative to YourApp.app/Contents/Resources/
|
||||||
|
///
|
||||||
|
String file_system_path = "./assets/";
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Whether or not we should load and compile shaders from the file system
|
||||||
|
/// (eg, from the /shaders/ path, relative to file_system_path).
|
||||||
|
///
|
||||||
|
/// If this is false (the default), we will instead load pre-compiled shaders
|
||||||
|
/// from memory which speeds up application startup time.
|
||||||
|
///
|
||||||
|
bool load_shaders_from_file_system = false;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// We try to use the GPU renderer when a compatible GPU is detected.
|
||||||
|
///
|
||||||
|
/// Set this to true to force the engine to always use the CPU renderer.
|
||||||
|
///
|
||||||
|
bool force_cpu_renderer = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Main application class.
|
||||||
|
///
|
||||||
|
class AExport App : public RefCounted {
|
||||||
|
public:
|
||||||
|
///
|
||||||
|
/// Create the App singleton.
|
||||||
|
///
|
||||||
|
/// @param settings Settings to customize App runtime behavior.
|
||||||
|
///
|
||||||
|
/// @param config Config options for the Ultralight renderer.
|
||||||
|
///
|
||||||
|
/// @return Returns a ref-pointer to the created App instance.
|
||||||
|
///
|
||||||
|
/// @note You should only create one of these per application lifetime.
|
||||||
|
///
|
||||||
|
/// @note Certain Config options may be overridden during App creation,
|
||||||
|
/// most commonly Config::face_winding and Config::device_scale_hint.
|
||||||
|
///
|
||||||
|
static Ref<App> Create(Settings settings = Settings(), Config config = Config());
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get the App singleton.
|
||||||
|
///
|
||||||
|
static App* instance();
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get the settings this App was created with.
|
||||||
|
///
|
||||||
|
virtual const Settings& settings() const = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Set the main window. You must set this before calling Run.
|
||||||
|
///
|
||||||
|
/// @param window The window to use for all rendering.
|
||||||
|
///
|
||||||
|
/// @note We currently only support one Window per App, this will change
|
||||||
|
/// later once we add support for multiple driver instances.
|
||||||
|
///
|
||||||
|
virtual void set_window(Ref<Window> window) = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get the main window.
|
||||||
|
///
|
||||||
|
virtual RefPtr<Window> window() = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Set an AppListener to receive callbacks for app-related events.
|
||||||
|
///
|
||||||
|
/// @note Ownership remains with the caller.
|
||||||
|
///
|
||||||
|
virtual void set_listener(AppListener* listener) = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get the AppListener, if any.
|
||||||
|
///
|
||||||
|
virtual AppListener* listener() = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Whether or not the App is running.
|
||||||
|
///
|
||||||
|
virtual bool is_running() const = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get the main monitor (this is never NULL).
|
||||||
|
///
|
||||||
|
/// @note We'll add monitor enumeration later.
|
||||||
|
///
|
||||||
|
virtual Monitor* main_monitor() = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get the underlying Renderer instance.
|
||||||
|
///
|
||||||
|
virtual Ref<Renderer> renderer() = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Run the main loop.
|
||||||
|
///
|
||||||
|
/// @note Make sure to call set_window before calling this.
|
||||||
|
///
|
||||||
|
virtual void Run() = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Quit the application.
|
||||||
|
///
|
||||||
|
virtual void Quit() = 0;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual ~App();
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace ultralight
|
|
@ -0,0 +1,6 @@
|
||||||
|
#include <AppCore/App.h>
|
||||||
|
#include <AppCore/Monitor.h>
|
||||||
|
#include <AppCore/Window.h>
|
||||||
|
#include <AppCore/Overlay.h>
|
||||||
|
#include <AppCore/JSHelpers.h>
|
||||||
|
#include <AppCore/Platform.h>
|
|
@ -9,7 +9,7 @@
|
||||||
///
|
///
|
||||||
/// Website: <http://ultralig.ht>
|
/// Website: <http://ultralig.ht>
|
||||||
///
|
///
|
||||||
/// Copyright (C) 2019 Ultralight, Inc. All rights reserved.
|
/// Copyright (C) 2020 Ultralight, Inc. All rights reserved.
|
||||||
///
|
///
|
||||||
#ifndef APPCORE_CAPI_H
|
#ifndef APPCORE_CAPI_H
|
||||||
#define APPCORE_CAPI_H
|
#define APPCORE_CAPI_H
|
||||||
|
@ -56,15 +56,38 @@ ACExport ULSettings ulCreateSettings();
|
||||||
///
|
///
|
||||||
ACExport void ulDestroySettings(ULSettings settings);
|
ACExport void ulDestroySettings(ULSettings settings);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Set the name of the developer of this app.
|
||||||
|
///
|
||||||
|
/// This is used to generate a unique path to store local application data
|
||||||
|
/// on the user's machine.
|
||||||
|
///
|
||||||
|
/// Default is "MyCompany"
|
||||||
|
///
|
||||||
|
ACExport void ulSettingsSetDeveloperName(ULSettings settings, ULString name);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Set the name of this app.
|
||||||
|
///
|
||||||
|
/// This is used to generate a unique path to store local application data
|
||||||
|
/// on the user's machine.
|
||||||
|
///
|
||||||
|
/// Default is "MyApp"
|
||||||
|
///
|
||||||
|
ACExport void ulSettingsSetAppName(ULSettings settings, ULString name);
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Set the root file path for our file system, you should set this to the
|
/// Set the root file path for our file system, you should set this to the
|
||||||
/// relative path where all of your app data is.
|
/// relative path where all of your app data is.
|
||||||
///
|
///
|
||||||
/// This will be used to resolve all file URLs, eg file:///page.html
|
/// This will be used to resolve all file URLs, eg file:///page.html
|
||||||
///
|
///
|
||||||
/// @note By default, on macOS we use the app bundle's @resource_path,
|
/// @note The default path is "./assets/"
|
||||||
/// on all other platforms we use the "./assets/" directory relative
|
///
|
||||||
/// to the executable's directory.
|
/// This relative path is resolved using the following logic:
|
||||||
|
/// - Windows: relative to the executable path
|
||||||
|
/// - Linux: relative to the executable path
|
||||||
|
/// - macOS: relative to YourApp.app/Contents/Resources/
|
||||||
///
|
///
|
||||||
ACExport void ulSettingsSetFileSystemPath(ULSettings settings, ULString path);
|
ACExport void ulSettingsSetFileSystemPath(ULSettings settings, ULString path);
|
||||||
|
|
||||||
|
@ -79,6 +102,13 @@ ACExport void ulSettingsSetLoadShadersFromFileSystem(ULSettings settings,
|
||||||
bool enabled);
|
bool enabled);
|
||||||
|
|
||||||
///
|
///
|
||||||
|
/// We try to use the GPU renderer when a compatible GPU is detected.
|
||||||
|
///
|
||||||
|
/// Set this to true to force the engine to always use the CPU renderer.
|
||||||
|
///
|
||||||
|
ACExport void ulSettingsSetForceCPURenderer(ULSettings settings,
|
||||||
|
bool force_cpu);
|
||||||
|
///
|
||||||
/// Create the App singleton.
|
/// Create the App singleton.
|
||||||
///
|
///
|
||||||
/// @param settings Settings to customize App runtime behavior. You can pass
|
/// @param settings Settings to customize App runtime behavior. You can pass
|
||||||
|
@ -160,12 +190,12 @@ ACExport void ulAppQuit(ULApp app);
|
||||||
ACExport double ulMonitorGetScale(ULMonitor monitor);
|
ACExport double ulMonitorGetScale(ULMonitor monitor);
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Get the width of the monitor (in device coordinates).
|
/// Get the width of the monitor (in pixels).
|
||||||
///
|
///
|
||||||
ACExport unsigned int ulMonitorGetWidth(ULMonitor monitor);
|
ACExport unsigned int ulMonitorGetWidth(ULMonitor monitor);
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Get the height of the monitor (in device coordinates).
|
/// Get the height of the monitor (in pixels).
|
||||||
///
|
///
|
||||||
ACExport unsigned int ulMonitorGetHeight(ULMonitor monitor);
|
ACExport unsigned int ulMonitorGetHeight(ULMonitor monitor);
|
||||||
|
|
||||||
|
@ -206,19 +236,19 @@ typedef void
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Set a callback to be notified when a window resizes
|
/// Set a callback to be notified when a window resizes
|
||||||
/// (parameters are passed back in device coordinates).
|
/// (parameters are passed back in pixels).
|
||||||
///
|
///
|
||||||
ACExport void ulWindowSetResizeCallback(ULWindow window,
|
ACExport void ulWindowSetResizeCallback(ULWindow window,
|
||||||
ULResizeCallback callback,
|
ULResizeCallback callback,
|
||||||
void* user_data);
|
void* user_data);
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Get window width (in device coordinates).
|
/// Get window width (in pixels).
|
||||||
///
|
///
|
||||||
ACExport unsigned int ulWindowGetWidth(ULWindow window);
|
ACExport unsigned int ulWindowGetWidth(ULWindow window);
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Get window height (in device coordinates).
|
/// Get window height (in pixels).
|
||||||
///
|
///
|
||||||
ACExport unsigned int ulWindowGetHeight(ULWindow window);
|
ACExport unsigned int ulWindowGetHeight(ULWindow window);
|
||||||
|
|
||||||
|
@ -257,6 +287,15 @@ ACExport int ulWindowDeviceToPixel(ULWindow window, int val);
|
||||||
///
|
///
|
||||||
ACExport int ulWindowPixelsToDevice(ULWindow window, int val);
|
ACExport int ulWindowPixelsToDevice(ULWindow window, int val);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get the underlying native window handle.
|
||||||
|
///
|
||||||
|
/// @note This is: - HWND on Windows
|
||||||
|
/// - NSWindow* on macOS
|
||||||
|
/// - GLFWwindow* on Linux
|
||||||
|
///
|
||||||
|
ACExport void* ulWindowGetNativeHandle(ULWindow window);
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Create a new Overlay.
|
/// Create a new Overlay.
|
||||||
///
|
///
|
||||||
|
@ -268,10 +307,10 @@ ACExport int ulWindowPixelsToDevice(ULWindow window, int val);
|
||||||
/// @param height The height in device coordinates.
|
/// @param height The height in device coordinates.
|
||||||
///
|
///
|
||||||
/// @param x The x-position (offset from the left of the Window), in
|
/// @param x The x-position (offset from the left of the Window), in
|
||||||
/// device coordinates.
|
/// pixels.
|
||||||
///
|
///
|
||||||
/// @param y The y-position (offset from the top of the Window), in
|
/// @param y The y-position (offset from the top of the Window), in
|
||||||
/// device coordinates.
|
/// pixels.
|
||||||
///
|
///
|
||||||
/// @note Each Overlay is essentially a View and an on-screen quad. You should
|
/// @note Each Overlay is essentially a View and an on-screen quad. You should
|
||||||
/// create the Overlay then load content into the underlying View.
|
/// create the Overlay then load content into the underlying View.
|
||||||
|
@ -279,6 +318,26 @@ ACExport int ulWindowPixelsToDevice(ULWindow window, int val);
|
||||||
ACExport ULOverlay ulCreateOverlay(ULWindow window, unsigned int width,
|
ACExport ULOverlay ulCreateOverlay(ULWindow window, unsigned int width,
|
||||||
unsigned int height, int x, int y);
|
unsigned int height, int x, int y);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Create a new Overlay, wrapping an existing View.
|
||||||
|
///
|
||||||
|
/// @param window The window to create the Overlay in. (we currently only
|
||||||
|
/// support one window per application)
|
||||||
|
///
|
||||||
|
/// @param view The View to wrap (will use its width and height).
|
||||||
|
///
|
||||||
|
/// @param x The x-position (offset from the left of the Window), in
|
||||||
|
/// pixels.
|
||||||
|
///
|
||||||
|
/// @param y The y-position (offset from the top of the Window), in
|
||||||
|
/// pixels.
|
||||||
|
///
|
||||||
|
/// @note Each Overlay is essentially a View and an on-screen quad. You should
|
||||||
|
/// create the Overlay then load content into the underlying View.
|
||||||
|
///
|
||||||
|
ACExport ULOverlay ulCreateOverlayWithView(ULWindow window, ULView view,
|
||||||
|
int x, int y);
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Destroy an overlay.
|
/// Destroy an overlay.
|
||||||
///
|
///
|
||||||
|
@ -290,35 +349,33 @@ ACExport void ulDestroyOverlay(ULOverlay overlay);
|
||||||
ACExport ULView ulOverlayGetView(ULOverlay overlay);
|
ACExport ULView ulOverlayGetView(ULOverlay overlay);
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Get the width (in device coordinates).
|
/// Get the width (in pixels).
|
||||||
///
|
///
|
||||||
ACExport unsigned int ulOverlayGetWidth(ULOverlay overlay);
|
ACExport unsigned int ulOverlayGetWidth(ULOverlay overlay);
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Get the height (in device coordinates).
|
/// Get the height (in pixels).
|
||||||
///
|
///
|
||||||
ACExport unsigned int ulOverlayGetHeight(ULOverlay overlay);
|
ACExport unsigned int ulOverlayGetHeight(ULOverlay overlay);
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Get the x-position (offset from the left of the Window), in device
|
/// Get the x-position (offset from the left of the Window), in pixels.
|
||||||
/// coordinates.
|
|
||||||
///
|
///
|
||||||
ACExport int ulOverlayGetX(ULOverlay overlay);
|
ACExport int ulOverlayGetX(ULOverlay overlay);
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Get the y-position (offset from the top of the Window), in device
|
/// Get the y-position (offset from the top of the Window), in pixels.
|
||||||
/// coordinates.
|
|
||||||
///
|
///
|
||||||
ACExport int ulOverlayGetY(ULOverlay overlay);
|
ACExport int ulOverlayGetY(ULOverlay overlay);
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Move the overlay to a new position (in device coordinates).
|
/// Move the overlay to a new position (in pixels).
|
||||||
///
|
///
|
||||||
ACExport void ulOverlayMoveTo(ULOverlay overlay, int x, int y);
|
ACExport void ulOverlayMoveTo(ULOverlay overlay, int x, int y);
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Resize the overlay (and underlying View), dimensions should be
|
/// Resize the overlay (and underlying View), dimensions should be
|
||||||
/// specified in device coordinates.
|
/// specified in pixels.
|
||||||
///
|
///
|
||||||
ACExport void ulOverlayResize(ULOverlay overlay, unsigned int width,
|
ACExport void ulOverlayResize(ULOverlay overlay, unsigned int width,
|
||||||
unsigned int height);
|
unsigned int height);
|
||||||
|
@ -353,6 +410,37 @@ ACExport void ulOverlayFocus(ULOverlay overlay);
|
||||||
///
|
///
|
||||||
ACExport void ulOverlayUnfocus(ULOverlay overlay);
|
ACExport void ulOverlayUnfocus(ULOverlay overlay);
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
* Platform
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
///
|
||||||
|
/// This is only needed if you are not calling ulCreateApp().
|
||||||
|
///
|
||||||
|
/// Initializes the platform font loader and sets it as the current FontLoader.
|
||||||
|
///
|
||||||
|
ACExport void ulEnablePlatformFontLoader();
|
||||||
|
|
||||||
|
///
|
||||||
|
/// This is only needed if you are not calling ulCreateApp().
|
||||||
|
///
|
||||||
|
/// Initializes the platform file system (needed for loading file:/// URLs) and
|
||||||
|
/// sets it as the current FileSystem.
|
||||||
|
///
|
||||||
|
/// You can specify a base directory path to resolve relative paths against.
|
||||||
|
///
|
||||||
|
ACExport void ulEnablePlatformFileSystem(ULString base_dir);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// This is only needed if you are not calling ulCreateApp().
|
||||||
|
///
|
||||||
|
/// Initializes the default logger (writes the log to a file).
|
||||||
|
///
|
||||||
|
/// You should specify a writable log path to write the log to
|
||||||
|
/// for example "./ultralight.log".
|
||||||
|
///
|
||||||
|
ACExport void ulEnableDefaultLogger(ULString log_path);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -0,0 +1,50 @@
|
||||||
|
// Copyright 2018 Ultralight, Inc. All rights reserved.
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
// Needed for limit defines, like INTMAX_MAX, which is used by the std C++ library
|
||||||
|
#ifndef __STDC_LIMIT_MACROS
|
||||||
|
#define __STDC_LIMIT_MACROS
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include <cstddef>
|
||||||
|
#include <limits.h>
|
||||||
|
|
||||||
|
#ifdef SWIG
|
||||||
|
#define AExport
|
||||||
|
#else
|
||||||
|
|
||||||
|
// Require C++11 Support
|
||||||
|
#if defined(_MSC_VER)
|
||||||
|
# if _MSC_VER < 1800
|
||||||
|
# error This project needs at least Visual Studio 2013 to build
|
||||||
|
# endif
|
||||||
|
#elif __cplusplus <= 199711L
|
||||||
|
# error This project can only be compiled with a compiler that supports C++11
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(__WIN32__) || defined(_WIN32)
|
||||||
|
# if defined(ULTRALIGHT_STATIC_BUILD)
|
||||||
|
# define AExport
|
||||||
|
# else
|
||||||
|
# if defined(APPCORE_IMPLEMENTATION)
|
||||||
|
# define AExport __declspec(dllexport)
|
||||||
|
# else
|
||||||
|
# define AExport __declspec(dllimport)
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
#define _thread_local __declspec(thread)
|
||||||
|
#ifndef _NATIVE_WCHAR_T_DEFINED
|
||||||
|
#define DISABLE_NATIVE_WCHAR_T
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
# if defined(ULTRALIGHT_STATIC_BUILD)
|
||||||
|
# define AExport
|
||||||
|
# else
|
||||||
|
# define AExport __attribute__((visibility("default")))
|
||||||
|
# endif
|
||||||
|
#define _thread_local __thread
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,554 @@
|
||||||
|
#pragma once
|
||||||
|
#include <AppCore/Defines.h>
|
||||||
|
#include <JavaScriptCore/JavaScript.h>
|
||||||
|
#include <JavaScriptCore/JSStringRef.h>
|
||||||
|
#include <Ultralight/String.h>
|
||||||
|
#include <functional>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
namespace ultralight {
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Set the current JSContext.
|
||||||
|
///
|
||||||
|
/// Most JavaScriptCore C API calls require an active JavaScript execution
|
||||||
|
/// context (JSContextRef). You can get the JSContextRef for a page via
|
||||||
|
/// `View::LockJSContext()`. This context changes with each page navigation.
|
||||||
|
///
|
||||||
|
/// **Note**:
|
||||||
|
/// You MUST set a JSContext before using most of the C++ API below.
|
||||||
|
///
|
||||||
|
void AExport SetJSContext(JSContextRef ctx);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get the current JSContext.
|
||||||
|
///
|
||||||
|
JSContextRef AExport GetJSContext();
|
||||||
|
|
||||||
|
///
|
||||||
|
/// JavaScript String wrapper that automatically manages JSStringRef lifetime
|
||||||
|
/// and provides helpful conversions.
|
||||||
|
///
|
||||||
|
class AExport JSString {
|
||||||
|
public:
|
||||||
|
/// Create empty string
|
||||||
|
JSString();
|
||||||
|
|
||||||
|
/// Create from C-string
|
||||||
|
JSString(const char* str);
|
||||||
|
|
||||||
|
/// Create from Ultralight String
|
||||||
|
JSString(const String& str);
|
||||||
|
|
||||||
|
/// Take ownership of existing JSStringRef (will not increase ref-count)
|
||||||
|
JSString(JSStringRef str);
|
||||||
|
|
||||||
|
/// Copy constructor (will increase ref-count)
|
||||||
|
JSString(const JSString& other);
|
||||||
|
|
||||||
|
/// Destructor
|
||||||
|
~JSString();
|
||||||
|
|
||||||
|
/// Assignment operator (will increase ref-count)
|
||||||
|
JSString& operator=(const JSString& other);
|
||||||
|
|
||||||
|
/// Cast to String
|
||||||
|
operator String();
|
||||||
|
|
||||||
|
/// Cast to underlying JSStringRef
|
||||||
|
operator JSStringRef() const { return instance_; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
JSStringRef instance_;
|
||||||
|
};
|
||||||
|
|
||||||
|
class JSArray;
|
||||||
|
class JSObject;
|
||||||
|
class JSFunction;
|
||||||
|
|
||||||
|
/// Tag type used with the JSValue constructor to create "Null" types
|
||||||
|
struct AExport JSValueNullTag {};
|
||||||
|
|
||||||
|
/// Tag type used with the JSValue constructor to create "Undefined" types
|
||||||
|
struct AExport JSValueUndefinedTag {};
|
||||||
|
|
||||||
|
///
|
||||||
|
/// JavaScript variant value wrapper that automatically manages JSValueRef
|
||||||
|
/// lifetime and provides helpful conversions.
|
||||||
|
///
|
||||||
|
class AExport JSValue {
|
||||||
|
public:
|
||||||
|
/// Create null (empty) JSValue
|
||||||
|
JSValue();
|
||||||
|
|
||||||
|
/// Create null JSValue explicitly
|
||||||
|
JSValue(JSValueNullTag);
|
||||||
|
|
||||||
|
/// Create undefined JSValue
|
||||||
|
JSValue(JSValueUndefinedTag);
|
||||||
|
|
||||||
|
/// Create boolean JSValue
|
||||||
|
JSValue(bool val);
|
||||||
|
|
||||||
|
/// Create unsigned integer JSValue (aka, Number) [will be cast to double]
|
||||||
|
JSValue(uint32_t val);
|
||||||
|
|
||||||
|
/// Create integer JSValue (aka, Number) [will be cast to double]
|
||||||
|
JSValue(int32_t val);
|
||||||
|
|
||||||
|
/// Create unsigned integer JSValue (aka, Number) [will be cast to double]
|
||||||
|
JSValue(uint64_t val);
|
||||||
|
|
||||||
|
/// Create integer JSValue (aka, Number) [will be cast to double]
|
||||||
|
JSValue(int64_t val);
|
||||||
|
|
||||||
|
/// Create double JSValue (aka, Number)
|
||||||
|
JSValue(double val);
|
||||||
|
|
||||||
|
/// Create string JSValue
|
||||||
|
JSValue(const char* val);
|
||||||
|
|
||||||
|
/// Create string JSValue
|
||||||
|
JSValue(const String& val);
|
||||||
|
|
||||||
|
/// Create string JSValue
|
||||||
|
JSValue(JSString val);
|
||||||
|
|
||||||
|
/// Create from existing JSValueRef
|
||||||
|
JSValue(JSValueRef val);
|
||||||
|
|
||||||
|
/// Create object JSValue
|
||||||
|
JSValue(JSObjectRef obj);
|
||||||
|
|
||||||
|
/// Copy constructor, a shallow copy is made, the constructed JSValue will
|
||||||
|
/// point to the same JSValueRef.
|
||||||
|
JSValue(const JSValue& other);
|
||||||
|
|
||||||
|
/// Destructor
|
||||||
|
virtual ~JSValue();
|
||||||
|
|
||||||
|
/// A shallow copy is made, this JSValue will point to the same JSValueRef
|
||||||
|
virtual JSValue& operator=(const JSValue& other);
|
||||||
|
|
||||||
|
/// Whether or not the value is a JavaScript Null type.
|
||||||
|
bool IsNull() const;
|
||||||
|
|
||||||
|
/// Whether or not the value is a JavaScript Undefined type.
|
||||||
|
bool IsUndefined() const;
|
||||||
|
|
||||||
|
/// Whether or not the value is a JavaScript Boolean type.
|
||||||
|
bool IsBoolean() const;
|
||||||
|
|
||||||
|
/// Whether or not the value is a JavaScript Number type.
|
||||||
|
bool IsNumber() const;
|
||||||
|
|
||||||
|
/// Whether or not the value is a JavaScript String type.
|
||||||
|
bool IsString() const;
|
||||||
|
|
||||||
|
/// Whether or not the value is a JavaScript Object type.
|
||||||
|
bool IsObject() const;
|
||||||
|
|
||||||
|
/// Whether or not the value is a JavaScript Array type.
|
||||||
|
bool IsArray() const;
|
||||||
|
|
||||||
|
/// Whether or not the value is a JavaScript Function type.
|
||||||
|
bool IsFunction() const;
|
||||||
|
|
||||||
|
/// Get the value as a Boolean
|
||||||
|
bool ToBoolean() const;
|
||||||
|
|
||||||
|
/// Get the value as a Number (Double)
|
||||||
|
double ToNumber() const;
|
||||||
|
|
||||||
|
/// Get the value as a Number (Integer)
|
||||||
|
int64_t ToInteger() const { return static_cast<int64_t>(ToNumber()); }
|
||||||
|
|
||||||
|
/// Get the value as a String
|
||||||
|
JSString ToString() const;
|
||||||
|
|
||||||
|
/// Get the value as an Object (will debug assert if not an Object)
|
||||||
|
JSObject ToObject() const;
|
||||||
|
|
||||||
|
/// Get the value as an Array (will debug asset if not an Array)
|
||||||
|
JSArray ToArray() const;
|
||||||
|
|
||||||
|
/// Get the value as a Function (will debug asset if not a Function)
|
||||||
|
JSFunction ToFunction() const;
|
||||||
|
|
||||||
|
operator bool() const { return ToBoolean(); }
|
||||||
|
|
||||||
|
operator double() const { return ToNumber(); }
|
||||||
|
|
||||||
|
operator uint32_t() const { return static_cast<uint32_t>(ToNumber()); }
|
||||||
|
|
||||||
|
operator int32_t() const { return static_cast<uint32_t>(ToNumber()); }
|
||||||
|
|
||||||
|
operator uint64_t() const { return static_cast<uint64_t>(ToNumber()); }
|
||||||
|
|
||||||
|
operator int64_t() const { return ToInteger(); }
|
||||||
|
|
||||||
|
operator String() const { return ToString(); }
|
||||||
|
|
||||||
|
operator JSString() const { return ToString(); }
|
||||||
|
|
||||||
|
operator JSObject() const;
|
||||||
|
|
||||||
|
operator JSObjectRef() const;
|
||||||
|
|
||||||
|
operator JSArray() const;
|
||||||
|
|
||||||
|
operator JSFunction() const;
|
||||||
|
|
||||||
|
/// Get the underlying JSValueRef
|
||||||
|
operator JSValueRef() const { return instance(); }
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get the bound context for this JSValue (it is cached at creation).
|
||||||
|
///
|
||||||
|
JSContextRef context() const { return ctx_; }
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Set the JSContext for this JSValue.
|
||||||
|
///
|
||||||
|
/// **Note**:
|
||||||
|
/// JSValues created from within a JSCallback have a temporary JSContext
|
||||||
|
/// that is destroyed when the callback returns. You will need to "move"
|
||||||
|
/// any JSValues created within these callbacks to the View's main context
|
||||||
|
/// (call set_context() with the main context) before using them outside
|
||||||
|
/// the callback.
|
||||||
|
///
|
||||||
|
void set_context(JSContextRef context) { ctx_ = context; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
JSValue(JSContextRef ctx);
|
||||||
|
JSValue(JSContextRef ctx, JSValueRef val);
|
||||||
|
virtual JSValueRef instance() const;
|
||||||
|
|
||||||
|
JSContextRef ctx_;
|
||||||
|
JSValueRef instance_ = nullptr;
|
||||||
|
friend class JSFunction;
|
||||||
|
};
|
||||||
|
|
||||||
|
///
|
||||||
|
/// A vector of JSValues, used for passing around arguments in JSCallback.
|
||||||
|
///
|
||||||
|
class AExport JSArgs {
|
||||||
|
public:
|
||||||
|
/// Create an empty list of JavaScript arguments
|
||||||
|
JSArgs();
|
||||||
|
|
||||||
|
/// Create a list of JavaScript arguments using a C++ initializer list
|
||||||
|
JSArgs(const std::initializer_list<JSValue>& values);
|
||||||
|
|
||||||
|
/// Copy-constructor
|
||||||
|
JSArgs(const JSArgs& other);
|
||||||
|
|
||||||
|
/// Destructor
|
||||||
|
~JSArgs();
|
||||||
|
|
||||||
|
/// Assignment operator
|
||||||
|
JSArgs& operator=(const JSArgs& other);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Access an element of the argument list by index.
|
||||||
|
///
|
||||||
|
/// **Note**:
|
||||||
|
/// All JSValues are actually wrappers of JSValueRef instances so even
|
||||||
|
/// though this function doesn't return a JSValue& you are still operating
|
||||||
|
/// directly on the underlying JavaScript value instance.
|
||||||
|
///
|
||||||
|
JSValue operator[](size_t pos);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Access an element of the argument list by index. (const overload)
|
||||||
|
///
|
||||||
|
/// **Note**:
|
||||||
|
/// All JSValues are actually wrappers of JSValueRef instances so even
|
||||||
|
/// though this function doesn't return a JSValue& you are still operating
|
||||||
|
/// directly on the underlying JavaScript value instance.
|
||||||
|
///
|
||||||
|
const JSValue operator[](size_t pos) const;
|
||||||
|
|
||||||
|
/// Whether or not the argument list is empty.
|
||||||
|
bool empty() const;
|
||||||
|
|
||||||
|
/// The number of elements in the argument list.
|
||||||
|
size_t size() const;
|
||||||
|
|
||||||
|
/// Clear the argument list.
|
||||||
|
void clear();
|
||||||
|
|
||||||
|
/// Add a new argument to the end of the list.
|
||||||
|
void push_back(const JSValue& val);
|
||||||
|
|
||||||
|
/// Remove the last item from the end of the list.
|
||||||
|
void pop_back();
|
||||||
|
|
||||||
|
/// Get the argument list as a C-array of JSValues
|
||||||
|
JSValue* data();
|
||||||
|
|
||||||
|
/// Get the argument list as a C-array of JSValues (const overload)
|
||||||
|
const JSValue* data() const;
|
||||||
|
protected:
|
||||||
|
void* instance_;
|
||||||
|
};
|
||||||
|
|
||||||
|
///
|
||||||
|
/// JSCallback typedef used for binding C++ callbacks to JavaScript functions.
|
||||||
|
///
|
||||||
|
/// Takes two arguments (const JSObject& thisObj, const JSArgs& args) and
|
||||||
|
/// returns nothing (void).
|
||||||
|
///
|
||||||
|
typedef std::function<void(const JSObject&, const JSArgs&)> JSCallback;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// JSCallbackWithRetval typedef used for binding C++ callbacks to JavaScript
|
||||||
|
/// functions with an optional return value.
|
||||||
|
///
|
||||||
|
/// Takes two arguments (const JSObject& thisObj, const JSArgs& args) and
|
||||||
|
/// returns a JSValue back to JavaScript.
|
||||||
|
///
|
||||||
|
typedef std::function<JSValue(const JSObject&, const JSArgs&)> JSCallbackWithRetval;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Macro to help bind C++ member functions to a JSCallback
|
||||||
|
///
|
||||||
|
/// Usage: JSCallback callback = BindJSCallback(&MyClass::MyMemberFunction);
|
||||||
|
///
|
||||||
|
/// **Note**: Expected to run from within an instance of 'MyClass', note the
|
||||||
|
/// 'this' keyword in the macro.
|
||||||
|
///
|
||||||
|
#define BindJSCallback(fn) (JSCallback)std::bind(fn, this, std::placeholders::_1, std::placeholders::_2)
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Macro to help bind C++ member functions to a JSCallbackWithRetval
|
||||||
|
///
|
||||||
|
/// Usage: JSCallback callback = BindJSCallback(&MyClass::MyMemberFunction);
|
||||||
|
///
|
||||||
|
/// **Note**: Expected to run from within an instance of 'MyClass', note the
|
||||||
|
/// 'this' keyword in the macro.
|
||||||
|
///
|
||||||
|
#define BindJSCallbackWithRetval(fn) (JSCallbackWithRetval)std::bind(fn, this, std::placeholders::_1, std::placeholders::_2)
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Wrapper for JSObject property value (JSValue subclass). Allows new value assignment
|
||||||
|
/// to object property, binding C++ callbacks to object properties via function objects,
|
||||||
|
/// as well as value query via the JSValue interface.
|
||||||
|
///
|
||||||
|
class AExport JSPropertyValue : public JSValue {
|
||||||
|
public:
|
||||||
|
virtual ~JSPropertyValue();
|
||||||
|
|
||||||
|
/// Assign a new value to the property (internally calls JSObjectSetProperty)
|
||||||
|
virtual JSPropertyValue& operator=(const JSValue& value);
|
||||||
|
|
||||||
|
/// Bind to native C++ callback (creates a Function object that can be called from JS)
|
||||||
|
JSPropertyValue& operator=(const JSCallback& callback);
|
||||||
|
|
||||||
|
/// Bind to native C++ callback with return value (creates a Function object that can be called from JS)
|
||||||
|
JSPropertyValue& operator=(const JSCallbackWithRetval& callback);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual JSValueRef instance() const;
|
||||||
|
JSPropertyValue(JSContextRef ctx, JSObjectRef proxy_obj, unsigned idx);
|
||||||
|
JSPropertyValue(JSContextRef ctx, JSObjectRef proxy_obj, JSString idx);
|
||||||
|
JSPropertyValue(const JSPropertyValue&) = default;
|
||||||
|
JSPropertyValue& operator=(const JSPropertyValue&) = delete;
|
||||||
|
|
||||||
|
JSObject* proxyObj_;
|
||||||
|
bool using_numeric_idx_;
|
||||||
|
unsigned numeric_idx_;
|
||||||
|
JSString string_idx_;
|
||||||
|
friend class JSArray;
|
||||||
|
friend class JSObject;
|
||||||
|
};
|
||||||
|
|
||||||
|
///
|
||||||
|
/// JSArray wrapper that automatically manages lifetime and provides
|
||||||
|
/// convenient access to indices and Array functions.
|
||||||
|
///
|
||||||
|
class AExport JSArray {
|
||||||
|
public:
|
||||||
|
/// Create empty Array
|
||||||
|
JSArray();
|
||||||
|
|
||||||
|
/// Create Array from list of JSValues
|
||||||
|
JSArray(const std::initializer_list<JSValue>& values);
|
||||||
|
|
||||||
|
/// Create Array from existing JSObjectRef (JavaScriptCore C API)
|
||||||
|
JSArray(JSObjectRef array_obj);
|
||||||
|
|
||||||
|
/// Copy constructor (shallow copy, will point to same instance)
|
||||||
|
JSArray(const JSArray& other);
|
||||||
|
|
||||||
|
~JSArray();
|
||||||
|
|
||||||
|
/// Assignment (shallow assignment, will point to same instance)
|
||||||
|
JSArray& operator=(const JSArray& other);
|
||||||
|
|
||||||
|
/// Get number of elements in the Array
|
||||||
|
unsigned length();
|
||||||
|
|
||||||
|
/// Push an element to back of Array
|
||||||
|
void push(const JSValue& val);
|
||||||
|
|
||||||
|
/// Find the index (location) of a certain value, will return -1 if not found
|
||||||
|
int indexOf(const JSValue& val, int start = 0) const;
|
||||||
|
|
||||||
|
/// Get a property by array index (numbering starts at 0)
|
||||||
|
JSPropertyValue operator[](unsigned idx) const;
|
||||||
|
|
||||||
|
/// Get the underlying JSObjectRef (JavaScriptCore C API)
|
||||||
|
operator JSObjectRef() const { return instance_; }
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get the bound context for this JSArray (it is cached at creation).
|
||||||
|
///
|
||||||
|
JSContextRef context() const { return ctx_; }
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Set the JSContext for this JSArray.
|
||||||
|
///
|
||||||
|
/// **Note**:
|
||||||
|
/// JSArrays created from within a JSCallback have a temporary JSContext
|
||||||
|
/// that is destroyed when the callback returns. You will need to "move"
|
||||||
|
/// any JSArrays created within these callbacks to the View's main context
|
||||||
|
/// (call set_context() with the main context) before using them outside
|
||||||
|
/// the callback.
|
||||||
|
///
|
||||||
|
void set_context(JSContextRef context) { ctx_ = context; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
JSArray(JSContextRef ctx, JSValueRef val);
|
||||||
|
|
||||||
|
JSContextRef ctx_;
|
||||||
|
JSObjectRef instance_;
|
||||||
|
friend class JSValue;
|
||||||
|
};
|
||||||
|
|
||||||
|
///
|
||||||
|
/// JSObject wrapper that automatically manages lifetime and provides
|
||||||
|
/// convenient access to properties.
|
||||||
|
///
|
||||||
|
class AExport JSObject {
|
||||||
|
public:
|
||||||
|
/// Create empty Object
|
||||||
|
JSObject();
|
||||||
|
|
||||||
|
/// Create from existing JSObjectRef from JavaScriptCore C API
|
||||||
|
JSObject(JSObjectRef obj);
|
||||||
|
|
||||||
|
/// Copy constructor (shallow copy, will point to same instance)
|
||||||
|
JSObject(const JSObject& other);
|
||||||
|
|
||||||
|
~JSObject();
|
||||||
|
|
||||||
|
/// Assignment (shallow assignment, will point to same instance)
|
||||||
|
JSObject& operator=(const JSObject& other);
|
||||||
|
|
||||||
|
/// Get a property by name
|
||||||
|
JSPropertyValue operator[](JSString propertyName) const;
|
||||||
|
|
||||||
|
/// Check if a property exists
|
||||||
|
bool HasProperty(JSString propertyName) const;
|
||||||
|
|
||||||
|
/// Remove a property
|
||||||
|
bool DeleteProperty(JSString propertyName);
|
||||||
|
|
||||||
|
/// Get the underlying JSObjectRef (JavaScriptCore C API)
|
||||||
|
operator JSObjectRef() const { return instance_; }
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get the bound context for this JSObject (it is cached at creation).
|
||||||
|
///
|
||||||
|
JSContextRef context() const { return ctx_; }
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Set the JSContext for this JSObject.
|
||||||
|
///
|
||||||
|
/// **Note**:
|
||||||
|
/// JSObjects created from within a JSCallback have a temporary JSContext
|
||||||
|
/// that is destroyed when the callback returns. You will need to "move"
|
||||||
|
/// any JSObjects created within these callbacks to the View's main context
|
||||||
|
/// (call set_context() with the main context) before using them outside
|
||||||
|
/// the callback.
|
||||||
|
///
|
||||||
|
void set_context(JSContextRef context) { ctx_ = context; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
JSObject(JSContextRef ctx, JSValueRef val);
|
||||||
|
JSObject(JSContextRef ctx, JSObjectRef obj);
|
||||||
|
|
||||||
|
JSContextRef ctx_;
|
||||||
|
JSObjectRef instance_;
|
||||||
|
friend class JSValue;
|
||||||
|
friend class JSPropertyValue;
|
||||||
|
};
|
||||||
|
|
||||||
|
///
|
||||||
|
/// JSFunction wrapper that automatically manages lifetime and provides
|
||||||
|
/// convenient function invocation operators.
|
||||||
|
///
|
||||||
|
class AExport JSFunction {
|
||||||
|
public:
|
||||||
|
/// Create an empty Function.
|
||||||
|
/// NOTE: It is OKAY to create this without calling SetJSContext() first.
|
||||||
|
JSFunction();
|
||||||
|
|
||||||
|
/// Copy constructor (shallow copy, will point to same instance)
|
||||||
|
JSFunction(const JSFunction& other);
|
||||||
|
|
||||||
|
~JSFunction();
|
||||||
|
|
||||||
|
/// Assignment (shallow assignment, will point to same instance)
|
||||||
|
JSFunction& operator=(const JSFunction& other);
|
||||||
|
|
||||||
|
/// Whether or not this is a valid, callable Function object.
|
||||||
|
bool IsValid() const;
|
||||||
|
|
||||||
|
/// Call function (using Global Object for 'this') and return the result.
|
||||||
|
JSValue operator()(const JSArgs& args);
|
||||||
|
|
||||||
|
/// Call function (with explicit object for 'this') and return the result
|
||||||
|
JSValue operator()(const JSObject& thisObject, const JSArgs& args);
|
||||||
|
|
||||||
|
/// Get the underlying JSObjectRef (JavaScriptCore C API)
|
||||||
|
operator JSObjectRef() const { return instance_; }
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get the bound context for this JSFunction (it is cached at creation).
|
||||||
|
///
|
||||||
|
JSContextRef context() const { return ctx_; }
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Set the JSContext for this JSFunction.
|
||||||
|
///
|
||||||
|
/// **Note**:
|
||||||
|
/// JSFunctions created from within a JSCallback have a temporary JSContext
|
||||||
|
/// that is destroyed when the callback returns. You will need to "move"
|
||||||
|
/// any JSFunctions created within these callbacks to the View's main context
|
||||||
|
/// (call set_context() with the main context) before using them outside
|
||||||
|
/// the callback.
|
||||||
|
///
|
||||||
|
void set_context(JSContextRef context) { ctx_ = context; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
JSFunction(JSContextRef ctx, JSValueRef val);
|
||||||
|
|
||||||
|
JSContextRef ctx_;
|
||||||
|
JSObjectRef instance_;
|
||||||
|
friend class JSValue;
|
||||||
|
};
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get the Global Object for the current JSContext.
|
||||||
|
/// In JavaScript, this would be equivalent to the "window" object.
|
||||||
|
///
|
||||||
|
JSObject AExport JSGlobalObject();
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Evaluate a string of JavaScript and return a result.
|
||||||
|
///
|
||||||
|
JSValue AExport JSEval(const JSString& str);
|
||||||
|
|
||||||
|
} // namespace ultralight
|
|
@ -0,0 +1,41 @@
|
||||||
|
///
|
||||||
|
/// @file Monitor.h
|
||||||
|
///
|
||||||
|
/// @brief The header for the Monitor class.
|
||||||
|
///
|
||||||
|
/// @author
|
||||||
|
///
|
||||||
|
/// This file is a part of Ultralight, a fast, lightweight, HTML UI engine
|
||||||
|
///
|
||||||
|
/// Website: <http://ultralig.ht>
|
||||||
|
///
|
||||||
|
/// Copyright (C) 2019 Ultralight, Inc. All rights reserved.
|
||||||
|
///
|
||||||
|
#pragma once
|
||||||
|
#include "Defines.h"
|
||||||
|
|
||||||
|
namespace ultralight {
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Monitor class, represents a platform monitor.
|
||||||
|
///
|
||||||
|
class AExport Monitor {
|
||||||
|
public:
|
||||||
|
virtual ~Monitor() {}
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get the DPI scale (1.0 = 100%)
|
||||||
|
///
|
||||||
|
virtual double scale() const = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get the width of the monitor.
|
||||||
|
///
|
||||||
|
virtual uint32_t width() const = 0;
|
||||||
|
|
||||||
|
/// Get the height of the monitor.
|
||||||
|
///
|
||||||
|
virtual uint32_t height() const = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace ultralight
|
|
@ -0,0 +1,141 @@
|
||||||
|
///
|
||||||
|
/// @file Overlay.h
|
||||||
|
///
|
||||||
|
/// @brief The header for the Overlay class.
|
||||||
|
///
|
||||||
|
/// @author
|
||||||
|
///
|
||||||
|
/// This file is a part of Ultralight, a fast, lightweight, HTML UI engine
|
||||||
|
///
|
||||||
|
/// Website: <http://ultralig.ht>
|
||||||
|
///
|
||||||
|
/// Copyright (C) 2019 Ultralight, Inc. All rights reserved.
|
||||||
|
///
|
||||||
|
#pragma once
|
||||||
|
#include "Window.h"
|
||||||
|
#include <Ultralight/View.h>
|
||||||
|
|
||||||
|
namespace ultralight {
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Web-content overlay. Displays a web-page within an area of the main window.
|
||||||
|
///
|
||||||
|
/// @note Each Overlay is essentially a View and an on-screen quad. You should
|
||||||
|
/// create the Overlay then load content into the underlying View.
|
||||||
|
///
|
||||||
|
class AExport Overlay : public RefCounted {
|
||||||
|
public:
|
||||||
|
///
|
||||||
|
/// Create a new Overlay.
|
||||||
|
///
|
||||||
|
/// @param window The window to create the Overlay in. (we currently only
|
||||||
|
/// support one window per application)
|
||||||
|
///
|
||||||
|
/// @param width The width in pixels.
|
||||||
|
///
|
||||||
|
/// @param height The height in pixels.
|
||||||
|
///
|
||||||
|
/// @param x The x-position (offset from the left of the Window), in
|
||||||
|
/// pixels.
|
||||||
|
///
|
||||||
|
/// @param y The y-position (offset from the top of the Window), in
|
||||||
|
/// pixels.
|
||||||
|
///
|
||||||
|
static Ref<Overlay> Create(Ref<Window> window, uint32_t width,
|
||||||
|
uint32_t height, int x, int y);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Create a new Overlay, wrapping an existing View.
|
||||||
|
///
|
||||||
|
/// @param window The window to create the Overlay in. (we currently only
|
||||||
|
/// support one window per application)
|
||||||
|
///
|
||||||
|
/// @param view The View to wrap (will use its width and height).
|
||||||
|
///
|
||||||
|
/// @param x The x-position (offset from the left of the Window), in
|
||||||
|
/// pixels.
|
||||||
|
///
|
||||||
|
/// @param y The y-position (offset from the top of the Window), in
|
||||||
|
/// pixels.
|
||||||
|
///
|
||||||
|
static Ref<Overlay> Create(Ref<Window> window, Ref<View> view, int x, int y);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get the underlying View.
|
||||||
|
///
|
||||||
|
virtual ultralight::Ref<ultralight::View> view() = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get the width (in pixels).
|
||||||
|
///
|
||||||
|
virtual uint32_t width() const = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get the height (in pixels).
|
||||||
|
///
|
||||||
|
virtual uint32_t height() const = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get the x-position (offset from the left of the Window), in pixels.
|
||||||
|
///
|
||||||
|
virtual int x() const = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get the y-position (offset from the top of the Window), in pixels.
|
||||||
|
///
|
||||||
|
virtual int y() const = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Whether or not the overlay is hidden (not drawn).
|
||||||
|
///
|
||||||
|
virtual bool is_hidden() const = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Hide the overlay (will no longer be drawn)
|
||||||
|
///
|
||||||
|
virtual void Hide() = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Show the overlay.
|
||||||
|
///
|
||||||
|
virtual void Show() = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Whether or not this overlay has keyboard focus.
|
||||||
|
///
|
||||||
|
virtual bool has_focus() const = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Grant this overlay exclusive keyboard focus.
|
||||||
|
///
|
||||||
|
virtual void Focus() = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Remove keyboard focus.
|
||||||
|
///
|
||||||
|
virtual void Unfocus() = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Move the overlay to a new position (in pixels).
|
||||||
|
///
|
||||||
|
virtual void MoveTo(int x, int y) = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Resize the overlay (and underlying View), dimensions should be
|
||||||
|
/// specified in pixels.
|
||||||
|
///
|
||||||
|
virtual void Resize(uint32_t width, uint32_t height) = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Whether or not this Overlay needs repaint (either it has moved, resized,
|
||||||
|
/// or the internal View needs repaint).
|
||||||
|
///
|
||||||
|
virtual bool NeedsRepaint() = 0;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual ~Overlay();
|
||||||
|
virtual void Draw() = 0;
|
||||||
|
friend class OverlayManager;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace framework
|
|
@ -0,0 +1,53 @@
|
||||||
|
///
|
||||||
|
/// @file Platform.h
|
||||||
|
///
|
||||||
|
/// @brief The header for the Platform helpers.
|
||||||
|
///
|
||||||
|
/// @author
|
||||||
|
///
|
||||||
|
/// This file is a part of Ultralight, a fast, lightweight, HTML UI engine
|
||||||
|
///
|
||||||
|
/// Website: <http://ultralig.ht>
|
||||||
|
///
|
||||||
|
/// Copyright (C) 2020 Ultralight, Inc. All rights reserved.
|
||||||
|
///
|
||||||
|
#pragma once
|
||||||
|
#include "Defines.h"
|
||||||
|
#include <Ultralight/String.h>
|
||||||
|
#include <Ultralight/platform/FontLoader.h>
|
||||||
|
#include <Ultralight/platform/FileSystem.h>
|
||||||
|
#include <Ultralight/platform/Logger.h>
|
||||||
|
|
||||||
|
namespace ultralight {
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get the native font loader for the current platform.
|
||||||
|
///
|
||||||
|
/// @note This singleton is owned by the library, do not destroy it.
|
||||||
|
///
|
||||||
|
AExport FontLoader* GetPlatformFontLoader();
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get the native file system for the current platform, creating it if it
|
||||||
|
/// doesn't exist using the base directory provided.
|
||||||
|
///
|
||||||
|
/// This is used to load data for file:/// URLs.
|
||||||
|
///
|
||||||
|
/// @param baseDir An base file path that will be used to resolve relative
|
||||||
|
/// file paths. You can optionally specify "@resource_path"
|
||||||
|
/// on macOS to use the app bundle's resource path.
|
||||||
|
///
|
||||||
|
/// @note This singleton is owned by the library, do not destroy it.
|
||||||
|
///
|
||||||
|
AExport FileSystem* GetPlatformFileSystem(const String& baseDir);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get the default logger (writes the log to a file on disk).
|
||||||
|
///
|
||||||
|
/// @param logPath A file path to write the log to.
|
||||||
|
///
|
||||||
|
/// @note This singleton is owned by the library, do not destroy it.
|
||||||
|
///
|
||||||
|
AExport Logger* GetDefaultLogger(const String& logPath);
|
||||||
|
|
||||||
|
} // namespace ultralight
|
|
@ -0,0 +1,157 @@
|
||||||
|
///
|
||||||
|
/// @file Window.h
|
||||||
|
///
|
||||||
|
/// @brief The header for the Window class.
|
||||||
|
///
|
||||||
|
/// @author
|
||||||
|
///
|
||||||
|
/// This file is a part of Ultralight, a fast, lightweight, HTML UI engine
|
||||||
|
///
|
||||||
|
/// Website: <http://ultralig.ht>
|
||||||
|
///
|
||||||
|
/// Copyright (C) 2019 Ultralight, Inc. All rights reserved.
|
||||||
|
///
|
||||||
|
#pragma once
|
||||||
|
#include "Defines.h"
|
||||||
|
#include <Ultralight/RefPtr.h>
|
||||||
|
#include <Ultralight/Listener.h>
|
||||||
|
#include <Ultralight/Bitmap.h>
|
||||||
|
|
||||||
|
namespace ultralight {
|
||||||
|
|
||||||
|
class Monitor;
|
||||||
|
class OverlayManager;
|
||||||
|
class Surface;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Interface for all Window-related events. @see Window::set_listener
|
||||||
|
///
|
||||||
|
class WindowListener {
|
||||||
|
public:
|
||||||
|
virtual ~WindowListener() {}
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Called when the Window is closed.
|
||||||
|
///
|
||||||
|
virtual void OnClose() = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Called when the Window is resized.
|
||||||
|
///
|
||||||
|
/// @param width The new width (in pixels).
|
||||||
|
///
|
||||||
|
/// @param height The new height (in pixels).
|
||||||
|
///
|
||||||
|
virtual void OnResize(uint32_t width, uint32_t height) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Window creation flags. @see Window::Create
|
||||||
|
///
|
||||||
|
enum WindowFlags : uint8_t {
|
||||||
|
kWindowFlags_Borderless = 1 << 0,
|
||||||
|
kWindowFlags_Titled = 1 << 1,
|
||||||
|
kWindowFlags_Resizable = 1 << 2,
|
||||||
|
kWindowFlags_Maximizable = 1 << 3,
|
||||||
|
};
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Window class, represents a platform window.
|
||||||
|
///
|
||||||
|
class AExport Window : public RefCounted {
|
||||||
|
public:
|
||||||
|
///
|
||||||
|
/// Create a new Window.
|
||||||
|
///
|
||||||
|
/// @param monitor The monitor to create the Window on.
|
||||||
|
///
|
||||||
|
/// @param width The width (in device coordinates).
|
||||||
|
///
|
||||||
|
/// @param height The height (in device coordinates).
|
||||||
|
///
|
||||||
|
/// @param fullscreen Whether or not the window is fullscreen.
|
||||||
|
///
|
||||||
|
/// @param window_flags Various window flags.
|
||||||
|
///
|
||||||
|
static Ref<Window> Create(Monitor* monitor, uint32_t width, uint32_t height,
|
||||||
|
bool fullscreen, unsigned int window_flags);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Set a WindowListener to receive callbacks for window-related events.
|
||||||
|
///
|
||||||
|
/// @note Ownership remains with the caller.
|
||||||
|
///
|
||||||
|
virtual void set_listener(WindowListener* listener) = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get the WindowListener, if any.
|
||||||
|
///
|
||||||
|
virtual WindowListener* listener() = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get the window width (in pixels).
|
||||||
|
///
|
||||||
|
virtual uint32_t width() const = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get the window height (in pixels).
|
||||||
|
///
|
||||||
|
virtual uint32_t height() const = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Whether or not the window is fullscreen.
|
||||||
|
///
|
||||||
|
virtual bool is_fullscreen() const = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// The DPI scale of the window.
|
||||||
|
///
|
||||||
|
virtual double scale() const = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Set the window title.
|
||||||
|
///
|
||||||
|
virtual void SetTitle(const char* title) = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Set the cursor.
|
||||||
|
///
|
||||||
|
virtual void SetCursor(ultralight::Cursor cursor) = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Close the window.
|
||||||
|
///
|
||||||
|
virtual void Close() = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Convert device coordinates to pixels using the current DPI scale.
|
||||||
|
///
|
||||||
|
virtual int DeviceToPixels(int val) const = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Convert pixels to device coordinates using the current DPI scale.
|
||||||
|
///
|
||||||
|
virtual int PixelsToDevice(int val) const = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Draw a surface directly to window, used only by CPU renderer
|
||||||
|
///
|
||||||
|
virtual void DrawSurface(int x, int y, Surface* surface) {}
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get the underlying native window handle.
|
||||||
|
///
|
||||||
|
/// @note This is: - HWND on Windows
|
||||||
|
/// - NSWindow* on macOS
|
||||||
|
/// - GLFWwindow* on Linux
|
||||||
|
///
|
||||||
|
virtual void* native_handle() const = 0;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual ~Window();
|
||||||
|
virtual OverlayManager* overlay_manager() const = 0;
|
||||||
|
|
||||||
|
friend class OverlayImpl;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace ultralight
|
|
@ -68,20 +68,27 @@ typedef const struct OpaqueJSValue* JSValueRef;
|
||||||
/*! @typedef JSObjectRef A JavaScript object. A JSObject is a JSValue. */
|
/*! @typedef JSObjectRef A JavaScript object. A JSObject is a JSValue. */
|
||||||
typedef struct OpaqueJSValue* JSObjectRef;
|
typedef struct OpaqueJSValue* JSObjectRef;
|
||||||
|
|
||||||
|
/* Clang's __has_declspec_attribute emulation */
|
||||||
|
/* https://clang.llvm.org/docs/LanguageExtensions.html#has-declspec-attribute */
|
||||||
|
|
||||||
|
#ifndef __has_declspec_attribute
|
||||||
|
#define __has_declspec_attribute(x) 0
|
||||||
|
#endif
|
||||||
|
|
||||||
/* JavaScript symbol exports */
|
/* JavaScript symbol exports */
|
||||||
/* These rules should stay the same as in WebKit2/Shared/API/c/WKBase.h */
|
/* These rules should stay the same as in WebKit/Shared/API/c/WKDeclarationSpecifiers.h */
|
||||||
|
|
||||||
#undef JS_EXPORT
|
#undef JS_EXPORT
|
||||||
#if defined(JS_NO_EXPORT)
|
#if defined(JS_NO_EXPORT)
|
||||||
#define JS_EXPORT
|
#define JS_EXPORT
|
||||||
#elif defined(__GNUC__) && !defined(__CC_ARM) && !defined(__ARMCC__)
|
#elif defined(WIN32) || defined(_WIN32) || defined(__CC_ARM) || defined(__ARMCC__) || (__has_declspec_attribute(dllimport) && __has_declspec_attribute(dllexport))
|
||||||
#define JS_EXPORT __attribute__((visibility("default")))
|
|
||||||
#elif defined(WIN32) || defined(_WIN32) || defined(_WIN32_WCE) || defined(__CC_ARM) || defined(__ARMCC__)
|
|
||||||
#if defined(BUILDING_JavaScriptCore) || defined(STATICALLY_LINKED_WITH_JavaScriptCore)
|
#if defined(BUILDING_JavaScriptCore) || defined(STATICALLY_LINKED_WITH_JavaScriptCore)
|
||||||
#define JS_EXPORT __declspec(dllexport)
|
#define JS_EXPORT __declspec(dllexport)
|
||||||
#else
|
#else
|
||||||
#define JS_EXPORT __declspec(dllimport)
|
#define JS_EXPORT __declspec(dllimport)
|
||||||
#endif
|
#endif
|
||||||
|
#elif defined(__GNUC__)
|
||||||
|
#define JS_EXPORT __attribute__((visibility("default")))
|
||||||
#else /* !defined(JS_NO_EXPORT) */
|
#else /* !defined(JS_NO_EXPORT) */
|
||||||
#define JS_EXPORT
|
#define JS_EXPORT
|
||||||
#endif /* defined(JS_NO_EXPORT) */
|
#endif /* defined(JS_NO_EXPORT) */
|
||||||
|
@ -136,9 +143,13 @@ JS_EXPORT void JSGarbageCollect(JSContextRef ctx);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Enable the Objective-C API for platforms with a modern runtime. */
|
/* Enable the Objective-C API for platforms with a modern runtime. NOTE: This is duplicated in VM.h. */
|
||||||
#if !defined(JSC_OBJC_API_ENABLED)
|
#if !defined(JSC_OBJC_API_ENABLED)
|
||||||
#define JSC_OBJC_API_ENABLED (defined(__clang__) && defined(__APPLE__) && ((defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && !defined(__i386__)) || (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE)))
|
#if (defined(__clang__) && defined(__APPLE__) && ((defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && !defined(__i386__)) || (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE)))
|
||||||
|
#define JSC_OBJC_API_ENABLED 1
|
||||||
|
#else
|
||||||
|
#define JSC_OBJC_API_ENABLED 0
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* JSBase_h */
|
#endif /* JSBase_h */
|
||||||
|
|
|
@ -46,9 +46,14 @@ extern "C" {
|
||||||
JavaScript objects between contexts in different groups will produce undefined behavior.
|
JavaScript objects between contexts in different groups will produce undefined behavior.
|
||||||
When objects from the same context group are used in multiple threads, explicit
|
When objects from the same context group are used in multiple threads, explicit
|
||||||
synchronization is required.
|
synchronization is required.
|
||||||
|
|
||||||
|
A JSContextGroup may need to run deferred tasks on a run loop, such as garbage collection
|
||||||
|
or resolving WebAssembly compilations. By default, calling JSContextGroupCreate will use
|
||||||
|
the run loop of the thread it was called on. Currently, there is no API to change a
|
||||||
|
JSContextGroup's run loop once it has been created.
|
||||||
@result The created JSContextGroup.
|
@result The created JSContextGroup.
|
||||||
*/
|
*/
|
||||||
JS_EXPORT JSContextGroupRef JSContextGroupCreate(void) CF_AVAILABLE(10_6, 7_0);
|
JS_EXPORT JSContextGroupRef JSContextGroupCreate(void) JSC_API_AVAILABLE(macos(10.6), ios(7.0));
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@function
|
@function
|
||||||
|
@ -56,14 +61,14 @@ JS_EXPORT JSContextGroupRef JSContextGroupCreate(void) CF_AVAILABLE(10_6, 7_0);
|
||||||
@param group The JSContextGroup to retain.
|
@param group The JSContextGroup to retain.
|
||||||
@result A JSContextGroup that is the same as group.
|
@result A JSContextGroup that is the same as group.
|
||||||
*/
|
*/
|
||||||
JS_EXPORT JSContextGroupRef JSContextGroupRetain(JSContextGroupRef group) CF_AVAILABLE(10_6, 7_0);
|
JS_EXPORT JSContextGroupRef JSContextGroupRetain(JSContextGroupRef group) JSC_API_AVAILABLE(macos(10.6), ios(7.0));
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@function
|
@function
|
||||||
@abstract Releases a JavaScript context group.
|
@abstract Releases a JavaScript context group.
|
||||||
@param group The JSContextGroup to release.
|
@param group The JSContextGroup to release.
|
||||||
*/
|
*/
|
||||||
JS_EXPORT void JSContextGroupRelease(JSContextGroupRef group) CF_AVAILABLE(10_6, 7_0);
|
JS_EXPORT void JSContextGroupRelease(JSContextGroupRef group) JSC_API_AVAILABLE(macos(10.6), ios(7.0));
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@function
|
@function
|
||||||
|
@ -78,7 +83,7 @@ JS_EXPORT void JSContextGroupRelease(JSContextGroupRef group) CF_AVAILABLE(10_6,
|
||||||
NULL to use the default object class.
|
NULL to use the default object class.
|
||||||
@result A JSGlobalContext with a global object of class globalObjectClass.
|
@result A JSGlobalContext with a global object of class globalObjectClass.
|
||||||
*/
|
*/
|
||||||
JS_EXPORT JSGlobalContextRef JSGlobalContextCreate(JSClassRef globalObjectClass) CF_AVAILABLE(10_5, 7_0);
|
JS_EXPORT JSGlobalContextRef JSGlobalContextCreate(JSClassRef globalObjectClass) JSC_API_AVAILABLE(macos(10.5), ios(7.0));
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@function
|
@function
|
||||||
|
@ -92,7 +97,7 @@ JS_EXPORT JSGlobalContextRef JSGlobalContextCreate(JSClassRef globalObjectClass)
|
||||||
@result A JSGlobalContext with a global object of class globalObjectClass and a context
|
@result A JSGlobalContext with a global object of class globalObjectClass and a context
|
||||||
group equal to group.
|
group equal to group.
|
||||||
*/
|
*/
|
||||||
JS_EXPORT JSGlobalContextRef JSGlobalContextCreateInGroup(JSContextGroupRef group, JSClassRef globalObjectClass) CF_AVAILABLE(10_6, 7_0);
|
JS_EXPORT JSGlobalContextRef JSGlobalContextCreateInGroup(JSContextGroupRef group, JSClassRef globalObjectClass) JSC_API_AVAILABLE(macos(10.6), ios(7.0));
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@function
|
@function
|
||||||
|
@ -123,7 +128,7 @@ JS_EXPORT JSObjectRef JSContextGetGlobalObject(JSContextRef ctx);
|
||||||
@param ctx The JSContext whose group you want to get.
|
@param ctx The JSContext whose group you want to get.
|
||||||
@result ctx's group.
|
@result ctx's group.
|
||||||
*/
|
*/
|
||||||
JS_EXPORT JSContextGroupRef JSContextGetGroup(JSContextRef ctx) CF_AVAILABLE(10_6, 7_0);
|
JS_EXPORT JSContextGroupRef JSContextGetGroup(JSContextRef ctx) JSC_API_AVAILABLE(macos(10.6), ios(7.0));
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@function
|
@function
|
||||||
|
@ -131,7 +136,7 @@ JS_EXPORT JSContextGroupRef JSContextGetGroup(JSContextRef ctx) CF_AVAILABLE(10_
|
||||||
@param ctx The JSContext whose global context you want to get.
|
@param ctx The JSContext whose global context you want to get.
|
||||||
@result ctx's global context.
|
@result ctx's global context.
|
||||||
*/
|
*/
|
||||||
JS_EXPORT JSGlobalContextRef JSContextGetGlobalContext(JSContextRef ctx) CF_AVAILABLE(10_7, 7_0);
|
JS_EXPORT JSGlobalContextRef JSContextGetGlobalContext(JSContextRef ctx) JSC_API_AVAILABLE(macos(10.7), ios(7.0));
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@function
|
@function
|
||||||
|
@ -141,7 +146,7 @@ JS_EXPORT JSGlobalContextRef JSContextGetGlobalContext(JSContextRef ctx) CF_AVAI
|
||||||
@discussion A JSGlobalContext's name is exposed for remote debugging to make it
|
@discussion A JSGlobalContext's name is exposed for remote debugging to make it
|
||||||
easier to identify the context you would like to attach to.
|
easier to identify the context you would like to attach to.
|
||||||
*/
|
*/
|
||||||
JS_EXPORT JSStringRef JSGlobalContextCopyName(JSGlobalContextRef ctx) CF_AVAILABLE(10_10, 8_0);
|
JS_EXPORT JSStringRef JSGlobalContextCopyName(JSGlobalContextRef ctx) JSC_API_AVAILABLE(macos(10.10), ios(8.0));
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@function
|
@function
|
||||||
|
@ -149,7 +154,7 @@ JS_EXPORT JSStringRef JSGlobalContextCopyName(JSGlobalContextRef ctx) CF_AVAILAB
|
||||||
@param ctx The JSGlobalContext that you want to name.
|
@param ctx The JSGlobalContext that you want to name.
|
||||||
@param name The remote debugging name to set on ctx.
|
@param name The remote debugging name to set on ctx.
|
||||||
*/
|
*/
|
||||||
JS_EXPORT void JSGlobalContextSetName(JSGlobalContextRef ctx, JSStringRef name) CF_AVAILABLE(10_10, 8_0);
|
JS_EXPORT void JSGlobalContextSetName(JSGlobalContextRef ctx, JSStringRef name) JSC_API_AVAILABLE(macos(10.10), ios(8.0));
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
|
* Copyright (C) 2006-2019 Apple Inc. All rights reserved.
|
||||||
* Copyright (C) 2008 Kelvin W Sherlock (ksherlock@gmail.com)
|
* Copyright (C) 2008 Kelvin W Sherlock (ksherlock@gmail.com)
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -91,6 +91,10 @@ derived class (the parent class) first, and the most derived class last.
|
||||||
typedef void
|
typedef void
|
||||||
(*JSObjectInitializeCallback) (JSContextRef ctx, JSObjectRef object);
|
(*JSObjectInitializeCallback) (JSContextRef ctx, JSObjectRef object);
|
||||||
|
|
||||||
|
/* Extension of the above callback with the class that the method is being invoked for. */
|
||||||
|
typedef void
|
||||||
|
(*JSObjectInitializeCallbackEx) (JSContextRef ctx, JSClassRef jsClass, JSObjectRef object);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@typedef JSObjectFinalizeCallback
|
@typedef JSObjectFinalizeCallback
|
||||||
@abstract The callback invoked when an object is finalized (prepared for garbage collection). An object may be finalized on any thread.
|
@abstract The callback invoked when an object is finalized (prepared for garbage collection). An object may be finalized on any thread.
|
||||||
|
@ -109,6 +113,10 @@ all functions that have a JSContextRef parameter.
|
||||||
typedef void
|
typedef void
|
||||||
(*JSObjectFinalizeCallback) (JSObjectRef object);
|
(*JSObjectFinalizeCallback) (JSObjectRef object);
|
||||||
|
|
||||||
|
/* Extension of the above callback with the class that the method is being invoked for. */
|
||||||
|
typedef void
|
||||||
|
(*JSObjectFinalizeCallbackEx) (JSClassRef jsClass, JSObjectRef object);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@typedef JSObjectHasPropertyCallback
|
@typedef JSObjectHasPropertyCallback
|
||||||
@abstract The callback invoked when determining whether an object has a property.
|
@abstract The callback invoked when determining whether an object has a property.
|
||||||
|
@ -129,6 +137,10 @@ If this callback is NULL, the getProperty callback will be used to service hasPr
|
||||||
typedef bool
|
typedef bool
|
||||||
(*JSObjectHasPropertyCallback) (JSContextRef ctx, JSObjectRef object, JSStringRef propertyName);
|
(*JSObjectHasPropertyCallback) (JSContextRef ctx, JSObjectRef object, JSStringRef propertyName);
|
||||||
|
|
||||||
|
/* Extension of the above callback with the class that the method is being invoked for. */
|
||||||
|
typedef bool
|
||||||
|
(*JSObjectHasPropertyCallbackEx) (JSContextRef ctx, JSClassRef jsClass, JSObjectRef object, JSStringRef propertyName);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@typedef JSObjectGetPropertyCallback
|
@typedef JSObjectGetPropertyCallback
|
||||||
@abstract The callback invoked when getting a property's value.
|
@abstract The callback invoked when getting a property's value.
|
||||||
|
@ -146,6 +158,10 @@ If this function returns NULL, the get request forwards to object's statically d
|
||||||
typedef JSValueRef
|
typedef JSValueRef
|
||||||
(*JSObjectGetPropertyCallback) (JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
|
(*JSObjectGetPropertyCallback) (JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
|
||||||
|
|
||||||
|
/* Extension of the above callback with the class that the method is being invoked for. */
|
||||||
|
typedef JSValueRef
|
||||||
|
(*JSObjectGetPropertyCallbackEx) (JSContextRef ctx, JSClassRef jsClass, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@typedef JSObjectSetPropertyCallback
|
@typedef JSObjectSetPropertyCallback
|
||||||
@abstract The callback invoked when setting a property's value.
|
@abstract The callback invoked when setting a property's value.
|
||||||
|
@ -164,6 +180,10 @@ If this function returns false, the set request forwards to object's statically
|
||||||
typedef bool
|
typedef bool
|
||||||
(*JSObjectSetPropertyCallback) (JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSValueRef* exception);
|
(*JSObjectSetPropertyCallback) (JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSValueRef* exception);
|
||||||
|
|
||||||
|
/* Extension of the above callback with the class that the method is being invoked for. */
|
||||||
|
typedef bool
|
||||||
|
(*JSObjectSetPropertyCallbackEx) (JSContextRef ctx, JSClassRef jsClass, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSValueRef* exception);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@typedef JSObjectDeletePropertyCallback
|
@typedef JSObjectDeletePropertyCallback
|
||||||
@abstract The callback invoked when deleting a property.
|
@abstract The callback invoked when deleting a property.
|
||||||
|
@ -181,6 +201,10 @@ If this function returns false, the delete request forwards to object's statical
|
||||||
typedef bool
|
typedef bool
|
||||||
(*JSObjectDeletePropertyCallback) (JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
|
(*JSObjectDeletePropertyCallback) (JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
|
||||||
|
|
||||||
|
/* Extension of the above callback with the class that the method is being invoked for. */
|
||||||
|
typedef bool
|
||||||
|
(*JSObjectDeletePropertyCallbackEx) (JSContextRef ctx, JSClassRef jsClass, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@typedef JSObjectGetPropertyNamesCallback
|
@typedef JSObjectGetPropertyNamesCallback
|
||||||
@abstract The callback invoked when collecting the names of an object's properties.
|
@abstract The callback invoked when collecting the names of an object's properties.
|
||||||
|
@ -198,6 +222,10 @@ Use JSPropertyNameAccumulatorAddName to add property names to accumulator. A cla
|
||||||
typedef void
|
typedef void
|
||||||
(*JSObjectGetPropertyNamesCallback) (JSContextRef ctx, JSObjectRef object, JSPropertyNameAccumulatorRef propertyNames);
|
(*JSObjectGetPropertyNamesCallback) (JSContextRef ctx, JSObjectRef object, JSPropertyNameAccumulatorRef propertyNames);
|
||||||
|
|
||||||
|
/* Extension of the above callback with the class that the method is being invoked for. */
|
||||||
|
typedef void
|
||||||
|
(*JSObjectGetPropertyNamesCallbackEx) (JSContextRef ctx, JSClassRef jsClass, JSObjectRef object, JSPropertyNameAccumulatorRef propertyNames);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@typedef JSObjectCallAsFunctionCallback
|
@typedef JSObjectCallAsFunctionCallback
|
||||||
@abstract The callback invoked when an object is called as a function.
|
@abstract The callback invoked when an object is called as a function.
|
||||||
|
@ -219,6 +247,12 @@ If this callback is NULL, calling your object as a function will throw an except
|
||||||
typedef JSValueRef
|
typedef JSValueRef
|
||||||
(*JSObjectCallAsFunctionCallback) (JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
|
(*JSObjectCallAsFunctionCallback) (JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
|
||||||
|
|
||||||
|
/* Extension of the above callback with the class and class name of the object being called as a function.
|
||||||
|
@discussion If this is a JSStaticFunctionEx, className will actually be the name of the function.
|
||||||
|
*/
|
||||||
|
typedef JSValueRef
|
||||||
|
(*JSObjectCallAsFunctionCallbackEx) (JSContextRef ctx, JSClassRef jsClass, JSStringRef className, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@typedef JSObjectCallAsConstructorCallback
|
@typedef JSObjectCallAsConstructorCallback
|
||||||
@abstract The callback invoked when an object is used as a constructor in a 'new' expression.
|
@abstract The callback invoked when an object is used as a constructor in a 'new' expression.
|
||||||
|
@ -239,6 +273,10 @@ If this callback is NULL, using your object as a constructor in a 'new' expressi
|
||||||
typedef JSObjectRef
|
typedef JSObjectRef
|
||||||
(*JSObjectCallAsConstructorCallback) (JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
|
(*JSObjectCallAsConstructorCallback) (JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
|
||||||
|
|
||||||
|
/* Extension of the above callback with the class that the method is being invoked for. */
|
||||||
|
typedef JSObjectRef
|
||||||
|
(*JSObjectCallAsConstructorCallbackEx) (JSContextRef ctx, JSClassRef jsClass, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@typedef JSObjectHasInstanceCallback
|
@typedef JSObjectHasInstanceCallback
|
||||||
@abstract hasInstance The callback invoked when an object is used as the target of an 'instanceof' expression.
|
@abstract hasInstance The callback invoked when an object is used as the target of an 'instanceof' expression.
|
||||||
|
@ -260,6 +298,10 @@ Standard JavaScript practice calls for objects that implement the callAsConstruc
|
||||||
typedef bool
|
typedef bool
|
||||||
(*JSObjectHasInstanceCallback) (JSContextRef ctx, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception);
|
(*JSObjectHasInstanceCallback) (JSContextRef ctx, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception);
|
||||||
|
|
||||||
|
/* Extension of the above callback with the class that the method is being invoked for. */
|
||||||
|
typedef bool
|
||||||
|
(*JSObjectHasInstanceCallbackEx) (JSContextRef ctx, JSClassRef jsClass, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@typedef JSObjectConvertToTypeCallback
|
@typedef JSObjectConvertToTypeCallback
|
||||||
@abstract The callback invoked when converting an object to a particular JavaScript type.
|
@abstract The callback invoked when converting an object to a particular JavaScript type.
|
||||||
|
@ -279,6 +321,10 @@ This function is only invoked when converting an object to number or string. An
|
||||||
typedef JSValueRef
|
typedef JSValueRef
|
||||||
(*JSObjectConvertToTypeCallback) (JSContextRef ctx, JSObjectRef object, JSType type, JSValueRef* exception);
|
(*JSObjectConvertToTypeCallback) (JSContextRef ctx, JSObjectRef object, JSType type, JSValueRef* exception);
|
||||||
|
|
||||||
|
/* Extension of the above callback with the class that the method is being invoked for. */
|
||||||
|
typedef JSValueRef
|
||||||
|
(*JSObjectConvertToTypeCallbackEx) (JSContextRef ctx, JSClassRef jsClass, JSObjectRef object, JSType type, JSValueRef* exception);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@struct JSStaticValue
|
@struct JSStaticValue
|
||||||
@abstract This structure describes a statically declared value property.
|
@abstract This structure describes a statically declared value property.
|
||||||
|
@ -294,6 +340,14 @@ typedef struct {
|
||||||
JSPropertyAttributes attributes;
|
JSPropertyAttributes attributes;
|
||||||
} JSStaticValue;
|
} JSStaticValue;
|
||||||
|
|
||||||
|
/* Extension of the above structure for use with class version 1000 */
|
||||||
|
typedef struct {
|
||||||
|
const char* name;
|
||||||
|
JSObjectGetPropertyCallbackEx getPropertyEx;
|
||||||
|
JSObjectSetPropertyCallbackEx setPropertyEx;
|
||||||
|
JSPropertyAttributes attributes;
|
||||||
|
} JSStaticValueEx;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@struct JSStaticFunction
|
@struct JSStaticFunction
|
||||||
@abstract This structure describes a statically declared function property.
|
@abstract This structure describes a statically declared function property.
|
||||||
|
@ -307,6 +361,13 @@ typedef struct {
|
||||||
JSPropertyAttributes attributes;
|
JSPropertyAttributes attributes;
|
||||||
} JSStaticFunction;
|
} JSStaticFunction;
|
||||||
|
|
||||||
|
/* Extension of the above structure for use with class version 1000 */
|
||||||
|
typedef struct {
|
||||||
|
const char* name;
|
||||||
|
JSObjectCallAsFunctionCallbackEx callAsFunctionEx;
|
||||||
|
JSPropertyAttributes attributes;
|
||||||
|
} JSStaticFunctionEx;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@struct JSClassDefinition
|
@struct JSClassDefinition
|
||||||
@abstract This structure contains properties and callbacks that define a type of object. All fields other than the version field are optional. Any pointer may be NULL.
|
@abstract This structure contains properties and callbacks that define a type of object. All fields other than the version field are optional. Any pointer may be NULL.
|
||||||
|
@ -341,26 +402,49 @@ Standard JavaScript practice calls for storing function objects in prototypes, s
|
||||||
A NULL callback specifies that the default object callback should substitute, except in the case of hasProperty, where it specifies that getProperty should substitute.
|
A NULL callback specifies that the default object callback should substitute, except in the case of hasProperty, where it specifies that getProperty should substitute.
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int version; /* current (and only) version is 0 */
|
int version; /* default version is 0, use version 1000 for callbacks with extended class information */
|
||||||
JSClassAttributes attributes;
|
JSClassAttributes attributes;
|
||||||
|
|
||||||
const char* className;
|
const char* className;
|
||||||
JSClassRef parentClass;
|
JSClassRef parentClass;
|
||||||
|
|
||||||
const JSStaticValue* staticValues;
|
union {
|
||||||
const JSStaticFunction* staticFunctions;
|
/* version 0 */
|
||||||
|
struct {
|
||||||
JSObjectInitializeCallback initialize;
|
const JSStaticValue* staticValues;
|
||||||
JSObjectFinalizeCallback finalize;
|
const JSStaticFunction* staticFunctions;
|
||||||
JSObjectHasPropertyCallback hasProperty;
|
JSObjectInitializeCallback initialize;
|
||||||
JSObjectGetPropertyCallback getProperty;
|
JSObjectFinalizeCallback finalize;
|
||||||
JSObjectSetPropertyCallback setProperty;
|
JSObjectHasPropertyCallback hasProperty;
|
||||||
JSObjectDeletePropertyCallback deleteProperty;
|
JSObjectGetPropertyCallback getProperty;
|
||||||
JSObjectGetPropertyNamesCallback getPropertyNames;
|
JSObjectSetPropertyCallback setProperty;
|
||||||
JSObjectCallAsFunctionCallback callAsFunction;
|
JSObjectDeletePropertyCallback deleteProperty;
|
||||||
JSObjectCallAsConstructorCallback callAsConstructor;
|
JSObjectGetPropertyNamesCallback getPropertyNames;
|
||||||
JSObjectHasInstanceCallback hasInstance;
|
JSObjectCallAsFunctionCallback callAsFunction;
|
||||||
JSObjectConvertToTypeCallback convertToType;
|
JSObjectCallAsConstructorCallback callAsConstructor;
|
||||||
|
JSObjectHasInstanceCallback hasInstance;
|
||||||
|
JSObjectConvertToTypeCallback convertToType;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* version 1000 */
|
||||||
|
struct {
|
||||||
|
const JSStaticValueEx* staticValuesEx;
|
||||||
|
const JSStaticFunctionEx* staticFunctionsEx;
|
||||||
|
JSObjectInitializeCallbackEx initializeEx;
|
||||||
|
JSObjectFinalizeCallbackEx finalizeEx;
|
||||||
|
JSObjectHasPropertyCallbackEx hasPropertyEx;
|
||||||
|
JSObjectGetPropertyCallbackEx getPropertyEx;
|
||||||
|
JSObjectSetPropertyCallbackEx setPropertyEx;
|
||||||
|
JSObjectDeletePropertyCallbackEx deletePropertyEx;
|
||||||
|
JSObjectGetPropertyNamesCallbackEx getPropertyNamesEx;
|
||||||
|
JSObjectCallAsFunctionCallbackEx callAsFunctionEx;
|
||||||
|
JSObjectCallAsConstructorCallbackEx callAsConstructorEx;
|
||||||
|
JSObjectHasInstanceCallbackEx hasInstanceEx;
|
||||||
|
JSObjectConvertToTypeCallbackEx convertToTypeEx;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
void* privateData; /* version 1000 only */
|
||||||
} JSClassDefinition;
|
} JSClassDefinition;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -396,6 +480,25 @@ JS_EXPORT JSClassRef JSClassRetain(JSClassRef jsClass);
|
||||||
*/
|
*/
|
||||||
JS_EXPORT void JSClassRelease(JSClassRef jsClass);
|
JS_EXPORT void JSClassRelease(JSClassRef jsClass);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
@function
|
||||||
|
@abstract Retrieves the private data from a class reference, only possible with classes created with version 1000 (extended callbacks).
|
||||||
|
@param jsClass The class to get the data from
|
||||||
|
@result The private data on the class, or NULL, if not set
|
||||||
|
@discussion Only classes with version 1000 (extended callbacks) can store private data, for other classes always NULL will always be returned.
|
||||||
|
*/
|
||||||
|
JS_EXPORT void* JSClassGetPrivate(JSClassRef jsClass);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
@function
|
||||||
|
@abstract Sets the private data on a class, only possible with classes created with version 1000 (extended callbacks).
|
||||||
|
@param jsClass The class to set the data on
|
||||||
|
@param data A void* to set as the private data for the class
|
||||||
|
@result true if the data has been set on the class, false if the class has not been created with version 1000 (extended callbacks)
|
||||||
|
@discussion Only classes with version 1000 (extended callbacks) can store private data, for other classes the function always fails. The set pointer is not touched by the engine.
|
||||||
|
*/
|
||||||
|
JS_EXPORT bool JSClassSetPrivate(JSClassRef jsClass, void* data);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@function
|
@function
|
||||||
@abstract Creates a JavaScript object.
|
@abstract Creates a JavaScript object.
|
||||||
|
@ -441,7 +544,7 @@ JS_EXPORT JSObjectRef JSObjectMakeConstructor(JSContextRef ctx, JSClassRef jsCla
|
||||||
@discussion The behavior of this function does not exactly match the behavior of the built-in Array constructor. Specifically, if one argument
|
@discussion The behavior of this function does not exactly match the behavior of the built-in Array constructor. Specifically, if one argument
|
||||||
is supplied, this function returns an array with one element.
|
is supplied, this function returns an array with one element.
|
||||||
*/
|
*/
|
||||||
JS_EXPORT JSObjectRef JSObjectMakeArray(JSContextRef ctx, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) CF_AVAILABLE(10_6, 7_0);
|
JS_EXPORT JSObjectRef JSObjectMakeArray(JSContextRef ctx, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) JSC_API_AVAILABLE(macos(10.6), ios(7.0));
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@function
|
@function
|
||||||
|
@ -452,7 +555,7 @@ JS_EXPORT JSObjectRef JSObjectMakeArray(JSContextRef ctx, size_t argumentCount,
|
||||||
@param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
|
@param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
|
||||||
@result A JSObject that is a Date.
|
@result A JSObject that is a Date.
|
||||||
*/
|
*/
|
||||||
JS_EXPORT JSObjectRef JSObjectMakeDate(JSContextRef ctx, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) CF_AVAILABLE(10_6, 7_0);
|
JS_EXPORT JSObjectRef JSObjectMakeDate(JSContextRef ctx, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) JSC_API_AVAILABLE(macos(10.6), ios(7.0));
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@function
|
@function
|
||||||
|
@ -463,7 +566,7 @@ JS_EXPORT JSObjectRef JSObjectMakeDate(JSContextRef ctx, size_t argumentCount, c
|
||||||
@param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
|
@param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
|
||||||
@result A JSObject that is a Error.
|
@result A JSObject that is a Error.
|
||||||
*/
|
*/
|
||||||
JS_EXPORT JSObjectRef JSObjectMakeError(JSContextRef ctx, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) CF_AVAILABLE(10_6, 7_0);
|
JS_EXPORT JSObjectRef JSObjectMakeError(JSContextRef ctx, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) JSC_API_AVAILABLE(macos(10.6), ios(7.0));
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@function
|
@function
|
||||||
|
@ -474,7 +577,18 @@ JS_EXPORT JSObjectRef JSObjectMakeError(JSContextRef ctx, size_t argumentCount,
|
||||||
@param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
|
@param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
|
||||||
@result A JSObject that is a RegExp.
|
@result A JSObject that is a RegExp.
|
||||||
*/
|
*/
|
||||||
JS_EXPORT JSObjectRef JSObjectMakeRegExp(JSContextRef ctx, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) CF_AVAILABLE(10_6, 7_0);
|
JS_EXPORT JSObjectRef JSObjectMakeRegExp(JSContextRef ctx, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) JSC_API_AVAILABLE(macos(10.6), ios(7.0));
|
||||||
|
|
||||||
|
/*!
|
||||||
|
@function
|
||||||
|
@abstract Creates a JavaScript promise object by invoking the provided executor.
|
||||||
|
@param ctx The execution context to use.
|
||||||
|
@param resolve A pointer to a JSObjectRef in which to store the resolve function for the new promise. Pass NULL if you do not care to store the resolve callback.
|
||||||
|
@param reject A pointer to a JSObjectRef in which to store the reject function for the new promise. Pass NULL if you do not care to store the reject callback.
|
||||||
|
@param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
|
||||||
|
@result A JSObject that is a promise or NULL if an exception occurred.
|
||||||
|
*/
|
||||||
|
JS_EXPORT JSObjectRef JSObjectMakeDeferredPromise(JSContextRef ctx, JSObjectRef* resolve, JSObjectRef* reject, JSValueRef* exception) JSC_API_AVAILABLE(macos(10.15), ios(13.0));
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@function
|
@function
|
||||||
|
@ -536,9 +650,9 @@ JS_EXPORT JSValueRef JSObjectGetProperty(JSContextRef ctx, JSObjectRef object, J
|
||||||
@param ctx The execution context to use.
|
@param ctx The execution context to use.
|
||||||
@param object The JSObject whose property you want to set.
|
@param object The JSObject whose property you want to set.
|
||||||
@param propertyName A JSString containing the property's name.
|
@param propertyName A JSString containing the property's name.
|
||||||
@param value A JSValue to use as the property's value.
|
@param value A JSValueRef to use as the property's value.
|
||||||
@param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
|
|
||||||
@param attributes A logically ORed set of JSPropertyAttributes to give to the property.
|
@param attributes A logically ORed set of JSPropertyAttributes to give to the property.
|
||||||
|
@param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
|
||||||
*/
|
*/
|
||||||
JS_EXPORT void JSObjectSetProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSPropertyAttributes attributes, JSValueRef* exception);
|
JS_EXPORT void JSObjectSetProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSPropertyAttributes attributes, JSValueRef* exception);
|
||||||
|
|
||||||
|
@ -553,6 +667,54 @@ JS_EXPORT void JSObjectSetProperty(JSContextRef ctx, JSObjectRef object, JSStrin
|
||||||
*/
|
*/
|
||||||
JS_EXPORT bool JSObjectDeleteProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
|
JS_EXPORT bool JSObjectDeleteProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
@function
|
||||||
|
@abstract Tests whether an object has a given property using a JSValueRef as the property key.
|
||||||
|
@param object The JSObject to test.
|
||||||
|
@param propertyKey A JSValueRef containing the property key to use when looking up the property.
|
||||||
|
@param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
|
||||||
|
@result true if the object has a property whose name matches propertyKey, otherwise false.
|
||||||
|
@discussion This function is the same as performing "propertyKey in object" from JavaScript.
|
||||||
|
*/
|
||||||
|
JS_EXPORT bool JSObjectHasPropertyForKey(JSContextRef ctx, JSObjectRef object, JSValueRef propertyKey, JSValueRef* exception) JSC_API_AVAILABLE(macos(10.15), ios(13.0));
|
||||||
|
|
||||||
|
/*!
|
||||||
|
@function
|
||||||
|
@abstract Gets a property from an object using a JSValueRef as the property key.
|
||||||
|
@param ctx The execution context to use.
|
||||||
|
@param object The JSObject whose property you want to get.
|
||||||
|
@param propertyKey A JSValueRef containing the property key to use when looking up the property.
|
||||||
|
@param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
|
||||||
|
@result The property's value if object has the property key, otherwise the undefined value.
|
||||||
|
@discussion This function is the same as performing "object[propertyKey]" from JavaScript.
|
||||||
|
*/
|
||||||
|
JS_EXPORT JSValueRef JSObjectGetPropertyForKey(JSContextRef ctx, JSObjectRef object, JSValueRef propertyKey, JSValueRef* exception) JSC_API_AVAILABLE(macos(10.15), ios(13.0));
|
||||||
|
|
||||||
|
/*!
|
||||||
|
@function
|
||||||
|
@abstract Sets a property on an object using a JSValueRef as the property key.
|
||||||
|
@param ctx The execution context to use.
|
||||||
|
@param object The JSObject whose property you want to set.
|
||||||
|
@param propertyKey A JSValueRef containing the property key to use when looking up the property.
|
||||||
|
@param value A JSValueRef to use as the property's value.
|
||||||
|
@param attributes A logically ORed set of JSPropertyAttributes to give to the property.
|
||||||
|
@param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
|
||||||
|
@discussion This function is the same as performing "object[propertyKey] = value" from JavaScript.
|
||||||
|
*/
|
||||||
|
JS_EXPORT void JSObjectSetPropertyForKey(JSContextRef ctx, JSObjectRef object, JSValueRef propertyKey, JSValueRef value, JSPropertyAttributes attributes, JSValueRef* exception) JSC_API_AVAILABLE(macos(10.15), ios(13.0));
|
||||||
|
|
||||||
|
/*!
|
||||||
|
@function
|
||||||
|
@abstract Deletes a property from an object using a JSValueRef as the property key.
|
||||||
|
@param ctx The execution context to use.
|
||||||
|
@param object The JSObject whose property you want to delete.
|
||||||
|
@param propertyKey A JSValueRef containing the property key to use when looking up the property.
|
||||||
|
@param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
|
||||||
|
@result true if the delete operation succeeds, otherwise false (for example, if the property has the kJSPropertyAttributeDontDelete attribute set).
|
||||||
|
@discussion This function is the same as performing "delete object[propertyKey]" from JavaScript.
|
||||||
|
*/
|
||||||
|
JS_EXPORT bool JSObjectDeletePropertyForKey(JSContextRef ctx, JSObjectRef object, JSValueRef propertyKey, JSValueRef* exception) JSC_API_AVAILABLE(macos(10.15), ios(13.0));
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@function
|
@function
|
||||||
@abstract Gets a property from an object by numeric index.
|
@abstract Gets a property from an object by numeric index.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2010 Apple Inc. All rights reserved.
|
* Copyright (C) 2010-2019 Apple Inc. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
|
@ -67,6 +67,10 @@ JS_EXPORT JSValueRef JSObjectGetPrivateProperty(JSContextRef ctx, JSObjectRef ob
|
||||||
*/
|
*/
|
||||||
JS_EXPORT bool JSObjectDeletePrivateProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName);
|
JS_EXPORT bool JSObjectDeletePrivateProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName);
|
||||||
|
|
||||||
|
JS_EXPORT JSObjectRef JSObjectGetProxyTarget(JSObjectRef);
|
||||||
|
|
||||||
|
JS_EXPORT JSGlobalContextRef JSObjectGetGlobalContext(JSObjectRef object);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2005, 2006, 2007, 2010 Apple Inc. All rights reserved.
|
* Copyright (C) 2005-2018 Apple Inc. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
|
@ -26,13 +26,16 @@
|
||||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef JSRetainPtr_h
|
#pragma once
|
||||||
#define JSRetainPtr_h
|
|
||||||
|
|
||||||
#include <JavaScriptCore/JSContextRef.h>
|
#include <JavaScriptCore/JSContextRef.h>
|
||||||
#include <JavaScriptCore/JSStringRef.h>
|
#include <JavaScriptCore/JSStringRef.h>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
#if !defined(WARN_UNUSED_RETURN)
|
||||||
|
#define WARN_UNUSED_RETURN
|
||||||
|
#endif
|
||||||
|
|
||||||
inline void JSRetain(JSStringRef string) { JSStringRetain(string); }
|
inline void JSRetain(JSStringRef string) { JSStringRetain(string); }
|
||||||
inline void JSRelease(JSStringRef string) { JSStringRelease(string); }
|
inline void JSRelease(JSStringRef string) { JSStringRelease(string); }
|
||||||
inline void JSRetain(JSGlobalContextRef context) { JSGlobalContextRetain(context); }
|
inline void JSRetain(JSGlobalContextRef context) { JSGlobalContextRetain(context); }
|
||||||
|
@ -42,17 +45,16 @@ enum AdoptTag { Adopt };
|
||||||
|
|
||||||
template<typename T> class JSRetainPtr {
|
template<typename T> class JSRetainPtr {
|
||||||
public:
|
public:
|
||||||
JSRetainPtr() : m_ptr(0) { }
|
JSRetainPtr() = default;
|
||||||
JSRetainPtr(T ptr) : m_ptr(ptr) { if (ptr) JSRetain(ptr); }
|
JSRetainPtr(T ptr) : m_ptr(ptr) { if (ptr) JSRetain(ptr); }
|
||||||
JSRetainPtr(AdoptTag, T ptr) : m_ptr(ptr) { }
|
|
||||||
JSRetainPtr(const JSRetainPtr&);
|
JSRetainPtr(const JSRetainPtr&);
|
||||||
template<typename U> JSRetainPtr(const JSRetainPtr<U>&);
|
JSRetainPtr(JSRetainPtr&&);
|
||||||
~JSRetainPtr();
|
~JSRetainPtr();
|
||||||
|
|
||||||
T get() const { return m_ptr; }
|
T get() const { return m_ptr; }
|
||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
T leakRef();
|
T leakRef() WARN_UNUSED_RETURN;
|
||||||
|
|
||||||
T operator->() const { return m_ptr; }
|
T operator->() const { return m_ptr; }
|
||||||
|
|
||||||
|
@ -60,18 +62,30 @@ public:
|
||||||
explicit operator bool() const { return m_ptr; }
|
explicit operator bool() const { return m_ptr; }
|
||||||
|
|
||||||
JSRetainPtr& operator=(const JSRetainPtr&);
|
JSRetainPtr& operator=(const JSRetainPtr&);
|
||||||
template<typename U> JSRetainPtr& operator=(const JSRetainPtr<U>&);
|
JSRetainPtr& operator=(JSRetainPtr&&);
|
||||||
JSRetainPtr& operator=(T);
|
JSRetainPtr& operator=(T);
|
||||||
template<typename U> JSRetainPtr& operator=(U*);
|
|
||||||
|
|
||||||
void adopt(T);
|
|
||||||
|
|
||||||
void swap(JSRetainPtr&);
|
void swap(JSRetainPtr&);
|
||||||
|
|
||||||
|
friend JSRetainPtr<JSStringRef> adopt(JSStringRef);
|
||||||
|
friend JSRetainPtr<JSGlobalContextRef> adopt(JSGlobalContextRef);
|
||||||
|
|
||||||
|
// FIXME: Make this private once Apple's internal code is updated to not rely on it.
|
||||||
|
// https://bugs.webkit.org/show_bug.cgi?id=189644
|
||||||
|
JSRetainPtr(AdoptTag, T);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
T m_ptr;
|
T m_ptr { nullptr };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
JSRetainPtr<JSStringRef> adopt(JSStringRef);
|
||||||
|
JSRetainPtr<JSGlobalContextRef> adopt(JSGlobalContextRef);
|
||||||
|
|
||||||
|
template<typename T> inline JSRetainPtr<T>::JSRetainPtr(AdoptTag, T ptr)
|
||||||
|
: m_ptr(ptr)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
inline JSRetainPtr<JSStringRef> adopt(JSStringRef o)
|
inline JSRetainPtr<JSStringRef> adopt(JSStringRef o)
|
||||||
{
|
{
|
||||||
return JSRetainPtr<JSStringRef>(Adopt, o);
|
return JSRetainPtr<JSStringRef>(Adopt, o);
|
||||||
|
@ -89,11 +103,9 @@ template<typename T> inline JSRetainPtr<T>::JSRetainPtr(const JSRetainPtr& o)
|
||||||
JSRetain(m_ptr);
|
JSRetain(m_ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T> template<typename U> inline JSRetainPtr<T>::JSRetainPtr(const JSRetainPtr<U>& o)
|
template<typename T> inline JSRetainPtr<T>::JSRetainPtr(JSRetainPtr&& o)
|
||||||
: m_ptr(o.get())
|
: m_ptr(o.leakRef())
|
||||||
{
|
{
|
||||||
if (m_ptr)
|
|
||||||
JSRetain(m_ptr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T> inline JSRetainPtr<T>::~JSRetainPtr()
|
template<typename T> inline JSRetainPtr<T>::~JSRetainPtr()
|
||||||
|
@ -104,39 +116,23 @@ template<typename T> inline JSRetainPtr<T>::~JSRetainPtr()
|
||||||
|
|
||||||
template<typename T> inline void JSRetainPtr<T>::clear()
|
template<typename T> inline void JSRetainPtr<T>::clear()
|
||||||
{
|
{
|
||||||
if (T ptr = m_ptr) {
|
if (T ptr = leakRef())
|
||||||
m_ptr = 0;
|
|
||||||
JSRelease(ptr);
|
JSRelease(ptr);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T> inline T JSRetainPtr<T>::leakRef()
|
template<typename T> inline T JSRetainPtr<T>::leakRef()
|
||||||
{
|
{
|
||||||
T ptr = m_ptr;
|
return std::exchange(m_ptr, nullptr);
|
||||||
m_ptr = 0;
|
|
||||||
return ptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T> inline JSRetainPtr<T>& JSRetainPtr<T>::operator=(const JSRetainPtr<T>& o)
|
template<typename T> inline JSRetainPtr<T>& JSRetainPtr<T>::operator=(const JSRetainPtr<T>& o)
|
||||||
{
|
{
|
||||||
T optr = o.get();
|
return operator=(o.get());
|
||||||
if (optr)
|
|
||||||
JSRetain(optr);
|
|
||||||
T ptr = m_ptr;
|
|
||||||
m_ptr = optr;
|
|
||||||
if (ptr)
|
|
||||||
JSRelease(ptr);
|
|
||||||
return *this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T> template<typename U> inline JSRetainPtr<T>& JSRetainPtr<T>::operator=(const JSRetainPtr<U>& o)
|
template<typename T> inline JSRetainPtr<T>& JSRetainPtr<T>::operator=(JSRetainPtr&& o)
|
||||||
{
|
{
|
||||||
T optr = o.get();
|
if (T ptr = std::exchange(m_ptr, o.leakRef()))
|
||||||
if (optr)
|
|
||||||
JSRetain(optr);
|
|
||||||
T ptr = m_ptr;
|
|
||||||
m_ptr = optr;
|
|
||||||
if (ptr)
|
|
||||||
JSRelease(ptr);
|
JSRelease(ptr);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
@ -145,28 +141,7 @@ template<typename T> inline JSRetainPtr<T>& JSRetainPtr<T>::operator=(T optr)
|
||||||
{
|
{
|
||||||
if (optr)
|
if (optr)
|
||||||
JSRetain(optr);
|
JSRetain(optr);
|
||||||
T ptr = m_ptr;
|
if (T ptr = std::exchange(m_ptr, optr))
|
||||||
m_ptr = optr;
|
|
||||||
if (ptr)
|
|
||||||
JSRelease(ptr);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T> inline void JSRetainPtr<T>::adopt(T optr)
|
|
||||||
{
|
|
||||||
T ptr = m_ptr;
|
|
||||||
m_ptr = optr;
|
|
||||||
if (ptr)
|
|
||||||
JSRelease(ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T> template<typename U> inline JSRetainPtr<T>& JSRetainPtr<T>::operator=(U* optr)
|
|
||||||
{
|
|
||||||
if (optr)
|
|
||||||
JSRetain(optr);
|
|
||||||
T ptr = m_ptr;
|
|
||||||
m_ptr = optr;
|
|
||||||
if (ptr)
|
|
||||||
JSRelease(ptr);
|
JSRelease(ptr);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
@ -210,6 +185,3 @@ template<typename T, typename U> inline bool operator!=(T* a, const JSRetainPtr<
|
||||||
{
|
{
|
||||||
return a != b.get();
|
return a != b.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // JSRetainPtr_h
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ extern "C" {
|
||||||
@param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
|
@param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
|
||||||
@result A JSObjectRef that is a Typed Array with all elements set to zero or NULL if there was an error.
|
@result A JSObjectRef that is a Typed Array with all elements set to zero or NULL if there was an error.
|
||||||
*/
|
*/
|
||||||
JS_EXPORT JSObjectRef JSObjectMakeTypedArray(JSContextRef ctx, JSTypedArrayType arrayType, size_t length, JSValueRef* exception) CF_AVAILABLE(10_12, 10_0);
|
JS_EXPORT JSObjectRef JSObjectMakeTypedArray(JSContextRef ctx, JSTypedArrayType arrayType, size_t length, JSValueRef* exception) JSC_API_AVAILABLE(macos(10.12), ios(10.0));
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@function
|
@function
|
||||||
|
@ -60,7 +60,7 @@ JS_EXPORT JSObjectRef JSObjectMakeTypedArray(JSContextRef ctx, JSTypedArrayType
|
||||||
@result A JSObjectRef Typed Array whose backing store is the same as the one pointed to by bytes or NULL if there was an error.
|
@result A JSObjectRef Typed Array whose backing store is the same as the one pointed to by bytes or NULL if there was an error.
|
||||||
@discussion If an exception is thrown during this function the bytesDeallocator will always be called.
|
@discussion If an exception is thrown during this function the bytesDeallocator will always be called.
|
||||||
*/
|
*/
|
||||||
JS_EXPORT JSObjectRef JSObjectMakeTypedArrayWithBytesNoCopy(JSContextRef ctx, JSTypedArrayType arrayType, void* bytes, size_t byteLength, JSTypedArrayBytesDeallocator bytesDeallocator, void* deallocatorContext, JSValueRef* exception) CF_AVAILABLE(10_12, 10_0);
|
JS_EXPORT JSObjectRef JSObjectMakeTypedArrayWithBytesNoCopy(JSContextRef ctx, JSTypedArrayType arrayType, void* bytes, size_t byteLength, JSTypedArrayBytesDeallocator bytesDeallocator, void* deallocatorContext, JSValueRef* exception) JSC_API_AVAILABLE(macos(10.12), ios(10.0));
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@function
|
@function
|
||||||
|
@ -71,7 +71,7 @@ JS_EXPORT JSObjectRef JSObjectMakeTypedArrayWithBytesNoCopy(JSContextRef ctx, JS
|
||||||
@param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
|
@param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
|
||||||
@result A JSObjectRef that is a Typed Array or NULL if there was an error. The backing store of the Typed Array will be buffer.
|
@result A JSObjectRef that is a Typed Array or NULL if there was an error. The backing store of the Typed Array will be buffer.
|
||||||
*/
|
*/
|
||||||
JS_EXPORT JSObjectRef JSObjectMakeTypedArrayWithArrayBuffer(JSContextRef ctx, JSTypedArrayType arrayType, JSObjectRef buffer, JSValueRef* exception) CF_AVAILABLE(10_12, 10_0);
|
JS_EXPORT JSObjectRef JSObjectMakeTypedArrayWithArrayBuffer(JSContextRef ctx, JSTypedArrayType arrayType, JSObjectRef buffer, JSValueRef* exception) JSC_API_AVAILABLE(macos(10.12), ios(10.0));
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@function
|
@function
|
||||||
|
@ -84,7 +84,7 @@ JS_EXPORT JSObjectRef JSObjectMakeTypedArrayWithArrayBuffer(JSContextRef ctx, JS
|
||||||
@param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
|
@param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
|
||||||
@result A JSObjectRef that is a Typed Array or NULL if there was an error. The backing store of the Typed Array will be buffer.
|
@result A JSObjectRef that is a Typed Array or NULL if there was an error. The backing store of the Typed Array will be buffer.
|
||||||
*/
|
*/
|
||||||
JS_EXPORT JSObjectRef JSObjectMakeTypedArrayWithArrayBufferAndOffset(JSContextRef ctx, JSTypedArrayType arrayType, JSObjectRef buffer, size_t byteOffset, size_t length, JSValueRef* exception) CF_AVAILABLE(10_12, 10_0);
|
JS_EXPORT JSObjectRef JSObjectMakeTypedArrayWithArrayBufferAndOffset(JSContextRef ctx, JSTypedArrayType arrayType, JSObjectRef buffer, size_t byteOffset, size_t length, JSValueRef* exception) JSC_API_AVAILABLE(macos(10.12), ios(10.0));
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@function
|
@function
|
||||||
|
@ -95,7 +95,7 @@ JS_EXPORT JSObjectRef JSObjectMakeTypedArrayWithArrayBufferAndOffset(JSContextRe
|
||||||
@result A pointer to the raw data buffer that serves as object's backing store or NULL if object is not a Typed Array object.
|
@result A pointer to the raw data buffer that serves as object's backing store or NULL if object is not a Typed Array object.
|
||||||
@discussion The pointer returned by this function is temporary and is not guaranteed to remain valid across JavaScriptCore API calls.
|
@discussion The pointer returned by this function is temporary and is not guaranteed to remain valid across JavaScriptCore API calls.
|
||||||
*/
|
*/
|
||||||
JS_EXPORT void* JSObjectGetTypedArrayBytesPtr(JSContextRef ctx, JSObjectRef object, JSValueRef* exception) CF_AVAILABLE(10_12, 10_0);
|
JS_EXPORT void* JSObjectGetTypedArrayBytesPtr(JSContextRef ctx, JSObjectRef object, JSValueRef* exception) JSC_API_AVAILABLE(macos(10.12), ios(10.0));
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@function
|
@function
|
||||||
|
@ -105,7 +105,7 @@ JS_EXPORT void* JSObjectGetTypedArrayBytesPtr(JSContextRef ctx, JSObjectRef obje
|
||||||
@param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
|
@param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
|
||||||
@result The length of the Typed Array object or 0 if the object is not a Typed Array object.
|
@result The length of the Typed Array object or 0 if the object is not a Typed Array object.
|
||||||
*/
|
*/
|
||||||
JS_EXPORT size_t JSObjectGetTypedArrayLength(JSContextRef ctx, JSObjectRef object, JSValueRef* exception) CF_AVAILABLE(10_12, 10_0);
|
JS_EXPORT size_t JSObjectGetTypedArrayLength(JSContextRef ctx, JSObjectRef object, JSValueRef* exception) JSC_API_AVAILABLE(macos(10.12), ios(10.0));
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@function
|
@function
|
||||||
|
@ -115,7 +115,7 @@ JS_EXPORT size_t JSObjectGetTypedArrayLength(JSContextRef ctx, JSObjectRef objec
|
||||||
@param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
|
@param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
|
||||||
@result The byte length of the Typed Array object or 0 if the object is not a Typed Array object.
|
@result The byte length of the Typed Array object or 0 if the object is not a Typed Array object.
|
||||||
*/
|
*/
|
||||||
JS_EXPORT size_t JSObjectGetTypedArrayByteLength(JSContextRef ctx, JSObjectRef object, JSValueRef* exception) CF_AVAILABLE(10_12, 10_0);
|
JS_EXPORT size_t JSObjectGetTypedArrayByteLength(JSContextRef ctx, JSObjectRef object, JSValueRef* exception) JSC_API_AVAILABLE(macos(10.12), ios(10.0));
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@function
|
@function
|
||||||
|
@ -125,7 +125,7 @@ JS_EXPORT size_t JSObjectGetTypedArrayByteLength(JSContextRef ctx, JSObjectRef o
|
||||||
@param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
|
@param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
|
||||||
@result The byte offset of the Typed Array object or 0 if the object is not a Typed Array object.
|
@result The byte offset of the Typed Array object or 0 if the object is not a Typed Array object.
|
||||||
*/
|
*/
|
||||||
JS_EXPORT size_t JSObjectGetTypedArrayByteOffset(JSContextRef ctx, JSObjectRef object, JSValueRef* exception) CF_AVAILABLE(10_12, 10_0);
|
JS_EXPORT size_t JSObjectGetTypedArrayByteOffset(JSContextRef ctx, JSObjectRef object, JSValueRef* exception) JSC_API_AVAILABLE(macos(10.12), ios(10.0));
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@function
|
@function
|
||||||
|
@ -135,7 +135,7 @@ JS_EXPORT size_t JSObjectGetTypedArrayByteOffset(JSContextRef ctx, JSObjectRef o
|
||||||
@param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
|
@param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
|
||||||
@result A JSObjectRef with a JSTypedArrayType of kJSTypedArrayTypeArrayBuffer or NULL if object is not a Typed Array.
|
@result A JSObjectRef with a JSTypedArrayType of kJSTypedArrayTypeArrayBuffer or NULL if object is not a Typed Array.
|
||||||
*/
|
*/
|
||||||
JS_EXPORT JSObjectRef JSObjectGetTypedArrayBuffer(JSContextRef ctx, JSObjectRef object, JSValueRef* exception) CF_AVAILABLE(10_12, 10_0);
|
JS_EXPORT JSObjectRef JSObjectGetTypedArrayBuffer(JSContextRef ctx, JSObjectRef object, JSValueRef* exception) JSC_API_AVAILABLE(macos(10.12), ios(10.0));
|
||||||
|
|
||||||
// ------------- Array Buffer functions -------------
|
// ------------- Array Buffer functions -------------
|
||||||
|
|
||||||
|
@ -151,7 +151,7 @@ JS_EXPORT JSObjectRef JSObjectGetTypedArrayBuffer(JSContextRef ctx, JSObjectRef
|
||||||
@result A JSObjectRef Array Buffer whose backing store is the same as the one pointed to by bytes or NULL if there was an error.
|
@result A JSObjectRef Array Buffer whose backing store is the same as the one pointed to by bytes or NULL if there was an error.
|
||||||
@discussion If an exception is thrown during this function the bytesDeallocator will always be called.
|
@discussion If an exception is thrown during this function the bytesDeallocator will always be called.
|
||||||
*/
|
*/
|
||||||
JS_EXPORT JSObjectRef JSObjectMakeArrayBufferWithBytesNoCopy(JSContextRef ctx, void* bytes, size_t byteLength, JSTypedArrayBytesDeallocator bytesDeallocator, void* deallocatorContext, JSValueRef* exception) CF_AVAILABLE(10_12, 10_0);
|
JS_EXPORT JSObjectRef JSObjectMakeArrayBufferWithBytesNoCopy(JSContextRef ctx, void* bytes, size_t byteLength, JSTypedArrayBytesDeallocator bytesDeallocator, void* deallocatorContext, JSValueRef* exception) JSC_API_AVAILABLE(macos(10.12), ios(10.0));
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@function
|
@function
|
||||||
|
@ -161,7 +161,7 @@ JS_EXPORT JSObjectRef JSObjectMakeArrayBufferWithBytesNoCopy(JSContextRef ctx, v
|
||||||
@result A pointer to the raw data buffer that serves as object's backing store or NULL if object is not an Array Buffer object.
|
@result A pointer to the raw data buffer that serves as object's backing store or NULL if object is not an Array Buffer object.
|
||||||
@discussion The pointer returned by this function is temporary and is not guaranteed to remain valid across JavaScriptCore API calls.
|
@discussion The pointer returned by this function is temporary and is not guaranteed to remain valid across JavaScriptCore API calls.
|
||||||
*/
|
*/
|
||||||
JS_EXPORT void* JSObjectGetArrayBufferBytesPtr(JSContextRef ctx, JSObjectRef object, JSValueRef* exception) CF_AVAILABLE(10_12, 10_0);
|
JS_EXPORT void* JSObjectGetArrayBufferBytesPtr(JSContextRef ctx, JSObjectRef object, JSValueRef* exception) JSC_API_AVAILABLE(macos(10.12), ios(10.0));
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@function
|
@function
|
||||||
|
@ -171,7 +171,7 @@ JS_EXPORT void* JSObjectGetArrayBufferBytesPtr(JSContextRef ctx, JSObjectRef obj
|
||||||
@param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
|
@param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
|
||||||
@result The number of bytes stored in the data object.
|
@result The number of bytes stored in the data object.
|
||||||
*/
|
*/
|
||||||
JS_EXPORT size_t JSObjectGetArrayBufferByteLength(JSContextRef ctx, JSObjectRef object, JSValueRef* exception) CF_AVAILABLE(10_12, 10_0);
|
JS_EXPORT size_t JSObjectGetArrayBufferByteLength(JSContextRef ctx, JSObjectRef object, JSValueRef* exception) JSC_API_AVAILABLE(macos(10.12), ios(10.0));
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2006 Apple Inc. All rights reserved.
|
* Copyright (C) 2006-2019 Apple Inc. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
|
@ -42,6 +42,7 @@
|
||||||
@constant kJSTypeNumber A primitive number value.
|
@constant kJSTypeNumber A primitive number value.
|
||||||
@constant kJSTypeString A primitive string value.
|
@constant kJSTypeString A primitive string value.
|
||||||
@constant kJSTypeObject An object value (meaning that this JSValueRef is a JSObjectRef).
|
@constant kJSTypeObject An object value (meaning that this JSValueRef is a JSObjectRef).
|
||||||
|
@constant kJSTypeSymbol A primitive symbol value.
|
||||||
*/
|
*/
|
||||||
typedef enum {
|
typedef enum {
|
||||||
kJSTypeUndefined,
|
kJSTypeUndefined,
|
||||||
|
@ -49,7 +50,8 @@ typedef enum {
|
||||||
kJSTypeBoolean,
|
kJSTypeBoolean,
|
||||||
kJSTypeNumber,
|
kJSTypeNumber,
|
||||||
kJSTypeString,
|
kJSTypeString,
|
||||||
kJSTypeObject
|
kJSTypeObject,
|
||||||
|
kJSTypeSymbol JSC_API_AVAILABLE(macos(10.15), ios(13.0))
|
||||||
} JSType;
|
} JSType;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -80,7 +82,7 @@ typedef enum {
|
||||||
kJSTypedArrayTypeFloat64Array,
|
kJSTypedArrayTypeFloat64Array,
|
||||||
kJSTypedArrayTypeArrayBuffer,
|
kJSTypedArrayTypeArrayBuffer,
|
||||||
kJSTypedArrayTypeNone,
|
kJSTypedArrayTypeNone,
|
||||||
} JSTypedArrayType CF_ENUM_AVAILABLE(10_12, 10_0);
|
} JSTypedArrayType JSC_API_AVAILABLE(macos(10.12), ios(10.0));
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -140,6 +142,15 @@ JS_EXPORT bool JSValueIsNumber(JSContextRef ctx, JSValueRef value);
|
||||||
*/
|
*/
|
||||||
JS_EXPORT bool JSValueIsString(JSContextRef ctx, JSValueRef value);
|
JS_EXPORT bool JSValueIsString(JSContextRef ctx, JSValueRef value);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
@function
|
||||||
|
@abstract Tests whether a JavaScript value's type is the symbol type.
|
||||||
|
@param ctx The execution context to use.
|
||||||
|
@param value The JSValue to test.
|
||||||
|
@result true if value's type is the symbol type, otherwise false.
|
||||||
|
*/
|
||||||
|
JS_EXPORT bool JSValueIsSymbol(JSContextRef ctx, JSValueRef value) JSC_API_AVAILABLE(macos(10.15), ios(13.0));
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@function
|
@function
|
||||||
@abstract Tests whether a JavaScript value's type is the object type.
|
@abstract Tests whether a JavaScript value's type is the object type.
|
||||||
|
@ -149,6 +160,7 @@ JS_EXPORT bool JSValueIsString(JSContextRef ctx, JSValueRef value);
|
||||||
*/
|
*/
|
||||||
JS_EXPORT bool JSValueIsObject(JSContextRef ctx, JSValueRef value);
|
JS_EXPORT bool JSValueIsObject(JSContextRef ctx, JSValueRef value);
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@function
|
@function
|
||||||
@abstract Tests whether a JavaScript value is an object with a given class in its class chain.
|
@abstract Tests whether a JavaScript value is an object with a given class in its class chain.
|
||||||
|
@ -166,7 +178,7 @@ JS_EXPORT bool JSValueIsObjectOfClass(JSContextRef ctx, JSValueRef value, JSClas
|
||||||
@param value The JSValue to test.
|
@param value The JSValue to test.
|
||||||
@result true if value is an array, otherwise false.
|
@result true if value is an array, otherwise false.
|
||||||
*/
|
*/
|
||||||
JS_EXPORT bool JSValueIsArray(JSContextRef ctx, JSValueRef value) CF_AVAILABLE(10_11, 9_0);
|
JS_EXPORT bool JSValueIsArray(JSContextRef ctx, JSValueRef value) JSC_API_AVAILABLE(macos(10.11), ios(9.0));
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@function
|
@function
|
||||||
|
@ -175,7 +187,7 @@ JS_EXPORT bool JSValueIsArray(JSContextRef ctx, JSValueRef value) CF_AVAILABLE(1
|
||||||
@param value The JSValue to test.
|
@param value The JSValue to test.
|
||||||
@result true if value is a date, otherwise false.
|
@result true if value is a date, otherwise false.
|
||||||
*/
|
*/
|
||||||
JS_EXPORT bool JSValueIsDate(JSContextRef ctx, JSValueRef value) CF_AVAILABLE(10_11, 9_0);
|
JS_EXPORT bool JSValueIsDate(JSContextRef ctx, JSValueRef value) JSC_API_AVAILABLE(macos(10.11), ios(9.0));
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@function
|
@function
|
||||||
|
@ -185,7 +197,7 @@ JS_EXPORT bool JSValueIsDate(JSContextRef ctx, JSValueRef value) CF_AVAILABLE(10
|
||||||
@param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
|
@param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
|
||||||
@result A value of type JSTypedArrayType that identifies value's Typed Array type, or kJSTypedArrayTypeNone if the value is not a Typed Array object.
|
@result A value of type JSTypedArrayType that identifies value's Typed Array type, or kJSTypedArrayTypeNone if the value is not a Typed Array object.
|
||||||
*/
|
*/
|
||||||
JS_EXPORT JSTypedArrayType JSValueGetTypedArrayType(JSContextRef ctx, JSValueRef value, JSValueRef* exception) CF_AVAILABLE(10_12, 10_0);
|
JS_EXPORT JSTypedArrayType JSValueGetTypedArrayType(JSContextRef ctx, JSValueRef value, JSValueRef* exception) JSC_API_AVAILABLE(macos(10.12), ios(10.0));
|
||||||
|
|
||||||
/* Comparing values */
|
/* Comparing values */
|
||||||
|
|
||||||
|
@ -267,6 +279,15 @@ JS_EXPORT JSValueRef JSValueMakeNumber(JSContextRef ctx, double number);
|
||||||
*/
|
*/
|
||||||
JS_EXPORT JSValueRef JSValueMakeString(JSContextRef ctx, JSStringRef string);
|
JS_EXPORT JSValueRef JSValueMakeString(JSContextRef ctx, JSStringRef string);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
@function
|
||||||
|
@abstract Creates a JavaScript value of the symbol type.
|
||||||
|
@param ctx The execution context to use.
|
||||||
|
@param description A description of the newly created symbol value.
|
||||||
|
@result A unique JSValue of the symbol type, whose description matches the one provided.
|
||||||
|
*/
|
||||||
|
JS_EXPORT JSValueRef JSValueMakeSymbol(JSContextRef ctx, JSStringRef description) JSC_API_AVAILABLE(macos(10.15), ios(13.0));
|
||||||
|
|
||||||
/* Converting to and from JSON formatted strings */
|
/* Converting to and from JSON formatted strings */
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -276,7 +297,7 @@ JS_EXPORT JSValueRef JSValueMakeString(JSContextRef ctx, JSStringRef string);
|
||||||
@param string The JSString containing the JSON string to be parsed.
|
@param string The JSString containing the JSON string to be parsed.
|
||||||
@result A JSValue containing the parsed value, or NULL if the input is invalid.
|
@result A JSValue containing the parsed value, or NULL if the input is invalid.
|
||||||
*/
|
*/
|
||||||
JS_EXPORT JSValueRef JSValueMakeFromJSONString(JSContextRef ctx, JSStringRef string) CF_AVAILABLE(10_7, 7_0);
|
JS_EXPORT JSValueRef JSValueMakeFromJSONString(JSContextRef ctx, JSStringRef string) JSC_API_AVAILABLE(macos(10.7), ios(7.0));
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@function
|
@function
|
||||||
|
@ -287,7 +308,7 @@ JS_EXPORT JSValueRef JSValueMakeFromJSONString(JSContextRef ctx, JSStringRef str
|
||||||
@param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
|
@param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
|
||||||
@result A JSString with the result of serialization, or NULL if an exception is thrown.
|
@result A JSString with the result of serialization, or NULL if an exception is thrown.
|
||||||
*/
|
*/
|
||||||
JS_EXPORT JSStringRef JSValueCreateJSONString(JSContextRef ctx, JSValueRef value, unsigned indent, JSValueRef* exception) CF_AVAILABLE(10_7, 7_0);
|
JS_EXPORT JSStringRef JSValueCreateJSONString(JSContextRef ctx, JSValueRef value, unsigned indent, JSValueRef* exception) JSC_API_AVAILABLE(macos(10.7), ios(7.0));
|
||||||
|
|
||||||
/* Converting to primitive values */
|
/* Converting to primitive values */
|
||||||
|
|
||||||
|
|
|
@ -66,20 +66,15 @@
|
||||||
#define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER
|
#define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* __MAC_OS_X_VERSION_MIN_REQUIRED <= 101100 */
|
#endif /* !TARGET_OS_IPHONE && __MAC_OS_X_VERSION_MIN_REQUIRED < 101100 */
|
||||||
|
|
||||||
#if defined(BUILDING_GTK__)
|
#if defined(BUILDING_GTK__)
|
||||||
#undef CF_AVAILABLE
|
#undef JSC_API_AVAILABLE
|
||||||
#define CF_AVAILABLE(_mac, _ios)
|
#define JSC_API_AVAILABLE(...)
|
||||||
#undef CF_ENUM_AVAILABLE
|
|
||||||
#define CF_ENUM_AVAILABLE(_mac, _ios)
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#ifndef CF_AVAILABLE
|
#define JSC_API_AVAILABLE(...)
|
||||||
#define CF_AVAILABLE(_mac, _ios)
|
|
||||||
#define CF_ENUM_AVAILABLE(_mac, _ios)
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* __WebKitAvailability__ */
|
#endif /* __WebKitAvailability__ */
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
# Ultralight-API
|
||||||
|
|
||||||
|
These are the C/C++ API Headers for the Ultralight SDK
|
||||||
|
|
||||||
|
For more info see: [ultralight-ux/Ultralight](https://github.com/ultralight-ux/Ultralight)
|
|
@ -0,0 +1,279 @@
|
||||||
|
///
|
||||||
|
/// @file Bitmap.h
|
||||||
|
///
|
||||||
|
/// @brief The header for the Bitmap class.
|
||||||
|
///
|
||||||
|
/// @author
|
||||||
|
///
|
||||||
|
/// This file is a part of Ultralight, a fast, lightweight, HTML UI engine
|
||||||
|
///
|
||||||
|
/// Website: <http://ultralig.ht>
|
||||||
|
///
|
||||||
|
/// Copyright (C) 2020 Ultralight, Inc. All rights reserved.
|
||||||
|
///
|
||||||
|
#pragma once
|
||||||
|
#include <Ultralight/Defines.h>
|
||||||
|
#include <Ultralight/RefPtr.h>
|
||||||
|
#include <Ultralight/Geometry.h>
|
||||||
|
|
||||||
|
namespace ultralight {
|
||||||
|
|
||||||
|
#pragma pack(push, 1)
|
||||||
|
|
||||||
|
///
|
||||||
|
/// The various Bitmap formats.
|
||||||
|
///
|
||||||
|
enum UExport BitmapFormat {
|
||||||
|
/**
|
||||||
|
* Alpha channel only, 8-bits per pixel.
|
||||||
|
*
|
||||||
|
* Encoding: 8-bits per channel, unsigned normalized.
|
||||||
|
*
|
||||||
|
* Color-space: Linear (no gamma), alpha-coverage only.
|
||||||
|
*/
|
||||||
|
kBitmapFormat_A8_UNORM,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Blue Green Red Alpha channels, 32-bits per pixel.
|
||||||
|
*
|
||||||
|
* Encoding: 8-bits per channel, unsigned normalized.
|
||||||
|
*
|
||||||
|
* Color-space: sRGB gamma with premultiplied linear alpha channel.
|
||||||
|
*
|
||||||
|
* NOTE: Alpha is premultiplied with BGR channels _before_ sRGB gamma is
|
||||||
|
* applied so we can use sRGB conversion hardware and perform all
|
||||||
|
* blending in linear space on GPU.
|
||||||
|
*/
|
||||||
|
kBitmapFormat_BGRA8_UNORM_SRGB,
|
||||||
|
};
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Macro to get the bytes per pixel from a BitmapFormat
|
||||||
|
///
|
||||||
|
#define GetBytesPerPixel(x) (x == kBitmapFormat_A8_UNORM? 1 : 4)
|
||||||
|
|
||||||
|
///
|
||||||
|
/// @brief Bitmap container with basic blitting and conversion routines.
|
||||||
|
///
|
||||||
|
class UExport Bitmap : public RefCounted {
|
||||||
|
public:
|
||||||
|
///
|
||||||
|
/// Create an empty Bitmap. No pixels will be allocated.
|
||||||
|
///
|
||||||
|
static Ref<Bitmap> Create();
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Create a Bitmap with a certain configuration. Pixels will be allocated
|
||||||
|
/// but not initialized.
|
||||||
|
///
|
||||||
|
/// @param width The width in pixels.
|
||||||
|
///
|
||||||
|
/// @param height The height in pixels.
|
||||||
|
///
|
||||||
|
/// @param format The pixel format to use.
|
||||||
|
///
|
||||||
|
/// @return A ref-pointer to a new Bitmap instance.
|
||||||
|
///
|
||||||
|
static Ref<Bitmap> Create(uint32_t width, uint32_t height,
|
||||||
|
BitmapFormat format);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Create a Bitmap with existing pixels and configuration.
|
||||||
|
///
|
||||||
|
/// @param width The width in pixels.
|
||||||
|
///
|
||||||
|
/// @param height The height in pixels.
|
||||||
|
///
|
||||||
|
/// @param format The pixel format to use.
|
||||||
|
///
|
||||||
|
/// @param row_bytes The number of bytes between each row (note that this
|
||||||
|
/// value should be >= width * bytes_per_pixel).
|
||||||
|
///
|
||||||
|
/// @param pixels Pointer to raw pixel buffer.
|
||||||
|
///
|
||||||
|
/// @param size Size of the raw pixel buffer.
|
||||||
|
///
|
||||||
|
/// @param should_copy Whether or not a copy should be made of the pixels.
|
||||||
|
/// If this is false, the returned Bitmap will use the
|
||||||
|
/// raw pixels passed in as its own, but you are still
|
||||||
|
/// responsible for destroying your buffer afterwards.
|
||||||
|
///
|
||||||
|
/// @param fixup_gamma Whether or not we should reinterpret the source
|
||||||
|
/// as an sRGB bitmap with premultiplied alpha applied
|
||||||
|
/// after the gamma function (typical of PNGs). We
|
||||||
|
/// expect all premultiplication to be applied before
|
||||||
|
/// the gamma function so we can blend properly in
|
||||||
|
/// linear space. Only valid for
|
||||||
|
/// kBitmapFormat_BGRA8_UNORM_SRGB.
|
||||||
|
///
|
||||||
|
/// @return A ref-pointer to a new Bitmap instance.
|
||||||
|
///
|
||||||
|
static Ref<Bitmap> Create(uint32_t width, uint32_t height,
|
||||||
|
BitmapFormat format, uint32_t row_bytes,
|
||||||
|
const void* pixels, size_t size,
|
||||||
|
bool should_copy = true, bool fixup_gamma = false);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Create a bitmap from a deep copy of another Bitmap.
|
||||||
|
///
|
||||||
|
static Ref<Bitmap> Create(const Bitmap& bitmap);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get the width in pixels.
|
||||||
|
///
|
||||||
|
virtual uint32_t width() const = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get the height in pixels.
|
||||||
|
///
|
||||||
|
virtual uint32_t height() const = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get the bounds as an IntRect
|
||||||
|
///
|
||||||
|
virtual IntRect bounds() const = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get the pixel format.
|
||||||
|
///
|
||||||
|
virtual BitmapFormat format() const = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get the number of bytes per pixel.
|
||||||
|
///
|
||||||
|
virtual uint32_t bpp() const = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get the number of bytes between each row of pixels.
|
||||||
|
///
|
||||||
|
/// @note This value is usually calculated as width * bytes_per_pixel (bpp)
|
||||||
|
/// but it may be larger due to alignment rules in the allocator.
|
||||||
|
///
|
||||||
|
virtual uint32_t row_bytes() const = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get the size in bytes of the pixel buffer.
|
||||||
|
///
|
||||||
|
/// @note Size is calculated as row_bytes() * height().
|
||||||
|
///
|
||||||
|
virtual size_t size() const = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Whether or not this Bitmap owns the pixel buffer and will destroy it
|
||||||
|
/// at the end of its lifetime.
|
||||||
|
///
|
||||||
|
virtual bool owns_pixels() const = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Lock the pixel buffer for reading/writing.
|
||||||
|
///
|
||||||
|
/// @return A pointer to the pixel buffer.
|
||||||
|
///
|
||||||
|
virtual void* LockPixels() = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Unlock the pixel buffer.
|
||||||
|
///
|
||||||
|
virtual void UnlockPixels() = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Lock the pixel buffer for reading/writing. (const)
|
||||||
|
///
|
||||||
|
/// @return A const pointer to the pixel buffer.
|
||||||
|
///
|
||||||
|
virtual const void* LockPixels() const = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Unlock the pixel buffer. (const)
|
||||||
|
///
|
||||||
|
virtual void UnlockPixels() const = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get the raw pixel buffer.
|
||||||
|
///
|
||||||
|
/// @note You should only call this if pixels are already locked.
|
||||||
|
///
|
||||||
|
virtual void* raw_pixels() = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Whether or not this Bitmap is empty (no pixels allocated).
|
||||||
|
///
|
||||||
|
virtual bool IsEmpty() const = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Erase the Bitmap (set all pixels to 0).
|
||||||
|
///
|
||||||
|
virtual void Erase() = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Assign another bitmap to this one.
|
||||||
|
///
|
||||||
|
/// @param bitmap The bitmap to copy from.
|
||||||
|
///
|
||||||
|
virtual void Set(Ref<Bitmap> bitmap) = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Draw another bitmap to this bitmap.
|
||||||
|
///
|
||||||
|
/// @note Formats do not need to match. Bitmap formats will be converted
|
||||||
|
/// to one another automatically. Note that when converting from
|
||||||
|
/// BGRA8 to A8, only the Blue channel will be used.
|
||||||
|
///
|
||||||
|
/// @param src_rect The source rectangle, relative to src bitmap.
|
||||||
|
///
|
||||||
|
/// @param dest_rect The destination rectangle, relative to this bitmap.
|
||||||
|
///
|
||||||
|
/// @param src The source bitmap.
|
||||||
|
///
|
||||||
|
/// @param pad_repeat Whether or not we should pad the drawn bitmap by one
|
||||||
|
/// pixel of repeated edge pixels from the source bitmap.
|
||||||
|
///
|
||||||
|
/// @return Whether or not the operation succeeded (this can fail if the
|
||||||
|
/// src_rect and/or dest_rect are invalid, or if their total
|
||||||
|
/// dimensions do not match).
|
||||||
|
///
|
||||||
|
virtual bool DrawBitmap(IntRect src_rect, IntRect dest_rect,
|
||||||
|
Ref<Bitmap> src, bool pad_repeat) = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Write this Bitmap out to a PNG image. (mainly used for Debug)
|
||||||
|
///
|
||||||
|
/// @param path The filepath to write to (opened with fopen())
|
||||||
|
///
|
||||||
|
/// @return Whether or not the operation succeeded.
|
||||||
|
///
|
||||||
|
virtual bool WritePNG(const char* path) = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Make a resized copy of this bitmap by writing to a pre-allocated
|
||||||
|
/// destination bitmap.
|
||||||
|
///
|
||||||
|
/// @param destination The bitmap to store the result in, the width and
|
||||||
|
/// height of the destination will be used.
|
||||||
|
///
|
||||||
|
/// @param high_quality Whether or not a high quality resampling will be
|
||||||
|
/// used during the resize. (Otherwise, just uses fast
|
||||||
|
/// nearest-neighbor sampling)
|
||||||
|
///
|
||||||
|
/// @return Whether or not the operation succeeded. This operation is only
|
||||||
|
/// valid if both formats are kBitmapFormat_BGRA8_UNORM_SRGB and
|
||||||
|
/// both the source and destination are non-empty.
|
||||||
|
///
|
||||||
|
virtual bool Resample(Ref<Bitmap> destination, bool high_quality) = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// This converts a BGRA bitmap to RGBA bitmap and vice-versa by swapping
|
||||||
|
/// the red and blue channels.
|
||||||
|
///
|
||||||
|
virtual void SwapRedBlueChannels() = 0;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
Bitmap();
|
||||||
|
virtual ~Bitmap();
|
||||||
|
Bitmap(const Bitmap&);
|
||||||
|
void operator=(const Bitmap&);
|
||||||
|
};
|
||||||
|
|
||||||
|
#pragma pack(pop)
|
||||||
|
|
||||||
|
} // namespace ultralight
|
|
@ -0,0 +1,47 @@
|
||||||
|
///
|
||||||
|
/// @file Buffer.h
|
||||||
|
///
|
||||||
|
/// @brief The header for the Buffer class.
|
||||||
|
///
|
||||||
|
/// @author
|
||||||
|
///
|
||||||
|
/// This file is a part of Ultralight, a fast, lightweight, HTML UI engine
|
||||||
|
///
|
||||||
|
/// Website: <http://ultralig.ht>
|
||||||
|
///
|
||||||
|
/// Copyright (C) 2020 Ultralight, Inc. All rights reserved.
|
||||||
|
///
|
||||||
|
#pragma once
|
||||||
|
#include <Ultralight/Defines.h>
|
||||||
|
#include <Ultralight/RefPtr.h>
|
||||||
|
|
||||||
|
namespace ultralight {
|
||||||
|
|
||||||
|
///
|
||||||
|
/// A fixed-size byte container for passing data around.
|
||||||
|
///
|
||||||
|
class UExport Buffer : public RefCounted {
|
||||||
|
public:
|
||||||
|
///
|
||||||
|
/// Create a Buffer, a copy of data is made.
|
||||||
|
///
|
||||||
|
static Ref<Buffer> Create(const void* data, size_t size);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get a pointer to raw byte data.
|
||||||
|
///
|
||||||
|
virtual void* data() = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get the size in bytes.
|
||||||
|
///
|
||||||
|
virtual size_t size() const = 0;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
Buffer();
|
||||||
|
virtual ~Buffer();
|
||||||
|
Buffer(const Buffer&);
|
||||||
|
void operator=(const Buffer&);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace ultralight
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,103 @@
|
||||||
|
///
|
||||||
|
/// @file Defines.h
|
||||||
|
///
|
||||||
|
/// @brief Common platform definitions
|
||||||
|
///
|
||||||
|
/// @author
|
||||||
|
///
|
||||||
|
/// This file is a part of Ultralight, a next-generation HTML renderer.
|
||||||
|
///
|
||||||
|
/// Website: <http://ultralig.ht>
|
||||||
|
///
|
||||||
|
/// Copyright (C) 2020 Ultralight, Inc. All rights reserved.
|
||||||
|
///
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
// Needed for limit defines, like INTMAX_MAX, which is used by the std C++ library
|
||||||
|
#ifndef __STDC_LIMIT_MACROS
|
||||||
|
#define __STDC_LIMIT_MACROS
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include <cstddef>
|
||||||
|
#include <limits.h>
|
||||||
|
|
||||||
|
#ifdef SWIG
|
||||||
|
#define UExport
|
||||||
|
#else
|
||||||
|
|
||||||
|
// Require C++11 Support
|
||||||
|
#if defined(_MSC_VER)
|
||||||
|
# if _MSC_VER < 1800
|
||||||
|
# error This project needs at least Visual Studio 2013 to build
|
||||||
|
# endif
|
||||||
|
#elif __cplusplus <= 199711L
|
||||||
|
# error This project can only be compiled with a compiler that supports C++11
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(__WIN32__) || defined(_WIN32)
|
||||||
|
# if defined(ULTRALIGHT_STATIC_BUILD)
|
||||||
|
# define UExport
|
||||||
|
# else
|
||||||
|
# if defined(ULTRALIGHT_IMPLEMENTATION)
|
||||||
|
# define UExport __declspec(dllexport)
|
||||||
|
# else
|
||||||
|
# define UExport __declspec(dllimport)
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
#define _thread_local __declspec(thread)
|
||||||
|
#ifndef _NATIVE_WCHAR_T_DEFINED
|
||||||
|
#define DISABLE_NATIVE_WCHAR_T
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
# if defined(ULTRALIGHT_STATIC_BUILD)
|
||||||
|
# define UExport
|
||||||
|
# else
|
||||||
|
# define UExport __attribute__((visibility("default")))
|
||||||
|
# endif
|
||||||
|
#define _thread_local __thread
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define ULTRALIGHT_VERSION "1.2.1"
|
||||||
|
#define ULTRALIGHT_VERSION_MAJOR 1
|
||||||
|
#define ULTRALIGHT_VERSION_MINOR 2
|
||||||
|
#define ULTRALIGHT_VERSION_PATCH 1
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
UExport const char* UltralightVersionString();
|
||||||
|
UExport uint32_t UltralightVersionMajor();
|
||||||
|
UExport uint32_t UltralightVersionMinor();
|
||||||
|
UExport uint32_t UltralightVersionPatch();
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
///
|
||||||
|
/// @mainpage Ultralight C++ API Reference
|
||||||
|
///
|
||||||
|
/// @section intro_sec Introduction
|
||||||
|
///
|
||||||
|
/// Hi there, welcome to the C++ API Reference for Ultralight!
|
||||||
|
///
|
||||||
|
/// Ultralight is a next-generation HTML renderer for desktop apps and games.
|
||||||
|
///
|
||||||
|
/// If this is your first time exploring the API, we recommend
|
||||||
|
/// starting with ultralight::Renderer and ultralight::View.
|
||||||
|
///
|
||||||
|
///
|
||||||
|
/// @section usefullinks_sec Useful Links
|
||||||
|
/// - Home: <https://ultralig.ht> -- Get the latest binaries
|
||||||
|
/// - Docs: <https://docs.ultralig.ht> -- API overview, code snippets, tutorials and more!
|
||||||
|
/// - Discord: <http://chat.ultralig.ht/> -- Stuck? Have questions? Come chat with us!
|
||||||
|
/// - GitHub: <https://github.com/ultralight-ux/ultralight> -- Report issues and browse code
|
||||||
|
///
|
||||||
|
/// @section copyright_sec Copyright
|
||||||
|
/// Documentation is Copyright (C) 2020 Ultralight, Inc. All rights reserved.
|
||||||
|
///
|
|
@ -0,0 +1,677 @@
|
||||||
|
///
|
||||||
|
/// @file Geometry.h
|
||||||
|
///
|
||||||
|
/// @brief The header for various geometry definitions and helpers
|
||||||
|
///
|
||||||
|
/// @author
|
||||||
|
///
|
||||||
|
/// This file is a part of Ultralight, a fast, lightweight, HTML UI engine
|
||||||
|
///
|
||||||
|
/// Website: <http://ultralig.ht>
|
||||||
|
///
|
||||||
|
/// Copyright (C) 2020 Ultralight, Inc. All rights reserved.
|
||||||
|
///
|
||||||
|
#pragma once
|
||||||
|
#include <Ultralight/Defines.h>
|
||||||
|
#include <memory.h>
|
||||||
|
#include <cmath>
|
||||||
|
#include <cstring>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
|
namespace ultralight {
|
||||||
|
|
||||||
|
///
|
||||||
|
/// 2D Vector Helper
|
||||||
|
///
|
||||||
|
struct UExport vec2 {
|
||||||
|
union {
|
||||||
|
float value[2];
|
||||||
|
struct { float x, y; };
|
||||||
|
};
|
||||||
|
|
||||||
|
inline vec2() {}
|
||||||
|
|
||||||
|
inline vec2(float x, float y) : x(x), y(y) {}
|
||||||
|
|
||||||
|
inline vec2(float x) : x(x), y(x) {}
|
||||||
|
|
||||||
|
inline vec2 yx() const { return { y, x }; }
|
||||||
|
|
||||||
|
inline vec2 xx() const { return { x, x }; }
|
||||||
|
|
||||||
|
inline vec2 yy() const { return { y, y }; }
|
||||||
|
|
||||||
|
inline friend vec2 operator+(vec2 lhs, const vec2& rhs) { lhs += rhs; return lhs; }
|
||||||
|
|
||||||
|
inline friend vec2 operator-(vec2 lhs, const vec2& rhs) { lhs -= rhs; return lhs; }
|
||||||
|
|
||||||
|
inline friend vec2 operator*(vec2 lhs, const vec2& rhs) { lhs *= rhs; return lhs; }
|
||||||
|
|
||||||
|
inline friend vec2 operator/(vec2 lhs, const vec2& rhs) { lhs /= rhs; return lhs; }
|
||||||
|
|
||||||
|
inline friend vec2 operator+(vec2 lhs, float rhs) { lhs += rhs; return lhs; }
|
||||||
|
|
||||||
|
inline friend vec2 operator-(vec2 lhs, float rhs) { lhs -= rhs; return lhs; }
|
||||||
|
|
||||||
|
inline friend vec2 operator*(vec2 lhs, float rhs) { lhs *= rhs; return lhs; }
|
||||||
|
|
||||||
|
inline friend vec2 operator/(vec2 lhs, float rhs) { lhs /= rhs; return lhs; }
|
||||||
|
|
||||||
|
inline vec2& operator+=(const vec2& rhs) {
|
||||||
|
value[0] += rhs.value[0];
|
||||||
|
value[1] += rhs.value[1];
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline vec2& operator-=(const vec2& rhs) {
|
||||||
|
value[0] -= rhs.value[0];
|
||||||
|
value[1] -= rhs.value[1];
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline vec2& operator*=(const vec2& rhs) {
|
||||||
|
value[0] *= rhs.value[0];
|
||||||
|
value[1] *= rhs.value[1];
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline vec2& operator/=(const vec2& rhs) {
|
||||||
|
value[0] /= rhs.value[0];
|
||||||
|
value[1] /= rhs.value[1];
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline vec2& operator+=(float rhs) {
|
||||||
|
value[0] += rhs;
|
||||||
|
value[1] += rhs;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline vec2& operator-=(float rhs) {
|
||||||
|
value[0] -= rhs;
|
||||||
|
value[1] -= rhs;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline vec2& operator*=(float rhs) {
|
||||||
|
value[0] *= rhs;
|
||||||
|
value[1] *= rhs;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline vec2& operator/=(float rhs) {
|
||||||
|
value[0] /= rhs;
|
||||||
|
value[1] /= rhs;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline friend bool operator==(const vec2& a, const vec2& b) {
|
||||||
|
return !memcmp(&a, &b, sizeof(a));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline friend bool operator!=(const vec2& a, const vec2& b) {
|
||||||
|
return !(a == b);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline friend vec2 min_(const vec2& a, const vec2& b) {
|
||||||
|
return{ (b.x < a.x) ? b.x : a.x,
|
||||||
|
(b.y < a.y) ? b.y : a.y };
|
||||||
|
}
|
||||||
|
|
||||||
|
inline friend vec2 max_(const vec2& a, const vec2& b) {
|
||||||
|
return{ (a.x < b.x) ? b.x : a.x,
|
||||||
|
(a.y < b.y) ? b.y : a.y };
|
||||||
|
}
|
||||||
|
|
||||||
|
inline friend vec2 clamp(const vec2& x, const vec2& minVal, const vec2& maxVal) {
|
||||||
|
return min_(max_(x, minVal), maxVal);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline friend vec2 mix(const vec2& a, const vec2& b, float t) {
|
||||||
|
return a * (1.0f - t) + b * t;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline friend float length(const vec2& a) {
|
||||||
|
return sqrtf(a.x * a.x + a.y * a.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
// squared length
|
||||||
|
inline friend float length2(const vec2& a) {
|
||||||
|
return dot(a, a);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline friend float distance(const vec2& a, const vec2& b) {
|
||||||
|
return length(a - b);
|
||||||
|
}
|
||||||
|
|
||||||
|
// squared distance
|
||||||
|
inline friend float distance2(const vec2& a, const vec2& b) {
|
||||||
|
return length2(a - b);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline friend vec2 normalize(const vec2& a) {
|
||||||
|
return a / length(a);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline friend float dot(const vec2& a, const vec2& b) {
|
||||||
|
return a.x * b.x + a.y * b.y;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
///
|
||||||
|
/// 3D Vector Helper
|
||||||
|
///
|
||||||
|
struct UExport vec3 {
|
||||||
|
union {
|
||||||
|
float value[3];
|
||||||
|
struct { float x, y, z; };
|
||||||
|
};
|
||||||
|
|
||||||
|
inline vec3() {}
|
||||||
|
|
||||||
|
inline vec3(float x, float y, float z) : x(x), y(y), z(z) {}
|
||||||
|
|
||||||
|
inline vec3(float x) : x(x), y(x), z(x) {}
|
||||||
|
|
||||||
|
inline friend vec3 operator+(vec3 lhs, const vec3& rhs) { lhs += rhs; return lhs; }
|
||||||
|
|
||||||
|
inline friend vec3 operator-(vec3 lhs, const vec3& rhs) { lhs -= rhs; return lhs; }
|
||||||
|
|
||||||
|
inline friend vec3 operator*(vec3 lhs, const vec3& rhs) { lhs *= rhs; return lhs; }
|
||||||
|
|
||||||
|
inline friend vec3 operator/(vec3 lhs, const vec3& rhs) { lhs /= rhs; return lhs; }
|
||||||
|
|
||||||
|
inline friend vec3 operator+(vec3 lhs, float rhs) { lhs += rhs; return lhs; }
|
||||||
|
|
||||||
|
inline friend vec3 operator-(vec3 lhs, float rhs) { lhs -= rhs; return lhs; }
|
||||||
|
|
||||||
|
inline friend vec3 operator*(vec3 lhs, float rhs) { lhs *= rhs; return lhs; }
|
||||||
|
|
||||||
|
inline friend vec3 operator/(vec3 lhs, float rhs) { lhs /= rhs; return lhs; }
|
||||||
|
|
||||||
|
inline vec3& operator+=(const vec3& rhs) {
|
||||||
|
value[0] += rhs.value[0];
|
||||||
|
value[1] += rhs.value[1];
|
||||||
|
value[2] += rhs.value[2];
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline vec3& operator-=(const vec3& rhs) {
|
||||||
|
value[0] -= rhs.value[0];
|
||||||
|
value[1] -= rhs.value[1];
|
||||||
|
value[2] -= rhs.value[2];
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline vec3& operator*=(const vec3& rhs) {
|
||||||
|
value[0] *= rhs.value[0];
|
||||||
|
value[1] *= rhs.value[1];
|
||||||
|
value[2] *= rhs.value[2];
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline vec3& operator/=(const vec3& rhs) {
|
||||||
|
value[0] /= rhs.value[0];
|
||||||
|
value[1] /= rhs.value[1];
|
||||||
|
value[2] /= rhs.value[2];
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline vec3& operator+=(float rhs) {
|
||||||
|
value[0] += rhs;
|
||||||
|
value[1] += rhs;
|
||||||
|
value[2] += rhs;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline vec3& operator-=(float rhs) {
|
||||||
|
value[0] -= rhs;
|
||||||
|
value[1] -= rhs;
|
||||||
|
value[2] -= rhs;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline vec3& operator*=(float rhs) {
|
||||||
|
value[0] *= rhs;
|
||||||
|
value[1] *= rhs;
|
||||||
|
value[2] *= rhs;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline vec3& operator/=(float rhs) {
|
||||||
|
value[0] /= rhs;
|
||||||
|
value[1] /= rhs;
|
||||||
|
value[2] /= rhs;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline friend bool operator==(const vec3& a, const vec3& b) {
|
||||||
|
return !memcmp(&a, &b, sizeof(a));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline friend bool operator!=(const vec3& a, const vec3& b) {
|
||||||
|
return !(a == b);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline friend vec3 min_(const vec3& a, const vec3& b) {
|
||||||
|
return{ (b.x < a.x) ? b.x : a.x,
|
||||||
|
(b.y < a.y) ? b.y : a.y,
|
||||||
|
(b.z < a.z) ? b.z : a.z };
|
||||||
|
}
|
||||||
|
|
||||||
|
inline friend vec3 max_(const vec3& a, const vec3& b) {
|
||||||
|
return{ (a.x < b.x) ? b.x : a.x,
|
||||||
|
(a.y < b.y) ? b.y : a.y,
|
||||||
|
(a.z < b.z) ? b.z : a.z };
|
||||||
|
}
|
||||||
|
inline friend vec3 clamp(const vec3& x, const vec3& minVal, const vec3& maxVal) {
|
||||||
|
return min_(max_(x, minVal), maxVal);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline friend vec3 mix(const vec3& a, const vec3& b, float t) {
|
||||||
|
return a * (1.0f - t) + b * t;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline friend float length(const vec3& a) {
|
||||||
|
return sqrtf(a.x * a.x + a.y * a.y + a.z * a.z);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline friend float distance(const vec3& a, const vec3& b) {
|
||||||
|
return length(a - b);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline friend vec3 normalize(const vec3& a) {
|
||||||
|
return a / length(a);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline friend float dot(const vec3& a, const vec3& b) {
|
||||||
|
return a.x * b.x + a.y * b.y + a.z * b.z;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
///
|
||||||
|
/// 4D Vector Helper
|
||||||
|
///
|
||||||
|
struct UExport vec4 {
|
||||||
|
union {
|
||||||
|
float value[4];
|
||||||
|
struct { float x, y, z, w; };
|
||||||
|
};
|
||||||
|
|
||||||
|
inline vec4() {}
|
||||||
|
|
||||||
|
inline vec4(float x, float y, float z, float w) : x(x), y(y), z(z), w(w) {}
|
||||||
|
|
||||||
|
inline vec4(float x) : x(x), y(x), z(x), w(x) {}
|
||||||
|
|
||||||
|
inline vec4(const float x[4]) { memcpy(value, x, sizeof(value)); }
|
||||||
|
|
||||||
|
inline friend bool operator==(const vec4& a, const vec4& b) {
|
||||||
|
return !memcmp(&a, &b, sizeof(a));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline friend bool operator!=(const vec4& a, const vec4& b) {
|
||||||
|
return !(a == b);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline friend vec4 operator+(vec4 lhs, const vec4& rhs) { lhs += rhs; return lhs; }
|
||||||
|
|
||||||
|
inline friend vec4 operator-(vec4 lhs, const vec4& rhs) { lhs -= rhs; return lhs; }
|
||||||
|
|
||||||
|
inline friend vec4 operator*(vec4 lhs, const vec4& rhs) { lhs *= rhs; return lhs; }
|
||||||
|
|
||||||
|
inline friend vec4 operator/(vec4 lhs, const vec4& rhs) { lhs /= rhs; return lhs; }
|
||||||
|
|
||||||
|
inline friend vec4 operator+(vec4 lhs, float rhs) { lhs += rhs; return lhs; }
|
||||||
|
|
||||||
|
inline friend vec4 operator-(vec4 lhs, float rhs) { lhs -= rhs; return lhs; }
|
||||||
|
|
||||||
|
inline friend vec4 operator*(vec4 lhs, float rhs) { lhs *= rhs; return lhs; }
|
||||||
|
|
||||||
|
inline friend vec4 operator/(vec4 lhs, float rhs) { lhs /= rhs; return lhs; }
|
||||||
|
|
||||||
|
inline vec4& operator+=(const vec4& rhs) {
|
||||||
|
value[0] += rhs.value[0];
|
||||||
|
value[1] += rhs.value[1];
|
||||||
|
value[2] += rhs.value[2];
|
||||||
|
value[3] += rhs.value[3];
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline vec4& operator-=(const vec4& rhs) {
|
||||||
|
value[0] -= rhs.value[0];
|
||||||
|
value[1] -= rhs.value[1];
|
||||||
|
value[2] -= rhs.value[2];
|
||||||
|
value[3] -= rhs.value[3];
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline vec4& operator*=(const vec4& rhs) {
|
||||||
|
value[0] *= rhs.value[0];
|
||||||
|
value[1] *= rhs.value[1];
|
||||||
|
value[2] *= rhs.value[2];
|
||||||
|
value[3] *= rhs.value[3];
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline vec4& operator/=(const vec4& rhs) {
|
||||||
|
value[0] /= rhs.value[0];
|
||||||
|
value[1] /= rhs.value[1];
|
||||||
|
value[2] /= rhs.value[2];
|
||||||
|
value[3] /= rhs.value[3];
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline vec4& operator+=(float rhs) {
|
||||||
|
value[0] += rhs;
|
||||||
|
value[1] += rhs;
|
||||||
|
value[2] += rhs;
|
||||||
|
value[3] += rhs;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline vec4& operator-=(float rhs) {
|
||||||
|
value[0] -= rhs;
|
||||||
|
value[1] -= rhs;
|
||||||
|
value[2] -= rhs;
|
||||||
|
value[3] -= rhs;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline vec4& operator*=(float rhs) {
|
||||||
|
value[0] *= rhs;
|
||||||
|
value[1] *= rhs;
|
||||||
|
value[2] *= rhs;
|
||||||
|
value[3] *= rhs;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline vec4& operator/=(float rhs) {
|
||||||
|
value[0] /= rhs;
|
||||||
|
value[1] /= rhs;
|
||||||
|
value[2] /= rhs;
|
||||||
|
value[3] /= rhs;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline friend vec4 min_(const vec4& a, const vec4& b) {
|
||||||
|
return{ (b.x < a.x) ? b.x : a.x,
|
||||||
|
(b.y < a.y) ? b.y : a.y,
|
||||||
|
(b.z < a.z) ? b.z : a.z,
|
||||||
|
(b.w < a.w) ? b.w : a.w };
|
||||||
|
}
|
||||||
|
|
||||||
|
inline friend vec4 max_(const vec4& a, const vec4& b) {
|
||||||
|
return{ (a.x < b.x) ? b.x : a.x,
|
||||||
|
(a.y < b.y) ? b.y : a.y,
|
||||||
|
(a.z < b.z) ? b.z : a.z,
|
||||||
|
(a.w < b.w) ? b.w : a.w };
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Point is typedef'd to a 2D vector
|
||||||
|
///
|
||||||
|
typedef vec2 Point;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Float Rectangle Helper
|
||||||
|
///
|
||||||
|
struct UExport Rect {
|
||||||
|
union {
|
||||||
|
float value[4];
|
||||||
|
struct { float left, top, right, bottom; };
|
||||||
|
};
|
||||||
|
|
||||||
|
static inline Rect MakeEmpty() {
|
||||||
|
Rect result;
|
||||||
|
result.SetEmpty();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline float width() const { return right - left; }
|
||||||
|
inline float height() const { return bottom - top; }
|
||||||
|
inline float x() const { return left; }
|
||||||
|
inline float y() const { return top; }
|
||||||
|
inline float center_x() const { return (left + right) * 0.5f; }
|
||||||
|
inline float center_y() const { return (top + bottom) * 0.5f; }
|
||||||
|
|
||||||
|
inline Point origin() const { return { left, top }; }
|
||||||
|
|
||||||
|
inline void SetEmpty() {
|
||||||
|
memset(this, 0, sizeof(*this));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool IsEmpty() const {
|
||||||
|
return *this == MakeEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool IsValid() const {
|
||||||
|
return width() > 0 && height() > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void Inset(float dx, float dy) {
|
||||||
|
value[0] += dx;
|
||||||
|
value[1] += dy;
|
||||||
|
value[2] -= dx;
|
||||||
|
value[3] -= dy;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void Outset(float dx, float dy) {
|
||||||
|
Inset(-dx, -dy);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void Move(float dx, float dy) {
|
||||||
|
value[0] += dx;
|
||||||
|
value[1] += dy;
|
||||||
|
value[2] += dx;
|
||||||
|
value[3] += dy;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline float area() const {
|
||||||
|
return width() * height();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void Join(const Rect& rhs) {
|
||||||
|
// if we are empty, just assign
|
||||||
|
if (IsEmpty()) {
|
||||||
|
*this = rhs;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (rhs.value[0] < value[0]) value[0] = rhs.value[0];
|
||||||
|
if (rhs.value[1] < value[1]) value[1] = rhs.value[1];
|
||||||
|
if (rhs.value[2] > value[2]) value[2] = rhs.value[2];
|
||||||
|
if (rhs.value[3] > value[3]) value[3] = rhs.value[3];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void Join(const Point& p) {
|
||||||
|
// if we are empty, just assign
|
||||||
|
if (IsEmpty()) {
|
||||||
|
*this = { p.x, p.y, p.x, p.y };
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (p.x < value[0]) value[0] = p.x;
|
||||||
|
if (p.y < value[1]) value[1] = p.y;
|
||||||
|
if (p.x > value[2]) value[2] = p.x;
|
||||||
|
if (p.y > value[3]) value[3] = p.y;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool Contains(const Point& p) const {
|
||||||
|
return p.x >= left && p.x <= right &&
|
||||||
|
p.y >= top && p.y <= bottom;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool Contains(const Rect& r) const {
|
||||||
|
return left <= r.left && top <= r.top &&
|
||||||
|
right >= r.right && bottom >= r.bottom;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool Intersects(const Rect& rhs) const {
|
||||||
|
return !(rhs.left > right ||
|
||||||
|
rhs.right < left ||
|
||||||
|
rhs.top > bottom ||
|
||||||
|
rhs.bottom < top);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Rect Intersect(const Rect& other) const {
|
||||||
|
return{ (left < other.left) ? other.left : left,
|
||||||
|
(top < other.top) ? other.top : top,
|
||||||
|
(other.right < right) ? other.right : right,
|
||||||
|
(other.bottom < bottom) ? other.bottom : bottom };
|
||||||
|
}
|
||||||
|
|
||||||
|
friend inline bool operator==(const Rect& a, const Rect& b) {
|
||||||
|
return !memcmp(&a, &b, sizeof(a));
|
||||||
|
}
|
||||||
|
|
||||||
|
friend inline bool operator!=(const Rect& a, const Rect& b) {
|
||||||
|
return !(a == b);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Integer Rectangle Helper
|
||||||
|
///
|
||||||
|
struct UExport IntRect {
|
||||||
|
union {
|
||||||
|
int value[4];
|
||||||
|
struct { int left, top, right, bottom; };
|
||||||
|
};
|
||||||
|
|
||||||
|
static inline IntRect MakeEmpty() {
|
||||||
|
IntRect result;
|
||||||
|
result.SetEmpty();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline int width() const { return right - left; }
|
||||||
|
inline int height() const { return bottom - top; }
|
||||||
|
inline int x() const { return left; }
|
||||||
|
inline int y() const { return top; }
|
||||||
|
inline int center_x() const { return (int)std::round((left + right) * 0.5f); }
|
||||||
|
inline int center_y() const { return (int)std::round((top + bottom) * 0.5f); }
|
||||||
|
|
||||||
|
inline Point origin() const { return{ (float)left, (float)top }; }
|
||||||
|
|
||||||
|
inline void SetEmpty() {
|
||||||
|
memset(this, 0, sizeof(*this));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool IsEmpty() const {
|
||||||
|
return *this == MakeEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool IsValid() const {
|
||||||
|
return width() > 0 && height() > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void Inset(int dx, int dy) {
|
||||||
|
value[0] += dx;
|
||||||
|
value[1] += dy;
|
||||||
|
value[2] -= dx;
|
||||||
|
value[3] -= dy;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void Outset(int dx, int dy) {
|
||||||
|
Inset(-dx, -dy);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void Move(int dx, int dy) {
|
||||||
|
value[0] += dx;
|
||||||
|
value[1] += dy;
|
||||||
|
value[2] += dx;
|
||||||
|
value[3] += dy;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline int area() const {
|
||||||
|
return width() * height();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void Join(const IntRect& rhs) {
|
||||||
|
// if we are empty, just assign
|
||||||
|
if (IsEmpty()) {
|
||||||
|
*this = rhs;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (rhs.value[0] < value[0]) value[0] = rhs.value[0];
|
||||||
|
if (rhs.value[1] < value[1]) value[1] = rhs.value[1];
|
||||||
|
if (rhs.value[2] > value[2]) value[2] = rhs.value[2];
|
||||||
|
if (rhs.value[3] > value[3]) value[3] = rhs.value[3];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void Join(const Point& p) {
|
||||||
|
// if we are empty, just assign
|
||||||
|
if (IsEmpty()) {
|
||||||
|
*this = { (int)std::floor(p.x), (int)std::floor(p.y), (int)std::ceil(p.x), (int)std::ceil(p.y) };
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if ((int)std::floor(p.x) < value[0]) value[0] = (int)std::floor(p.x);
|
||||||
|
if ((int)std::floor(p.y) < value[1]) value[1] = (int)std::floor(p.y);
|
||||||
|
if ((int)std::ceil(p.x) > value[2]) value[2] = (int)std::ceil(p.x);
|
||||||
|
if ((int)std::ceil(p.y) > value[3]) value[3] = (int)std::ceil(p.y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool Contains(const Point& p) const {
|
||||||
|
return p.x >= left && p.x <= right &&
|
||||||
|
p.y >= top && p.y <= bottom;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool Contains(const IntRect& r) const {
|
||||||
|
return left <= r.left && top <= r.top &&
|
||||||
|
right >= r.right && bottom >= r.bottom;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool Intersects(const IntRect& rhs) const {
|
||||||
|
// Since this is mostly used for pixel operations, we only count
|
||||||
|
// intersections that have width and height >= 1.
|
||||||
|
return !(rhs.left > right - 1 ||
|
||||||
|
rhs.right < left ||
|
||||||
|
rhs.top > bottom - 1 ||
|
||||||
|
rhs.bottom < top);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline IntRect Intersect(const IntRect& other) const {
|
||||||
|
return{ (left < other.left) ? other.left : left,
|
||||||
|
(top < other.top) ? other.top : top,
|
||||||
|
(other.right < right) ? other.right : right,
|
||||||
|
(other.bottom < bottom) ? other.bottom : bottom };
|
||||||
|
}
|
||||||
|
|
||||||
|
friend inline bool operator==(const IntRect& a, const IntRect& b) {
|
||||||
|
return !memcmp(&a, &b, sizeof(a));
|
||||||
|
}
|
||||||
|
|
||||||
|
friend inline bool operator!=(const IntRect& a, const IntRect& b) {
|
||||||
|
return !(a == b);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Rounded Rectangle Helper
|
||||||
|
///
|
||||||
|
struct UExport RoundedRect {
|
||||||
|
Rect rect;
|
||||||
|
float radii_x[4];
|
||||||
|
float radii_y[4];
|
||||||
|
|
||||||
|
void SetEmpty();
|
||||||
|
|
||||||
|
bool IsRounded() const;
|
||||||
|
|
||||||
|
// Negative is inside, positive is outside.
|
||||||
|
float GetSignedDistance(const Point& p) const;
|
||||||
|
|
||||||
|
// Returns whether or not intersection is found. Can fail if the resulting
|
||||||
|
// geometry is not a rounded rectangle.
|
||||||
|
bool Intersect(const RoundedRect& other, RoundedRect& result) const;
|
||||||
|
|
||||||
|
void SnapToPixels();
|
||||||
|
|
||||||
|
Rect CalculateInterior() const;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace ultralight
|
|
@ -0,0 +1,39 @@
|
||||||
|
///
|
||||||
|
/// @file View.h
|
||||||
|
///
|
||||||
|
/// @brief The header for the View class.
|
||||||
|
///
|
||||||
|
/// @author
|
||||||
|
///
|
||||||
|
/// This file is a part of Ultralight, a fast, lightweight, HTML UI engine
|
||||||
|
///
|
||||||
|
/// Website: <http://ultralig.ht>
|
||||||
|
///
|
||||||
|
/// Copyright (C) 2020 Ultralight, Inc. All rights reserved.
|
||||||
|
///
|
||||||
|
#pragma once
|
||||||
|
#include <JavaScriptCore/JavaScript.h>
|
||||||
|
#include <Ultralight/Defines.h>
|
||||||
|
#include <Ultralight/RefPtr.h>
|
||||||
|
#include <Ultralight/String.h>
|
||||||
|
|
||||||
|
namespace ultralight {
|
||||||
|
|
||||||
|
///
|
||||||
|
/// This class wraps a JSContextRef (a JavaScript execution context for use
|
||||||
|
/// with JavaScriptCore) and locks the context on the current thread for the
|
||||||
|
/// duration of its lifetime.
|
||||||
|
///
|
||||||
|
class UExport JSContext : public RefCounted {
|
||||||
|
public:
|
||||||
|
/// Get the underlying JSContextRef for use with JavaScriptCore C API
|
||||||
|
virtual JSContextRef ctx() = 0;
|
||||||
|
|
||||||
|
/// Typecast to a JSContextRef for use with JavaScriptCore C API
|
||||||
|
operator JSContextRef();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual ~JSContext();
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace ultralight
|
|
@ -0,0 +1,527 @@
|
||||||
|
///
|
||||||
|
/// @file KeyCodes.h
|
||||||
|
///
|
||||||
|
/// @brief The header for the KeyCodes definitions.
|
||||||
|
///
|
||||||
|
/// @author
|
||||||
|
///
|
||||||
|
/// This file is a part of Ultralight, a fast, lightweight, HTML UI engine
|
||||||
|
///
|
||||||
|
/// Website: <http://ultralig.ht>
|
||||||
|
///
|
||||||
|
/// Copyright (C) 2020 Ultralight, Inc. All rights reserved.
|
||||||
|
///
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace ultralight {
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Namespace containing all the key-code definitions for KeyboardEvent.
|
||||||
|
/// Most of these correspond directly to the key-code values on Windows.
|
||||||
|
///
|
||||||
|
namespace KeyCodes {
|
||||||
|
|
||||||
|
// GK_BACK (08) BACKSPACE key
|
||||||
|
const int GK_BACK = 0x08;
|
||||||
|
|
||||||
|
// GK_TAB (09) TAB key
|
||||||
|
const int GK_TAB = 0x09;
|
||||||
|
|
||||||
|
// GK_CLEAR (0C) CLEAR key
|
||||||
|
const int GK_CLEAR = 0x0C;
|
||||||
|
|
||||||
|
// GK_RETURN (0D)
|
||||||
|
const int GK_RETURN = 0x0D;
|
||||||
|
|
||||||
|
// GK_SHIFT (10) SHIFT key
|
||||||
|
const int GK_SHIFT = 0x10;
|
||||||
|
|
||||||
|
// GK_CONTROL (11) CTRL key
|
||||||
|
const int GK_CONTROL = 0x11;
|
||||||
|
|
||||||
|
// GK_MENU (12) ALT key
|
||||||
|
const int GK_MENU = 0x12;
|
||||||
|
|
||||||
|
// GK_PAUSE (13) PAUSE key
|
||||||
|
const int GK_PAUSE = 0x13;
|
||||||
|
|
||||||
|
// GK_CAPITAL (14) CAPS LOCK key
|
||||||
|
const int GK_CAPITAL = 0x14;
|
||||||
|
|
||||||
|
// GK_KANA (15) Input Method Editor (IME) Kana mode
|
||||||
|
const int GK_KANA = 0x15;
|
||||||
|
|
||||||
|
// GK_HANGUEL (15) IME Hanguel mode (maintained for compatibility; use GK_HANGUL)
|
||||||
|
// GK_HANGUL (15) IME Hangul mode
|
||||||
|
const int GK_HANGUL = 0x15;
|
||||||
|
|
||||||
|
// GK_JUNJA (17) IME Junja mode
|
||||||
|
const int GK_JUNJA = 0x17;
|
||||||
|
|
||||||
|
// GK_FINAL (18) IME final mode
|
||||||
|
const int GK_FINAL = 0x18;
|
||||||
|
|
||||||
|
// GK_HANJA (19) IME Hanja mode
|
||||||
|
const int GK_HANJA = 0x19;
|
||||||
|
|
||||||
|
// GK_KANJI (19) IME Kanji mode
|
||||||
|
const int GK_KANJI = 0x19;
|
||||||
|
|
||||||
|
// GK_ESCAPE (1B) ESC key
|
||||||
|
const int GK_ESCAPE = 0x1B;
|
||||||
|
|
||||||
|
// GK_CONVERT (1C) IME convert
|
||||||
|
const int GK_CONVERT = 0x1C;
|
||||||
|
|
||||||
|
// GK_NONCONVERT (1D) IME nonconvert
|
||||||
|
const int GK_NONCONVERT = 0x1D;
|
||||||
|
|
||||||
|
// GK_ACCEPT (1E) IME accept
|
||||||
|
const int GK_ACCEPT = 0x1E;
|
||||||
|
|
||||||
|
// GK_MODECHANGE (1F) IME mode change request
|
||||||
|
const int GK_MODECHANGE = 0x1F;
|
||||||
|
|
||||||
|
// GK_SPACE (20) SPACEBAR
|
||||||
|
const int GK_SPACE = 0x20;
|
||||||
|
|
||||||
|
// GK_PRIOR (21) PAGE UP key
|
||||||
|
const int GK_PRIOR = 0x21;
|
||||||
|
|
||||||
|
// GK_NEXT (22) PAGE DOWN key
|
||||||
|
const int GK_NEXT = 0x22;
|
||||||
|
|
||||||
|
// GK_END (23) END key
|
||||||
|
const int GK_END = 0x23;
|
||||||
|
|
||||||
|
// GK_HOME (24) HOME key
|
||||||
|
const int GK_HOME = 0x24;
|
||||||
|
|
||||||
|
// GK_LEFT (25) LEFT ARROW key
|
||||||
|
const int GK_LEFT = 0x25;
|
||||||
|
|
||||||
|
// GK_UP (26) UP ARROW key
|
||||||
|
const int GK_UP = 0x26;
|
||||||
|
|
||||||
|
// GK_RIGHT (27) RIGHT ARROW key
|
||||||
|
const int GK_RIGHT = 0x27;
|
||||||
|
|
||||||
|
// GK_DOWN (28) DOWN ARROW key
|
||||||
|
const int GK_DOWN = 0x28;
|
||||||
|
|
||||||
|
// GK_SELECT (29) SELECT key
|
||||||
|
const int GK_SELECT = 0x29;
|
||||||
|
|
||||||
|
// GK_PRINT (2A) PRINT key
|
||||||
|
const int GK_PRINT = 0x2A;
|
||||||
|
|
||||||
|
// GK_EXECUTE (2B) EXECUTE key
|
||||||
|
const int GK_EXECUTE = 0x2B;
|
||||||
|
|
||||||
|
// GK_SNAPSHOT (2C) PRINT SCREEN key
|
||||||
|
const int GK_SNAPSHOT = 0x2C;
|
||||||
|
|
||||||
|
// GK_INSERT (2D) INS key
|
||||||
|
const int GK_INSERT = 0x2D;
|
||||||
|
|
||||||
|
// GK_DELETE (2E) DEL key
|
||||||
|
const int GK_DELETE = 0x2E;
|
||||||
|
|
||||||
|
// GK_HELP (2F) HELP key
|
||||||
|
const int GK_HELP = 0x2F;
|
||||||
|
|
||||||
|
// (30) 0 key
|
||||||
|
const int GK_0 = 0x30;
|
||||||
|
|
||||||
|
// (31) 1 key
|
||||||
|
const int GK_1 = 0x31;
|
||||||
|
|
||||||
|
// (32) 2 key
|
||||||
|
const int GK_2 = 0x32;
|
||||||
|
|
||||||
|
// (33) 3 key
|
||||||
|
const int GK_3 = 0x33;
|
||||||
|
|
||||||
|
// (34) 4 key
|
||||||
|
const int GK_4 = 0x34;
|
||||||
|
|
||||||
|
// (35) 5 key;
|
||||||
|
const int GK_5 = 0x35;
|
||||||
|
|
||||||
|
// (36) 6 key
|
||||||
|
const int GK_6 = 0x36;
|
||||||
|
|
||||||
|
// (37) 7 key
|
||||||
|
const int GK_7 = 0x37;
|
||||||
|
|
||||||
|
// (38) 8 key
|
||||||
|
const int GK_8 = 0x38;
|
||||||
|
|
||||||
|
// (39) 9 key
|
||||||
|
const int GK_9 = 0x39;
|
||||||
|
|
||||||
|
// (41) A key
|
||||||
|
const int GK_A = 0x41;
|
||||||
|
|
||||||
|
// (42) B key
|
||||||
|
const int GK_B = 0x42;
|
||||||
|
|
||||||
|
// (43) C key
|
||||||
|
const int GK_C = 0x43;
|
||||||
|
|
||||||
|
// (44) D key
|
||||||
|
const int GK_D = 0x44;
|
||||||
|
|
||||||
|
// (45) E key
|
||||||
|
const int GK_E = 0x45;
|
||||||
|
|
||||||
|
// (46) F key
|
||||||
|
const int GK_F = 0x46;
|
||||||
|
|
||||||
|
// (47) G key
|
||||||
|
const int GK_G = 0x47;
|
||||||
|
|
||||||
|
// (48) H key
|
||||||
|
const int GK_H = 0x48;
|
||||||
|
|
||||||
|
// (49) I key
|
||||||
|
const int GK_I = 0x49;
|
||||||
|
|
||||||
|
// (4A) J key
|
||||||
|
const int GK_J = 0x4A;
|
||||||
|
|
||||||
|
// (4B) K key
|
||||||
|
const int GK_K = 0x4B;
|
||||||
|
|
||||||
|
// (4C) L key
|
||||||
|
const int GK_L = 0x4C;
|
||||||
|
|
||||||
|
// (4D) M key
|
||||||
|
const int GK_M = 0x4D;
|
||||||
|
|
||||||
|
// (4E) N key
|
||||||
|
const int GK_N = 0x4E;
|
||||||
|
|
||||||
|
// (4F) O key
|
||||||
|
const int GK_O = 0x4F;
|
||||||
|
|
||||||
|
// (50) P key
|
||||||
|
const int GK_P = 0x50;
|
||||||
|
|
||||||
|
// (51) Q key
|
||||||
|
const int GK_Q = 0x51;
|
||||||
|
|
||||||
|
// (52) R key
|
||||||
|
const int GK_R = 0x52;
|
||||||
|
|
||||||
|
// (53) S key
|
||||||
|
const int GK_S = 0x53;
|
||||||
|
|
||||||
|
// (54) T key
|
||||||
|
const int GK_T = 0x54;
|
||||||
|
|
||||||
|
// (55) U key
|
||||||
|
const int GK_U = 0x55;
|
||||||
|
|
||||||
|
// (56) V key
|
||||||
|
const int GK_V = 0x56;
|
||||||
|
|
||||||
|
// (57) W key
|
||||||
|
const int GK_W = 0x57;
|
||||||
|
|
||||||
|
// (58) X key
|
||||||
|
const int GK_X = 0x58;
|
||||||
|
|
||||||
|
// (59) Y key
|
||||||
|
const int GK_Y = 0x59;
|
||||||
|
|
||||||
|
// (5A) Z key
|
||||||
|
const int GK_Z = 0x5A;
|
||||||
|
|
||||||
|
// GK_LWIN (5B) Left Windows key (Microsoft Natural keyboard)
|
||||||
|
const int GK_LWIN = 0x5B;
|
||||||
|
|
||||||
|
// GK_RWIN (5C) Right Windows key (Natural keyboard)
|
||||||
|
const int GK_RWIN = 0x5C;
|
||||||
|
|
||||||
|
// GK_APPS (5D) Applications key (Natural keyboard)
|
||||||
|
const int GK_APPS = 0x5D;
|
||||||
|
|
||||||
|
// GK_SLEEP (5F) Computer Sleep key
|
||||||
|
const int GK_SLEEP = 0x5F;
|
||||||
|
|
||||||
|
// GK_NUMPAD0 (60) Numeric keypad 0 key
|
||||||
|
const int GK_NUMPAD0 = 0x60;
|
||||||
|
|
||||||
|
// GK_NUMPAD1 (61) Numeric keypad 1 key
|
||||||
|
const int GK_NUMPAD1 = 0x61;
|
||||||
|
|
||||||
|
// GK_NUMPAD2 (62) Numeric keypad 2 key
|
||||||
|
const int GK_NUMPAD2 = 0x62;
|
||||||
|
|
||||||
|
// GK_NUMPAD3 (63) Numeric keypad 3 key
|
||||||
|
const int GK_NUMPAD3 = 0x63;
|
||||||
|
|
||||||
|
// GK_NUMPAD4 (64) Numeric keypad 4 key
|
||||||
|
const int GK_NUMPAD4 = 0x64;
|
||||||
|
|
||||||
|
// GK_NUMPAD5 (65) Numeric keypad 5 key
|
||||||
|
const int GK_NUMPAD5 = 0x65;
|
||||||
|
|
||||||
|
// GK_NUMPAD6 (66) Numeric keypad 6 key
|
||||||
|
const int GK_NUMPAD6 = 0x66;
|
||||||
|
|
||||||
|
// GK_NUMPAD7 (67) Numeric keypad 7 key
|
||||||
|
const int GK_NUMPAD7 = 0x67;
|
||||||
|
|
||||||
|
// GK_NUMPAD8 (68) Numeric keypad 8 key
|
||||||
|
const int GK_NUMPAD8 = 0x68;
|
||||||
|
|
||||||
|
// GK_NUMPAD9 (69) Numeric keypad 9 key
|
||||||
|
const int GK_NUMPAD9 = 0x69;
|
||||||
|
|
||||||
|
// GK_MULTIPLY (6A) Multiply key
|
||||||
|
const int GK_MULTIPLY = 0x6A;
|
||||||
|
|
||||||
|
// GK_ADD (6B) Add key
|
||||||
|
const int GK_ADD = 0x6B;
|
||||||
|
|
||||||
|
// GK_SEPARATOR (6C) Separator key
|
||||||
|
const int GK_SEPARATOR = 0x6C;
|
||||||
|
|
||||||
|
// GK_SUBTRACT (6D) Subtract key
|
||||||
|
const int GK_SUBTRACT = 0x6D;
|
||||||
|
|
||||||
|
// GK_DECIMAL (6E) Decimal key
|
||||||
|
const int GK_DECIMAL = 0x6E;
|
||||||
|
|
||||||
|
// GK_DIVIDE (6F) Divide key
|
||||||
|
const int GK_DIVIDE = 0x6F;
|
||||||
|
|
||||||
|
// GK_F1 (70) F1 key
|
||||||
|
const int GK_F1 = 0x70;
|
||||||
|
|
||||||
|
// GK_F2 (71) F2 key
|
||||||
|
const int GK_F2 = 0x71;
|
||||||
|
|
||||||
|
// GK_F3 (72) F3 key
|
||||||
|
const int GK_F3 = 0x72;
|
||||||
|
|
||||||
|
// GK_F4 (73) F4 key
|
||||||
|
const int GK_F4 = 0x73;
|
||||||
|
|
||||||
|
// GK_F5 (74) F5 key
|
||||||
|
const int GK_F5 = 0x74;
|
||||||
|
|
||||||
|
// GK_F6 (75) F6 key
|
||||||
|
const int GK_F6 = 0x75;
|
||||||
|
|
||||||
|
// GK_F7 (76) F7 key
|
||||||
|
const int GK_F7 = 0x76;
|
||||||
|
|
||||||
|
// GK_F8 (77) F8 key
|
||||||
|
const int GK_F8 = 0x77;
|
||||||
|
|
||||||
|
// GK_F9 (78) F9 key
|
||||||
|
const int GK_F9 = 0x78;
|
||||||
|
|
||||||
|
// GK_F10 (79) F10 key
|
||||||
|
const int GK_F10 = 0x79;
|
||||||
|
|
||||||
|
// GK_F11 (7A) F11 key
|
||||||
|
const int GK_F11 = 0x7A;
|
||||||
|
|
||||||
|
// GK_F12 (7B) F12 key
|
||||||
|
const int GK_F12 = 0x7B;
|
||||||
|
|
||||||
|
// GK_F13 (7C) F13 key
|
||||||
|
const int GK_F13 = 0x7C;
|
||||||
|
|
||||||
|
// GK_F14 (7D) F14 key
|
||||||
|
const int GK_F14 = 0x7D;
|
||||||
|
|
||||||
|
// GK_F15 (7E) F15 key
|
||||||
|
const int GK_F15 = 0x7E;
|
||||||
|
|
||||||
|
// GK_F16 (7F) F16 key
|
||||||
|
const int GK_F16 = 0x7F;
|
||||||
|
|
||||||
|
// GK_F17 (80H) F17 key
|
||||||
|
const int GK_F17 = 0x80;
|
||||||
|
|
||||||
|
// GK_F18 (81H) F18 key
|
||||||
|
const int GK_F18 = 0x81;
|
||||||
|
|
||||||
|
// GK_F19 (82H) F19 key
|
||||||
|
const int GK_F19 = 0x82;
|
||||||
|
|
||||||
|
// GK_F20 (83H) F20 key
|
||||||
|
const int GK_F20 = 0x83;
|
||||||
|
|
||||||
|
// GK_F21 (84H) F21 key
|
||||||
|
const int GK_F21 = 0x84;
|
||||||
|
|
||||||
|
// GK_F22 (85H) F22 key
|
||||||
|
const int GK_F22 = 0x85;
|
||||||
|
|
||||||
|
// GK_F23 (86H) F23 key
|
||||||
|
const int GK_F23 = 0x86;
|
||||||
|
|
||||||
|
// GK_F24 (87H) F24 key
|
||||||
|
const int GK_F24 = 0x87;
|
||||||
|
|
||||||
|
// GK_NUMLOCK (90) NUM LOCK key
|
||||||
|
const int GK_NUMLOCK = 0x90;
|
||||||
|
|
||||||
|
// GK_SCROLL (91) SCROLL LOCK key
|
||||||
|
const int GK_SCROLL = 0x91;
|
||||||
|
|
||||||
|
// GK_LSHIFT (A0) Left SHIFT key
|
||||||
|
const int GK_LSHIFT = 0xA0;
|
||||||
|
|
||||||
|
// GK_RSHIFT (A1) Right SHIFT key
|
||||||
|
const int GK_RSHIFT = 0xA1;
|
||||||
|
|
||||||
|
// GK_LCONTROL (A2) Left CONTROL key
|
||||||
|
const int GK_LCONTROL = 0xA2;
|
||||||
|
|
||||||
|
// GK_RCONTROL (A3) Right CONTROL key
|
||||||
|
const int GK_RCONTROL = 0xA3;
|
||||||
|
|
||||||
|
// GK_LMENU (A4) Left MENU key
|
||||||
|
const int GK_LMENU = 0xA4;
|
||||||
|
|
||||||
|
// GK_RMENU (A5) Right MENU key
|
||||||
|
const int GK_RMENU = 0xA5;
|
||||||
|
|
||||||
|
// GK_BROWSER_BACK (A6) Windows 2000/XP: Browser Back key
|
||||||
|
const int GK_BROWSER_BACK = 0xA6;
|
||||||
|
|
||||||
|
// GK_BROWSER_FORWARD (A7) Windows 2000/XP: Browser Forward key
|
||||||
|
const int GK_BROWSER_FORWARD = 0xA7;
|
||||||
|
|
||||||
|
// GK_BROWSER_REFRESH (A8) Windows 2000/XP: Browser Refresh key
|
||||||
|
const int GK_BROWSER_REFRESH = 0xA8;
|
||||||
|
|
||||||
|
// GK_BROWSER_STOP (A9) Windows 2000/XP: Browser Stop key
|
||||||
|
const int GK_BROWSER_STOP = 0xA9;
|
||||||
|
|
||||||
|
// GK_BROWSER_SEARCH (AA) Windows 2000/XP: Browser Search key
|
||||||
|
const int GK_BROWSER_SEARCH = 0xAA;
|
||||||
|
|
||||||
|
// GK_BROWSER_FAVORITES (AB) Windows 2000/XP: Browser Favorites key
|
||||||
|
const int GK_BROWSER_FAVORITES = 0xAB;
|
||||||
|
|
||||||
|
// GK_BROWSER_HOME (AC) Windows 2000/XP: Browser Start and Home key
|
||||||
|
const int GK_BROWSER_HOME = 0xAC;
|
||||||
|
|
||||||
|
// GK_VOLUME_MUTE (AD) Windows 2000/XP: Volume Mute key
|
||||||
|
const int GK_VOLUME_MUTE = 0xAD;
|
||||||
|
|
||||||
|
// GK_VOLUME_DOWN (AE) Windows 2000/XP: Volume Down key
|
||||||
|
const int GK_VOLUME_DOWN = 0xAE;
|
||||||
|
|
||||||
|
// GK_VOLUME_UP (AF) Windows 2000/XP: Volume Up key
|
||||||
|
const int GK_VOLUME_UP = 0xAF;
|
||||||
|
|
||||||
|
// GK_MEDIA_NEXT_TRACK (B0) Windows 2000/XP: Next Track key
|
||||||
|
const int GK_MEDIA_NEXT_TRACK = 0xB0;
|
||||||
|
|
||||||
|
// GK_MEDIA_PREV_TRACK (B1) Windows 2000/XP: Previous Track key
|
||||||
|
const int GK_MEDIA_PREV_TRACK = 0xB1;
|
||||||
|
|
||||||
|
// GK_MEDIA_STOP (B2) Windows 2000/XP: Stop Media key
|
||||||
|
const int GK_MEDIA_STOP = 0xB2;
|
||||||
|
|
||||||
|
// GK_MEDIA_PLAY_PAUSE (B3) Windows 2000/XP: Play/Pause Media key
|
||||||
|
const int GK_MEDIA_PLAY_PAUSE = 0xB3;
|
||||||
|
|
||||||
|
// GK_LAUNCH_MAIL (B4) Windows 2000/XP: Start Mail key
|
||||||
|
const int GK_MEDIA_LAUNCH_MAIL = 0xB4;
|
||||||
|
|
||||||
|
// GK_LAUNCH_MEDIA_SELECT (B5) Windows 2000/XP: Select Media key
|
||||||
|
const int GK_MEDIA_LAUNCH_MEDIA_SELECT = 0xB5;
|
||||||
|
|
||||||
|
// GK_LAUNCH_APP1 (B6) Windows 2000/XP: Start Application 1 key
|
||||||
|
const int GK_MEDIA_LAUNCH_APP1 = 0xB6;
|
||||||
|
|
||||||
|
// GK_LAUNCH_APP2 (B7) Windows 2000/XP: Start Application 2 key
|
||||||
|
const int GK_MEDIA_LAUNCH_APP2 = 0xB7;
|
||||||
|
|
||||||
|
// GK_OEM_1 (BA) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the ';:' key
|
||||||
|
const int GK_OEM_1 = 0xBA;
|
||||||
|
|
||||||
|
// GK_OEM_PLUS (BB) Windows 2000/XP: For any country/region, the '+' key
|
||||||
|
const int GK_OEM_PLUS = 0xBB;
|
||||||
|
|
||||||
|
// GK_OEM_COMMA (BC) Windows 2000/XP: For any country/region, the ',' key
|
||||||
|
const int GK_OEM_COMMA = 0xBC;
|
||||||
|
|
||||||
|
// GK_OEM_MINUS (BD) Windows 2000/XP: For any country/region, the '-' key
|
||||||
|
const int GK_OEM_MINUS = 0xBD;
|
||||||
|
|
||||||
|
// GK_OEM_PERIOD (BE) Windows 2000/XP: For any country/region, the '.' key
|
||||||
|
const int GK_OEM_PERIOD = 0xBE;
|
||||||
|
|
||||||
|
// GK_OEM_2 (BF) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '/?' key
|
||||||
|
const int GK_OEM_2 = 0xBF;
|
||||||
|
|
||||||
|
// GK_OEM_3 (C0) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '`~' key
|
||||||
|
const int GK_OEM_3 = 0xC0;
|
||||||
|
|
||||||
|
// GK_OEM_4 (DB) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '[{' key
|
||||||
|
const int GK_OEM_4 = 0xDB;
|
||||||
|
|
||||||
|
// GK_OEM_5 (DC) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '\|' key
|
||||||
|
const int GK_OEM_5 = 0xDC;
|
||||||
|
|
||||||
|
// GK_OEM_6 (DD) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the ']}' key
|
||||||
|
const int GK_OEM_6 = 0xDD;
|
||||||
|
|
||||||
|
// GK_OEM_7 (DE) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the 'single-quote/double-quote' key
|
||||||
|
const int GK_OEM_7 = 0xDE;
|
||||||
|
|
||||||
|
// GK_OEM_8 (DF) Used for miscellaneous characters; it can vary by keyboard.
|
||||||
|
const int GK_OEM_8 = 0xDF;
|
||||||
|
|
||||||
|
// GK_OEM_102 (E2) Windows 2000/XP: Either the angle bracket key or the backslash key on the RT 102-key keyboard
|
||||||
|
const int GK_OEM_102 = 0xE2;
|
||||||
|
|
||||||
|
// GK_PROCESSKEY (E5) Windows 95/98/Me, Windows NT 4.0, Windows 2000/XP: IME PROCESS key
|
||||||
|
const int GK_PROCESSKEY = 0xE5;
|
||||||
|
|
||||||
|
// GK_PACKET (E7) Windows 2000/XP: Used to pass Unicode characters as if they were keystrokes. The GK_PACKET key is the low word of a 32-bit Virtual Key value used for non-keyboard input methods. For more information, see Remark in KEYBDINPUT,SendInput, WM_KEYDOWN, and WM_KEYUP
|
||||||
|
const int GK_PACKET = 0xE7;
|
||||||
|
|
||||||
|
// GK_ATTN (F6) Attn key
|
||||||
|
const int GK_ATTN = 0xF6;
|
||||||
|
|
||||||
|
// GK_CRSEL (F7) CrSel key
|
||||||
|
const int GK_CRSEL = 0xF7;
|
||||||
|
|
||||||
|
// GK_EXSEL (F8) ExSel key
|
||||||
|
const int GK_EXSEL = 0xF8;
|
||||||
|
|
||||||
|
// GK_EREOF (F9) Erase EOF key
|
||||||
|
const int GK_EREOF = 0xF9;
|
||||||
|
|
||||||
|
// GK_PLAY (FA) Play key
|
||||||
|
const int GK_PLAY = 0xFA;
|
||||||
|
|
||||||
|
// GK_ZOOM (FB) Zoom key
|
||||||
|
const int GK_ZOOM = 0xFB;
|
||||||
|
|
||||||
|
// GK_NONAME (FC) Reserved for future use
|
||||||
|
const int GK_NONAME = 0xFC;
|
||||||
|
|
||||||
|
// GK_PA1 (FD) PA1 key
|
||||||
|
const int GK_PA1 = 0xFD;
|
||||||
|
|
||||||
|
// GK_OEM_CLEAR (FE) Clear key
|
||||||
|
const int GK_OEM_CLEAR = 0xFE;
|
||||||
|
|
||||||
|
const int GK_UNKNOWN = 0;
|
||||||
|
|
||||||
|
} // namespace KeyCodes
|
||||||
|
|
||||||
|
} // namespace ultralight
|
|
@ -0,0 +1,180 @@
|
||||||
|
///
|
||||||
|
/// @file KeyEvent.h
|
||||||
|
///
|
||||||
|
/// @brief The header for the KeyEvent class.
|
||||||
|
///
|
||||||
|
/// @author
|
||||||
|
///
|
||||||
|
/// This file is a part of Ultralight, a fast, lightweight, HTML UI engine
|
||||||
|
///
|
||||||
|
/// Website: <http://ultralig.ht>
|
||||||
|
///
|
||||||
|
/// Copyright (C) 2020 Ultralight, Inc. All rights reserved.
|
||||||
|
///
|
||||||
|
#pragma once
|
||||||
|
#include <Ultralight/Defines.h>
|
||||||
|
#include <Ultralight/KeyCodes.h>
|
||||||
|
#include <Ultralight/String.h>
|
||||||
|
#ifdef __OBJC__
|
||||||
|
#import <AppKit/NSEvent.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace ultralight {
|
||||||
|
|
||||||
|
///
|
||||||
|
/// @brief A generic keyboard event that can be created from a platform event
|
||||||
|
/// or synthesized from scratch.
|
||||||
|
///
|
||||||
|
/// @see View::FireKeyEvent
|
||||||
|
///
|
||||||
|
class UExport KeyEvent {
|
||||||
|
public:
|
||||||
|
///
|
||||||
|
/// The various KeyEvent types.
|
||||||
|
///
|
||||||
|
enum Type {
|
||||||
|
///
|
||||||
|
/// Key-Down event type. (Does not trigger accelerator commands in WebCore)
|
||||||
|
///
|
||||||
|
/// @NOTE: You should probably use RawKeyDown instead when a physical key
|
||||||
|
/// is pressed. This member is only here for historic compatibility
|
||||||
|
/// with WebCore's key event types.
|
||||||
|
///
|
||||||
|
kType_KeyDown,
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Key-Up event type. Use this when a physical key is released.
|
||||||
|
///
|
||||||
|
kType_KeyUp,
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Raw Key-Down type. Use this when a physical key is pressed.
|
||||||
|
///
|
||||||
|
/// @NOTE: You should use RawKeyDown for physical key presses since it
|
||||||
|
/// allows WebCore to do additional command translation.
|
||||||
|
///
|
||||||
|
kType_RawKeyDown,
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Character input event type. Use this when the OS generates text from
|
||||||
|
/// a physical key being pressed (eg, WM_CHAR on Windows).
|
||||||
|
///
|
||||||
|
kType_Char,
|
||||||
|
};
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Creates an empty KeyEvent, you will need to initialize its members
|
||||||
|
/// yourself. This is useful for synthesizing your own keyboard events.
|
||||||
|
///
|
||||||
|
KeyEvent();
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
///
|
||||||
|
/// Create a KeyEvent directly from a Windows keyboard event.
|
||||||
|
///
|
||||||
|
KeyEvent(Type type, uintptr_t wparam, intptr_t lparam, bool is_system_key);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __OBJC__
|
||||||
|
///
|
||||||
|
/// Create a KeyEvent directly from a macOS NSEvent.
|
||||||
|
///
|
||||||
|
KeyEvent(NSEvent* evt);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
///
|
||||||
|
/// An enumeration of the different keyboard modifiers.
|
||||||
|
///
|
||||||
|
enum Modifiers : uint8_t {
|
||||||
|
/// Whether or not an ALT key is down
|
||||||
|
kMod_AltKey = 1 << 0,
|
||||||
|
|
||||||
|
/// Whether or not a Control key is down
|
||||||
|
kMod_CtrlKey = 1 << 1,
|
||||||
|
|
||||||
|
/// Whether or not a meta key (Command-key on Mac, Windows-key on Win) is down
|
||||||
|
kMod_MetaKey = 1 << 2,
|
||||||
|
|
||||||
|
/// Whether or not a Shift key is down
|
||||||
|
kMod_ShiftKey = 1 << 3,
|
||||||
|
};
|
||||||
|
|
||||||
|
///
|
||||||
|
// The type of this KeyEvent
|
||||||
|
///
|
||||||
|
Type type;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// The current state of the keyboard. Modifiers may be OR'd together to
|
||||||
|
/// represent multiple values.
|
||||||
|
///
|
||||||
|
unsigned modifiers;
|
||||||
|
|
||||||
|
///
|
||||||
|
// The virtual key-code associated with this keyboard event. This is either
|
||||||
|
// directly from the event (ie, WPARAM on Windows) or via a mapping function.
|
||||||
|
// You can see a full list of the possible virtual key-codes in
|
||||||
|
// KeyboardCodes.h
|
||||||
|
///
|
||||||
|
int virtual_key_code;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// The actual key-code generated by the platform. The DOM spec primarily
|
||||||
|
/// uses Windows-equivalent codes (hence virtualKeyCode above) but it helps to
|
||||||
|
/// also specify the platform-specific key-code as well.
|
||||||
|
///
|
||||||
|
int native_key_code;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// This is a string identifying the key that was pressed. This can be
|
||||||
|
/// generated from the virtual_key_code via the GetKeyIdentifierFromVirtualKeyCode()
|
||||||
|
/// utility function. You can find the full list of key identifiers at:
|
||||||
|
/// <https://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/keyset.html>
|
||||||
|
///
|
||||||
|
String key_identifier;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// The actual text generated by this keyboard event. This is usually only a
|
||||||
|
/// single character.
|
||||||
|
///
|
||||||
|
String text;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// The text generated by this keyboard event before all modifiers except
|
||||||
|
/// shift are applied. This is used internally for working out shortcut keys.
|
||||||
|
/// This is usually only a single character.
|
||||||
|
///
|
||||||
|
String unmodified_text;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Whether or not this is a keypad event.
|
||||||
|
///
|
||||||
|
bool is_keypad;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Whether or not this was generated as the result of an auto-repeat
|
||||||
|
/// (eg, holding down a key).
|
||||||
|
///
|
||||||
|
bool is_auto_repeat;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Whether or not the pressed key is a "system key". This is a Windows-only
|
||||||
|
/// concept and should be "false" for all non-Windows platforms. For more
|
||||||
|
/// information, see the following link:
|
||||||
|
/// <http://msdn.microsoft.com/en-us/library/ms646286(VS.85).aspx>
|
||||||
|
bool is_system_key;
|
||||||
|
};
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Utility function for generating a key identifier string from a virtual
|
||||||
|
/// key-code.
|
||||||
|
///
|
||||||
|
/// @param virtual_key_code The virtual key-code to generate the key
|
||||||
|
/// identifier from.
|
||||||
|
///
|
||||||
|
/// @param key_identifier_result The string to store the result in.
|
||||||
|
///
|
||||||
|
void UExport GetKeyIdentifierFromVirtualKeyCode(int virtual_key_code,
|
||||||
|
String& key_identifier_result);
|
||||||
|
|
||||||
|
} // namespace ultralight
|
|
@ -0,0 +1,287 @@
|
||||||
|
///
|
||||||
|
/// @file Listener.h
|
||||||
|
///
|
||||||
|
/// @brief The header for View listener interfaces.
|
||||||
|
///
|
||||||
|
/// @author
|
||||||
|
///
|
||||||
|
/// This file is a part of Ultralight, a fast, lightweight, HTML UI engine
|
||||||
|
///
|
||||||
|
/// Website: <http://ultralig.ht>
|
||||||
|
///
|
||||||
|
/// Copyright (C) 2020 Ultralight, Inc. All rights reserved.
|
||||||
|
///
|
||||||
|
#pragma once
|
||||||
|
#include <Ultralight/Defines.h>
|
||||||
|
#include <Ultralight/String.h>
|
||||||
|
#include <Ultralight/RefPtr.h>
|
||||||
|
#include <Ultralight/Geometry.h>
|
||||||
|
|
||||||
|
namespace ultralight {
|
||||||
|
|
||||||
|
class View;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// MessageSource types, @see ViewListener::OnAddConsoleMessage
|
||||||
|
///
|
||||||
|
enum MessageSource {
|
||||||
|
kMessageSource_XML = 0,
|
||||||
|
kMessageSource_JS,
|
||||||
|
kMessageSource_Network,
|
||||||
|
kMessageSource_ConsoleAPI,
|
||||||
|
kMessageSource_Storage,
|
||||||
|
kMessageSource_AppCache,
|
||||||
|
kMessageSource_Rendering,
|
||||||
|
kMessageSource_CSS,
|
||||||
|
kMessageSource_Security,
|
||||||
|
kMessageSource_ContentBlocker,
|
||||||
|
kMessageSource_Other,
|
||||||
|
};
|
||||||
|
|
||||||
|
///
|
||||||
|
/// MessageLevel types, @see ViewListener::OnAddConsoleMessage
|
||||||
|
///
|
||||||
|
enum MessageLevel {
|
||||||
|
kMessageLevel_Log = 1,
|
||||||
|
kMessageLevel_Warning = 2,
|
||||||
|
kMessageLevel_Error = 3,
|
||||||
|
kMessageLevel_Debug = 4,
|
||||||
|
kMessageLevel_Info = 5,
|
||||||
|
};
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Cursor types, @see ViewListener::OnChangeCursor
|
||||||
|
///
|
||||||
|
enum Cursor {
|
||||||
|
kCursor_Pointer = 0,
|
||||||
|
kCursor_Cross,
|
||||||
|
kCursor_Hand,
|
||||||
|
kCursor_IBeam,
|
||||||
|
kCursor_Wait,
|
||||||
|
kCursor_Help,
|
||||||
|
kCursor_EastResize,
|
||||||
|
kCursor_NorthResize,
|
||||||
|
kCursor_NorthEastResize,
|
||||||
|
kCursor_NorthWestResize,
|
||||||
|
kCursor_SouthResize,
|
||||||
|
kCursor_SouthEastResize,
|
||||||
|
kCursor_SouthWestResize,
|
||||||
|
kCursor_WestResize,
|
||||||
|
kCursor_NorthSouthResize,
|
||||||
|
kCursor_EastWestResize,
|
||||||
|
kCursor_NorthEastSouthWestResize,
|
||||||
|
kCursor_NorthWestSouthEastResize,
|
||||||
|
kCursor_ColumnResize,
|
||||||
|
kCursor_RowResize,
|
||||||
|
kCursor_MiddlePanning,
|
||||||
|
kCursor_EastPanning,
|
||||||
|
kCursor_NorthPanning,
|
||||||
|
kCursor_NorthEastPanning,
|
||||||
|
kCursor_NorthWestPanning,
|
||||||
|
kCursor_SouthPanning,
|
||||||
|
kCursor_SouthEastPanning,
|
||||||
|
kCursor_SouthWestPanning,
|
||||||
|
kCursor_WestPanning,
|
||||||
|
kCursor_Move,
|
||||||
|
kCursor_VerticalText,
|
||||||
|
kCursor_Cell,
|
||||||
|
kCursor_ContextMenu,
|
||||||
|
kCursor_Alias,
|
||||||
|
kCursor_Progress,
|
||||||
|
kCursor_NoDrop,
|
||||||
|
kCursor_Copy,
|
||||||
|
kCursor_None,
|
||||||
|
kCursor_NotAllowed,
|
||||||
|
kCursor_ZoomIn,
|
||||||
|
kCursor_ZoomOut,
|
||||||
|
kCursor_Grab,
|
||||||
|
kCursor_Grabbing,
|
||||||
|
kCursor_Custom
|
||||||
|
};
|
||||||
|
|
||||||
|
///
|
||||||
|
/// @brief Interface for View-related events
|
||||||
|
///
|
||||||
|
/// @note For more info @see View::set_view_listener
|
||||||
|
///
|
||||||
|
class UExport ViewListener {
|
||||||
|
public:
|
||||||
|
virtual ~ViewListener() {}
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Called when the page title changes
|
||||||
|
///
|
||||||
|
virtual void OnChangeTitle(ultralight::View* caller,
|
||||||
|
const String& title) {}
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Called when the page URL changes
|
||||||
|
///
|
||||||
|
virtual void OnChangeURL(ultralight::View* caller,
|
||||||
|
const String& url) {}
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Called when the tooltip changes (usually as result of a mouse hover)
|
||||||
|
///
|
||||||
|
virtual void OnChangeTooltip(ultralight::View* caller,
|
||||||
|
const String& tooltip) {}
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Called when the mouse cursor changes
|
||||||
|
///
|
||||||
|
virtual void OnChangeCursor(ultralight::View* caller,
|
||||||
|
Cursor cursor) {}
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Called when a message is added to the console (useful for errors / debug)
|
||||||
|
///
|
||||||
|
virtual void OnAddConsoleMessage(ultralight::View* caller,
|
||||||
|
MessageSource source,
|
||||||
|
MessageLevel level,
|
||||||
|
const String& message,
|
||||||
|
uint32_t line_number,
|
||||||
|
uint32_t column_number,
|
||||||
|
const String& source_id) {}
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Called when the page wants to create a new View.
|
||||||
|
///
|
||||||
|
/// This is usually the result of a user clicking a link with target="_blank"
|
||||||
|
/// or by JavaScript calling window.open(url).
|
||||||
|
///
|
||||||
|
/// To allow creation of these new Views, you should create a new View in
|
||||||
|
/// this callback (eg, Renderer::CreateView()), resize it to your container,
|
||||||
|
/// and return it. You are responsible for displaying the returned View.
|
||||||
|
///
|
||||||
|
/// @param caller The View that called this event.
|
||||||
|
///
|
||||||
|
/// @param opener_url The URL of the page that initiated this request.
|
||||||
|
///
|
||||||
|
/// @param target_url The URL that the new View will navigate to.
|
||||||
|
///
|
||||||
|
/// @param is_popup Whether or not this was triggered by window.open().
|
||||||
|
///
|
||||||
|
/// @param popup_rect Popups can optionally request certain dimensions and
|
||||||
|
/// coordinates via window.open(). You can choose to
|
||||||
|
/// respect these or not by resizing/moving the View to
|
||||||
|
/// this rect.
|
||||||
|
///
|
||||||
|
/// @return Returns a RefPtr<> to a created View to use to satisfy the
|
||||||
|
/// the request (or return nullptr if you want to block the action).
|
||||||
|
///
|
||||||
|
virtual RefPtr<View> OnCreateChildView(ultralight::View* caller,
|
||||||
|
const String& opener_url,
|
||||||
|
const String& target_url,
|
||||||
|
bool is_popup,
|
||||||
|
const IntRect& popup_rect);
|
||||||
|
};
|
||||||
|
|
||||||
|
///
|
||||||
|
/// @brief Interface for Load-related events
|
||||||
|
///
|
||||||
|
/// @note For more info @see View::set_load_listener
|
||||||
|
///
|
||||||
|
class UExport LoadListener {
|
||||||
|
public:
|
||||||
|
virtual ~LoadListener() {}
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Called when the page begins loading a new URL into a frame.
|
||||||
|
///
|
||||||
|
/// @param frame_id A unique ID for the frame.
|
||||||
|
///
|
||||||
|
/// @param is_main_frame Whether or not this is the main frame.
|
||||||
|
///
|
||||||
|
/// @param url The URL for the load.
|
||||||
|
///
|
||||||
|
virtual void OnBeginLoading(ultralight::View* caller,
|
||||||
|
uint64_t frame_id,
|
||||||
|
bool is_main_frame,
|
||||||
|
const String& url) {}
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Called when the page finishes loading a URL into a frame.
|
||||||
|
///
|
||||||
|
/// @param frame_id A unique ID for the frame.
|
||||||
|
///
|
||||||
|
/// @param is_main_frame Whether or not this is the main frame.
|
||||||
|
///
|
||||||
|
/// @param url The URL for the load.
|
||||||
|
///
|
||||||
|
virtual void OnFinishLoading(ultralight::View* caller,
|
||||||
|
uint64_t frame_id,
|
||||||
|
bool is_main_frame,
|
||||||
|
const String& url) {}
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Called when an error occurs while loading a URL into a frame.
|
||||||
|
///
|
||||||
|
/// @param frame_id A unique ID for the frame.
|
||||||
|
///
|
||||||
|
/// @param is_main_frame Whether or not this is the main frame.
|
||||||
|
///
|
||||||
|
/// @param url The URL for the load.
|
||||||
|
///
|
||||||
|
/// @param description A human-readable description of the error.
|
||||||
|
///
|
||||||
|
/// @param error_domain The name of the module that triggered the error.
|
||||||
|
///
|
||||||
|
/// @param error_code Internal error code generated by the module.
|
||||||
|
///
|
||||||
|
virtual void OnFailLoading(ultralight::View* caller,
|
||||||
|
uint64_t frame_id,
|
||||||
|
bool is_main_frame,
|
||||||
|
const String& url,
|
||||||
|
const String& description,
|
||||||
|
const String& error_domain,
|
||||||
|
int error_code) {}
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Called when the JavaScript window object is reset for a new page load.
|
||||||
|
///
|
||||||
|
/// This is called before any scripts are executed on the page and is the
|
||||||
|
/// earliest time to setup any initial JavaScript state or bindings.
|
||||||
|
///
|
||||||
|
/// The document is not guaranteed to be loaded/parsed at this point. If
|
||||||
|
/// you need to make any JavaScript calls that are dependent on DOM elements
|
||||||
|
/// or scripts on the page, use OnDOMReady instead.
|
||||||
|
///
|
||||||
|
/// The window object is lazily initialized (this will not be called on pages
|
||||||
|
/// with no scripts).
|
||||||
|
///
|
||||||
|
/// @param frame_id A unique ID for the frame.
|
||||||
|
///
|
||||||
|
/// @param is_main_frame Whether or not this is the main frame.
|
||||||
|
///
|
||||||
|
/// @param url The URL for the load.
|
||||||
|
///
|
||||||
|
virtual void OnWindowObjectReady(ultralight::View* caller,
|
||||||
|
uint64_t frame_id,
|
||||||
|
bool is_main_frame,
|
||||||
|
const String& url) {}
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Called when all JavaScript has been parsed and the document is ready.
|
||||||
|
///
|
||||||
|
/// This is the best time to make any JavaScript calls that are dependent on
|
||||||
|
/// DOM elements or scripts on the page.
|
||||||
|
///
|
||||||
|
/// @param frame_id A unique ID for the frame.
|
||||||
|
///
|
||||||
|
/// @param is_main_frame Whether or not this is the main frame.
|
||||||
|
///
|
||||||
|
/// @param url The URL for the load.
|
||||||
|
///
|
||||||
|
virtual void OnDOMReady(ultralight::View* caller,
|
||||||
|
uint64_t frame_id,
|
||||||
|
bool is_main_frame,
|
||||||
|
const String& url) {}
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Called when the session history (back/forward state) is modified.
|
||||||
|
///
|
||||||
|
virtual void OnUpdateHistory(ultralight::View* caller) {}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace ultralight
|
|
@ -0,0 +1,190 @@
|
||||||
|
///
|
||||||
|
/// @file Matrix.h
|
||||||
|
///
|
||||||
|
/// @brief The header for Matrix helpers
|
||||||
|
///
|
||||||
|
/// @author
|
||||||
|
///
|
||||||
|
/// This file is a part of Ultralight, a fast, lightweight, HTML UI engine
|
||||||
|
///
|
||||||
|
/// Website: <http://ultralig.ht>
|
||||||
|
///
|
||||||
|
/// Copyright (C) 2020 Ultralight, Inc. All rights reserved.
|
||||||
|
///
|
||||||
|
#pragma once
|
||||||
|
#include <Ultralight/Defines.h>
|
||||||
|
#include <Ultralight/RefPtr.h>
|
||||||
|
#include <Ultralight/Geometry.h>
|
||||||
|
|
||||||
|
namespace ultralight {
|
||||||
|
|
||||||
|
///
|
||||||
|
/// 4x4 Matrix Helper
|
||||||
|
///
|
||||||
|
struct UExport Matrix4x4 {
|
||||||
|
///
|
||||||
|
/// Raw 4x4 matrix as an array
|
||||||
|
///
|
||||||
|
float data[16];
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Set to identity matrix.
|
||||||
|
///
|
||||||
|
void SetIdentity();
|
||||||
|
};
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Transformation Matrix helper
|
||||||
|
///
|
||||||
|
struct UExport Matrix {
|
||||||
|
#if defined(__x86_64__) || defined(_M_X64)
|
||||||
|
#if defined(_MSC_VER)
|
||||||
|
__declspec(align(16)) typedef double Aligned4x4[4][4];
|
||||||
|
#else
|
||||||
|
typedef double Aligned4x4[4][4] __attribute__((aligned(16)));
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
typedef double Aligned4x4[4][4];
|
||||||
|
#endif
|
||||||
|
|
||||||
|
Aligned4x4 data;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Set to identity matrix.
|
||||||
|
///
|
||||||
|
void SetIdentity();
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Set to an orthographic projection matrix suitable for use with our
|
||||||
|
/// vertex shaders. Optionally flip the y-coordinate space (eg, for OpenGL).
|
||||||
|
///
|
||||||
|
void SetOrthographicProjection(double screen_width, double screen_height,
|
||||||
|
bool flip_y);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Set to another matrix.
|
||||||
|
///
|
||||||
|
void Set(const Matrix& other);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Set to another matrix.
|
||||||
|
///
|
||||||
|
void Set(const Matrix4x4& other);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Set from raw affine members.
|
||||||
|
///
|
||||||
|
void Set(double a, double b, double c, double d, double e, double f);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Set from raw 4x4 components.
|
||||||
|
///
|
||||||
|
void Set(double m11, double m12, double m13, double m14,
|
||||||
|
double m21, double m22, double m23, double m24,
|
||||||
|
double m31, double m32, double m33, double m34,
|
||||||
|
double m41, double m42, double m43, double m44);
|
||||||
|
|
||||||
|
inline double m11() const { return data[0][0]; }
|
||||||
|
inline double m12() const { return data[0][1]; }
|
||||||
|
inline double m13() const { return data[0][2]; }
|
||||||
|
inline double m14() const { return data[0][3]; }
|
||||||
|
inline double m21() const { return data[1][0]; }
|
||||||
|
inline double m22() const { return data[1][1]; }
|
||||||
|
inline double m23() const { return data[1][2]; }
|
||||||
|
inline double m24() const { return data[1][3]; }
|
||||||
|
inline double m31() const { return data[2][0]; }
|
||||||
|
inline double m32() const { return data[2][1]; }
|
||||||
|
inline double m33() const { return data[2][2]; }
|
||||||
|
inline double m34() const { return data[2][3]; }
|
||||||
|
inline double m41() const { return data[3][0]; }
|
||||||
|
inline double m42() const { return data[3][1]; }
|
||||||
|
inline double m43() const { return data[3][2]; }
|
||||||
|
inline double m44() const { return data[3][3]; }
|
||||||
|
|
||||||
|
inline double a() const { return data[0][0]; }
|
||||||
|
inline double b() const { return data[0][1]; }
|
||||||
|
inline double c() const { return data[1][0]; }
|
||||||
|
inline double d() const { return data[1][1]; }
|
||||||
|
inline double e() const { return data[3][0]; }
|
||||||
|
inline double f() const { return data[3][1]; }
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Whether or not this is an identity matrix.
|
||||||
|
///
|
||||||
|
bool IsIdentity() const;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Whether or not this is an identity matrix or translation.
|
||||||
|
///
|
||||||
|
bool IsIdentityOrTranslation() const;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Whether or not this matrix uses only affine transformations.
|
||||||
|
///
|
||||||
|
bool IsAffine() const;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Whether or not this is an identity, translation, or non-negative
|
||||||
|
/// uniform scale.
|
||||||
|
///
|
||||||
|
bool IsSimple() const;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Translate by x and y.
|
||||||
|
///
|
||||||
|
void Translate(double x, double y);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Scale by x and y.
|
||||||
|
///
|
||||||
|
void Scale(double x, double y);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Rotate matrix by theta (in degrees)
|
||||||
|
///
|
||||||
|
void Rotate(double theta);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Rotate matrix by x and y
|
||||||
|
///
|
||||||
|
void Rotate(double x, double y);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Transform (multiply) by another Matrix
|
||||||
|
///
|
||||||
|
void Transform(const Matrix& other);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get the inverse of this matrix. May return false if not invertible.
|
||||||
|
///
|
||||||
|
bool GetInverse(Matrix& result) const;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Transform point by this matrix and get the result.
|
||||||
|
///
|
||||||
|
Point Apply(const Point& p) const;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Transform rect by this matrix and get the result as an axis-aligned rect.
|
||||||
|
///
|
||||||
|
Rect Apply(const Rect& r) const;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get an integer hash of this matrix's members.
|
||||||
|
///
|
||||||
|
uint32_t Hash() const;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get this matrix as unaligned 4x4 float components (for use passing to
|
||||||
|
/// GPU driver APIs).
|
||||||
|
///
|
||||||
|
Matrix4x4 GetMatrix4x4() const;
|
||||||
|
};
|
||||||
|
|
||||||
|
bool UExport operator==(const Matrix& a, const Matrix& b);
|
||||||
|
bool UExport operator!=(const Matrix& a, const Matrix& b);
|
||||||
|
|
||||||
|
bool UExport operator==(const Matrix4x4& a, const Matrix4x4& b);
|
||||||
|
bool UExport operator!=(const Matrix4x4& a, const Matrix4x4& b);
|
||||||
|
|
||||||
|
} // namespace ultralight
|
|
@ -0,0 +1,77 @@
|
||||||
|
///
|
||||||
|
/// @file MouseEvent.h
|
||||||
|
///
|
||||||
|
/// @brief The header for the MouseEvent class.
|
||||||
|
///
|
||||||
|
/// @author
|
||||||
|
///
|
||||||
|
/// This file is a part of Ultralight, a fast, lightweight, HTML UI engine
|
||||||
|
///
|
||||||
|
/// Website: <http://ultralig.ht>
|
||||||
|
///
|
||||||
|
/// Copyright (C) 2020 Ultralight, Inc. All rights reserved.
|
||||||
|
///
|
||||||
|
#pragma once
|
||||||
|
#include <Ultralight/Defines.h>
|
||||||
|
|
||||||
|
namespace ultralight {
|
||||||
|
|
||||||
|
///
|
||||||
|
/// @brief A generic mouse event.
|
||||||
|
///
|
||||||
|
/// @note @see View::FireMouseEvent
|
||||||
|
///
|
||||||
|
class MouseEvent {
|
||||||
|
public:
|
||||||
|
///
|
||||||
|
/// The various MouseEvent types.
|
||||||
|
///
|
||||||
|
enum Type {
|
||||||
|
///
|
||||||
|
/// Mouse moved type
|
||||||
|
///
|
||||||
|
kType_MouseMoved,
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Mouse button pressed type
|
||||||
|
///
|
||||||
|
kType_MouseDown,
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Mouse button released type
|
||||||
|
///
|
||||||
|
kType_MouseUp,
|
||||||
|
};
|
||||||
|
|
||||||
|
///
|
||||||
|
/// The various mouse button types.
|
||||||
|
///
|
||||||
|
enum Button {
|
||||||
|
kButton_None = 0,
|
||||||
|
kButton_Left,
|
||||||
|
kButton_Middle,
|
||||||
|
kButton_Right,
|
||||||
|
};
|
||||||
|
|
||||||
|
///
|
||||||
|
/// The type of this MouseEvent
|
||||||
|
///
|
||||||
|
Type type;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// The current x-position of the mouse, relative to the View
|
||||||
|
///
|
||||||
|
int x;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// The current y-position of the mouse, relative to the View
|
||||||
|
///
|
||||||
|
int y;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// The mouse button that was pressed/released, if any.
|
||||||
|
///
|
||||||
|
Button button;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace ultralight
|
|
@ -0,0 +1,538 @@
|
||||||
|
///
|
||||||
|
/// @file RefPtr.h
|
||||||
|
///
|
||||||
|
/// @brief The header for all ref-counting utilities.
|
||||||
|
///
|
||||||
|
/// @author
|
||||||
|
///
|
||||||
|
/// This file is a part of Ultralight, a fast, lightweight, HTML UI engine
|
||||||
|
///
|
||||||
|
/// Website: <http://ultralig.ht>
|
||||||
|
///
|
||||||
|
/// Copyright (C) 2020 Ultralight, Inc. All rights reserved.
|
||||||
|
///
|
||||||
|
/*
|
||||||
|
* Portions of the below code are derived from 'RefPtr.h' from Apple's WTF,
|
||||||
|
* with the following license header:
|
||||||
|
*
|
||||||
|
* Copyright (C) 2013-2014 Apple Inc. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
|
||||||
|
* AND ANY EXPRESS 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 APPLE INC. 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include <Ultralight/Defines.h>
|
||||||
|
#include <assert.h>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
|
namespace ultralight {
|
||||||
|
|
||||||
|
///
|
||||||
|
/// @brief Interface for all ref-counted objects that will be managed using
|
||||||
|
/// the Ref<> and RefPtr<> smart pointers.
|
||||||
|
///
|
||||||
|
class UExport RefCounted {
|
||||||
|
public:
|
||||||
|
virtual void AddRef() const = 0;
|
||||||
|
virtual void Release() const = 0;
|
||||||
|
virtual int ref_count() const = 0;
|
||||||
|
protected:
|
||||||
|
virtual ~RefCounted();
|
||||||
|
};
|
||||||
|
|
||||||
|
inline void adopted(const void*) { }
|
||||||
|
|
||||||
|
template<typename T> class Ref;
|
||||||
|
template<typename T> class RefPtr;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// @brief Helper for wrapping new objects with the Ref smart pointer.
|
||||||
|
///
|
||||||
|
/// All ref-counted object are created with an initial ref-count of '1'.
|
||||||
|
/// The AdoptRef() helper returns a Ref<T> without calling AddRef().
|
||||||
|
/// This is used for creating new objects, like so:
|
||||||
|
///
|
||||||
|
/// Ref<Object> ref = AdoptRef(*new ObjectImpl());
|
||||||
|
///
|
||||||
|
template<typename T> Ref<T> AdoptRef(T&);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// @brief A non-nullable smart pointer.
|
||||||
|
///
|
||||||
|
/// This smart pointer automatically manages the lifetime of a RefCounted
|
||||||
|
/// object. Also guarantees that the managed instance is not NULL.
|
||||||
|
///
|
||||||
|
template<typename T> class Ref {
|
||||||
|
public:
|
||||||
|
///
|
||||||
|
/// Destroy Ref (wll decrement ref-count by one)
|
||||||
|
///
|
||||||
|
~Ref()
|
||||||
|
{
|
||||||
|
if (instance_)
|
||||||
|
instance_->Release();
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Construct Ref from a reference. (Will increment ref-count by one)
|
||||||
|
///
|
||||||
|
Ref(T& object)
|
||||||
|
: instance_(&object)
|
||||||
|
{
|
||||||
|
instance_->AddRef();
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Copy constructor.
|
||||||
|
///
|
||||||
|
Ref(const Ref& other)
|
||||||
|
: instance_(other.instance_)
|
||||||
|
{
|
||||||
|
instance_->AddRef();
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Copy constructor with internal type conversion.
|
||||||
|
///
|
||||||
|
template<typename U>
|
||||||
|
Ref(Ref<U>& other)
|
||||||
|
: instance_(other.ptr())
|
||||||
|
{
|
||||||
|
instance_->AddRef();
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Copy constructor with internal type conversion.
|
||||||
|
///
|
||||||
|
template<typename U>
|
||||||
|
Ref(const Ref<U>& other)
|
||||||
|
: instance_(other.ptr())
|
||||||
|
{
|
||||||
|
instance_->AddRef();
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Move constructor.
|
||||||
|
///
|
||||||
|
Ref(Ref&& other)
|
||||||
|
: instance_(&other.LeakRef())
|
||||||
|
{
|
||||||
|
assert(instance_);
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Move constructor.
|
||||||
|
///
|
||||||
|
template<typename U>
|
||||||
|
Ref(Ref<U>&& other)
|
||||||
|
: instance_(&other.LeakRef())
|
||||||
|
{
|
||||||
|
assert(instance_);
|
||||||
|
}
|
||||||
|
|
||||||
|
Ref& operator=(T& object)
|
||||||
|
{
|
||||||
|
assert(instance_);
|
||||||
|
object.AddRef();
|
||||||
|
instance_->Release();
|
||||||
|
instance_ = &object;
|
||||||
|
assert(instance_);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ref& operator=(const Ref& other)
|
||||||
|
{
|
||||||
|
assert(instance_);
|
||||||
|
other.instance_->AddRef();
|
||||||
|
instance_->Release();
|
||||||
|
instance_ = other.instance_;
|
||||||
|
assert(instance_);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename U>
|
||||||
|
Ref& operator=(const Ref<U>& other)
|
||||||
|
{
|
||||||
|
assert(instance_);
|
||||||
|
other.instance_->AddRef();
|
||||||
|
instance_->Release();
|
||||||
|
instance_ = other.instance_;
|
||||||
|
assert(instance_);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ref& operator=(Ref&& reference)
|
||||||
|
{
|
||||||
|
assert(instance_);
|
||||||
|
instance_->Release();
|
||||||
|
instance_ = &reference.LeakRef();
|
||||||
|
assert(instance_);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename U> Ref& operator=(Ref<U>&& reference)
|
||||||
|
{
|
||||||
|
assert(instance_);
|
||||||
|
instance_->Release();
|
||||||
|
instance_ = &reference.LeakRef();
|
||||||
|
assert(instance_);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
const T* operator->() const { assert(instance_); return instance_; }
|
||||||
|
T* operator->() { assert(instance_); return instance_; }
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get a pointer to wrapped object.
|
||||||
|
///
|
||||||
|
const T* ptr() const { assert(instance_); return instance_; }
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get a pointer to wrapped object.
|
||||||
|
///
|
||||||
|
T* ptr() { assert(instance_); return instance_; }
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get a reference to wrapped object.
|
||||||
|
///
|
||||||
|
const T& get() const { assert(instance_); return *instance_; }
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get a reference to wrapped object.
|
||||||
|
///
|
||||||
|
T& get() { assert(instance_); return *instance_; }
|
||||||
|
|
||||||
|
operator T&() { assert(instance_); return *instance_; }
|
||||||
|
operator const T&() const { assert(instance_); return *instance_; }
|
||||||
|
|
||||||
|
template<typename U> Ref<T> Replace(Ref<U>&&);
|
||||||
|
|
||||||
|
T& LeakRef() {
|
||||||
|
assert(instance_);
|
||||||
|
|
||||||
|
T* result = std::move(instance_);
|
||||||
|
instance_ = std::forward<T*>(nullptr);
|
||||||
|
return *result;
|
||||||
|
}
|
||||||
|
|
||||||
|
friend inline bool operator==(const Ref& a, const Ref& b) {
|
||||||
|
return a.instance_ == b.instance_;
|
||||||
|
}
|
||||||
|
|
||||||
|
friend inline bool operator!=(const Ref& a, const Ref& b) {
|
||||||
|
return a.instance_ != b.instance_;
|
||||||
|
}
|
||||||
|
|
||||||
|
friend inline bool operator<(const Ref& a, const Ref& b) {
|
||||||
|
return a.instance_ < b.instance_;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
friend Ref AdoptRef<T>(T&);
|
||||||
|
template<typename U> friend class RefPtr;
|
||||||
|
|
||||||
|
enum AdoptTag { Adopt };
|
||||||
|
Ref(T& object, AdoptTag)
|
||||||
|
: instance_(&object)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
T* instance_;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename T> template<typename U> Ref<T> Ref<T>::Replace(Ref<U>&& reference)
|
||||||
|
{
|
||||||
|
auto oldReference = AdoptRef(*instance_);
|
||||||
|
instance_ = &reference.LeakRef();
|
||||||
|
return oldReference;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
Ref<T> AdoptRef(T& reference)
|
||||||
|
{
|
||||||
|
adopted(&reference);
|
||||||
|
return Ref<T>(reference, Ref<T>::Adopt);
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
/// @brief A nullable smart pointer.
|
||||||
|
///
|
||||||
|
/// This smart pointer automatically manages the lifetime of a RefCounted
|
||||||
|
/// object. The managed instance may be NULL.
|
||||||
|
///
|
||||||
|
template<typename T> class RefPtr {
|
||||||
|
public:
|
||||||
|
///
|
||||||
|
/// Construct a NULL ref-pointer.
|
||||||
|
///
|
||||||
|
RefPtr()
|
||||||
|
: instance_(nullptr)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Construct a NULL ref-pointer.
|
||||||
|
///
|
||||||
|
RefPtr(std::nullptr_t)
|
||||||
|
: instance_(nullptr)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Construct from a pointer. (Will increment ref-count by one)
|
||||||
|
///
|
||||||
|
RefPtr(T* other)
|
||||||
|
: instance_(other)
|
||||||
|
{
|
||||||
|
if (instance_)
|
||||||
|
instance_->AddRef();
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Copy constructor.
|
||||||
|
///
|
||||||
|
RefPtr(const RefPtr& other)
|
||||||
|
: instance_(other.instance_)
|
||||||
|
{
|
||||||
|
if (instance_)
|
||||||
|
instance_->AddRef();
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Copy constructor with internal type conversion.
|
||||||
|
///
|
||||||
|
template<typename U>
|
||||||
|
RefPtr(const RefPtr<U>& other)
|
||||||
|
: instance_(other.instance_)
|
||||||
|
{
|
||||||
|
if (instance_)
|
||||||
|
instance_->AddRef();
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Move constructor.
|
||||||
|
///
|
||||||
|
RefPtr(RefPtr&& other)
|
||||||
|
: instance_(other.LeakRef())
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Move constructor.
|
||||||
|
///
|
||||||
|
template<typename U>
|
||||||
|
RefPtr(RefPtr<U>&& other)
|
||||||
|
: instance_(other.LeakRef())
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Construct from a Ref
|
||||||
|
///
|
||||||
|
template<typename U>
|
||||||
|
RefPtr(const Ref<U>& other)
|
||||||
|
: instance_(other.instance_)
|
||||||
|
{
|
||||||
|
if (instance_)
|
||||||
|
instance_->AddRef();
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Construct by moving from a Ref
|
||||||
|
///
|
||||||
|
template<typename U>
|
||||||
|
RefPtr(Ref<U>&& other);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Destroy RefPtr (wll decrement ref-count by one)
|
||||||
|
///
|
||||||
|
~RefPtr()
|
||||||
|
{
|
||||||
|
T* old_value = std::move(instance_);
|
||||||
|
instance_ = std::forward<T*>(nullptr);
|
||||||
|
if (old_value)
|
||||||
|
old_value->Release();
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get a pointer to wrapped object.
|
||||||
|
///
|
||||||
|
T* get() const { return instance_; }
|
||||||
|
|
||||||
|
T* LeakRef() {
|
||||||
|
T* result = std::move(instance_);
|
||||||
|
instance_ = std::forward<T*>(nullptr);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
T& operator*() const { assert(instance_); return *instance_; }
|
||||||
|
T* operator->() const { return instance_; }
|
||||||
|
|
||||||
|
bool operator!() const { return !instance_; }
|
||||||
|
|
||||||
|
// This conversion operator allows implicit conversion to bool but not to other integer types.
|
||||||
|
typedef T* (RefPtr::*UnspecifiedBoolType);
|
||||||
|
operator UnspecifiedBoolType() const { return instance_ ? &RefPtr::instance_ : nullptr; }
|
||||||
|
|
||||||
|
RefPtr& operator=(const RefPtr&);
|
||||||
|
RefPtr& operator=(T*);
|
||||||
|
RefPtr& operator=(std::nullptr_t);
|
||||||
|
template<typename U> RefPtr& operator=(const RefPtr<U>&);
|
||||||
|
RefPtr& operator=(RefPtr&&);
|
||||||
|
template<typename U> RefPtr& operator=(RefPtr<U>&&);
|
||||||
|
template<typename U> RefPtr& operator=(Ref<U>&&);
|
||||||
|
|
||||||
|
friend inline bool operator==(const RefPtr& a, const RefPtr& b) {
|
||||||
|
return a.instance_ == b.instance_;
|
||||||
|
}
|
||||||
|
|
||||||
|
friend inline bool operator!=(const RefPtr& a, const RefPtr& b) {
|
||||||
|
return a.instance_ != b.instance_;
|
||||||
|
}
|
||||||
|
|
||||||
|
friend inline bool operator<(const RefPtr& a, const RefPtr& b) {
|
||||||
|
return a.instance_ < b.instance_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Swap(RefPtr&);
|
||||||
|
|
||||||
|
private:
|
||||||
|
T* instance_;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
template<typename U>
|
||||||
|
RefPtr<T>::RefPtr(Ref<U>&& reference)
|
||||||
|
: instance_(&reference.LeakRef())
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
RefPtr<T>& RefPtr<T>::operator=(const RefPtr& other)
|
||||||
|
{
|
||||||
|
RefPtr ptr = other;
|
||||||
|
Swap(ptr);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
template<typename U>
|
||||||
|
RefPtr<T>& RefPtr<T>::operator=(const RefPtr<U>& other)
|
||||||
|
{
|
||||||
|
RefPtr ptr = other;
|
||||||
|
Swap(ptr);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
RefPtr<T>& RefPtr<T>::operator=(T* object)
|
||||||
|
{
|
||||||
|
RefPtr ptr = object;
|
||||||
|
Swap(ptr);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
RefPtr<T>& RefPtr<T>::operator=(std::nullptr_t)
|
||||||
|
{
|
||||||
|
T* old_instance = std::move(instance_);
|
||||||
|
instance_ = std::forward<T*>(nullptr);
|
||||||
|
if (old_instance)
|
||||||
|
old_instance->Release();
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
RefPtr<T>& RefPtr<T>::operator=(RefPtr&& other)
|
||||||
|
{
|
||||||
|
RefPtr ptr = std::move(other);
|
||||||
|
Swap(ptr);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
template<typename U>
|
||||||
|
RefPtr<T>& RefPtr<T>::operator=(RefPtr<U>&& other)
|
||||||
|
{
|
||||||
|
RefPtr ptr = std::move(other);
|
||||||
|
Swap(ptr);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
template<typename U>
|
||||||
|
RefPtr<T>& RefPtr<T>::operator=(Ref<U>&& other)
|
||||||
|
{
|
||||||
|
RefPtr ptr = std::move(other);
|
||||||
|
Swap(ptr);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
void RefPtr<T>::Swap(RefPtr& other)
|
||||||
|
{
|
||||||
|
std::swap(instance_, other.instance_);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
void Swap(RefPtr<T>& a, RefPtr<T>& b)
|
||||||
|
{
|
||||||
|
a.Swap(b);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T, typename U>
|
||||||
|
bool operator==(const RefPtr<T>& a, const RefPtr<U>& b)
|
||||||
|
{
|
||||||
|
return a.get() == b.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T, typename U>
|
||||||
|
bool operator==(const RefPtr<T>& a, U* b)
|
||||||
|
{
|
||||||
|
return a.get() == b;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T, typename U>
|
||||||
|
bool operator==(T* a, const RefPtr<U>& b)
|
||||||
|
{
|
||||||
|
return a == b.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T, typename U>
|
||||||
|
bool operator!=(const RefPtr<T>& a, const RefPtr<U>& b)
|
||||||
|
{
|
||||||
|
return a.get() != b.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T, typename U>
|
||||||
|
bool operator!=(const RefPtr<T>& a, U* b)
|
||||||
|
{
|
||||||
|
return a.get() != b;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T, typename U>
|
||||||
|
bool operator!=(T* a, const RefPtr<U>& b)
|
||||||
|
{
|
||||||
|
return a != b.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace ultralight
|
|
@ -0,0 +1,84 @@
|
||||||
|
///
|
||||||
|
/// @file RenderTarget.h
|
||||||
|
///
|
||||||
|
/// @brief The header for the RenderTarget struct.
|
||||||
|
///
|
||||||
|
/// @author
|
||||||
|
///
|
||||||
|
/// This file is a part of Ultralight, a fast, lightweight, HTML UI engine
|
||||||
|
///
|
||||||
|
/// Website: <http://ultralig.ht>
|
||||||
|
///
|
||||||
|
/// Copyright (C) 2020 Ultralight, Inc. All rights reserved.
|
||||||
|
///
|
||||||
|
#pragma once
|
||||||
|
#include <Ultralight/Defines.h>
|
||||||
|
#include <Ultralight/Bitmap.h>
|
||||||
|
#include <Ultralight/Geometry.h>
|
||||||
|
|
||||||
|
namespace ultralight {
|
||||||
|
|
||||||
|
#pragma pack(push, 1)
|
||||||
|
|
||||||
|
///
|
||||||
|
/// @brief Rendering details for a View, to be used with your own GPUDriver
|
||||||
|
///
|
||||||
|
/// When using your own GPUDriver, each View is rendered to an offscreen
|
||||||
|
/// texture that you can display on a 3D quad in your application. This struct
|
||||||
|
/// provides all the details you need to display the corresponding texture in
|
||||||
|
/// your application.
|
||||||
|
///
|
||||||
|
struct UExport RenderTarget {
|
||||||
|
///
|
||||||
|
/// Whether this target is empty (null texture)
|
||||||
|
///
|
||||||
|
bool is_empty;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// The viewport width (in device coordinates).
|
||||||
|
///
|
||||||
|
uint32_t width;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// The viewport height (in device coordinates).
|
||||||
|
///
|
||||||
|
uint32_t height;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// The GPUDriver-specific texture ID (you should bind the texture using
|
||||||
|
/// your implementation of GPUDriver::BindTexture before drawing a quad).
|
||||||
|
///
|
||||||
|
uint32_t texture_id;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// The texture width (in pixels). This may be padded.
|
||||||
|
///
|
||||||
|
uint32_t texture_width;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// The texture height (in pixels). This may be padded.
|
||||||
|
///
|
||||||
|
uint32_t texture_height;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// The pixel format of the texture.
|
||||||
|
///
|
||||||
|
BitmapFormat texture_format;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// UV coordinates of the texture (this is needed because the texture may
|
||||||
|
/// be padded).
|
||||||
|
///
|
||||||
|
Rect uv_coords;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// The GPUDriver-specific render buffer ID.
|
||||||
|
///
|
||||||
|
uint32_t render_buffer_id;
|
||||||
|
|
||||||
|
RenderTarget();
|
||||||
|
};
|
||||||
|
|
||||||
|
#pragma pack(pop)
|
||||||
|
|
||||||
|
} // namespace ultralight
|
|
@ -0,0 +1,137 @@
|
||||||
|
///
|
||||||
|
/// @file Renderer.h
|
||||||
|
///
|
||||||
|
/// @brief The header for the Renderer class.
|
||||||
|
///
|
||||||
|
/// @author
|
||||||
|
///
|
||||||
|
/// This file is a part of Ultralight, a fast, lightweight, HTML UI engine
|
||||||
|
///
|
||||||
|
/// Website: <http://ultralig.ht>
|
||||||
|
///
|
||||||
|
/// Copyright (C) 2020 Ultralight, Inc. All rights reserved.
|
||||||
|
///
|
||||||
|
#pragma once
|
||||||
|
#include <Ultralight/Defines.h>
|
||||||
|
#include <Ultralight/RefPtr.h>
|
||||||
|
#include <Ultralight/Session.h>
|
||||||
|
#include <Ultralight/View.h>
|
||||||
|
|
||||||
|
namespace ultralight {
|
||||||
|
|
||||||
|
///
|
||||||
|
/// @brief This singleton manages the lifetime of all Views (@see View) and
|
||||||
|
/// coordinates painting, network requests, and event dispatch.
|
||||||
|
///
|
||||||
|
/// @note You don't have to create this instance directly if you use the
|
||||||
|
/// AppCore API. The App class will automatically create a Renderer and
|
||||||
|
/// perform all rendering within its run loop. @see App::Create
|
||||||
|
///
|
||||||
|
class UExport Renderer : public RefCounted {
|
||||||
|
public:
|
||||||
|
///
|
||||||
|
/// Create the Ultralight Renderer directly.
|
||||||
|
///
|
||||||
|
/// Unlike App::Create(), this does not use any native windows for drawing
|
||||||
|
/// and allows you to manage your own runloop and painting. This method is
|
||||||
|
/// recommended for those wishing to integrate the library into a game.
|
||||||
|
///
|
||||||
|
/// You should set up your Platform config, file-system, font loader,
|
||||||
|
/// and surface-factories/gpu-drivers before calling this function.
|
||||||
|
/// (@see <Ultralight/Platform.h>)
|
||||||
|
///
|
||||||
|
/// At a minimum, you will need to define a FontLoader ahead of time or this
|
||||||
|
/// call will fail. You can use the platform's native FontLoader by calling:
|
||||||
|
/// <pre>
|
||||||
|
/// /// This function is defined in <AppCore/Platform.h>
|
||||||
|
/// Platform::instance().set_font_loader(GetPlatformFontLoader());
|
||||||
|
/// </pre>
|
||||||
|
///
|
||||||
|
/// @note You should only create one Renderer per application lifetime.
|
||||||
|
///
|
||||||
|
/// @note: You should not call this if you are using App::Create(), it
|
||||||
|
/// creates its own renderer and provides default implementations for
|
||||||
|
/// various platform handlers automatically.
|
||||||
|
///
|
||||||
|
/// @return Renderer is ref-counted. This method returns a ref-pointer
|
||||||
|
/// to a new instance, you should store it in a RefPtr<> to keep
|
||||||
|
/// the instance alive.
|
||||||
|
///
|
||||||
|
static Ref<Renderer> Create();
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Create a Session to store local data in (such as cookies, local storage,
|
||||||
|
/// application cache, indexed db, etc).
|
||||||
|
///
|
||||||
|
/// @note A default, persistent Session is already created for you. You
|
||||||
|
/// only need to call this if you want to create private, in-memory
|
||||||
|
/// session or use a separate session for each View.
|
||||||
|
///
|
||||||
|
/// @param is_persistent Whether or not to store the session on disk.
|
||||||
|
/// Persistent sessions will be written to the path
|
||||||
|
/// set in Config::cache_path
|
||||||
|
///
|
||||||
|
/// @param name A unique name for this session, this will be used to
|
||||||
|
/// generate a unique disk path for persistent sessions.
|
||||||
|
///
|
||||||
|
virtual Ref<Session> CreateSession(bool is_persistent, const String& name) = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get the default Session. This session is persistent (backed to disk) and
|
||||||
|
/// has the name "default".
|
||||||
|
///
|
||||||
|
virtual Ref<Session> default_session() = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Create a new View.
|
||||||
|
///
|
||||||
|
/// @param width The initial width, in pixels.
|
||||||
|
///
|
||||||
|
/// @param height The initial height, in pixels.
|
||||||
|
///
|
||||||
|
/// @param transparent Whether or not the view background is transparent.
|
||||||
|
///
|
||||||
|
/// @param session The session to store local data in. Pass a nullptr to
|
||||||
|
/// use the default session.
|
||||||
|
///
|
||||||
|
/// @return Returns a ref-pointer to a new View instance. You should assign
|
||||||
|
/// it to either a Ref<View> (non-nullable) or RefPtr<View>
|
||||||
|
/// (nullable).
|
||||||
|
///
|
||||||
|
virtual Ref<View> CreateView(uint32_t width, uint32_t height,
|
||||||
|
bool transparent, RefPtr<Session> session,
|
||||||
|
bool force_cpu_renderer = false) = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Update timers and dispatch internal callbacks. You should call this often
|
||||||
|
/// from your main application loop.
|
||||||
|
///
|
||||||
|
virtual void Update() = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Render all active views to their respective render-targets/surfaces.
|
||||||
|
///
|
||||||
|
/// You should call this once per frame (usually in synchrony with the
|
||||||
|
/// monitor's refresh rate).
|
||||||
|
///
|
||||||
|
/// @note Views are only repainted if they actually need painting.
|
||||||
|
///
|
||||||
|
virtual void Render() = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Attempt to release as much memory as possible. Don't call this from any
|
||||||
|
/// callbacks or driver code.
|
||||||
|
///
|
||||||
|
virtual void PurgeMemory() = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Print detailed memory usage statistics to the log.
|
||||||
|
/// (@see Platform::set_logger())
|
||||||
|
///
|
||||||
|
virtual void LogMemoryUsage() = 0;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual ~Renderer();
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace ultralight
|
|
@ -0,0 +1,53 @@
|
||||||
|
///
|
||||||
|
/// @file ScrollEvent.h
|
||||||
|
///
|
||||||
|
/// @brief The header for the ScrollEvent class.
|
||||||
|
///
|
||||||
|
/// @author
|
||||||
|
///
|
||||||
|
/// This file is a part of Ultralight, a fast, lightweight, HTML UI engine
|
||||||
|
///
|
||||||
|
/// Website: <http://ultralig.ht>
|
||||||
|
///
|
||||||
|
/// Copyright (C) 2020 Ultralight, Inc. All rights reserved.
|
||||||
|
///
|
||||||
|
#pragma once
|
||||||
|
#include <Ultralight/Defines.h>
|
||||||
|
|
||||||
|
namespace ultralight {
|
||||||
|
|
||||||
|
///
|
||||||
|
/// @brief A generic scroll event.
|
||||||
|
///
|
||||||
|
/// @note @see View::FireScrollEvent
|
||||||
|
///
|
||||||
|
class ScrollEvent {
|
||||||
|
public:
|
||||||
|
///
|
||||||
|
/// The scroll event granularity type
|
||||||
|
///
|
||||||
|
enum Type {
|
||||||
|
/// The delta value is interpreted as number of pixels
|
||||||
|
kType_ScrollByPixel,
|
||||||
|
|
||||||
|
/// The delta value is interpreted as number of pages
|
||||||
|
kType_ScrollByPage,
|
||||||
|
};
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Scroll granularity type
|
||||||
|
///
|
||||||
|
Type type;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Horizontal scroll amount
|
||||||
|
///
|
||||||
|
int delta_x;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Vertical scroll amount
|
||||||
|
///
|
||||||
|
int delta_y;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace ultralight
|
|
@ -0,0 +1,53 @@
|
||||||
|
///
|
||||||
|
/// @file Session.h
|
||||||
|
///
|
||||||
|
/// @brief The header for the Session class.
|
||||||
|
///
|
||||||
|
/// @author
|
||||||
|
///
|
||||||
|
/// This file is a part of Ultralight, a fast, lightweight, HTML UI engine
|
||||||
|
///
|
||||||
|
/// Website: <http://ultralig.ht>
|
||||||
|
///
|
||||||
|
/// Copyright (C) 2020 Ultralight, Inc. All rights reserved.
|
||||||
|
///
|
||||||
|
#pragma once
|
||||||
|
#include <Ultralight/Defines.h>
|
||||||
|
#include <Ultralight/RefPtr.h>
|
||||||
|
#include <Ultralight/String.h>
|
||||||
|
|
||||||
|
namespace ultralight {
|
||||||
|
|
||||||
|
///
|
||||||
|
/// @brief A Session stores local data such as cookies, local storage,
|
||||||
|
/// and application cache for one or more Views.
|
||||||
|
///
|
||||||
|
/// @see Renderer::CreateSession
|
||||||
|
///
|
||||||
|
class UExport Session : public RefCounted {
|
||||||
|
public:
|
||||||
|
///
|
||||||
|
/// Whether or not this session is written to disk.
|
||||||
|
///
|
||||||
|
virtual bool is_persistent() const = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// A unique name identifying this session.
|
||||||
|
///
|
||||||
|
virtual String name() const = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// A unique numeric ID identifying this session.
|
||||||
|
///
|
||||||
|
virtual uint64_t id() const = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// The disk path of this session (only valid for persistent sessions).
|
||||||
|
///
|
||||||
|
virtual String disk_path() const = 0;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual ~Session();
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace ultralight
|
|
@ -0,0 +1,120 @@
|
||||||
|
///
|
||||||
|
/// @file String.h
|
||||||
|
///
|
||||||
|
/// @brief The header for the String class.
|
||||||
|
///
|
||||||
|
/// @author
|
||||||
|
///
|
||||||
|
/// This file is a part of Ultralight, a fast, lightweight, HTML UI engine
|
||||||
|
///
|
||||||
|
/// Website: <http://ultralig.ht>
|
||||||
|
///
|
||||||
|
/// Copyright (C) 2020 Ultralight, Inc. All rights reserved.
|
||||||
|
///
|
||||||
|
#pragma once
|
||||||
|
#include <Ultralight/Defines.h>
|
||||||
|
#include <Ultralight/String8.h>
|
||||||
|
#include <Ultralight/String16.h>
|
||||||
|
#include <Ultralight/String32.h>
|
||||||
|
|
||||||
|
namespace ultralight {
|
||||||
|
|
||||||
|
///
|
||||||
|
/// @brief UTF-16 String container with conversions for UTF-8 and UTF-32.
|
||||||
|
///
|
||||||
|
/// @note Internally, all strings are represented as UTF-16.
|
||||||
|
///
|
||||||
|
class UExport String {
|
||||||
|
public:
|
||||||
|
///
|
||||||
|
/// Create empty string
|
||||||
|
///
|
||||||
|
String();
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Create from null-terminated, ASCII C-string
|
||||||
|
///
|
||||||
|
String(const char* str);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Create from raw, UTF-8 string with certain length
|
||||||
|
///
|
||||||
|
String(const char* str, size_t len);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Create from existing String8 (UTF-8).
|
||||||
|
///
|
||||||
|
String(const String8& str);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Create from raw UTF-16 string with certain length
|
||||||
|
///
|
||||||
|
String(const Char16* str, size_t len);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Create from existing String16 (UTF-16)
|
||||||
|
///
|
||||||
|
String(const String16& str);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Create from existing String32 (UTF-32)
|
||||||
|
///
|
||||||
|
String(const String32& str);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Copy constructor
|
||||||
|
///
|
||||||
|
String(const String& other);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Destructor
|
||||||
|
///
|
||||||
|
~String();
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Assign string from another, copy is made
|
||||||
|
///
|
||||||
|
String& operator=(const String& other);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Append string with another
|
||||||
|
///
|
||||||
|
String& operator+=(const String& other);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Concatenation operator
|
||||||
|
///
|
||||||
|
inline friend String operator+(String lhs, const String& rhs) { lhs += rhs; return lhs; }
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get native UTF-16 string
|
||||||
|
///
|
||||||
|
String16& utf16() { return str_; }
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get native UTF-16 string
|
||||||
|
///
|
||||||
|
const String16& utf16() const { return str_; }
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Convert to UTF-8 string
|
||||||
|
///
|
||||||
|
String8 utf8() const;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Convert to UTF-32 string
|
||||||
|
///
|
||||||
|
String32 utf32() const;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Check if string is empty or not
|
||||||
|
///
|
||||||
|
bool empty() const { return utf16().empty(); }
|
||||||
|
|
||||||
|
private:
|
||||||
|
String16 str_;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace ultralight
|
||||||
|
|
|
@ -0,0 +1,130 @@
|
||||||
|
///
|
||||||
|
/// @file String16.h
|
||||||
|
///
|
||||||
|
/// @brief The header for the String16 class.
|
||||||
|
///
|
||||||
|
/// @author
|
||||||
|
///
|
||||||
|
/// This file is a part of Ultralight, a fast, lightweight, HTML UI engine
|
||||||
|
///
|
||||||
|
/// Website: <http://ultralig.ht>
|
||||||
|
///
|
||||||
|
/// Copyright (C) 2020 Ultralight, Inc. All rights reserved.
|
||||||
|
///
|
||||||
|
#pragma once
|
||||||
|
#include <Ultralight/Defines.h>
|
||||||
|
#include <Ultralight/RefPtr.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
|
namespace ultralight {
|
||||||
|
|
||||||
|
namespace detail {
|
||||||
|
template<int> struct selector;
|
||||||
|
template<> struct selector<4> { typedef char16_t Char16; };
|
||||||
|
template<> struct selector<2> { typedef wchar_t Char16; };
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef DISABLE_NATIVE_WCHAR_T
|
||||||
|
// Force Char16 type to use char16_t, used on Windows when native wchar_t support is disabled.
|
||||||
|
typedef char16_t Char16;
|
||||||
|
#else
|
||||||
|
// We use wchar_t if size == 2, otherwise use char16_t
|
||||||
|
typedef detail::selector<sizeof(wchar_t)>::Char16 Char16;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
///
|
||||||
|
/// @brief A UTF-16 string container.
|
||||||
|
///
|
||||||
|
class UExport String16 {
|
||||||
|
public:
|
||||||
|
// Make an empty String16
|
||||||
|
String16();
|
||||||
|
|
||||||
|
// Make a String16 from null-terminated ASCII C-string
|
||||||
|
String16(const char* c_str);
|
||||||
|
|
||||||
|
// Make a String16 from ASCII C-string with certain length
|
||||||
|
String16(const char* c_str, size_t len);
|
||||||
|
|
||||||
|
// Make a String16 from raw UTF-16 buffer with certain length
|
||||||
|
String16(const Char16* str, size_t len);
|
||||||
|
|
||||||
|
// Make a String16 from raw unsigned short UTF-16 buffer with certain length. Useful on Windows
|
||||||
|
// when native support for wchar_t is disabled (eg, /Zc:wchar_t-).
|
||||||
|
String16(const unsigned short* str, size_t len);
|
||||||
|
|
||||||
|
// Make a deep copy of String16
|
||||||
|
String16(const String16& other);
|
||||||
|
|
||||||
|
~String16();
|
||||||
|
|
||||||
|
// Assign a String16 to this one, deep copy is made
|
||||||
|
String16& operator=(const String16& other);
|
||||||
|
|
||||||
|
// Append a String16 to this one.
|
||||||
|
String16& operator+=(const String16& other);
|
||||||
|
|
||||||
|
// Concatenation operator
|
||||||
|
inline friend String16 operator+(String16 lhs, const String16& rhs) { lhs += rhs; return lhs; }
|
||||||
|
|
||||||
|
// Get raw UTF-16 data
|
||||||
|
Char16* data() { return data_; }
|
||||||
|
|
||||||
|
// Get raw UTF-16 data (const)
|
||||||
|
const Char16* data() const { return data_; }
|
||||||
|
|
||||||
|
// Get raw UTF-16 data as unsigned short. This is useful on Windows if you compile without native
|
||||||
|
// support for wchar_t (eg, /Zc:wchar_t-)
|
||||||
|
unsigned short* udata() { return reinterpret_cast<unsigned short*>(data_); }
|
||||||
|
|
||||||
|
// Get raw UTF-16 data as unsigned short (const).
|
||||||
|
const unsigned short* udata() const { return reinterpret_cast<const unsigned short*>(data_); }
|
||||||
|
|
||||||
|
// Get length in characters.
|
||||||
|
size_t length() const { return length_; }
|
||||||
|
|
||||||
|
// Get size in characters (synonym for length)
|
||||||
|
size_t size() const { return length_; }
|
||||||
|
|
||||||
|
// Check if string is empty.
|
||||||
|
bool empty() const { return !data_ || length_ == 0; }
|
||||||
|
|
||||||
|
// Get character at specific position
|
||||||
|
Char16& operator[](size_t pos) { return data_[pos]; }
|
||||||
|
|
||||||
|
// Get character at specific position (const)
|
||||||
|
const Char16& operator[](size_t pos) const { return data_[pos]; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
Char16* data_;
|
||||||
|
size_t length_;
|
||||||
|
};
|
||||||
|
|
||||||
|
///
|
||||||
|
/// @brief A UTF-16 string vector.
|
||||||
|
///
|
||||||
|
class UExport String16Vector : public RefCounted {
|
||||||
|
public:
|
||||||
|
// Create an empty string vector
|
||||||
|
static Ref<String16Vector> Create();
|
||||||
|
|
||||||
|
// Create a string vector from an existing array (a deep copy is made)
|
||||||
|
static Ref<String16Vector> Create(const String16* stringArray, size_t len);
|
||||||
|
|
||||||
|
// Add an element to the back of the string vector
|
||||||
|
virtual void push_back(const String16& val) = 0;
|
||||||
|
|
||||||
|
// Get raw String16 vector array
|
||||||
|
virtual String16* data() = 0;
|
||||||
|
|
||||||
|
// Get the number of elements in vector
|
||||||
|
virtual size_t size() const = 0;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
String16Vector();
|
||||||
|
virtual ~String16Vector();
|
||||||
|
String16Vector(const String16Vector&);
|
||||||
|
void operator=(const String16Vector&);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace ultralight
|
|
@ -0,0 +1,71 @@
|
||||||
|
///
|
||||||
|
/// @file String32.h
|
||||||
|
///
|
||||||
|
/// @brief The header for the String32 class.
|
||||||
|
///
|
||||||
|
/// @author
|
||||||
|
///
|
||||||
|
/// This file is a part of Ultralight, a fast, lightweight, HTML UI engine
|
||||||
|
///
|
||||||
|
/// Website: <http://ultralig.ht>
|
||||||
|
///
|
||||||
|
/// Copyright (C) 2020 Ultralight, Inc. All rights reserved.
|
||||||
|
///
|
||||||
|
#pragma once
|
||||||
|
#include <Ultralight/Defines.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
|
namespace ultralight {
|
||||||
|
|
||||||
|
///
|
||||||
|
/// @brief A UTF-32 string container.
|
||||||
|
///
|
||||||
|
class UExport String32 {
|
||||||
|
public:
|
||||||
|
// Make an empty String32
|
||||||
|
String32();
|
||||||
|
|
||||||
|
// Make a String32 from raw UTF-32 string with certain length
|
||||||
|
String32(const char32_t* c_str, size_t len);
|
||||||
|
|
||||||
|
// Make a deep copy of String32
|
||||||
|
String32(const String32& other);
|
||||||
|
|
||||||
|
~String32();
|
||||||
|
|
||||||
|
// Assign a String32 to this one, deep copy is made
|
||||||
|
String32& operator=(const String32& other);
|
||||||
|
|
||||||
|
// Append a String32 to this one.
|
||||||
|
String32& operator+=(const String32& other);
|
||||||
|
|
||||||
|
// Concatenation operator
|
||||||
|
inline friend String32 operator+(String32 lhs, const String32& rhs) { lhs += rhs; return lhs; }
|
||||||
|
|
||||||
|
// Get raw UTF-32 data
|
||||||
|
char32_t* data() { return data_; }
|
||||||
|
|
||||||
|
// Get raw UTF-32 data (const)
|
||||||
|
const char32_t* data() const { return data_; }
|
||||||
|
|
||||||
|
// Get length in characters.
|
||||||
|
size_t length() const { return length_; }
|
||||||
|
|
||||||
|
// Get size in characters (synonym for length)
|
||||||
|
size_t size() const { return length_; }
|
||||||
|
|
||||||
|
// Check if string is empty.
|
||||||
|
bool empty() const { return !data_ || length_ == 0; }
|
||||||
|
|
||||||
|
// Get character at specific position
|
||||||
|
char32_t& operator[](size_t pos) { return data_[pos]; }
|
||||||
|
|
||||||
|
// Get character at specific position (const)
|
||||||
|
const char32_t& operator[](size_t pos) const { return data_[pos]; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
char32_t* data_;
|
||||||
|
size_t length_;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace ultralight
|
|
@ -0,0 +1,74 @@
|
||||||
|
///
|
||||||
|
/// @file String8.h
|
||||||
|
///
|
||||||
|
/// @brief The header for the String8 class.
|
||||||
|
///
|
||||||
|
/// @author
|
||||||
|
///
|
||||||
|
/// This file is a part of Ultralight, a fast, lightweight, HTML UI engine
|
||||||
|
///
|
||||||
|
/// Website: <http://ultralig.ht>
|
||||||
|
///
|
||||||
|
/// Copyright (C) 2020 Ultralight, Inc. All rights reserved.
|
||||||
|
///
|
||||||
|
#pragma once
|
||||||
|
#include <Ultralight/Defines.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
|
namespace ultralight {
|
||||||
|
|
||||||
|
///
|
||||||
|
/// @brief A UTF-8 string container.
|
||||||
|
//
|
||||||
|
class UExport String8 {
|
||||||
|
public:
|
||||||
|
// Make an empty String8
|
||||||
|
String8();
|
||||||
|
|
||||||
|
// Make a String8 from raw, null-terminated UTF-8 string
|
||||||
|
String8(const char* c_str);
|
||||||
|
|
||||||
|
// Make a String8 from raw UTF-8 string with certain length
|
||||||
|
String8(const char* c_str, size_t len);
|
||||||
|
|
||||||
|
// Make a deep copy of String8
|
||||||
|
String8(const String8& other);
|
||||||
|
|
||||||
|
~String8();
|
||||||
|
|
||||||
|
// Assign a String8 to this one, deep copy is made
|
||||||
|
String8& operator=(const String8& other);
|
||||||
|
|
||||||
|
// Append a String8 to this one.
|
||||||
|
String8& operator+=(const String8& other);
|
||||||
|
|
||||||
|
// Concatenation operator
|
||||||
|
inline friend String8 operator+(String8 lhs, const String8& rhs) { lhs += rhs; return lhs; }
|
||||||
|
|
||||||
|
// Get raw UTF-8 data
|
||||||
|
char* data() { return data_; }
|
||||||
|
|
||||||
|
// Get raw UTF-8 data (const)
|
||||||
|
const char* data() const { return data_; }
|
||||||
|
|
||||||
|
// Get length in characters.
|
||||||
|
size_t length() const { return length_; }
|
||||||
|
|
||||||
|
// Get size in characters (synonym for length)
|
||||||
|
size_t size() const { return length_; }
|
||||||
|
|
||||||
|
// Check if string is empty.
|
||||||
|
bool empty() const { return !data_ || length_ == 0; }
|
||||||
|
|
||||||
|
// Get character at specific position
|
||||||
|
char& operator[](size_t pos) { return data_[pos]; }
|
||||||
|
|
||||||
|
// Get character at specific position (const)
|
||||||
|
const char& operator[](size_t pos) const { return data_[pos]; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
char* data_;
|
||||||
|
size_t length_;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace ultralight
|
|
@ -0,0 +1,29 @@
|
||||||
|
// Copyright 2020 Ultralight, Inc. All rights reserved.
|
||||||
|
#pragma once
|
||||||
|
#include <Ultralight/Defines.h>
|
||||||
|
#include <Ultralight/RefPtr.h>
|
||||||
|
#include <Ultralight/String8.h>
|
||||||
|
#include <Ultralight/String16.h>
|
||||||
|
#include <Ultralight/String32.h>
|
||||||
|
#include <Ultralight/String.h>
|
||||||
|
#include <Ultralight/Bitmap.h>
|
||||||
|
#include <Ultralight/Buffer.h>
|
||||||
|
#include <Ultralight/View.h>
|
||||||
|
#include <Ultralight/Session.h>
|
||||||
|
#include <Ultralight/KeyCodes.h>
|
||||||
|
#include <Ultralight/KeyEvent.h>
|
||||||
|
#include <Ultralight/Listener.h>
|
||||||
|
#include <Ultralight/Matrix.h>
|
||||||
|
#include <Ultralight/MouseEvent.h>
|
||||||
|
#include <Ultralight/Renderer.h>
|
||||||
|
#include <Ultralight/Geometry.h>
|
||||||
|
#include <Ultralight/RenderTarget.h>
|
||||||
|
#include <Ultralight/ScrollEvent.h>
|
||||||
|
#include <Ultralight/platform/Platform.h>
|
||||||
|
#include <Ultralight/platform/Config.h>
|
||||||
|
#include <Ultralight/platform/GPUDriver.h>
|
||||||
|
#include <Ultralight/platform/FileSystem.h>
|
||||||
|
#include <Ultralight/platform/FontLoader.h>
|
||||||
|
#include <Ultralight/platform/Surface.h>
|
||||||
|
#include <Ultralight/platform/Clipboard.h>
|
||||||
|
#include <Ultralight/platform/Logger.h>
|
|
@ -0,0 +1,307 @@
|
||||||
|
///
|
||||||
|
/// @file View.h
|
||||||
|
///
|
||||||
|
/// @brief The header for the View class.
|
||||||
|
///
|
||||||
|
/// @author
|
||||||
|
///
|
||||||
|
/// This file is a part of Ultralight, a fast, lightweight, HTML UI engine
|
||||||
|
///
|
||||||
|
/// Website: <http://ultralig.ht>
|
||||||
|
///
|
||||||
|
/// Copyright (C) 2020 Ultralight, Inc. All rights reserved.
|
||||||
|
///
|
||||||
|
#pragma once
|
||||||
|
#include <Ultralight/Defines.h>
|
||||||
|
#include <Ultralight/RefPtr.h>
|
||||||
|
#include <Ultralight/KeyEvent.h>
|
||||||
|
#include <Ultralight/JavaScript.h>
|
||||||
|
#include <Ultralight/MouseEvent.h>
|
||||||
|
#include <Ultralight/ScrollEvent.h>
|
||||||
|
#include <Ultralight/RenderTarget.h>
|
||||||
|
#include <Ultralight/Bitmap.h>
|
||||||
|
#include <Ultralight/Listener.h>
|
||||||
|
#include <Ultralight/platform/Surface.h>
|
||||||
|
|
||||||
|
namespace ultralight {
|
||||||
|
|
||||||
|
///
|
||||||
|
/// @brief The View class is used to load and display web content.
|
||||||
|
///
|
||||||
|
/// View is an offscreen web-page container that can be used to display
|
||||||
|
/// web-content in your application.
|
||||||
|
///
|
||||||
|
/// You can load content into a View via View::LoadURL() or View::LoadHTML()
|
||||||
|
/// and interact with it via View::FireMouseEvent() and similar API.
|
||||||
|
///
|
||||||
|
/// When displaying a View, the API is different depending on whether you
|
||||||
|
/// are using the CPU renderer or the GPU renderer:
|
||||||
|
///
|
||||||
|
/// When using the CPU renderer, you would get the underlying pixel-buffer
|
||||||
|
/// surface for a View via View::surface().
|
||||||
|
///
|
||||||
|
/// When using the GPU renderer, you would get the underlying render target
|
||||||
|
/// and texture information via View::render_target().
|
||||||
|
///
|
||||||
|
/// @note The API is not currently thread-safe, all calls must be made on the
|
||||||
|
/// same thread that the Renderer/App was created on.
|
||||||
|
///
|
||||||
|
class UExport View : public RefCounted {
|
||||||
|
public:
|
||||||
|
///
|
||||||
|
/// Get the URL of the current page loaded into this View, if any.
|
||||||
|
///
|
||||||
|
virtual String url() = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get the title of the current page loaded into this View, if any.
|
||||||
|
///
|
||||||
|
virtual String title() = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get the width of the View, in pixels.
|
||||||
|
///
|
||||||
|
virtual uint32_t width() const = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get the height of the View, in pixels.
|
||||||
|
///
|
||||||
|
virtual uint32_t height() const = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Check if the main frame of the page is currently loading.
|
||||||
|
///
|
||||||
|
virtual bool is_loading() = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get the offscreen RenderTarget for the View.
|
||||||
|
///
|
||||||
|
/// @note Only valid when the GPU renderer is enabled in Config.
|
||||||
|
///
|
||||||
|
/// You can use this with your GPUDriver implementation to bind
|
||||||
|
/// and display the corresponding texture in your application.
|
||||||
|
///
|
||||||
|
virtual RenderTarget render_target() = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get the offscreen Surface for the View (pixel-buffer container).
|
||||||
|
///
|
||||||
|
/// @note Only valid when the CPU is enabled (will return a nullptr
|
||||||
|
/// otherwise)
|
||||||
|
///
|
||||||
|
/// The default Surface is BitmapSurface but you can provide your
|
||||||
|
/// own Surface implementation via Platform::set_surface_factory.
|
||||||
|
///
|
||||||
|
virtual Surface* surface() = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Load a raw string of HTML, the View will navigate to it as a new page.
|
||||||
|
///
|
||||||
|
/// @param html The raw HTML string to load.
|
||||||
|
///
|
||||||
|
/// @param url An optional URL for this load (to make it appear as if we
|
||||||
|
/// we loaded this HTML from a certain URL). Can be used for
|
||||||
|
/// resolving relative URLs and cross-origin rules.
|
||||||
|
///
|
||||||
|
/// @param add_to_history Whether or not this load should be added to the
|
||||||
|
/// session's history (back/forward list).
|
||||||
|
///
|
||||||
|
virtual void LoadHTML(const String& html,
|
||||||
|
const String& url = "",
|
||||||
|
bool add_to_history = false) = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Load a URL, the View will navigate to it as a new page.
|
||||||
|
///
|
||||||
|
/// @note You can use File URLs (eg, file:///page.html) but you must define
|
||||||
|
/// your own FileSystem implementation if you are not using AppCore.
|
||||||
|
/// @see Platform::set_file_system
|
||||||
|
///
|
||||||
|
virtual void LoadURL(const String& url) = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Resize View to a certain size.
|
||||||
|
///
|
||||||
|
/// @param width The initial width, in pixels.
|
||||||
|
///
|
||||||
|
/// @param height The initial height, in pixels.
|
||||||
|
///
|
||||||
|
///
|
||||||
|
virtual void Resize(uint32_t width, uint32_t height) = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Acquire the page's JSContext for use with the JavaScriptCore API
|
||||||
|
///
|
||||||
|
/// @note You can use the underlying JSContextRef with the JavaScriptCore
|
||||||
|
/// C API. This allows you to marshall C/C++ objects to/from
|
||||||
|
/// JavaScript, bind callbacks, and call JS functions directly.
|
||||||
|
///
|
||||||
|
/// @note The JSContextRef gets reset after each page navigation. You
|
||||||
|
/// should initialize your JavaScript state within the
|
||||||
|
/// OnWindowObjectReady and OnDOMReady events, @see ViewListener.
|
||||||
|
///
|
||||||
|
/// @note This call locks the internal context for the current thread.
|
||||||
|
/// It will be unlocked when the returned JSContext's ref-count goes
|
||||||
|
/// to zero. The lock is recursive, you can call this multiple times.
|
||||||
|
///
|
||||||
|
virtual Ref<JSContext> LockJSContext() = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Helper function to evaluate a raw string of JavaScript and return the
|
||||||
|
/// result as a String.
|
||||||
|
///
|
||||||
|
/// @param script A string of JavaScript to evaluate in the main frame.
|
||||||
|
///
|
||||||
|
/// @param exception A string to store the exception in, if any. Pass a
|
||||||
|
/// nullptr if you don't care about exceptions.
|
||||||
|
///
|
||||||
|
/// @return Returns the JavaScript result typecast to a String.
|
||||||
|
///
|
||||||
|
///
|
||||||
|
/// @note You do not need to lock the JS context, it is done automatically.
|
||||||
|
///
|
||||||
|
/// @note If you need lower-level access to native JavaScript values, you
|
||||||
|
/// should instead lock the JS context and call JSEvaluateScript() in
|
||||||
|
/// the JavaScriptCore C API. @see <JavaScriptCore/JSBase.h>
|
||||||
|
///
|
||||||
|
virtual String EvaluateScript(const String& script, String* exception = nullptr) = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Whether or not we can navigate backwards in history
|
||||||
|
///
|
||||||
|
virtual bool CanGoBack() = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Whether or not we can navigate forwards in history
|
||||||
|
///
|
||||||
|
virtual bool CanGoForward() = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Navigate backwards in history
|
||||||
|
///
|
||||||
|
virtual void GoBack() = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Navigate forwards in history
|
||||||
|
///
|
||||||
|
virtual void GoForward() = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Navigate to an arbitrary offset in history
|
||||||
|
///
|
||||||
|
virtual void GoToHistoryOffset(int offset) = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Reload current page
|
||||||
|
///
|
||||||
|
virtual void Reload() = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Stop all page loads
|
||||||
|
///
|
||||||
|
virtual void Stop() = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Give focus to the View.
|
||||||
|
///
|
||||||
|
/// You should call this to give visual indication that the View has input
|
||||||
|
/// focus (changes active text selection colors, for example).
|
||||||
|
///
|
||||||
|
virtual void Focus() = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Remove focus from the View and unfocus any focused input elements.
|
||||||
|
///
|
||||||
|
/// You should call this to give visual indication that the View has lost
|
||||||
|
/// input focus.
|
||||||
|
///
|
||||||
|
virtual void Unfocus() = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Whether or not the View has focus.
|
||||||
|
///
|
||||||
|
virtual bool HasFocus() = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Whether or not the View has an input element with visible keyboard focus
|
||||||
|
/// (indicated by a blinking caret).
|
||||||
|
///
|
||||||
|
/// You can use this to decide whether or not the View should consume
|
||||||
|
/// keyboard input events (useful in games with mixed UI and key handling).
|
||||||
|
///
|
||||||
|
virtual bool HasInputFocus() = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Fire a keyboard event
|
||||||
|
///
|
||||||
|
/// @note Only 'Char' events actually generate text in input fields.
|
||||||
|
///
|
||||||
|
virtual void FireKeyEvent(const KeyEvent& evt) = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Fire a mouse event
|
||||||
|
///
|
||||||
|
virtual void FireMouseEvent(const MouseEvent& evt) = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Fire a scroll event
|
||||||
|
///
|
||||||
|
virtual void FireScrollEvent(const ScrollEvent& evt) = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Set a ViewListener to receive callbacks for View-related events.
|
||||||
|
///
|
||||||
|
/// @note Ownership remains with the caller.
|
||||||
|
///
|
||||||
|
virtual void set_view_listener(ViewListener* listener) = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get the active ViewListener, if any
|
||||||
|
///
|
||||||
|
virtual ViewListener* view_listener() const = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Set a LoadListener to receive callbacks for Load-related events.
|
||||||
|
///
|
||||||
|
/// @note Ownership remains with the caller.
|
||||||
|
///
|
||||||
|
virtual void set_load_listener(LoadListener* listener) = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get the active LoadListener, if any
|
||||||
|
///
|
||||||
|
virtual LoadListener* load_listener() const = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Set whether or not this View should be repainted during the next
|
||||||
|
/// call to Renderer::Render
|
||||||
|
///
|
||||||
|
/// @note This flag is automatically set whenever the page content changes
|
||||||
|
/// but you can set it directly in case you need to force a repaint.
|
||||||
|
///
|
||||||
|
virtual void set_needs_paint(bool needs_paint) = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Whether or not this View should be repainted during the next call to
|
||||||
|
/// Renderer::Render.
|
||||||
|
///
|
||||||
|
virtual bool needs_paint() const = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get the inspector for this View, this is useful for debugging and
|
||||||
|
/// inspecting pages locally. This will only succeed if you have the
|
||||||
|
/// inspector assets in your filesystem-- the inspector will look for
|
||||||
|
/// file:///inspector/Main.html when it first loads.
|
||||||
|
///
|
||||||
|
/// @note The inspector View is owned by the View and lazily-created on
|
||||||
|
/// first call. The initial dimensions are 10x10, you should call
|
||||||
|
/// View::Resize() on the returned View to resize it to your desired
|
||||||
|
/// dimensions.
|
||||||
|
///
|
||||||
|
virtual RefPtr<View> inspector() = 0;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual ~View();
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace ultralight
|
|
@ -0,0 +1,51 @@
|
||||||
|
///
|
||||||
|
/// @file Clipboard.h
|
||||||
|
///
|
||||||
|
/// @brief The header for the Clipboard interface.
|
||||||
|
///
|
||||||
|
/// @author
|
||||||
|
///
|
||||||
|
/// This file is a part of Ultralight, a fast, lightweight, HTML UI engine
|
||||||
|
///
|
||||||
|
/// Website: <http://ultralig.ht>
|
||||||
|
///
|
||||||
|
/// Copyright (C) 2020 Ultralight, Inc. All rights reserved.
|
||||||
|
///
|
||||||
|
#pragma once
|
||||||
|
#include <Ultralight/Defines.h>
|
||||||
|
#include <Ultralight/String16.h>
|
||||||
|
|
||||||
|
namespace ultralight {
|
||||||
|
|
||||||
|
///
|
||||||
|
/// @brief Clipboard interface.
|
||||||
|
///
|
||||||
|
/// This is used for reading and writing data to the platform Clipboard.
|
||||||
|
///
|
||||||
|
/// AppCore automatically provides a platform-specific implementation of this
|
||||||
|
/// that cuts/copies/pastes to the OS clipboard when you call App::Create().
|
||||||
|
///
|
||||||
|
/// If you are using Renderer::Create() instead, you will need to provide your
|
||||||
|
/// own implementation of this. @see Platform::set_clipboard().
|
||||||
|
///
|
||||||
|
class UExport Clipboard {
|
||||||
|
public:
|
||||||
|
virtual ~Clipboard();
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Clear the clipboard.
|
||||||
|
///
|
||||||
|
virtual void Clear() = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Read plain text from the clipboard
|
||||||
|
///
|
||||||
|
virtual String16 ReadPlainText() = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Write plain text to the clipboard.
|
||||||
|
///
|
||||||
|
virtual void WritePlainText(const String16& text) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace ultralight
|
|
@ -0,0 +1,230 @@
|
||||||
|
///
|
||||||
|
/// @file Config.h
|
||||||
|
///
|
||||||
|
/// @brief The header for the Config struct.
|
||||||
|
///
|
||||||
|
/// @author
|
||||||
|
///
|
||||||
|
/// This file is a part of Ultralight, a fast, lightweight, HTML UI engine
|
||||||
|
///
|
||||||
|
/// Website: <http://ultralig.ht>
|
||||||
|
///
|
||||||
|
/// Copyright (C) 2020 Ultralight, Inc. All rights reserved.
|
||||||
|
///
|
||||||
|
#pragma once
|
||||||
|
#include <Ultralight/Defines.h>
|
||||||
|
#include <Ultralight/String16.h>
|
||||||
|
|
||||||
|
namespace ultralight {
|
||||||
|
|
||||||
|
///
|
||||||
|
/// The winding order for front-facing triangles. (This is only used when the
|
||||||
|
/// GPU renderer is enabled)
|
||||||
|
///
|
||||||
|
/// @note In most 3D engines, there is the concept that triangles have a
|
||||||
|
/// a "front" and a "back". All the front-facing triangles (eg, those
|
||||||
|
/// that are facing the camera) are rendered, and all back-facing
|
||||||
|
/// triangles are culled (ignored). The winding-order of the triangle's
|
||||||
|
/// vertices is used to determine which side is front and back. You
|
||||||
|
/// should tell Ultralight which winding-order your 3D engine uses.
|
||||||
|
///
|
||||||
|
enum FaceWinding {
|
||||||
|
///
|
||||||
|
/// Clockwise Winding (Direct3D, etc.)
|
||||||
|
///
|
||||||
|
kFaceWinding_Clockwise,
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Counter-Clockwise Winding (OpenGL, etc.)
|
||||||
|
///
|
||||||
|
kFaceWinding_CounterClockwise,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum FontHinting {
|
||||||
|
///
|
||||||
|
/// Lighter hinting algorithm-- glyphs are slightly fuzzier but better
|
||||||
|
/// resemble their original shape. This is achieved by snapping glyphs to the
|
||||||
|
/// pixel grid only vertically which better preserves inter-glyph spacing.
|
||||||
|
///
|
||||||
|
kFontHinting_Smooth,
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Default hinting algorithm-- offers a good balance between sharpness and
|
||||||
|
/// shape at smaller font sizes.
|
||||||
|
///
|
||||||
|
kFontHinting_Normal,
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Strongest hinting algorithm-- outputs only black/white glyphs. The result
|
||||||
|
/// is usually unpleasant if the underlying TTF does not contain hints for
|
||||||
|
/// this type of rendering.
|
||||||
|
///
|
||||||
|
kFontHinting_Monochrome,
|
||||||
|
};
|
||||||
|
|
||||||
|
///
|
||||||
|
/// @brief Configuration settings for Ultralight.
|
||||||
|
///
|
||||||
|
/// This is intended to be implemented by users and defined before creating the
|
||||||
|
/// Renderer. @see Platform::set_config.
|
||||||
|
///
|
||||||
|
struct UExport Config {
|
||||||
|
///
|
||||||
|
/// The file path to the directory that contains Ultralight's bundled
|
||||||
|
/// resources (eg, cacert.pem and other localized resources).
|
||||||
|
///
|
||||||
|
String16 resource_path;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// The file path to a writable directory that will be used to store cookies,
|
||||||
|
/// cached resources, and other persistent data.
|
||||||
|
///
|
||||||
|
String16 cache_path;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// When enabled, each View will be rendered to an offscreen GPU texture
|
||||||
|
/// using the GPU driver set in Platform::set_gpu_driver. You can fetch
|
||||||
|
/// details for the texture via View::render_target.
|
||||||
|
///
|
||||||
|
/// When disabled (the default), each View will be rendered to an offscreen
|
||||||
|
/// pixel buffer. This pixel buffer can optionally be provided by the user--
|
||||||
|
/// for more info see <Ultralight/platform/Surface.h> and View::surface.
|
||||||
|
///
|
||||||
|
bool use_gpu_renderer = false;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// The amount that the application DPI has been scaled (200% = 2.0).
|
||||||
|
/// This should match the device scale set for the current monitor.
|
||||||
|
///
|
||||||
|
/// Note: Device scales are rounded to nearest 1/8th (eg, 0.125).
|
||||||
|
///
|
||||||
|
double device_scale = 1.0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// The winding order for front-facing triangles. @see FaceWinding
|
||||||
|
///
|
||||||
|
/// Note: This is only used when the GPU renderer is enabled.
|
||||||
|
///
|
||||||
|
FaceWinding face_winding = kFaceWinding_CounterClockwise;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Whether or not images should be enabled.
|
||||||
|
///
|
||||||
|
bool enable_images = true;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Whether or not JavaScript should be enabled.
|
||||||
|
///
|
||||||
|
bool enable_javascript = true;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// The hinting algorithm to use when rendering fonts. @see FontHinting
|
||||||
|
///
|
||||||
|
FontHinting font_hinting = kFontHinting_Normal;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// The gamma to use when compositing font glyphs, change this value to
|
||||||
|
/// adjust contrast (Adobe and Apple prefer 1.8, others may prefer 2.2).
|
||||||
|
///
|
||||||
|
double font_gamma = 1.8;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Default font-family to use.
|
||||||
|
///
|
||||||
|
String16 font_family_standard = "Times New Roman";
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Default font-family to use for fixed fonts. (pre/code)
|
||||||
|
///
|
||||||
|
String16 font_family_fixed = "Courier New";
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Default font-family to use for serif fonts.
|
||||||
|
///
|
||||||
|
String16 font_family_serif = "Times New Roman";
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Default font-family to use for sans-serif fonts.
|
||||||
|
///
|
||||||
|
String16 font_family_sans_serif = "Arial";
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Default user-agent string.
|
||||||
|
///
|
||||||
|
String16 user_agent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) "
|
||||||
|
"AppleWebKit/608.3.10 (KHTML, like Gecko) "
|
||||||
|
"Ultralight/1.2.0 Safari/608.3.10";
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Default user stylesheet. You should set this to your own custom CSS
|
||||||
|
/// string to define default styles for various DOM elements, scrollbars,
|
||||||
|
/// and platform input widgets.
|
||||||
|
///
|
||||||
|
String16 user_stylesheet;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Whether or not we should continuously repaint any Views or compositor
|
||||||
|
/// layers, regardless if they are dirty or not. This is mainly used to
|
||||||
|
/// diagnose painting/shader issues.
|
||||||
|
///
|
||||||
|
bool force_repaint = false;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// When a CSS animation is active, the amount of time (in seconds) to wait
|
||||||
|
/// before triggering another repaint. Default is 60 Hz.
|
||||||
|
///
|
||||||
|
double animation_timer_delay = 1.0 / 60.0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// When a smooth scroll animation is active, the amount of time (in seconds)
|
||||||
|
/// to wait before triggering another repaint. Default is 60 Hz.
|
||||||
|
///
|
||||||
|
double scroll_timer_delay = 1.0 / 60.0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// The amount of time (in seconds) to wait before running the recycler (will
|
||||||
|
/// attempt to return excess memory back to the system).
|
||||||
|
///
|
||||||
|
double recycle_delay = 4.0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Size of WebCore's memory cache in bytes.
|
||||||
|
///
|
||||||
|
/// @note You should increase this if you anticipate handling pages with
|
||||||
|
/// large resources, Safari typically uses 128+ MiB for its cache.
|
||||||
|
///
|
||||||
|
uint32_t memory_cache_size = 64 * 1024 * 1024;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Number of pages to keep in the cache. Defaults to 0 (none).
|
||||||
|
///
|
||||||
|
/// @note Safari typically caches about 5 pages and maintains an on-disk
|
||||||
|
/// cache to support typical web-browsing activities. If you increase
|
||||||
|
/// this, you should probably increase the memory cache size as well.
|
||||||
|
///
|
||||||
|
uint32_t page_cache_size = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// JavaScriptCore tries to detect the system's physical RAM size to set
|
||||||
|
/// reasonable allocation limits. Set this to anything other than 0 to
|
||||||
|
/// override the detected value. Size is in bytes.
|
||||||
|
///
|
||||||
|
/// This can be used to force JavaScriptCore to be more conservative with
|
||||||
|
/// its allocation strategy (at the cost of some performance).
|
||||||
|
///
|
||||||
|
uint32_t override_ram_size = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// The minimum size of large VM heaps in JavaScriptCore. Set this to a
|
||||||
|
/// lower value to make these heaps start with a smaller initial value.
|
||||||
|
///
|
||||||
|
uint32_t min_large_heap_size = 32 * 1024 * 1024;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// The minimum size of small VM heaps in JavaScriptCore. Set this to a
|
||||||
|
/// lower value to make these heaps start with a smaller initial value.
|
||||||
|
///
|
||||||
|
uint32_t min_small_heap_size = 1 * 1024 * 1024;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace ultralight
|
|
@ -0,0 +1,93 @@
|
||||||
|
///
|
||||||
|
/// @file FileSystem.h
|
||||||
|
///
|
||||||
|
/// @brief The header for the FileSystem interface.
|
||||||
|
///
|
||||||
|
/// @author
|
||||||
|
///
|
||||||
|
/// This file is a part of Ultralight, a fast, lightweight, HTML UI engine
|
||||||
|
///
|
||||||
|
/// Website: <http://ultralig.ht>
|
||||||
|
///
|
||||||
|
/// Copyright (C) 2020 Ultralight, Inc. All rights reserved.
|
||||||
|
///
|
||||||
|
#pragma once
|
||||||
|
#include <Ultralight/Defines.h>
|
||||||
|
#include <Ultralight/String16.h>
|
||||||
|
|
||||||
|
namespace ultralight {
|
||||||
|
|
||||||
|
///
|
||||||
|
/// File Handle type used as unique ID for opened files.
|
||||||
|
///
|
||||||
|
#if defined(__WIN32__) || defined(_WIN32)
|
||||||
|
typedef size_t FileHandle;
|
||||||
|
#else
|
||||||
|
typedef int FileHandle;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Handle used to denote an invalid file.
|
||||||
|
///
|
||||||
|
const FileHandle invalidFileHandle = (FileHandle)-1;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// @brief FileSystem interface.
|
||||||
|
///
|
||||||
|
/// This is used for loading File URLs (eg, <file:///page.html>).
|
||||||
|
///
|
||||||
|
/// You can provide the library with your own FileSystem implementation so that
|
||||||
|
/// file assets are loaded from your own pipeline (useful if you would like
|
||||||
|
/// to encrypt/compress your file assets or ship it in a custom format).
|
||||||
|
///
|
||||||
|
/// AppCore automatically provides a platform-specific implementation of this
|
||||||
|
/// that loads files from a local directory when you call App::Create().
|
||||||
|
///
|
||||||
|
/// If you are using Renderer::Create() instead, you will need to provide your
|
||||||
|
/// own implementation via `Platform::instance().set_file_system(). For
|
||||||
|
/// convenience, you can still use AppCore's file system implementation--
|
||||||
|
/// see the helper functions defined in <AppCore/Platform.h>.
|
||||||
|
///
|
||||||
|
/// To provide your own custom FileSystem implementation, you should inherit
|
||||||
|
/// from this class, handle the virtual member functions, and then pass an
|
||||||
|
/// instance of your class to `Platform::instance().set_file_system()` before
|
||||||
|
/// calling Renderer::Create() or App::Create().
|
||||||
|
///
|
||||||
|
class UExport FileSystem {
|
||||||
|
public:
|
||||||
|
virtual ~FileSystem();
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Check if file path exists, return true if exists.
|
||||||
|
///
|
||||||
|
virtual bool FileExists(const String16& path) = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get file size of previously opened file, store result in 'result'. Return true on success.
|
||||||
|
///
|
||||||
|
virtual bool GetFileSize(FileHandle handle, int64_t& result) = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get file mime type (eg "text/html"), store result in 'result'. Return true on success.
|
||||||
|
///
|
||||||
|
virtual bool GetFileMimeType(const String16& path, String16& result) = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Open file path for reading or writing. Return file handle on success, or invalidFileHandle on failure.
|
||||||
|
///
|
||||||
|
/// @NOTE: As of this writing (v1.2), this function is only used for reading.
|
||||||
|
///
|
||||||
|
virtual FileHandle OpenFile(const String16& path, bool open_for_writing) = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Close previously-opened file.
|
||||||
|
///
|
||||||
|
virtual void CloseFile(FileHandle& handle) = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Read from currently-opened file, return number of bytes read or -1 on failure.
|
||||||
|
///
|
||||||
|
virtual int64_t ReadFromFile(FileHandle handle, char* data, int64_t length) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace ultralight
|
|
@ -0,0 +1,132 @@
|
||||||
|
///
|
||||||
|
/// @file FontLoader.h
|
||||||
|
///
|
||||||
|
/// @brief The header for the FontLoader interface.
|
||||||
|
///
|
||||||
|
/// @author
|
||||||
|
///
|
||||||
|
/// This file is a part of Ultralight, a fast, lightweight, HTML UI engine
|
||||||
|
///
|
||||||
|
/// Website: <http://ultralig.ht>
|
||||||
|
///
|
||||||
|
/// Copyright (C) 2020 Ultralight, Inc. All rights reserved.
|
||||||
|
///
|
||||||
|
#pragma once
|
||||||
|
#include <Ultralight/Defines.h>
|
||||||
|
#include <Ultralight/String16.h>
|
||||||
|
#include <Ultralight/Buffer.h>
|
||||||
|
|
||||||
|
namespace ultralight {
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Represents a font file, either on-disk path or in-memory file contents.
|
||||||
|
///
|
||||||
|
class UExport FontFile : public RefCounted {
|
||||||
|
public:
|
||||||
|
///
|
||||||
|
/// Create a font file from an on-disk file path.
|
||||||
|
///
|
||||||
|
/// @note The file path should already exist.
|
||||||
|
///
|
||||||
|
static Ref<FontFile> Create(const String16& filepath);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Create a font file from an in-memory buffer.
|
||||||
|
///
|
||||||
|
static Ref<FontFile> Create(Ref<Buffer> buffer);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Whether or not this font file was created from an in-memory buffer.
|
||||||
|
///
|
||||||
|
virtual bool is_in_memory() const = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// The file path (if any).
|
||||||
|
///
|
||||||
|
virtual String16 filepath() const = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// The in-memory buffer (if any).
|
||||||
|
///
|
||||||
|
virtual RefPtr<Buffer> buffer() const = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Unique hash (if this is a filepath, only the path string is hashed).
|
||||||
|
///
|
||||||
|
virtual uint32_t hash() const = 0;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
FontFile();
|
||||||
|
virtual ~FontFile();
|
||||||
|
FontFile(const FontFile&);
|
||||||
|
void operator=(const FontFile&);
|
||||||
|
};
|
||||||
|
|
||||||
|
///
|
||||||
|
/// @brief Font Loader interface, used for all font lookup operations.
|
||||||
|
///
|
||||||
|
/// Every operating system has its own library of installed system fonts. The
|
||||||
|
/// FontLoader interface is used to lookup these fonts and fetch the actual
|
||||||
|
/// font data (raw TTF/OTF file data) for a given a certain font description.
|
||||||
|
///
|
||||||
|
/// AppCore automatically provides a platform-specific implementation of this
|
||||||
|
/// that loads installed fonts from the OS when you call App::Create().
|
||||||
|
///
|
||||||
|
/// If you are using Renderer::Create() instead, you will need to provide your
|
||||||
|
/// own implementation via `Platform::instance().set_font_loader(). For
|
||||||
|
/// convenience, you can still use AppCore's font loader implementation--
|
||||||
|
/// see the helper functions defined in <AppCore/Platform.h>.
|
||||||
|
///
|
||||||
|
/// To provide your own custom FontLoader implementation, you should inherit
|
||||||
|
/// from this class, handle the virtual member functions, and then pass an
|
||||||
|
/// instance of your class to `Platform::instance().set_font_loader()` before
|
||||||
|
/// calling Renderer::Create() or App::Create().
|
||||||
|
///
|
||||||
|
class UExport FontLoader {
|
||||||
|
public:
|
||||||
|
virtual ~FontLoader();
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Fallback font family name. Will be used if all other fonts fail to load.
|
||||||
|
///
|
||||||
|
/// @note This font should be guaranteed to exist (eg, FontLoader::Load
|
||||||
|
/// won't fail when passed this font family name).
|
||||||
|
///
|
||||||
|
virtual String16 fallback_font() const = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Fallback font family name that can render the specified characters. This
|
||||||
|
/// is mainly used to support CJK (Chinese, Japanese, Korean) text display.
|
||||||
|
///
|
||||||
|
/// @param characters One or more UTF-16 characters. This is almost always
|
||||||
|
/// a single character.
|
||||||
|
///
|
||||||
|
/// @param weight Font weight.
|
||||||
|
///
|
||||||
|
/// @param italic Whether or not italic is requested.
|
||||||
|
///
|
||||||
|
/// @return Should return a font family name that can render the text.
|
||||||
|
///
|
||||||
|
virtual String16 fallback_font_for_characters(const String16& characters,
|
||||||
|
int weight,
|
||||||
|
bool italic) const = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get the actual font file data (TTF/OTF) for a given font description.
|
||||||
|
///
|
||||||
|
/// @param family Font family name.
|
||||||
|
///
|
||||||
|
/// @param weight Font weight.
|
||||||
|
///
|
||||||
|
/// @param italic Whether or not italic is requested.
|
||||||
|
///
|
||||||
|
/// @return A font file matching the given description (either an on-disk
|
||||||
|
/// font filepath or an in-memory file contents). You can return
|
||||||
|
/// NULL here and the loader will fallback to another font.
|
||||||
|
///
|
||||||
|
virtual RefPtr<FontFile> Load(const String16& family,
|
||||||
|
int weight,
|
||||||
|
bool italic) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace ultralight
|
|
@ -0,0 +1,288 @@
|
||||||
|
///
|
||||||
|
/// @file GPUDriver.h
|
||||||
|
///
|
||||||
|
/// @brief The header for the GPUDriver interface.
|
||||||
|
///
|
||||||
|
/// @author
|
||||||
|
///
|
||||||
|
/// This file is a part of Ultralight, a fast, lightweight, HTML UI engine
|
||||||
|
///
|
||||||
|
/// Website: <http://ultralig.ht>
|
||||||
|
///
|
||||||
|
/// Copyright (C) 2020 Ultralight, Inc. All rights reserved.
|
||||||
|
///
|
||||||
|
#pragma once
|
||||||
|
#pragma warning(disable: 4251)
|
||||||
|
#include <Ultralight/Defines.h>
|
||||||
|
#include <Ultralight/Geometry.h>
|
||||||
|
#include <Ultralight/Matrix.h>
|
||||||
|
#include <Ultralight/Bitmap.h>
|
||||||
|
|
||||||
|
namespace ultralight {
|
||||||
|
|
||||||
|
///
|
||||||
|
/// @note This pragma pack(push, 1) command is important! Vertex layouts
|
||||||
|
/// should not be padded with any bytes.
|
||||||
|
///
|
||||||
|
#pragma pack(push, 1)
|
||||||
|
|
||||||
|
///
|
||||||
|
/// RenderBuffer description, @see GPUDriver::CreateRenderBuffer.
|
||||||
|
///
|
||||||
|
struct UExport RenderBuffer {
|
||||||
|
uint32_t texture_id; // The backing texture for this RenderBuffer
|
||||||
|
uint32_t width; // The width of the RenderBuffer texture
|
||||||
|
uint32_t height; // The height of the RenderBuffer texture
|
||||||
|
bool has_stencil_buffer; // Currently unused, always false.
|
||||||
|
bool has_depth_buffer; // Currently unsued, always false.
|
||||||
|
};
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Vertex layout for path vertices, useful for synthesizing or modifying
|
||||||
|
/// vertex data.
|
||||||
|
///
|
||||||
|
struct Vertex_2f_4ub_2f {
|
||||||
|
float pos[2];
|
||||||
|
unsigned char color[4];
|
||||||
|
float obj[2];
|
||||||
|
};
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Vertex layout for quad vertices, useful for synthesizing or modifying
|
||||||
|
/// vertex data.
|
||||||
|
///
|
||||||
|
struct Vertex_2f_4ub_2f_2f_28f {
|
||||||
|
float pos[2];
|
||||||
|
unsigned char color[4];
|
||||||
|
float tex[2];
|
||||||
|
float obj[2];
|
||||||
|
float data0[4];
|
||||||
|
float data1[4];
|
||||||
|
float data2[4];
|
||||||
|
float data3[4];
|
||||||
|
float data4[4];
|
||||||
|
float data5[4];
|
||||||
|
float data6[4];
|
||||||
|
};
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Vertex formats
|
||||||
|
///
|
||||||
|
enum UExport VertexBufferFormat {
|
||||||
|
kVertexBufferFormat_2f_4ub_2f,
|
||||||
|
kVertexBufferFormat_2f_4ub_2f_2f_28f,
|
||||||
|
};
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Vertex buffer, @see GPUDriver::CreateGeometry
|
||||||
|
///
|
||||||
|
struct UExport VertexBuffer {
|
||||||
|
VertexBufferFormat format;
|
||||||
|
uint32_t size;
|
||||||
|
uint8_t* data;
|
||||||
|
};
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Vertex index type
|
||||||
|
///
|
||||||
|
typedef uint32_t IndexType;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Vertex index buffer, @see GPUDriver::CreateGeometry
|
||||||
|
///
|
||||||
|
struct UExport IndexBuffer {
|
||||||
|
uint32_t size;
|
||||||
|
uint8_t* data;
|
||||||
|
};
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Shader types, used by GPUState::shader_type
|
||||||
|
///
|
||||||
|
/// Each of these correspond to a vertex/pixel shader pair. You can find
|
||||||
|
/// stock shader code for these in the `shaders` folder of the AppCore repo.
|
||||||
|
///
|
||||||
|
enum UExport ShaderType {
|
||||||
|
kShaderType_Fill, // Shader program for quad geometry
|
||||||
|
kShaderType_FillPath, // Shader program for path geometry
|
||||||
|
};
|
||||||
|
|
||||||
|
///
|
||||||
|
/// GPU state description.
|
||||||
|
///
|
||||||
|
struct UExport GPUState {
|
||||||
|
/// Viewport width in pixels
|
||||||
|
uint32_t viewport_width;
|
||||||
|
|
||||||
|
/// Viewport height in pixels
|
||||||
|
uint32_t viewport_height;
|
||||||
|
|
||||||
|
/// Transform matrix-- you should multiply this with the screen-space
|
||||||
|
/// orthographic projection matrix then pass to the vertex shader.
|
||||||
|
Matrix4x4 transform;
|
||||||
|
|
||||||
|
/// Whether or not we should enable texturing for the current draw command.
|
||||||
|
bool enable_texturing;
|
||||||
|
|
||||||
|
/// Whether or not we should enable blending for the current draw command.
|
||||||
|
/// If blending is disabled, any drawn pixels should overwrite existing.
|
||||||
|
/// Mainly used so we can modify alpha values of the RenderBuffer during
|
||||||
|
/// scissored clears.
|
||||||
|
bool enable_blend;
|
||||||
|
|
||||||
|
/// The vertex/pixel shader program pair to use for the current draw command.
|
||||||
|
/// You should cast this to ShaderType to get the corresponding enum.
|
||||||
|
uint8_t shader_type;
|
||||||
|
|
||||||
|
/// The render buffer to use for the current draw command.
|
||||||
|
uint32_t render_buffer_id;
|
||||||
|
|
||||||
|
/// The texture id to bind to slot #1. (Will be 0 if none)
|
||||||
|
uint32_t texture_1_id;
|
||||||
|
|
||||||
|
/// The texture id to bind to slot #2. (Will be 0 if none)
|
||||||
|
uint32_t texture_2_id;
|
||||||
|
|
||||||
|
/// The texture id to bind to slot #3. (Will be 0 if none)
|
||||||
|
uint32_t texture_3_id;
|
||||||
|
|
||||||
|
/// The following four members are passed to the pixel shader via uniforms.
|
||||||
|
float uniform_scalar[8];
|
||||||
|
vec4 uniform_vector[8];
|
||||||
|
uint8_t clip_size;
|
||||||
|
Matrix4x4 clip[8];
|
||||||
|
|
||||||
|
/// Whether or not scissor testing should be used for the current draw command.
|
||||||
|
bool enable_scissor;
|
||||||
|
|
||||||
|
/// The scissor rect to use for scissor testing (units in pixels)
|
||||||
|
IntRect scissor_rect;
|
||||||
|
};
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Command types, used by Command::command_type
|
||||||
|
///
|
||||||
|
enum UExport CommandType {
|
||||||
|
kCommandType_ClearRenderBuffer,
|
||||||
|
kCommandType_DrawGeometry,
|
||||||
|
};
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Command description.
|
||||||
|
///
|
||||||
|
struct UExport Command {
|
||||||
|
uint8_t command_type; // The type of command to dispatch.
|
||||||
|
GPUState gpu_state; // GPU state parameters for current command.
|
||||||
|
|
||||||
|
/// The following members are only used with kCommandType_DrawGeometry
|
||||||
|
uint32_t geometry_id; // The geometry ID to bind
|
||||||
|
uint32_t indices_count; // The number of indices
|
||||||
|
uint32_t indices_offset; // The index to start from
|
||||||
|
};
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Command list, @see GPUDriver::UpdateCommandList
|
||||||
|
///
|
||||||
|
struct UExport CommandList {
|
||||||
|
uint32_t size;
|
||||||
|
Command* commands;
|
||||||
|
};
|
||||||
|
|
||||||
|
#pragma pack(pop)
|
||||||
|
|
||||||
|
///
|
||||||
|
/// @brief GPUDriver interface, dispatches GPU calls to the native driver.
|
||||||
|
///
|
||||||
|
/// This is automatically provided for you when you use App::Create(), AppCore
|
||||||
|
/// provides platform-specific implementations of GPUDriver for each OS.
|
||||||
|
///
|
||||||
|
/// If you are using Renderer::Create(), you will need to provide your own
|
||||||
|
/// implementation of this class if you have enabled the GPU renderer in the
|
||||||
|
/// Config. @see Platform::set_gpu_driver
|
||||||
|
///
|
||||||
|
class UExport GPUDriver {
|
||||||
|
public:
|
||||||
|
virtual ~GPUDriver();
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Called before any commands are dispatched during a frame.
|
||||||
|
///
|
||||||
|
virtual void BeginSynchronize() = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Called after any commands are dispatched during a frame.
|
||||||
|
///
|
||||||
|
virtual void EndSynchronize() = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get the next available texture ID.
|
||||||
|
///
|
||||||
|
virtual uint32_t NextTextureId() = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Create a texture with a certain ID and optional bitmap.
|
||||||
|
///
|
||||||
|
/// **NOTE**: If the Bitmap is empty (Bitmap::IsEmpty), then a RTT Texture
|
||||||
|
/// should be created instead. This will be used as a backing
|
||||||
|
/// texture for a new RenderBuffer.
|
||||||
|
///
|
||||||
|
virtual void CreateTexture(uint32_t texture_id,
|
||||||
|
Ref<Bitmap> bitmap) = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Update an existing non-RTT texture with new bitmap data.
|
||||||
|
///
|
||||||
|
virtual void UpdateTexture(uint32_t texture_id,
|
||||||
|
Ref<Bitmap> bitmap) = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Destroy a texture.
|
||||||
|
///
|
||||||
|
virtual void DestroyTexture(uint32_t texture_id) = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Generate the next available render buffer ID.
|
||||||
|
///
|
||||||
|
virtual uint32_t NextRenderBufferId() = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Create a render buffer with certain ID and buffer description.
|
||||||
|
///
|
||||||
|
virtual void CreateRenderBuffer(uint32_t render_buffer_id,
|
||||||
|
const RenderBuffer& buffer) = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Destroy a render buffer
|
||||||
|
///
|
||||||
|
virtual void DestroyRenderBuffer(uint32_t render_buffer_id) = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Generate the next available geometry ID.
|
||||||
|
///
|
||||||
|
virtual uint32_t NextGeometryId() = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Create geometry with certain ID and vertex/index data.
|
||||||
|
///
|
||||||
|
virtual void CreateGeometry(uint32_t geometry_id,
|
||||||
|
const VertexBuffer& vertices,
|
||||||
|
const IndexBuffer& indices) = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Update existing geometry with new vertex/index data.
|
||||||
|
///
|
||||||
|
virtual void UpdateGeometry(uint32_t geometry_id,
|
||||||
|
const VertexBuffer& vertices,
|
||||||
|
const IndexBuffer& indices) = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Destroy geometry.
|
||||||
|
///
|
||||||
|
virtual void DestroyGeometry(uint32_t geometry_id) = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Update command list (you should copy the commands to your own structure).
|
||||||
|
///
|
||||||
|
virtual void UpdateCommandList(const CommandList& list) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace ultralight
|
|
@ -0,0 +1,47 @@
|
||||||
|
///
|
||||||
|
/// @file Logger.h
|
||||||
|
///
|
||||||
|
/// @brief The header for the Logger interface.
|
||||||
|
///
|
||||||
|
/// @author
|
||||||
|
///
|
||||||
|
/// This file is a part of Ultralight, a fast, lightweight, HTML UI engine
|
||||||
|
///
|
||||||
|
/// Website: <http://ultralig.ht>
|
||||||
|
///
|
||||||
|
/// Copyright (C) 2020 Ultralight, Inc. All rights reserved.
|
||||||
|
///
|
||||||
|
#pragma once
|
||||||
|
#include <Ultralight/Defines.h>
|
||||||
|
#include <Ultralight/String16.h>
|
||||||
|
|
||||||
|
namespace ultralight {
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Log levels, used with Logger::LogMessage
|
||||||
|
///
|
||||||
|
enum LogLevel {
|
||||||
|
kLogLevel_Error = 0,
|
||||||
|
kLogLevel_Warning,
|
||||||
|
kLogLevel_Info
|
||||||
|
};
|
||||||
|
|
||||||
|
///
|
||||||
|
/// @brief Logger interface.
|
||||||
|
///
|
||||||
|
/// This can be used to log debug messages to the console or to a log file.
|
||||||
|
///
|
||||||
|
/// This is intended to be implemented by users and defined before creating the
|
||||||
|
/// Renderer. @see Platform::set_file_system.
|
||||||
|
///
|
||||||
|
class UExport Logger {
|
||||||
|
public:
|
||||||
|
virtual ~Logger();
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Called when the library wants to print a message to the log.
|
||||||
|
///
|
||||||
|
virtual void LogMessage(LogLevel log_level, const String16& message) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace ultralight
|
|
@ -0,0 +1,141 @@
|
||||||
|
///
|
||||||
|
/// @file Platform.h
|
||||||
|
///
|
||||||
|
/// @brief The header for the Platform singleton.
|
||||||
|
///
|
||||||
|
/// @author
|
||||||
|
///
|
||||||
|
/// This file is a part of Ultralight, a fast, lightweight, HTML UI engine
|
||||||
|
///
|
||||||
|
/// Website: <http://ultralig.ht>
|
||||||
|
///
|
||||||
|
/// Copyright (C) 2020 Ultralight, Inc. All rights reserved.
|
||||||
|
///
|
||||||
|
#pragma once
|
||||||
|
#include <Ultralight/Defines.h>
|
||||||
|
|
||||||
|
namespace ultralight {
|
||||||
|
|
||||||
|
struct Config;
|
||||||
|
class Logger;
|
||||||
|
class GPUDriver;
|
||||||
|
class FontLoader;
|
||||||
|
class FileSystem;
|
||||||
|
class Clipboard;
|
||||||
|
class SurfaceFactory;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// @brief Platform singleton to configure Ultralight and provide user-defined
|
||||||
|
/// implementations for various platform operations.
|
||||||
|
///
|
||||||
|
/// @note All of these settings and user-defined interfaces should be set
|
||||||
|
/// BEFORE creating the Renderer.
|
||||||
|
///
|
||||||
|
class UExport Platform {
|
||||||
|
public:
|
||||||
|
///
|
||||||
|
/// Get the Platform singleton
|
||||||
|
///
|
||||||
|
static Platform& instance();
|
||||||
|
|
||||||
|
virtual ~Platform();
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Set the Config
|
||||||
|
///
|
||||||
|
virtual void set_config(const Config& config) = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get the Config
|
||||||
|
///
|
||||||
|
virtual const Config& config() const = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Set the Logger (to handle error messages and debug output).
|
||||||
|
///
|
||||||
|
/// @param logger A user-defined Logger implementation, ownership remains
|
||||||
|
/// with the caller.
|
||||||
|
///
|
||||||
|
virtual void set_logger(Logger* logger) = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get the Logger
|
||||||
|
///
|
||||||
|
virtual Logger* logger() const = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Set the GPU Driver (will handle all rendering)
|
||||||
|
///
|
||||||
|
/// @param gpu_driver A user-defined GPUDriver implementation, ownership
|
||||||
|
/// remains with the caller.
|
||||||
|
///
|
||||||
|
virtual void set_gpu_driver(GPUDriver* gpu_driver) = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get the GPU Driver
|
||||||
|
///
|
||||||
|
virtual GPUDriver* gpu_driver() const = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Set the Font Loader (will be used to map font families to actual fonts)
|
||||||
|
///
|
||||||
|
/// @param font_loader A user-defined FontLoader implementation, ownership
|
||||||
|
/// remains with the caller.
|
||||||
|
///
|
||||||
|
virtual void set_font_loader(FontLoader* font_loader) = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get the Font Loader
|
||||||
|
///
|
||||||
|
virtual FontLoader* font_loader() const = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Set the File System (will be used for all file system operations)
|
||||||
|
///
|
||||||
|
/// @param file_system A user-defined FileSystem implementation, ownership
|
||||||
|
/// remains with the caller.
|
||||||
|
///
|
||||||
|
virtual void set_file_system(FileSystem* file_system) = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get the File System
|
||||||
|
///
|
||||||
|
virtual FileSystem* file_system() const = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Set the Clipboard (will be used for all clipboard operations)
|
||||||
|
///
|
||||||
|
/// @param clipboard A user-defined Clipboard implementation, ownership
|
||||||
|
/// remains with the caller.
|
||||||
|
///
|
||||||
|
virtual void set_clipboard(Clipboard* clipboard) = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get the Clipboard
|
||||||
|
///
|
||||||
|
virtual Clipboard* clipboard() const = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Set the SurfaceFactory
|
||||||
|
///
|
||||||
|
/// This can be used to provide a platform-specific bitmap surface for View
|
||||||
|
/// to paint into when the CPU renderer is enabled. See View::surface().
|
||||||
|
///
|
||||||
|
/// @param surface_factory A user-defined SurfaceFactory implementation,
|
||||||
|
/// ownership remains with the caller.
|
||||||
|
///
|
||||||
|
/// @note A default BitmapSurfaceFactory is defined if you never call this,
|
||||||
|
/// View::surface() can be safely cast to BitmapSurface.
|
||||||
|
///
|
||||||
|
virtual void set_surface_factory(SurfaceFactory* surface_factory) = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get the SurfaceFactory
|
||||||
|
///
|
||||||
|
/// @note A default BitmapSurfaceFactory is set by default, View::surface()
|
||||||
|
/// can be safely cast to BitmapSurface if you don't define your own.
|
||||||
|
///
|
||||||
|
virtual SurfaceFactory* surface_factory() const = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace ultralight
|
|
@ -0,0 +1,191 @@
|
||||||
|
///
|
||||||
|
/// @file Surface.h
|
||||||
|
///
|
||||||
|
/// @brief The header for the Surface and SurfaceFactory interfaces.
|
||||||
|
///
|
||||||
|
/// @author
|
||||||
|
///
|
||||||
|
/// This file is a part of Ultralight, a fast, lightweight, HTML UI engine
|
||||||
|
///
|
||||||
|
/// Website: <http://ultralig.ht>
|
||||||
|
///
|
||||||
|
/// Copyright (C) 2020 Ultralight, Inc. All rights reserved.
|
||||||
|
///
|
||||||
|
#pragma once
|
||||||
|
#include <Ultralight/Defines.h>
|
||||||
|
#include <Ultralight/RefPtr.h>
|
||||||
|
#include <Ultralight/Bitmap.h>
|
||||||
|
#include <Ultralight/Geometry.h>
|
||||||
|
|
||||||
|
namespace ultralight {
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Offscreen pixel buffer surface. (Premultiplied BGRA 32-bit format)
|
||||||
|
///
|
||||||
|
/// When using the CPU renderer, each View is painted to its own Surface.
|
||||||
|
///
|
||||||
|
/// You can provide your own Surface implementation to make the renderer
|
||||||
|
/// paint directly to a block of memory controlled by you (this is useful for
|
||||||
|
/// lower-latency uploads to GPU memory or other platform-specific bitmaps).
|
||||||
|
///
|
||||||
|
/// A default Surface implementation, BitmapSurface, is automatically
|
||||||
|
/// provided by the library when you call Renderer::Create() without defining
|
||||||
|
/// a custom SurfaceFactory.
|
||||||
|
///
|
||||||
|
/// To provide your own custom Surface implementation, you should inherit
|
||||||
|
/// from this class, handle the virtual member functions, and then define a
|
||||||
|
/// custom SurfaceFactory that creates/destroys an instance of your class.
|
||||||
|
/// After that, you should pass an instance of your custom SurfaceFactory class
|
||||||
|
/// to `Platform::instance().set_font_loader()` before calling App::Create()
|
||||||
|
/// or Renderer::Create().
|
||||||
|
///
|
||||||
|
class UExport Surface {
|
||||||
|
public:
|
||||||
|
virtual ~Surface();
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Width (in pixels).
|
||||||
|
///
|
||||||
|
virtual uint32_t width() const = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Height (in pixels).
|
||||||
|
///
|
||||||
|
virtual uint32_t height() const = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Number of bytes between rows (usually width * 4)
|
||||||
|
///
|
||||||
|
virtual uint32_t row_bytes() const = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Size in bytes.
|
||||||
|
///
|
||||||
|
virtual size_t size() const = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Lock the pixel buffer and get a pointer to the beginning of the data
|
||||||
|
/// for reading/writing.
|
||||||
|
///
|
||||||
|
/// Native pixel format is premultiplied BGRA 32-bit (8 bits per channel).
|
||||||
|
///
|
||||||
|
virtual void* LockPixels() = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Unlock the pixel buffer.
|
||||||
|
///
|
||||||
|
virtual void UnlockPixels() = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Resize the pixel buffer to a certain width and height (both in pixels).
|
||||||
|
///
|
||||||
|
/// This should never be called while pixels are locked.
|
||||||
|
///
|
||||||
|
virtual void Resize(uint32_t width, uint32_t height) = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Set the dirty bounds to a certain value.
|
||||||
|
///
|
||||||
|
/// This is called after the Renderer paints to an area of the pixel buffer.
|
||||||
|
/// (The new value will be joined with the existing dirty_bounds())
|
||||||
|
///
|
||||||
|
virtual void set_dirty_bounds(const IntRect& bounds);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get the dirty bounds.
|
||||||
|
///
|
||||||
|
/// This value can be used to determine which portion of the pixel buffer has
|
||||||
|
/// been updated since the last call to ClearDirtyBounds().
|
||||||
|
///
|
||||||
|
/// The general algorithm to determine if a Surface needs display is:
|
||||||
|
/// <pre>
|
||||||
|
/// if (!surface.dirty_bounds().IsEmpty()) {
|
||||||
|
/// // Surface pixels are dirty and needs display.
|
||||||
|
/// // Cast Surface to native Surface and use it here (pseudo code)
|
||||||
|
/// DisplaySurface(surface);
|
||||||
|
///
|
||||||
|
/// // Once you're done, clear the dirty bounds:
|
||||||
|
/// surface.ClearDirtyBounds();
|
||||||
|
/// }
|
||||||
|
/// </pre>
|
||||||
|
///
|
||||||
|
virtual IntRect dirty_bounds() const;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Clear the dirty bounds.
|
||||||
|
///
|
||||||
|
/// You should call this after you're done displaying the Surface.
|
||||||
|
///
|
||||||
|
virtual void ClearDirtyBounds();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
Surface();
|
||||||
|
|
||||||
|
IntRect dirty_bounds_;
|
||||||
|
};
|
||||||
|
|
||||||
|
///
|
||||||
|
/// SurfaceFactory can be used to provide your own native Surface implementation.
|
||||||
|
///
|
||||||
|
/// This can be used to wrap a platform-specific GPU texture, Windows DIB,
|
||||||
|
/// macOS CGImage, or any other pixel buffer target for display on screen.
|
||||||
|
///
|
||||||
|
/// The default factory creates/destroys a BitmapSurface but you can override
|
||||||
|
/// this by providing your own factory to Platform::set_surface_factory.
|
||||||
|
///
|
||||||
|
class UExport SurfaceFactory {
|
||||||
|
public:
|
||||||
|
virtual ~SurfaceFactory();
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Create a native Surface with a certain width and height (in pixels).
|
||||||
|
///
|
||||||
|
virtual Surface* CreateSurface(uint32_t width, uint32_t height) = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Destroy a native Surface previously created by CreateSurface().
|
||||||
|
///
|
||||||
|
virtual void DestroySurface(Surface* surface) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
///
|
||||||
|
/// The default Surface implementation, backed by a Bitmap.
|
||||||
|
///
|
||||||
|
class UExport BitmapSurface : public Surface {
|
||||||
|
public:
|
||||||
|
virtual uint32_t width() const override;
|
||||||
|
|
||||||
|
virtual uint32_t height() const override;
|
||||||
|
|
||||||
|
virtual uint32_t row_bytes() const override;
|
||||||
|
|
||||||
|
virtual size_t size() const override;
|
||||||
|
|
||||||
|
virtual void* LockPixels() override;
|
||||||
|
|
||||||
|
virtual void UnlockPixels() override;
|
||||||
|
|
||||||
|
virtual void Resize(uint32_t width, uint32_t height) override;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get the underlying Bitmap.
|
||||||
|
///
|
||||||
|
RefPtr<Bitmap> bitmap();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
BitmapSurface(uint32_t width, uint32_t height);
|
||||||
|
virtual ~BitmapSurface();
|
||||||
|
BitmapSurface(const BitmapSurface&) = delete;
|
||||||
|
void operator=(const BitmapSurface&) = delete;
|
||||||
|
friend class BitmapSurfaceFactory;
|
||||||
|
|
||||||
|
void* impl_;
|
||||||
|
};
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get the default Bitmap Surface Factory singleton. (Do not destroy this,
|
||||||
|
/// this singleton is owned by the library).
|
||||||
|
///
|
||||||
|
UExport SurfaceFactory* GetBitmapSurfaceFactory();
|
||||||
|
|
||||||
|
} // namespace ultralight
|
|
@ -0,0 +1,17 @@
|
||||||
|
#pragma once
|
||||||
|
#include <Ultralight/Defines.h>
|
||||||
|
#include <Ultralight/String.h>
|
||||||
|
|
||||||
|
namespace ultralight {
|
||||||
|
namespace PlatformFileSystem {
|
||||||
|
|
||||||
|
bool UExport FileExists(const String& path);
|
||||||
|
bool UExport IsDirectory(const String& path, bool follow_symbolic_links);
|
||||||
|
String UExport AppendPath(const String& path, const String& component);
|
||||||
|
bool UExport MakeAllDirectories(const String& path);
|
||||||
|
String UExport GetFileName(const String& path);
|
||||||
|
String UExport GetDirectoryName(const String& path);
|
||||||
|
String UExport RealFilePath(const String& path);
|
||||||
|
|
||||||
|
} // PlatformFileSystem
|
||||||
|
} // ultralight
|
39
muon.go
39
muon.go
|
@ -49,8 +49,14 @@ func New(cfg *Config, handler http.Handler) *Window {
|
||||||
callbacks: make(map[string]*ipf),
|
callbacks: make(map[string]*ipf),
|
||||||
}
|
}
|
||||||
|
|
||||||
ufg := UlCreateConfig()
|
|
||||||
std := UlCreateSettings()
|
std := UlCreateSettings()
|
||||||
|
defer UlDestroySettings(std)
|
||||||
|
|
||||||
|
UlSettingsSetForceCPURenderer(std, true)
|
||||||
|
|
||||||
|
ufg := UlCreateConfig()
|
||||||
|
defer UlDestroyConfig(ufg)
|
||||||
|
|
||||||
w.app = UlCreateApp(std, ufg)
|
w.app = UlCreateApp(std, ufg)
|
||||||
mm := UlAppGetMainMonitor(w.app)
|
mm := UlAppGetMainMonitor(w.app)
|
||||||
|
|
||||||
|
@ -74,12 +80,11 @@ func New(cfg *Config, handler http.Handler) *Window {
|
||||||
hint |= 8
|
hint |= 8
|
||||||
}
|
}
|
||||||
|
|
||||||
w.wnd = UlCreateWindow(mm, w.cfg.Width, w.cfg.Height, false, hint)
|
w.wnd = UlCreateWindow(mm, w.cfg.Width, w.cfg.Height, false, 0)
|
||||||
|
|
||||||
UlWindowSetTitle(w.wnd, w.cfg.Title)
|
UlWindowSetTitle(w.wnd, w.cfg.Title)
|
||||||
UlAppSetWindow(w.app, w.wnd)
|
|
||||||
|
|
||||||
w.ov = UlCreateOverlay(w.wnd, w.cfg.Width, w.cfg.Height, w.cfg.X, w.cfg.Y)
|
w.ov = UlCreateOverlay(w.wnd, w.cfg.Width, w.cfg.Height, 0, 0)
|
||||||
|
|
||||||
UlWindowSetResizeCallback(w.wnd, resizeCallback(w.ov), nil)
|
UlWindowSetResizeCallback(w.wnd, resizeCallback(w.ov), nil)
|
||||||
|
|
||||||
|
@ -134,11 +139,17 @@ func (w *Window) Bind(name string, function interface{}) {
|
||||||
|
|
||||||
// Eval evaluates a given JavaScript string in the given Window view. `ret` is necessary for JSON serialization if an object is returned.
|
// Eval evaluates a given JavaScript string in the given Window view. `ret` is necessary for JSON serialization if an object is returned.
|
||||||
func (w *Window) Eval(js string, ret reflect.Type) (interface{}, error) {
|
func (w *Window) Eval(js string, ret reflect.Type) (interface{}, error) {
|
||||||
us := UlCreateString(js)
|
us := JSStringCreateWithUTF8CString(js)
|
||||||
defer UlDestroyString(us)
|
defer JSStringRelease(us)
|
||||||
|
src := JSStringCreateWithUTF8CString("")
|
||||||
|
defer JSStringRelease(src)
|
||||||
|
|
||||||
ref := UlViewEvaluateScript(w.view, us)
|
ctx := UlViewLockJSContext(w.view)
|
||||||
ctx := UlViewGetJSContext(w.view)
|
defer UlViewUnlockJSContext(w.view)
|
||||||
|
|
||||||
|
global := JSContextGetGlobalObject(ctx)
|
||||||
|
|
||||||
|
ref := JSEvaluateScript(ctx, us, global, src, 0, nil)
|
||||||
|
|
||||||
val, err := fromJSValue(ctx, ref, ret)
|
val, err := fromJSValue(ctx, ref, ret)
|
||||||
|
|
||||||
|
@ -159,11 +170,11 @@ func (w *Window) Move(x int, y int) {
|
||||||
UlOverlayMoveTo(w.ov, int32(x), int32(y))
|
UlOverlayMoveTo(w.ov, int32(x), int32(y))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *Window) ipcCallback(ctx JSContextRef, functin JSObjectRef, thisObject JSObjectRef, argumentCount uint, arguments []JSValueRef, exception []JSValueRef) JSValueRef {
|
func (w *Window) ipcCallback(ctx JSContextRef, function JSObjectRef, thisObject JSObjectRef, argumentCount uint32, arguments []JSValueRef, exception []JSValueRef) JSValueRef {
|
||||||
jsName := JSStringCreateWithUTF8CString("name")
|
jsName := JSStringCreateWithUTF8CString("name")
|
||||||
defer JSStringRelease(jsName)
|
defer JSStringRelease(jsName)
|
||||||
|
|
||||||
prop := JSObjectGetProperty(ctx, functin, jsName, nil)
|
prop := JSObjectGetProperty(ctx, function, jsName, nil)
|
||||||
jsProp := JSValueToStringCopy(ctx, prop, nil)
|
jsProp := JSValueToStringCopy(ctx, prop, nil)
|
||||||
defer JSStringRelease(jsProp)
|
defer JSStringRelease(jsProp)
|
||||||
|
|
||||||
|
@ -177,7 +188,7 @@ func (w *Window) ipcCallback(ctx JSContextRef, functin JSObjectRef, thisObject J
|
||||||
|
|
||||||
params := make([]reflect.Value, argumentCount)
|
params := make([]reflect.Value, argumentCount)
|
||||||
|
|
||||||
for i := uint(0); i < argumentCount; i++ {
|
for i := uint32(0); i < argumentCount; i++ {
|
||||||
val, err := fromJSValue(ctx, arguments[i], f.ParamTypes[i])
|
val, err := fromJSValue(ctx, arguments[i], f.ParamTypes[i])
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -298,7 +309,7 @@ func toJSValue(ctx JSContextRef, value reflect.Value) JSValueRef {
|
||||||
for i := 0; i < value.Len(); i++ {
|
for i := 0; i < value.Len(); i++ {
|
||||||
rets[i] = toJSValue(ctx, value.Index(i))
|
rets[i] = toJSValue(ctx, value.Index(i))
|
||||||
}
|
}
|
||||||
arr := JSObjectMakeArray(ctx, uint(len(rets)), rets, nil)
|
arr := JSObjectMakeArray(ctx, uint32(len(rets)), rets, nil)
|
||||||
jsv = *(*JSValueRef)(unsafe.Pointer(&arr))
|
jsv = *(*JSValueRef)(unsafe.Pointer(&arr))
|
||||||
default:
|
default:
|
||||||
panic("Not implemented!")
|
panic("Not implemented!")
|
||||||
|
@ -312,7 +323,9 @@ func toJSValue(ctx JSContextRef, value reflect.Value) JSValueRef {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *Window) addFunction(name string) {
|
func (w *Window) addFunction(name string) {
|
||||||
ctx := UlViewGetJSContext(w.view)
|
ctx := UlViewLockJSContext(w.view)
|
||||||
|
defer UlViewUnlockJSContext(w.view)
|
||||||
|
|
||||||
gobj := JSContextGetGlobalObject(ctx)
|
gobj := JSContextGetGlobalObject(ctx)
|
||||||
|
|
||||||
fn := JSStringCreateWithUTF8CString(name)
|
fn := JSStringCreateWithUTF8CString(name)
|
||||||
|
|
|
@ -11,8 +11,8 @@ var w *Window
|
||||||
|
|
||||||
func TestMain(m *testing.M) {
|
func TestMain(m *testing.M) {
|
||||||
cfg := &Config{
|
cfg := &Config{
|
||||||
Height: 1,
|
Height: 100,
|
||||||
Width: 1,
|
Width: 100,
|
||||||
}
|
}
|
||||||
|
|
||||||
w = New(cfg, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}))
|
w = New(cfg, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}))
|
||||||
|
|
|
@ -4,7 +4,7 @@ GENERATOR:
|
||||||
PackageLicense: "THE AUTOGENERATED LICENSE. ALL THE RIGHTS ARE RESERVED BY ROBOTS."
|
PackageLicense: "THE AUTOGENERATED LICENSE. ALL THE RIGHTS ARE RESERVED BY ROBOTS."
|
||||||
FlagGroups:
|
FlagGroups:
|
||||||
- {name: CFLAGS, flags: [-I../include]}
|
- {name: CFLAGS, flags: [-I../include]}
|
||||||
- {name: LDFLAGS, flags: ["-L${SRCDIR}/libs -lUltralightCore -lWebCore -lUltralight -lAppCore"]}
|
- {name: LDFLAGS, flags: ["-Wl,--allow-multiple-definition -L${SRCDIR}/libs/linux/x64 -Wl,-rpath,/home/co/code/Muon/ultralight/libs/linux/x64 -lUltralightCore -lAppCore -lUltralight -lWebCore"]}
|
||||||
Includes: ["AppCore/CAPI.h"]
|
Includes: ["AppCore/CAPI.h"]
|
||||||
Options:
|
Options:
|
||||||
SafeStrings: true
|
SafeStrings: true
|
||||||
|
@ -14,41 +14,48 @@ PARSER:
|
||||||
IncludePaths:
|
IncludePaths:
|
||||||
- include
|
- include
|
||||||
- /usr/include
|
- /usr/include
|
||||||
- /usr/lib/gcc/x86_64-linux-gnu/7/include
|
- /usr/lib/gcc/x86_64-linux-gnu/9/include
|
||||||
SourcesPaths:
|
SourcesPaths:
|
||||||
- AppCore/CAPI.h
|
- AppCore/CAPI.h
|
||||||
|
|
||||||
TRANSLATOR:
|
TRANSLATOR:
|
||||||
ConstRules:
|
ConstRules:
|
||||||
defines: eval
|
defines: expand
|
||||||
|
enum: eval
|
||||||
Rules:
|
Rules:
|
||||||
global:
|
global:
|
||||||
- {action: accept, from: "^ul"}
|
- {action: accept, from: "^ul"}
|
||||||
- {action: accept, from: "^UL"}
|
- {action: accept, from: "^Ul"}
|
||||||
- {action: accept, from: "^JS"}
|
- {action: accept, from: "^UL"}
|
||||||
- {action: accept, from: "^k"}
|
- {action: accept, from: "^js"}
|
||||||
- {action: accept, from: "^B"}
|
- {action: accept, from: "^JS"}
|
||||||
- {action: ignore, from: __size_t__}
|
- {action: accept, from: "^k"}
|
||||||
- {action: ignore, from: __SIZE_T__}
|
- {action: accept, from: "^B"}
|
||||||
- {action: ignore, from: _BSD_SIZE_T_DEFINED_}
|
- {transform: export}
|
||||||
- {action: ignore, from: _SIZE_T_DECLARED}
|
# - {action: accept, from: "^ul"}
|
||||||
- {action: ignore, from: __wchar_t__}
|
# - {action: accept, from: "^UL"}
|
||||||
- {action: ignore, from: __WCHAR_T__}
|
# - {action: accept, from: "^Ul"}
|
||||||
- {transform: export}
|
# - {action: accept, from: "^JS"}
|
||||||
|
# - {action: accept, from: "^k"}
|
||||||
|
# - {action: accept, from: "^B"}
|
||||||
|
# # - {action: ignore, from: __size_t__}
|
||||||
|
# # - {action: ignore, from: __SIZE_T__}
|
||||||
|
# # - {action: ignore, from: _BSD_SIZE_T_DEFINED_}
|
||||||
|
# # - {action: ignore, from: _SIZE_T_DECLARED}
|
||||||
|
# # - {action: ignore, from: __wchar_t__}
|
||||||
|
# # - {action: ignore, from: __WCHAR_T__}
|
||||||
|
#- {transform: export}
|
||||||
function:
|
function:
|
||||||
- {action: ignore, from: __GO__}
|
- {action: accept, from: "^ul"}
|
||||||
# - {action: ignore, from: JSObjectGetArrayBufferByteLength}
|
- {action: accept, from: "^Ul"}
|
||||||
# - {action: ignore, from: JSObjectGetArrayBufferBytesPtr}
|
- {action: accept, from: "^UL"}
|
||||||
# - {action: ignore, from: JSObjectGetTypedArrayBuffer}
|
- {action: accept, from: "^js"}
|
||||||
# - {action: ignore, from: JSObjectGetTypedArrayByteLength}
|
- {action: accept, from: "^JS"}
|
||||||
# - {action: ignore, from: JSObjectGetTypedArrayByteOffset}
|
- {action: ignore, from: "ulCreateStringFromCopy"} # Not actually exported the header lies!
|
||||||
# - {action: ignore, from: JSObjectGetTypedArrayBytesPtr}
|
|
||||||
# - {action: ignore, from: JSObjectGetTypedArrayLength}
|
- {transform: export}
|
||||||
# - {action: ignore, from: JSObjectMakeArrayBufferWithBytesNoCopy}
|
|
||||||
# - {action: ignore, from: JSObjectMakeTypedArray}
|
|
||||||
# - {action: ignore, from: JSObjectMakeTypedArrayWithArrayBuffer}
|
|
||||||
# - {action: ignore, from: JSObjectMakeTypedArrayWithArrayBufferAndOffset}
|
|
||||||
# - {action: ignore, from: JSObjectMakeTypedArrayWithBytesNoCopy}
|
|
||||||
# - {action: ignore, from: JSValueGetTypedArrayType}
|
|
||||||
private:
|
private:
|
||||||
- {transform: unexport}
|
- {transform: unexport}
|
||||||
|
post-global:
|
||||||
|
- {action: replace, from: _$}
|
||||||
|
- {load: snakecase}
|
|
@ -1,6 +1,6 @@
|
||||||
// THE AUTOGENERATED LICENSE. ALL THE RIGHTS ARE RESERVED BY ROBOTS.
|
// THE AUTOGENERATED LICENSE. ALL THE RIGHTS ARE RESERVED BY ROBOTS.
|
||||||
|
|
||||||
// WARNING: This file has automatically been generated on Mon, 07 Oct 2019 13:59:36 CDT.
|
// WARNING: This file has automatically been generated on Sun, 02 Oct 2022 19:40:55 PDT.
|
||||||
// Code generated by https://git.io/c-for-go. DO NOT EDIT.
|
// Code generated by https://git.io/c-for-go. DO NOT EDIT.
|
||||||
|
|
||||||
#include "_cgo_export.h"
|
#include "_cgo_export.h"
|
||||||
|
@ -38,20 +38,164 @@ void ULAddConsoleMessageCallback_44b8dd01(void* user_data, ULView caller, ULMess
|
||||||
uLAddConsoleMessageCallback44B8DD01(user_data, caller, source, level, message, line_number, column_number, source_id);
|
uLAddConsoleMessageCallback44B8DD01(user_data, caller, source, level, message, line_number, column_number, source_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ULBeginLoadingCallback_70d8c0ad(void* user_data, ULView caller) {
|
ULView ULCreateChildViewCallback_ef6d2cdd(void* user_data, ULView caller, ULString opener_url, ULString target_url, _Bool is_popup, ULIntRect popup_rect) {
|
||||||
uLBeginLoadingCallback70D8C0AD(user_data, caller);
|
return uLCreateChildViewCallbackEF6D2CDD(user_data, caller, opener_url, target_url, is_popup, popup_rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ULFinishLoadingCallback_1ed4ecae(void* user_data, ULView caller) {
|
void ULBeginLoadingCallback_70d8c0ad(void* user_data, ULView caller, unsigned long long frame_id, _Bool is_main_frame, ULString url) {
|
||||||
uLFinishLoadingCallback1ED4ECAE(user_data, caller);
|
uLBeginLoadingCallback70D8C0AD(user_data, caller, frame_id, is_main_frame, url);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ULFinishLoadingCallback_1ed4ecae(void* user_data, ULView caller, unsigned long long frame_id, _Bool is_main_frame, ULString url) {
|
||||||
|
uLFinishLoadingCallback1ED4ECAE(user_data, caller, frame_id, is_main_frame, url);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ULFailLoadingCallback_55ff90b8(void* user_data, ULView caller, unsigned long long frame_id, _Bool is_main_frame, ULString url, ULString description, ULString error_domain, int error_code) {
|
||||||
|
uLFailLoadingCallback55FF90B8(user_data, caller, frame_id, is_main_frame, url, description, error_domain, error_code);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ULWindowObjectReadyCallback_66dc25f3(void* user_data, ULView caller, unsigned long long frame_id, _Bool is_main_frame, ULString url) {
|
||||||
|
uLWindowObjectReadyCallback66DC25F3(user_data, caller, frame_id, is_main_frame, url);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ULDOMReadyCallback_6432c207(void* user_data, ULView caller, unsigned long long frame_id, _Bool is_main_frame, ULString url) {
|
||||||
|
uLDOMReadyCallback6432C207(user_data, caller, frame_id, is_main_frame, url);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ULUpdateHistoryCallback_6e105364(void* user_data, ULView caller) {
|
void ULUpdateHistoryCallback_6e105364(void* user_data, ULView caller) {
|
||||||
uLUpdateHistoryCallback6E105364(user_data, caller);
|
uLUpdateHistoryCallback6E105364(user_data, caller);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ULDOMReadyCallback_6432c207(void* user_data, ULView caller) {
|
void* ULSurfaceDefinitionCreateCallback_573ec115(unsigned int width, unsigned int height) {
|
||||||
uLDOMReadyCallback6432C207(user_data, caller);
|
return uLSurfaceDefinitionCreateCallback573EC115(width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ULSurfaceDefinitionDestroyCallback_851bacee(void* user_data) {
|
||||||
|
uLSurfaceDefinitionDestroyCallback851BACEE(user_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int ULSurfaceDefinitionGetWidthCallback_1a49a8fd(void* user_data) {
|
||||||
|
return uLSurfaceDefinitionGetWidthCallback1A49A8FD(user_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int ULSurfaceDefinitionGetHeightCallback_3e5fe408(void* user_data) {
|
||||||
|
return uLSurfaceDefinitionGetHeightCallback3E5FE408(user_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int ULSurfaceDefinitionGetRowBytesCallback_adcc8668(void* user_data) {
|
||||||
|
return uLSurfaceDefinitionGetRowBytesCallbackADCC8668(user_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned long int ULSurfaceDefinitionGetSizeCallback_83184afe(void* user_data) {
|
||||||
|
return uLSurfaceDefinitionGetSizeCallback83184AFE(user_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
void* ULSurfaceDefinitionLockPixelsCallback_7763e12f(void* user_data) {
|
||||||
|
return uLSurfaceDefinitionLockPixelsCallback7763E12F(user_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ULSurfaceDefinitionUnlockPixelsCallback_d4b69f9(void* user_data) {
|
||||||
|
uLSurfaceDefinitionUnlockPixelsCallbackD4B69F9(user_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ULSurfaceDefinitionResizeCallback_22d82567(void* user_data, unsigned int width, unsigned int height) {
|
||||||
|
uLSurfaceDefinitionResizeCallback22D82567(user_data, width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
_Bool ULFileSystemFileExistsCallback_d03bf100(ULString path) {
|
||||||
|
return uLFileSystemFileExistsCallbackD03BF100(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
_Bool ULFileSystemGetFileSizeCallback_e87ad8b1(int handle, long long* result) {
|
||||||
|
return uLFileSystemGetFileSizeCallbackE87AD8B1(handle, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
_Bool ULFileSystemGetFileMimeTypeCallback_7e6fd322(ULString path, ULString result) {
|
||||||
|
return uLFileSystemGetFileMimeTypeCallback7E6FD322(path, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
int ULFileSystemOpenFileCallback_bbb19604(ULString path, _Bool open_for_writing) {
|
||||||
|
return uLFileSystemOpenFileCallbackBBB19604(path, open_for_writing);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ULFileSystemCloseFileCallback_c90ac2e5(int handle) {
|
||||||
|
uLFileSystemCloseFileCallbackC90AC2E5(handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
long long ULFileSystemReadFromFileCallback_bc1997bc(int handle, char* data, long long length) {
|
||||||
|
return uLFileSystemReadFromFileCallbackBC1997BC(handle, data, length);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ULLoggerLogMessageCallback_454e682a(ULLogLevel log_level, ULString message) {
|
||||||
|
uLLoggerLogMessageCallback454E682A(log_level, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ULGPUDriverBeginSynchronizeCallback_650938c() {
|
||||||
|
uLGPUDriverBeginSynchronizeCallback650938C();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ULGPUDriverEndSynchronizeCallback_f6baad4d() {
|
||||||
|
uLGPUDriverEndSynchronizeCallbackF6BAAD4D();
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int ULGPUDriverNextTextureIdCallback_7de045b4() {
|
||||||
|
return uLGPUDriverNextTextureIdCallback7DE045B4();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ULGPUDriverCreateTextureCallback_a32244d8(unsigned int texture_id, ULBitmap bitmap) {
|
||||||
|
uLGPUDriverCreateTextureCallbackA32244D8(texture_id, bitmap);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ULGPUDriverUpdateTextureCallback_3d7a526(unsigned int texture_id, ULBitmap bitmap) {
|
||||||
|
uLGPUDriverUpdateTextureCallback3D7A526(texture_id, bitmap);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ULGPUDriverDestroyTextureCallback_a8eea310(unsigned int texture_id) {
|
||||||
|
uLGPUDriverDestroyTextureCallbackA8EEA310(texture_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int ULGPUDriverNextRenderBufferIdCallback_bfeb3fb8() {
|
||||||
|
return uLGPUDriverNextRenderBufferIdCallbackBFEB3FB8();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ULGPUDriverCreateRenderBufferCallback_68ee5367(unsigned int render_buffer_id, ULRenderBuffer buffer) {
|
||||||
|
uLGPUDriverCreateRenderBufferCallback68EE5367(render_buffer_id, buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ULGPUDriverDestroyRenderBufferCallback_81623f13(unsigned int render_buffer_id) {
|
||||||
|
uLGPUDriverDestroyRenderBufferCallback81623F13(render_buffer_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int ULGPUDriverNextGeometryIdCallback_5f2a8fea() {
|
||||||
|
return uLGPUDriverNextGeometryIdCallback5F2A8FEA();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ULGPUDriverCreateGeometryCallback_5957236d(unsigned int geometry_id, ULVertexBuffer vertices, ULIndexBuffer indices) {
|
||||||
|
uLGPUDriverCreateGeometryCallback5957236D(geometry_id, vertices, indices);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ULGPUDriverUpdateGeometryCallback_3f20997(unsigned int geometry_id, ULVertexBuffer vertices, ULIndexBuffer indices) {
|
||||||
|
uLGPUDriverUpdateGeometryCallback3F20997(geometry_id, vertices, indices);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ULGPUDriverDestroyGeometryCallback_cce3a508(unsigned int geometry_id) {
|
||||||
|
uLGPUDriverDestroyGeometryCallbackCCE3A508(geometry_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ULGPUDriverUpdateCommandListCallback_d3815a9e(ULCommandList list) {
|
||||||
|
uLGPUDriverUpdateCommandListCallbackD3815A9E(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ULClipboardClearCallback_eda3036a() {
|
||||||
|
uLClipboardClearCallbackEDA3036A();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ULClipboardReadPlainTextCallback_fedfb2b6(ULString result) {
|
||||||
|
uLClipboardReadPlainTextCallbackFEDFB2B6(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ULClipboardWritePlainTextCallback_6e8e0ca4(ULString text) {
|
||||||
|
uLClipboardWritePlainTextCallback6E8E0CA4(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
void JSTypedArrayBytesDeallocator_68d51f83(void* bytes, void* deallocatorContext) {
|
void JSTypedArrayBytesDeallocator_68d51f83(void* bytes, void* deallocatorContext) {
|
||||||
|
@ -62,43 +206,87 @@ void JSObjectInitializeCallback_5793b16(JSContextRef ctx, JSObjectRef object) {
|
||||||
jSObjectInitializeCallback5793B16(ctx, object);
|
jSObjectInitializeCallback5793B16(ctx, object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void JSObjectInitializeCallbackEx_3f9a093b(JSContextRef ctx, JSClassRef jsClass, JSObjectRef object) {
|
||||||
|
jSObjectInitializeCallbackEx3F9A093B(ctx, jsClass, object);
|
||||||
|
}
|
||||||
|
|
||||||
void JSObjectFinalizeCallback_93da0aea(JSObjectRef object) {
|
void JSObjectFinalizeCallback_93da0aea(JSObjectRef object) {
|
||||||
jSObjectFinalizeCallback93DA0AEA(object);
|
jSObjectFinalizeCallback93DA0AEA(object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void JSObjectFinalizeCallbackEx_d64d3113(JSClassRef jsClass, JSObjectRef object) {
|
||||||
|
jSObjectFinalizeCallbackExD64D3113(jsClass, object);
|
||||||
|
}
|
||||||
|
|
||||||
_Bool JSObjectHasPropertyCallback_340bfa95(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName) {
|
_Bool JSObjectHasPropertyCallback_340bfa95(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName) {
|
||||||
return jSObjectHasPropertyCallback340BFA95(ctx, object, propertyName);
|
return jSObjectHasPropertyCallback340BFA95(ctx, object, propertyName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_Bool JSObjectHasPropertyCallbackEx_c35701e7(JSContextRef ctx, JSClassRef jsClass, JSObjectRef object, JSStringRef propertyName) {
|
||||||
|
return jSObjectHasPropertyCallbackExC35701E7(ctx, jsClass, object, propertyName);
|
||||||
|
}
|
||||||
|
|
||||||
JSValueRef JSObjectGetPropertyCallback_5caec716(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception) {
|
JSValueRef JSObjectGetPropertyCallback_5caec716(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception) {
|
||||||
return jSObjectGetPropertyCallback5CAEC716(ctx, object, propertyName, exception);
|
return jSObjectGetPropertyCallback5CAEC716(ctx, object, propertyName, exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JSValueRef JSObjectGetPropertyCallbackEx_8b91eedb(JSContextRef ctx, JSClassRef jsClass, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception) {
|
||||||
|
return jSObjectGetPropertyCallbackEx8B91EEDB(ctx, jsClass, object, propertyName, exception);
|
||||||
|
}
|
||||||
|
|
||||||
_Bool JSObjectSetPropertyCallback_a684f1fe(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSValueRef* exception) {
|
_Bool JSObjectSetPropertyCallback_a684f1fe(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSValueRef* exception) {
|
||||||
return jSObjectSetPropertyCallbackA684F1FE(ctx, object, propertyName, value, exception);
|
return jSObjectSetPropertyCallbackA684F1FE(ctx, object, propertyName, value, exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_Bool JSObjectSetPropertyCallbackEx_d28cf88c(JSContextRef ctx, JSClassRef jsClass, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSValueRef* exception) {
|
||||||
|
return jSObjectSetPropertyCallbackExD28CF88C(ctx, jsClass, object, propertyName, value, exception);
|
||||||
|
}
|
||||||
|
|
||||||
_Bool JSObjectDeletePropertyCallback_b0108ebe(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception) {
|
_Bool JSObjectDeletePropertyCallback_b0108ebe(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception) {
|
||||||
return jSObjectDeletePropertyCallbackB0108EBE(ctx, object, propertyName, exception);
|
return jSObjectDeletePropertyCallbackB0108EBE(ctx, object, propertyName, exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_Bool JSObjectDeletePropertyCallbackEx_e24fcdb0(JSContextRef ctx, JSClassRef jsClass, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception) {
|
||||||
|
return jSObjectDeletePropertyCallbackExE24FCDB0(ctx, jsClass, object, propertyName, exception);
|
||||||
|
}
|
||||||
|
|
||||||
void JSObjectGetPropertyNamesCallback_e77d2329(JSContextRef ctx, JSObjectRef object, JSPropertyNameAccumulatorRef propertyNames) {
|
void JSObjectGetPropertyNamesCallback_e77d2329(JSContextRef ctx, JSObjectRef object, JSPropertyNameAccumulatorRef propertyNames) {
|
||||||
jSObjectGetPropertyNamesCallbackE77D2329(ctx, object, propertyNames);
|
jSObjectGetPropertyNamesCallbackE77D2329(ctx, object, propertyNames);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void JSObjectGetPropertyNamesCallbackEx_74285955(JSContextRef ctx, JSClassRef jsClass, JSObjectRef object, JSPropertyNameAccumulatorRef propertyNames) {
|
||||||
|
jSObjectGetPropertyNamesCallbackEx74285955(ctx, jsClass, object, propertyNames);
|
||||||
|
}
|
||||||
|
|
||||||
JSValueRef JSObjectCallAsFunctionCallback_89f9469b(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, unsigned long int argumentCount, JSValueRef* arguments, JSValueRef* exception) {
|
JSValueRef JSObjectCallAsFunctionCallback_89f9469b(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, unsigned long int argumentCount, JSValueRef* arguments, JSValueRef* exception) {
|
||||||
return jSObjectCallAsFunctionCallback89F9469B(ctx, function, thisObject, argumentCount, arguments, exception);
|
return jSObjectCallAsFunctionCallback89F9469B(ctx, function, thisObject, argumentCount, arguments, exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JSValueRef JSObjectCallAsFunctionCallbackEx_9f036e3c(JSContextRef ctx, JSClassRef jsClass, JSStringRef className, JSObjectRef function, JSObjectRef thisObject, unsigned long int argumentCount, JSValueRef* arguments, JSValueRef* exception) {
|
||||||
|
return jSObjectCallAsFunctionCallbackEx9F036E3C(ctx, jsClass, className, function, thisObject, argumentCount, arguments, exception);
|
||||||
|
}
|
||||||
|
|
||||||
JSObjectRef JSObjectCallAsConstructorCallback_45f4b71f(JSContextRef ctx, JSObjectRef constructor, unsigned long int argumentCount, JSValueRef* arguments, JSValueRef* exception) {
|
JSObjectRef JSObjectCallAsConstructorCallback_45f4b71f(JSContextRef ctx, JSObjectRef constructor, unsigned long int argumentCount, JSValueRef* arguments, JSValueRef* exception) {
|
||||||
return jSObjectCallAsConstructorCallback45F4B71F(ctx, constructor, argumentCount, arguments, exception);
|
return jSObjectCallAsConstructorCallback45F4B71F(ctx, constructor, argumentCount, arguments, exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JSObjectRef JSObjectCallAsConstructorCallbackEx_a563df4(JSContextRef ctx, JSClassRef jsClass, JSObjectRef constructor, unsigned long int argumentCount, JSValueRef* arguments, JSValueRef* exception) {
|
||||||
|
return jSObjectCallAsConstructorCallbackExA563DF4(ctx, jsClass, constructor, argumentCount, arguments, exception);
|
||||||
|
}
|
||||||
|
|
||||||
_Bool JSObjectHasInstanceCallback_aa527d2e(JSContextRef ctx, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception) {
|
_Bool JSObjectHasInstanceCallback_aa527d2e(JSContextRef ctx, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception) {
|
||||||
return jSObjectHasInstanceCallbackAA527D2E(ctx, constructor, possibleInstance, exception);
|
return jSObjectHasInstanceCallbackAA527D2E(ctx, constructor, possibleInstance, exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_Bool JSObjectHasInstanceCallbackEx_b7bafe4e(JSContextRef ctx, JSClassRef jsClass, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception) {
|
||||||
|
return jSObjectHasInstanceCallbackExB7BAFE4E(ctx, jsClass, constructor, possibleInstance, exception);
|
||||||
|
}
|
||||||
|
|
||||||
JSValueRef JSObjectConvertToTypeCallback_d379d61c(JSContextRef ctx, JSObjectRef object, JSType _type, JSValueRef* exception) {
|
JSValueRef JSObjectConvertToTypeCallback_d379d61c(JSContextRef ctx, JSObjectRef object, JSType _type, JSValueRef* exception) {
|
||||||
return jSObjectConvertToTypeCallbackD379D61C(ctx, object, _type, exception);
|
return jSObjectConvertToTypeCallbackD379D61C(ctx, object, _type, exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JSValueRef JSObjectConvertToTypeCallbackEx_1bcea974(JSContextRef ctx, JSClassRef jsClass, JSObjectRef object, JSType _type, JSValueRef* exception) {
|
||||||
|
return jSObjectConvertToTypeCallbackEx1BCEA974(ctx, jsClass, object, _type, exception);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,6 +1,6 @@
|
||||||
// THE AUTOGENERATED LICENSE. ALL THE RIGHTS ARE RESERVED BY ROBOTS.
|
// THE AUTOGENERATED LICENSE. ALL THE RIGHTS ARE RESERVED BY ROBOTS.
|
||||||
|
|
||||||
// WARNING: This file has automatically been generated on Mon, 07 Oct 2019 13:59:36 CDT.
|
// WARNING: This file has automatically been generated on Sun, 02 Oct 2022 19:40:55 PDT.
|
||||||
// Code generated by https://git.io/c-for-go. DO NOT EDIT.
|
// Code generated by https://git.io/c-for-go. DO NOT EDIT.
|
||||||
|
|
||||||
#include "AppCore/CAPI.h"
|
#include "AppCore/CAPI.h"
|
||||||
|
@ -33,17 +33,125 @@ void ULChangeCursorCallback_1a7011df(void* user_data, ULView caller, ULCursor cu
|
||||||
// ULAddConsoleMessageCallback_44b8dd01 is a proxy for callback ULAddConsoleMessageCallback.
|
// ULAddConsoleMessageCallback_44b8dd01 is a proxy for callback ULAddConsoleMessageCallback.
|
||||||
void ULAddConsoleMessageCallback_44b8dd01(void* user_data, ULView caller, ULMessageSource source, ULMessageLevel level, ULString message, unsigned int line_number, unsigned int column_number, ULString source_id);
|
void ULAddConsoleMessageCallback_44b8dd01(void* user_data, ULView caller, ULMessageSource source, ULMessageLevel level, ULString message, unsigned int line_number, unsigned int column_number, ULString source_id);
|
||||||
|
|
||||||
|
// ULCreateChildViewCallback_ef6d2cdd is a proxy for callback ULCreateChildViewCallback.
|
||||||
|
ULView ULCreateChildViewCallback_ef6d2cdd(void* user_data, ULView caller, ULString opener_url, ULString target_url, _Bool is_popup, ULIntRect popup_rect);
|
||||||
|
|
||||||
// ULBeginLoadingCallback_70d8c0ad is a proxy for callback ULBeginLoadingCallback.
|
// ULBeginLoadingCallback_70d8c0ad is a proxy for callback ULBeginLoadingCallback.
|
||||||
void ULBeginLoadingCallback_70d8c0ad(void* user_data, ULView caller);
|
void ULBeginLoadingCallback_70d8c0ad(void* user_data, ULView caller, unsigned long long frame_id, _Bool is_main_frame, ULString url);
|
||||||
|
|
||||||
// ULFinishLoadingCallback_1ed4ecae is a proxy for callback ULFinishLoadingCallback.
|
// ULFinishLoadingCallback_1ed4ecae is a proxy for callback ULFinishLoadingCallback.
|
||||||
void ULFinishLoadingCallback_1ed4ecae(void* user_data, ULView caller);
|
void ULFinishLoadingCallback_1ed4ecae(void* user_data, ULView caller, unsigned long long frame_id, _Bool is_main_frame, ULString url);
|
||||||
|
|
||||||
|
// ULFailLoadingCallback_55ff90b8 is a proxy for callback ULFailLoadingCallback.
|
||||||
|
void ULFailLoadingCallback_55ff90b8(void* user_data, ULView caller, unsigned long long frame_id, _Bool is_main_frame, ULString url, ULString description, ULString error_domain, int error_code);
|
||||||
|
|
||||||
|
// ULWindowObjectReadyCallback_66dc25f3 is a proxy for callback ULWindowObjectReadyCallback.
|
||||||
|
void ULWindowObjectReadyCallback_66dc25f3(void* user_data, ULView caller, unsigned long long frame_id, _Bool is_main_frame, ULString url);
|
||||||
|
|
||||||
|
// ULDOMReadyCallback_6432c207 is a proxy for callback ULDOMReadyCallback.
|
||||||
|
void ULDOMReadyCallback_6432c207(void* user_data, ULView caller, unsigned long long frame_id, _Bool is_main_frame, ULString url);
|
||||||
|
|
||||||
// ULUpdateHistoryCallback_6e105364 is a proxy for callback ULUpdateHistoryCallback.
|
// ULUpdateHistoryCallback_6e105364 is a proxy for callback ULUpdateHistoryCallback.
|
||||||
void ULUpdateHistoryCallback_6e105364(void* user_data, ULView caller);
|
void ULUpdateHistoryCallback_6e105364(void* user_data, ULView caller);
|
||||||
|
|
||||||
// ULDOMReadyCallback_6432c207 is a proxy for callback ULDOMReadyCallback.
|
// ULSurfaceDefinitionCreateCallback_573ec115 is a proxy for callback ULSurfaceDefinitionCreateCallback.
|
||||||
void ULDOMReadyCallback_6432c207(void* user_data, ULView caller);
|
void* ULSurfaceDefinitionCreateCallback_573ec115(unsigned int width, unsigned int height);
|
||||||
|
|
||||||
|
// ULSurfaceDefinitionDestroyCallback_851bacee is a proxy for callback ULSurfaceDefinitionDestroyCallback.
|
||||||
|
void ULSurfaceDefinitionDestroyCallback_851bacee(void* user_data);
|
||||||
|
|
||||||
|
// ULSurfaceDefinitionGetWidthCallback_1a49a8fd is a proxy for callback ULSurfaceDefinitionGetWidthCallback.
|
||||||
|
unsigned int ULSurfaceDefinitionGetWidthCallback_1a49a8fd(void* user_data);
|
||||||
|
|
||||||
|
// ULSurfaceDefinitionGetHeightCallback_3e5fe408 is a proxy for callback ULSurfaceDefinitionGetHeightCallback.
|
||||||
|
unsigned int ULSurfaceDefinitionGetHeightCallback_3e5fe408(void* user_data);
|
||||||
|
|
||||||
|
// ULSurfaceDefinitionGetRowBytesCallback_adcc8668 is a proxy for callback ULSurfaceDefinitionGetRowBytesCallback.
|
||||||
|
unsigned int ULSurfaceDefinitionGetRowBytesCallback_adcc8668(void* user_data);
|
||||||
|
|
||||||
|
// ULSurfaceDefinitionGetSizeCallback_83184afe is a proxy for callback ULSurfaceDefinitionGetSizeCallback.
|
||||||
|
unsigned long int ULSurfaceDefinitionGetSizeCallback_83184afe(void* user_data);
|
||||||
|
|
||||||
|
// ULSurfaceDefinitionLockPixelsCallback_7763e12f is a proxy for callback ULSurfaceDefinitionLockPixelsCallback.
|
||||||
|
void* ULSurfaceDefinitionLockPixelsCallback_7763e12f(void* user_data);
|
||||||
|
|
||||||
|
// ULSurfaceDefinitionUnlockPixelsCallback_d4b69f9 is a proxy for callback ULSurfaceDefinitionUnlockPixelsCallback.
|
||||||
|
void ULSurfaceDefinitionUnlockPixelsCallback_d4b69f9(void* user_data);
|
||||||
|
|
||||||
|
// ULSurfaceDefinitionResizeCallback_22d82567 is a proxy for callback ULSurfaceDefinitionResizeCallback.
|
||||||
|
void ULSurfaceDefinitionResizeCallback_22d82567(void* user_data, unsigned int width, unsigned int height);
|
||||||
|
|
||||||
|
// ULFileSystemFileExistsCallback_d03bf100 is a proxy for callback ULFileSystemFileExistsCallback.
|
||||||
|
_Bool ULFileSystemFileExistsCallback_d03bf100(ULString path);
|
||||||
|
|
||||||
|
// ULFileSystemGetFileSizeCallback_e87ad8b1 is a proxy for callback ULFileSystemGetFileSizeCallback.
|
||||||
|
_Bool ULFileSystemGetFileSizeCallback_e87ad8b1(int handle, long long* result);
|
||||||
|
|
||||||
|
// ULFileSystemGetFileMimeTypeCallback_7e6fd322 is a proxy for callback ULFileSystemGetFileMimeTypeCallback.
|
||||||
|
_Bool ULFileSystemGetFileMimeTypeCallback_7e6fd322(ULString path, ULString result);
|
||||||
|
|
||||||
|
// ULFileSystemOpenFileCallback_bbb19604 is a proxy for callback ULFileSystemOpenFileCallback.
|
||||||
|
int ULFileSystemOpenFileCallback_bbb19604(ULString path, _Bool open_for_writing);
|
||||||
|
|
||||||
|
// ULFileSystemCloseFileCallback_c90ac2e5 is a proxy for callback ULFileSystemCloseFileCallback.
|
||||||
|
void ULFileSystemCloseFileCallback_c90ac2e5(int handle);
|
||||||
|
|
||||||
|
// ULFileSystemReadFromFileCallback_bc1997bc is a proxy for callback ULFileSystemReadFromFileCallback.
|
||||||
|
long long ULFileSystemReadFromFileCallback_bc1997bc(int handle, char* data, long long length);
|
||||||
|
|
||||||
|
// ULLoggerLogMessageCallback_454e682a is a proxy for callback ULLoggerLogMessageCallback.
|
||||||
|
void ULLoggerLogMessageCallback_454e682a(ULLogLevel log_level, ULString message);
|
||||||
|
|
||||||
|
// ULGPUDriverBeginSynchronizeCallback_650938c is a proxy for callback ULGPUDriverBeginSynchronizeCallback.
|
||||||
|
void ULGPUDriverBeginSynchronizeCallback_650938c();
|
||||||
|
|
||||||
|
// ULGPUDriverEndSynchronizeCallback_f6baad4d is a proxy for callback ULGPUDriverEndSynchronizeCallback.
|
||||||
|
void ULGPUDriverEndSynchronizeCallback_f6baad4d();
|
||||||
|
|
||||||
|
// ULGPUDriverNextTextureIdCallback_7de045b4 is a proxy for callback ULGPUDriverNextTextureIdCallback.
|
||||||
|
unsigned int ULGPUDriverNextTextureIdCallback_7de045b4();
|
||||||
|
|
||||||
|
// ULGPUDriverCreateTextureCallback_a32244d8 is a proxy for callback ULGPUDriverCreateTextureCallback.
|
||||||
|
void ULGPUDriverCreateTextureCallback_a32244d8(unsigned int texture_id, ULBitmap bitmap);
|
||||||
|
|
||||||
|
// ULGPUDriverUpdateTextureCallback_3d7a526 is a proxy for callback ULGPUDriverUpdateTextureCallback.
|
||||||
|
void ULGPUDriverUpdateTextureCallback_3d7a526(unsigned int texture_id, ULBitmap bitmap);
|
||||||
|
|
||||||
|
// ULGPUDriverDestroyTextureCallback_a8eea310 is a proxy for callback ULGPUDriverDestroyTextureCallback.
|
||||||
|
void ULGPUDriverDestroyTextureCallback_a8eea310(unsigned int texture_id);
|
||||||
|
|
||||||
|
// ULGPUDriverNextRenderBufferIdCallback_bfeb3fb8 is a proxy for callback ULGPUDriverNextRenderBufferIdCallback.
|
||||||
|
unsigned int ULGPUDriverNextRenderBufferIdCallback_bfeb3fb8();
|
||||||
|
|
||||||
|
// ULGPUDriverCreateRenderBufferCallback_68ee5367 is a proxy for callback ULGPUDriverCreateRenderBufferCallback.
|
||||||
|
void ULGPUDriverCreateRenderBufferCallback_68ee5367(unsigned int render_buffer_id, ULRenderBuffer buffer);
|
||||||
|
|
||||||
|
// ULGPUDriverDestroyRenderBufferCallback_81623f13 is a proxy for callback ULGPUDriverDestroyRenderBufferCallback.
|
||||||
|
void ULGPUDriverDestroyRenderBufferCallback_81623f13(unsigned int render_buffer_id);
|
||||||
|
|
||||||
|
// ULGPUDriverNextGeometryIdCallback_5f2a8fea is a proxy for callback ULGPUDriverNextGeometryIdCallback.
|
||||||
|
unsigned int ULGPUDriverNextGeometryIdCallback_5f2a8fea();
|
||||||
|
|
||||||
|
// ULGPUDriverCreateGeometryCallback_5957236d is a proxy for callback ULGPUDriverCreateGeometryCallback.
|
||||||
|
void ULGPUDriverCreateGeometryCallback_5957236d(unsigned int geometry_id, ULVertexBuffer vertices, ULIndexBuffer indices);
|
||||||
|
|
||||||
|
// ULGPUDriverUpdateGeometryCallback_3f20997 is a proxy for callback ULGPUDriverUpdateGeometryCallback.
|
||||||
|
void ULGPUDriverUpdateGeometryCallback_3f20997(unsigned int geometry_id, ULVertexBuffer vertices, ULIndexBuffer indices);
|
||||||
|
|
||||||
|
// ULGPUDriverDestroyGeometryCallback_cce3a508 is a proxy for callback ULGPUDriverDestroyGeometryCallback.
|
||||||
|
void ULGPUDriverDestroyGeometryCallback_cce3a508(unsigned int geometry_id);
|
||||||
|
|
||||||
|
// ULGPUDriverUpdateCommandListCallback_d3815a9e is a proxy for callback ULGPUDriverUpdateCommandListCallback.
|
||||||
|
void ULGPUDriverUpdateCommandListCallback_d3815a9e(ULCommandList list);
|
||||||
|
|
||||||
|
// ULClipboardClearCallback_eda3036a is a proxy for callback ULClipboardClearCallback.
|
||||||
|
void ULClipboardClearCallback_eda3036a();
|
||||||
|
|
||||||
|
// ULClipboardReadPlainTextCallback_fedfb2b6 is a proxy for callback ULClipboardReadPlainTextCallback.
|
||||||
|
void ULClipboardReadPlainTextCallback_fedfb2b6(ULString result);
|
||||||
|
|
||||||
|
// ULClipboardWritePlainTextCallback_6e8e0ca4 is a proxy for callback ULClipboardWritePlainTextCallback.
|
||||||
|
void ULClipboardWritePlainTextCallback_6e8e0ca4(ULString text);
|
||||||
|
|
||||||
// JSTypedArrayBytesDeallocator_68d51f83 is a proxy for callback JSTypedArrayBytesDeallocator.
|
// JSTypedArrayBytesDeallocator_68d51f83 is a proxy for callback JSTypedArrayBytesDeallocator.
|
||||||
void JSTypedArrayBytesDeallocator_68d51f83(void* bytes, void* deallocatorContext);
|
void JSTypedArrayBytesDeallocator_68d51f83(void* bytes, void* deallocatorContext);
|
||||||
|
@ -51,33 +159,66 @@ void JSTypedArrayBytesDeallocator_68d51f83(void* bytes, void* deallocatorContext
|
||||||
// JSObjectInitializeCallback_5793b16 is a proxy for callback JSObjectInitializeCallback.
|
// JSObjectInitializeCallback_5793b16 is a proxy for callback JSObjectInitializeCallback.
|
||||||
void JSObjectInitializeCallback_5793b16(JSContextRef ctx, JSObjectRef object);
|
void JSObjectInitializeCallback_5793b16(JSContextRef ctx, JSObjectRef object);
|
||||||
|
|
||||||
|
// JSObjectInitializeCallbackEx_3f9a093b is a proxy for callback JSObjectInitializeCallbackEx.
|
||||||
|
void JSObjectInitializeCallbackEx_3f9a093b(JSContextRef ctx, JSClassRef jsClass, JSObjectRef object);
|
||||||
|
|
||||||
// JSObjectFinalizeCallback_93da0aea is a proxy for callback JSObjectFinalizeCallback.
|
// JSObjectFinalizeCallback_93da0aea is a proxy for callback JSObjectFinalizeCallback.
|
||||||
void JSObjectFinalizeCallback_93da0aea(JSObjectRef object);
|
void JSObjectFinalizeCallback_93da0aea(JSObjectRef object);
|
||||||
|
|
||||||
|
// JSObjectFinalizeCallbackEx_d64d3113 is a proxy for callback JSObjectFinalizeCallbackEx.
|
||||||
|
void JSObjectFinalizeCallbackEx_d64d3113(JSClassRef jsClass, JSObjectRef object);
|
||||||
|
|
||||||
// JSObjectHasPropertyCallback_340bfa95 is a proxy for callback JSObjectHasPropertyCallback.
|
// JSObjectHasPropertyCallback_340bfa95 is a proxy for callback JSObjectHasPropertyCallback.
|
||||||
_Bool JSObjectHasPropertyCallback_340bfa95(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName);
|
_Bool JSObjectHasPropertyCallback_340bfa95(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName);
|
||||||
|
|
||||||
|
// JSObjectHasPropertyCallbackEx_c35701e7 is a proxy for callback JSObjectHasPropertyCallbackEx.
|
||||||
|
_Bool JSObjectHasPropertyCallbackEx_c35701e7(JSContextRef ctx, JSClassRef jsClass, JSObjectRef object, JSStringRef propertyName);
|
||||||
|
|
||||||
// JSObjectGetPropertyCallback_5caec716 is a proxy for callback JSObjectGetPropertyCallback.
|
// JSObjectGetPropertyCallback_5caec716 is a proxy for callback JSObjectGetPropertyCallback.
|
||||||
JSValueRef JSObjectGetPropertyCallback_5caec716(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
|
JSValueRef JSObjectGetPropertyCallback_5caec716(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
|
||||||
|
|
||||||
|
// JSObjectGetPropertyCallbackEx_8b91eedb is a proxy for callback JSObjectGetPropertyCallbackEx.
|
||||||
|
JSValueRef JSObjectGetPropertyCallbackEx_8b91eedb(JSContextRef ctx, JSClassRef jsClass, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
|
||||||
|
|
||||||
// JSObjectSetPropertyCallback_a684f1fe is a proxy for callback JSObjectSetPropertyCallback.
|
// JSObjectSetPropertyCallback_a684f1fe is a proxy for callback JSObjectSetPropertyCallback.
|
||||||
_Bool JSObjectSetPropertyCallback_a684f1fe(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSValueRef* exception);
|
_Bool JSObjectSetPropertyCallback_a684f1fe(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSValueRef* exception);
|
||||||
|
|
||||||
|
// JSObjectSetPropertyCallbackEx_d28cf88c is a proxy for callback JSObjectSetPropertyCallbackEx.
|
||||||
|
_Bool JSObjectSetPropertyCallbackEx_d28cf88c(JSContextRef ctx, JSClassRef jsClass, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSValueRef* exception);
|
||||||
|
|
||||||
// JSObjectDeletePropertyCallback_b0108ebe is a proxy for callback JSObjectDeletePropertyCallback.
|
// JSObjectDeletePropertyCallback_b0108ebe is a proxy for callback JSObjectDeletePropertyCallback.
|
||||||
_Bool JSObjectDeletePropertyCallback_b0108ebe(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
|
_Bool JSObjectDeletePropertyCallback_b0108ebe(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
|
||||||
|
|
||||||
|
// JSObjectDeletePropertyCallbackEx_e24fcdb0 is a proxy for callback JSObjectDeletePropertyCallbackEx.
|
||||||
|
_Bool JSObjectDeletePropertyCallbackEx_e24fcdb0(JSContextRef ctx, JSClassRef jsClass, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
|
||||||
|
|
||||||
// JSObjectGetPropertyNamesCallback_e77d2329 is a proxy for callback JSObjectGetPropertyNamesCallback.
|
// JSObjectGetPropertyNamesCallback_e77d2329 is a proxy for callback JSObjectGetPropertyNamesCallback.
|
||||||
void JSObjectGetPropertyNamesCallback_e77d2329(JSContextRef ctx, JSObjectRef object, JSPropertyNameAccumulatorRef propertyNames);
|
void JSObjectGetPropertyNamesCallback_e77d2329(JSContextRef ctx, JSObjectRef object, JSPropertyNameAccumulatorRef propertyNames);
|
||||||
|
|
||||||
|
// JSObjectGetPropertyNamesCallbackEx_74285955 is a proxy for callback JSObjectGetPropertyNamesCallbackEx.
|
||||||
|
void JSObjectGetPropertyNamesCallbackEx_74285955(JSContextRef ctx, JSClassRef jsClass, JSObjectRef object, JSPropertyNameAccumulatorRef propertyNames);
|
||||||
|
|
||||||
// JSObjectCallAsFunctionCallback_89f9469b is a proxy for callback JSObjectCallAsFunctionCallback.
|
// JSObjectCallAsFunctionCallback_89f9469b is a proxy for callback JSObjectCallAsFunctionCallback.
|
||||||
JSValueRef JSObjectCallAsFunctionCallback_89f9469b(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, unsigned long int argumentCount, JSValueRef* arguments, JSValueRef* exception);
|
JSValueRef JSObjectCallAsFunctionCallback_89f9469b(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, unsigned long int argumentCount, JSValueRef* arguments, JSValueRef* exception);
|
||||||
|
|
||||||
|
// JSObjectCallAsFunctionCallbackEx_9f036e3c is a proxy for callback JSObjectCallAsFunctionCallbackEx.
|
||||||
|
JSValueRef JSObjectCallAsFunctionCallbackEx_9f036e3c(JSContextRef ctx, JSClassRef jsClass, JSStringRef className, JSObjectRef function, JSObjectRef thisObject, unsigned long int argumentCount, JSValueRef* arguments, JSValueRef* exception);
|
||||||
|
|
||||||
// JSObjectCallAsConstructorCallback_45f4b71f is a proxy for callback JSObjectCallAsConstructorCallback.
|
// JSObjectCallAsConstructorCallback_45f4b71f is a proxy for callback JSObjectCallAsConstructorCallback.
|
||||||
JSObjectRef JSObjectCallAsConstructorCallback_45f4b71f(JSContextRef ctx, JSObjectRef constructor, unsigned long int argumentCount, JSValueRef* arguments, JSValueRef* exception);
|
JSObjectRef JSObjectCallAsConstructorCallback_45f4b71f(JSContextRef ctx, JSObjectRef constructor, unsigned long int argumentCount, JSValueRef* arguments, JSValueRef* exception);
|
||||||
|
|
||||||
|
// JSObjectCallAsConstructorCallbackEx_a563df4 is a proxy for callback JSObjectCallAsConstructorCallbackEx.
|
||||||
|
JSObjectRef JSObjectCallAsConstructorCallbackEx_a563df4(JSContextRef ctx, JSClassRef jsClass, JSObjectRef constructor, unsigned long int argumentCount, JSValueRef* arguments, JSValueRef* exception);
|
||||||
|
|
||||||
// JSObjectHasInstanceCallback_aa527d2e is a proxy for callback JSObjectHasInstanceCallback.
|
// JSObjectHasInstanceCallback_aa527d2e is a proxy for callback JSObjectHasInstanceCallback.
|
||||||
_Bool JSObjectHasInstanceCallback_aa527d2e(JSContextRef ctx, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception);
|
_Bool JSObjectHasInstanceCallback_aa527d2e(JSContextRef ctx, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception);
|
||||||
|
|
||||||
|
// JSObjectHasInstanceCallbackEx_b7bafe4e is a proxy for callback JSObjectHasInstanceCallbackEx.
|
||||||
|
_Bool JSObjectHasInstanceCallbackEx_b7bafe4e(JSContextRef ctx, JSClassRef jsClass, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception);
|
||||||
|
|
||||||
// JSObjectConvertToTypeCallback_d379d61c is a proxy for callback JSObjectConvertToTypeCallback.
|
// JSObjectConvertToTypeCallback_d379d61c is a proxy for callback JSObjectConvertToTypeCallback.
|
||||||
JSValueRef JSObjectConvertToTypeCallback_d379d61c(JSContextRef ctx, JSObjectRef object, JSType _type, JSValueRef* exception);
|
JSValueRef JSObjectConvertToTypeCallback_d379d61c(JSContextRef ctx, JSObjectRef object, JSType _type, JSValueRef* exception);
|
||||||
|
|
||||||
|
// JSObjectConvertToTypeCallbackEx_1bcea974 is a proxy for callback JSObjectConvertToTypeCallbackEx.
|
||||||
|
JSValueRef JSObjectConvertToTypeCallbackEx_1bcea974(JSContextRef ctx, JSClassRef jsClass, JSObjectRef object, JSType _type, JSValueRef* exception);
|
||||||
|
|
||||||
|
|
|
@ -1,17 +1,13 @@
|
||||||
// THE AUTOGENERATED LICENSE. ALL THE RIGHTS ARE RESERVED BY ROBOTS.
|
// THE AUTOGENERATED LICENSE. ALL THE RIGHTS ARE RESERVED BY ROBOTS.
|
||||||
|
|
||||||
// WARNING: This file has automatically been generated on Mon, 07 Oct 2019 13:59:36 CDT.
|
// WARNING: This file has automatically been generated on Sun, 02 Oct 2022 19:40:55 PDT.
|
||||||
// Code generated by https://git.io/c-for-go. DO NOT EDIT.
|
// Code generated by https://git.io/c-for-go. DO NOT EDIT.
|
||||||
|
|
||||||
package ultralight
|
package ultralight
|
||||||
|
|
||||||
/*
|
/*
|
||||||
#cgo CFLAGS: -I../include
|
#cgo CFLAGS: -I../include
|
||||||
#cgo windows,386 LDFLAGS: -L${SRCDIR}/libs/windows/x32
|
#cgo LDFLAGS: -Wl,--allow-multiple-definition -L${SRCDIR}/libs/linux/x64 -Wl,-rpath,/home/co/code/Muon/ultralight/libs/linux/x64 -lUltralightCore -lAppCore -lUltralight -lWebCore
|
||||||
#cgo windows,amd64 LDFLAGS: -L${SRCDIR}/libs/windows/x64
|
|
||||||
#cgo darwin,amd64 LDFLAGS: -L${SRCDIR}/libs/darwin/x64
|
|
||||||
#cgo linux,amd64 LDFLAGS: -L${SRCDIR}/libs/linux/x64
|
|
||||||
#cgo LDFLAGS: -lUltralightCore -lWebCore -lUltralight -lAppCore
|
|
||||||
#include "AppCore/CAPI.h"
|
#include "AppCore/CAPI.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "cgo_helpers.h"
|
#include "cgo_helpers.h"
|
||||||
|
@ -19,8 +15,8 @@ package ultralight
|
||||||
import "C"
|
import "C"
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// JSC_OBJC_API_ENABLED as defined in JavaScriptCore/JSBase.h:141
|
// JSCOBJCAPIENABLED as defined in JavaScriptCore/JSBase.h:151
|
||||||
JSC_OBJC_API_ENABLED = 0
|
JSCOBJCAPIENABLED = 0
|
||||||
)
|
)
|
||||||
|
|
||||||
// ULWindowFlags as declared in AppCore/CAPI.h:47
|
// ULWindowFlags as declared in AppCore/CAPI.h:47
|
||||||
|
@ -28,147 +24,203 @@ type ULWindowFlags int32
|
||||||
|
|
||||||
// ULWindowFlags enumeration from AppCore/CAPI.h:47
|
// ULWindowFlags enumeration from AppCore/CAPI.h:47
|
||||||
const (
|
const (
|
||||||
KWindowFlags_Borderless ULWindowFlags = 1
|
KWindowFlagsBorderless ULWindowFlags = 1
|
||||||
KWindowFlags_Titled ULWindowFlags = 2
|
KWindowFlagsTitled ULWindowFlags = 2
|
||||||
KWindowFlags_Resizable ULWindowFlags = 4
|
KWindowFlagsResizable ULWindowFlags = 4
|
||||||
KWindowFlags_Maximizable ULWindowFlags = 8
|
KWindowFlagsMaximizable ULWindowFlags = 8
|
||||||
)
|
)
|
||||||
|
|
||||||
// ULMessageSource as declared in Ultralight/CAPI.h:73
|
// ULMessageSource as declared in Ultralight/CAPI.h:75
|
||||||
type ULMessageSource int32
|
type ULMessageSource int32
|
||||||
|
|
||||||
// ULMessageSource enumeration from Ultralight/CAPI.h:73
|
// ULMessageSource enumeration from Ultralight/CAPI.h:75
|
||||||
const (
|
const (
|
||||||
KMessageSource_XML ULMessageSource = iota
|
KMessageSourceXML ULMessageSource = iota
|
||||||
KMessageSource_JS ULMessageSource = 1
|
KMessageSourceJS ULMessageSource = 1
|
||||||
KMessageSource_Network ULMessageSource = 2
|
KMessageSourceNetwork ULMessageSource = 2
|
||||||
KMessageSource_ConsoleAPI ULMessageSource = 3
|
KMessageSourceConsoleAPI ULMessageSource = 3
|
||||||
KMessageSource_Storage ULMessageSource = 4
|
KMessageSourceStorage ULMessageSource = 4
|
||||||
KMessageSource_AppCache ULMessageSource = 5
|
KMessageSourceAppCache ULMessageSource = 5
|
||||||
KMessageSource_Rendering ULMessageSource = 6
|
KMessageSourceRendering ULMessageSource = 6
|
||||||
KMessageSource_CSS ULMessageSource = 7
|
KMessageSourceCSS ULMessageSource = 7
|
||||||
KMessageSource_Security ULMessageSource = 8
|
KMessageSourceSecurity ULMessageSource = 8
|
||||||
KMessageSource_ContentBlocker ULMessageSource = 9
|
KMessageSourceContentBlocker ULMessageSource = 9
|
||||||
KMessageSource_Other ULMessageSource = 10
|
KMessageSourceOther ULMessageSource = 10
|
||||||
)
|
)
|
||||||
|
|
||||||
// ULMessageLevel as declared in Ultralight/CAPI.h:81
|
// ULMessageLevel as declared in Ultralight/CAPI.h:83
|
||||||
type ULMessageLevel int32
|
type ULMessageLevel int32
|
||||||
|
|
||||||
// ULMessageLevel enumeration from Ultralight/CAPI.h:81
|
// ULMessageLevel enumeration from Ultralight/CAPI.h:83
|
||||||
const (
|
const (
|
||||||
KMessageLevel_Log ULMessageLevel = 1
|
KMessageLevelLog ULMessageLevel = 1
|
||||||
KMessageLevel_Warning ULMessageLevel = 2
|
KMessageLevelWarning ULMessageLevel = 2
|
||||||
KMessageLevel_Error ULMessageLevel = 3
|
KMessageLevelError ULMessageLevel = 3
|
||||||
KMessageLevel_Debug ULMessageLevel = 4
|
KMessageLevelDebug ULMessageLevel = 4
|
||||||
KMessageLevel_Info ULMessageLevel = 5
|
KMessageLevelInfo ULMessageLevel = 5
|
||||||
)
|
)
|
||||||
|
|
||||||
// ULCursor as declared in Ultralight/CAPI.h:128
|
// ULCursor as declared in Ultralight/CAPI.h:130
|
||||||
type ULCursor int32
|
type ULCursor int32
|
||||||
|
|
||||||
// ULCursor enumeration from Ultralight/CAPI.h:128
|
// ULCursor enumeration from Ultralight/CAPI.h:130
|
||||||
const (
|
const (
|
||||||
KCursor_Pointer ULCursor = iota
|
KCursorPointer ULCursor = iota
|
||||||
KCursor_Cross ULCursor = 1
|
KCursorCross ULCursor = 1
|
||||||
KCursor_Hand ULCursor = 2
|
KCursorHand ULCursor = 2
|
||||||
KCursor_IBeam ULCursor = 3
|
KCursorIBeam ULCursor = 3
|
||||||
KCursor_Wait ULCursor = 4
|
KCursorWait ULCursor = 4
|
||||||
KCursor_Help ULCursor = 5
|
KCursorHelp ULCursor = 5
|
||||||
KCursor_EastResize ULCursor = 6
|
KCursorEastResize ULCursor = 6
|
||||||
KCursor_NorthResize ULCursor = 7
|
KCursorNorthResize ULCursor = 7
|
||||||
KCursor_NorthEastResize ULCursor = 8
|
KCursorNorthEastResize ULCursor = 8
|
||||||
KCursor_NorthWestResize ULCursor = 9
|
KCursorNorthWestResize ULCursor = 9
|
||||||
KCursor_SouthResize ULCursor = 10
|
KCursorSouthResize ULCursor = 10
|
||||||
KCursor_SouthEastResize ULCursor = 11
|
KCursorSouthEastResize ULCursor = 11
|
||||||
KCursor_SouthWestResize ULCursor = 12
|
KCursorSouthWestResize ULCursor = 12
|
||||||
KCursor_WestResize ULCursor = 13
|
KCursorWestResize ULCursor = 13
|
||||||
KCursor_NorthSouthResize ULCursor = 14
|
KCursorNorthSouthResize ULCursor = 14
|
||||||
KCursor_EastWestResize ULCursor = 15
|
KCursorEastWestResize ULCursor = 15
|
||||||
KCursor_NorthEastSouthWestResize ULCursor = 16
|
KCursorNorthEastSouthWestResize ULCursor = 16
|
||||||
KCursor_NorthWestSouthEastResize ULCursor = 17
|
KCursorNorthWestSouthEastResize ULCursor = 17
|
||||||
KCursor_ColumnResize ULCursor = 18
|
KCursorColumnResize ULCursor = 18
|
||||||
KCursor_RowResize ULCursor = 19
|
KCursorRowResize ULCursor = 19
|
||||||
KCursor_MiddlePanning ULCursor = 20
|
KCursorMiddlePanning ULCursor = 20
|
||||||
KCursor_EastPanning ULCursor = 21
|
KCursorEastPanning ULCursor = 21
|
||||||
KCursor_NorthPanning ULCursor = 22
|
KCursorNorthPanning ULCursor = 22
|
||||||
KCursor_NorthEastPanning ULCursor = 23
|
KCursorNorthEastPanning ULCursor = 23
|
||||||
KCursor_NorthWestPanning ULCursor = 24
|
KCursorNorthWestPanning ULCursor = 24
|
||||||
KCursor_SouthPanning ULCursor = 25
|
KCursorSouthPanning ULCursor = 25
|
||||||
KCursor_SouthEastPanning ULCursor = 26
|
KCursorSouthEastPanning ULCursor = 26
|
||||||
KCursor_SouthWestPanning ULCursor = 27
|
KCursorSouthWestPanning ULCursor = 27
|
||||||
KCursor_WestPanning ULCursor = 28
|
KCursorWestPanning ULCursor = 28
|
||||||
KCursor_Move ULCursor = 29
|
KCursorMove ULCursor = 29
|
||||||
KCursor_VerticalText ULCursor = 30
|
KCursorVerticalText ULCursor = 30
|
||||||
KCursor_Cell ULCursor = 31
|
KCursorCell ULCursor = 31
|
||||||
KCursor_ContextMenu ULCursor = 32
|
KCursorContextMenu ULCursor = 32
|
||||||
KCursor_Alias ULCursor = 33
|
KCursorAlias ULCursor = 33
|
||||||
KCursor_Progress ULCursor = 34
|
KCursorProgress ULCursor = 34
|
||||||
KCursor_NoDrop ULCursor = 35
|
KCursorNoDrop ULCursor = 35
|
||||||
KCursor_Copy ULCursor = 36
|
KCursorCopy ULCursor = 36
|
||||||
KCursor_None ULCursor = 37
|
KCursorNone ULCursor = 37
|
||||||
KCursor_NotAllowed ULCursor = 38
|
KCursorNotAllowed ULCursor = 38
|
||||||
KCursor_ZoomIn ULCursor = 39
|
KCursorZoomIn ULCursor = 39
|
||||||
KCursor_ZoomOut ULCursor = 40
|
KCursorZoomOut ULCursor = 40
|
||||||
KCursor_Grab ULCursor = 41
|
KCursorGrab ULCursor = 41
|
||||||
KCursor_Grabbing ULCursor = 42
|
KCursorGrabbing ULCursor = 42
|
||||||
KCursor_Custom ULCursor = 43
|
KCursorCustom ULCursor = 43
|
||||||
)
|
)
|
||||||
|
|
||||||
// ULBitmapFormat as declared in Ultralight/CAPI.h:133
|
// ULBitmapFormat as declared in Ultralight/CAPI.h:150
|
||||||
type ULBitmapFormat int32
|
type ULBitmapFormat int32
|
||||||
|
|
||||||
// ULBitmapFormat enumeration from Ultralight/CAPI.h:133
|
// ULBitmapFormat enumeration from Ultralight/CAPI.h:150
|
||||||
const (
|
const (
|
||||||
KBitmapFormat_A8 ULBitmapFormat = iota
|
KBitmapFormatA8UNORM ULBitmapFormat = iota
|
||||||
KBitmapFormat_RGBA8 ULBitmapFormat = 1
|
KBitmapFormatBGRA8UNORMSRGB ULBitmapFormat = 1
|
||||||
)
|
)
|
||||||
|
|
||||||
// ULKeyEventType as declared in Ultralight/CAPI.h:140
|
// ULKeyEventType as declared in Ultralight/CAPI.h:180
|
||||||
type ULKeyEventType int32
|
type ULKeyEventType int32
|
||||||
|
|
||||||
// ULKeyEventType enumeration from Ultralight/CAPI.h:140
|
// ULKeyEventType enumeration from Ultralight/CAPI.h:180
|
||||||
const (
|
const (
|
||||||
KKeyEventType_KeyDown ULKeyEventType = iota
|
KKeyEventTypeKeyDown ULKeyEventType = iota
|
||||||
KKeyEventType_KeyUp ULKeyEventType = 1
|
KKeyEventTypeKeyUp ULKeyEventType = 1
|
||||||
KKeyEventType_RawKeyDown ULKeyEventType = 2
|
KKeyEventTypeRawKeyDown ULKeyEventType = 2
|
||||||
KKeyEventType_Char ULKeyEventType = 3
|
KKeyEventTypeChar ULKeyEventType = 3
|
||||||
)
|
)
|
||||||
|
|
||||||
// ULMouseEventType as declared in Ultralight/CAPI.h:146
|
// ULMouseEventType as declared in Ultralight/CAPI.h:186
|
||||||
type ULMouseEventType int32
|
type ULMouseEventType int32
|
||||||
|
|
||||||
// ULMouseEventType enumeration from Ultralight/CAPI.h:146
|
// ULMouseEventType enumeration from Ultralight/CAPI.h:186
|
||||||
const (
|
const (
|
||||||
KMouseEventType_MouseMoved ULMouseEventType = iota
|
KMouseEventTypeMouseMoved ULMouseEventType = iota
|
||||||
KMouseEventType_MouseDown ULMouseEventType = 1
|
KMouseEventTypeMouseDown ULMouseEventType = 1
|
||||||
KMouseEventType_MouseUp ULMouseEventType = 2
|
KMouseEventTypeMouseUp ULMouseEventType = 2
|
||||||
)
|
)
|
||||||
|
|
||||||
// ULMouseButton as declared in Ultralight/CAPI.h:153
|
// ULMouseButton as declared in Ultralight/CAPI.h:193
|
||||||
type ULMouseButton int32
|
type ULMouseButton int32
|
||||||
|
|
||||||
// ULMouseButton enumeration from Ultralight/CAPI.h:153
|
// ULMouseButton enumeration from Ultralight/CAPI.h:193
|
||||||
const (
|
const (
|
||||||
KMouseButton_None ULMouseButton = iota
|
KMouseButtonNone ULMouseButton = iota
|
||||||
KMouseButton_Left ULMouseButton = 1
|
KMouseButtonLeft ULMouseButton = 1
|
||||||
KMouseButton_Middle ULMouseButton = 2
|
KMouseButtonMiddle ULMouseButton = 2
|
||||||
KMouseButton_Right ULMouseButton = 3
|
KMouseButtonRight ULMouseButton = 3
|
||||||
)
|
)
|
||||||
|
|
||||||
// ULScrollEventType as declared in Ultralight/CAPI.h:158
|
// ULScrollEventType as declared in Ultralight/CAPI.h:198
|
||||||
type ULScrollEventType int32
|
type ULScrollEventType int32
|
||||||
|
|
||||||
// ULScrollEventType enumeration from Ultralight/CAPI.h:158
|
// ULScrollEventType enumeration from Ultralight/CAPI.h:198
|
||||||
const (
|
const (
|
||||||
KScrollEventType_ScrollByPixel ULScrollEventType = iota
|
KScrollEventTypeScrollByPixel ULScrollEventType = iota
|
||||||
KScrollEventType_ScrollByPage ULScrollEventType = 1
|
KScrollEventTypeScrollByPage ULScrollEventType = 1
|
||||||
)
|
)
|
||||||
|
|
||||||
// JSType as declared in JavaScriptCore/JSValueRef.h:53
|
// ULFaceWinding as declared in Ultralight/CAPI.h:203
|
||||||
|
type ULFaceWinding int32
|
||||||
|
|
||||||
|
// ULFaceWinding enumeration from Ultralight/CAPI.h:203
|
||||||
|
const (
|
||||||
|
KFaceWindingClockwise ULFaceWinding = iota
|
||||||
|
KFaceWindowCounterClockwise ULFaceWinding = 1
|
||||||
|
)
|
||||||
|
|
||||||
|
// ULFontHinting as declared in Ultralight/CAPI.h:225
|
||||||
|
type ULFontHinting int32
|
||||||
|
|
||||||
|
// ULFontHinting enumeration from Ultralight/CAPI.h:225
|
||||||
|
const (
|
||||||
|
KFontHintingSmooth ULFontHinting = iota
|
||||||
|
KFontHintingNormal ULFontHinting = 1
|
||||||
|
KFontHintingMonochrome ULFontHinting = 2
|
||||||
|
)
|
||||||
|
|
||||||
|
// ULLogLevel as declared in Ultralight/CAPI.h:1477
|
||||||
|
type ULLogLevel int32
|
||||||
|
|
||||||
|
// ULLogLevel enumeration from Ultralight/CAPI.h:1477
|
||||||
|
const (
|
||||||
|
KLogLevelError ULLogLevel = iota
|
||||||
|
KLogLevelWarning ULLogLevel = 1
|
||||||
|
KLogLevelInfo ULLogLevel = 2
|
||||||
|
)
|
||||||
|
|
||||||
|
// ULVertexBufferFormat as declared in Ultralight/CAPI.h:1552
|
||||||
|
type ULVertexBufferFormat int32
|
||||||
|
|
||||||
|
// ULVertexBufferFormat enumeration from Ultralight/CAPI.h:1552
|
||||||
|
const (
|
||||||
|
KVertexBufferFormat2f4ub2f ULVertexBufferFormat = iota
|
||||||
|
KVertexBufferFormat2f4ub2f2f28f ULVertexBufferFormat = 1
|
||||||
|
)
|
||||||
|
|
||||||
|
// ULShaderType as declared in Ultralight/CAPI.h:1585
|
||||||
|
type ULShaderType int32
|
||||||
|
|
||||||
|
// ULShaderType enumeration from Ultralight/CAPI.h:1585
|
||||||
|
const (
|
||||||
|
KShaderTypeFill ULShaderType = iota
|
||||||
|
KShaderTypeFillPath ULShaderType = 1
|
||||||
|
)
|
||||||
|
|
||||||
|
// ULCommandType as declared in Ultralight/CAPI.h:1660
|
||||||
|
type ULCommandType int32
|
||||||
|
|
||||||
|
// ULCommandType enumeration from Ultralight/CAPI.h:1660
|
||||||
|
const (
|
||||||
|
KCommandTypeClearRenderBuffer ULCommandType = iota
|
||||||
|
KCommandTypeDrawGeometry ULCommandType = 1
|
||||||
|
)
|
||||||
|
|
||||||
|
// JSType as declared in JavaScriptCore/JSValueRef.h:55
|
||||||
type JSType int32
|
type JSType int32
|
||||||
|
|
||||||
// JSType enumeration from JavaScriptCore/JSValueRef.h:53
|
// JSType enumeration from JavaScriptCore/JSValueRef.h:55
|
||||||
const (
|
const (
|
||||||
KJSTypeUndefined JSType = iota
|
KJSTypeUndefined JSType = iota
|
||||||
KJSTypeNull JSType = 1
|
KJSTypeNull JSType = 1
|
||||||
|
@ -176,12 +228,13 @@ const (
|
||||||
KJSTypeNumber JSType = 3
|
KJSTypeNumber JSType = 3
|
||||||
KJSTypeString JSType = 4
|
KJSTypeString JSType = 4
|
||||||
KJSTypeObject JSType = 5
|
KJSTypeObject JSType = 5
|
||||||
|
KJSTypeSymbol JSType = 6
|
||||||
)
|
)
|
||||||
|
|
||||||
// JSTypedArrayType as declared in JavaScriptCore/JSValueRef.h:83
|
// JSTypedArrayType as declared in JavaScriptCore/JSValueRef.h:85
|
||||||
type JSTypedArrayType int32
|
type JSTypedArrayType int32
|
||||||
|
|
||||||
// JSTypedArrayType enumeration from JavaScriptCore/JSValueRef.h:83
|
// JSTypedArrayType enumeration from JavaScriptCore/JSValueRef.h:85
|
||||||
const (
|
const (
|
||||||
KJSTypedArrayTypeInt8Array JSTypedArrayType = iota
|
KJSTypedArrayTypeInt8Array JSTypedArrayType = iota
|
||||||
KJSTypedArrayTypeInt16Array JSTypedArrayType = 1
|
KJSTypedArrayTypeInt16Array JSTypedArrayType = 1
|
||||||
|
@ -196,6 +249,8 @@ const (
|
||||||
KJSTypedArrayTypeNone JSTypedArrayType = 10
|
KJSTypedArrayTypeNone JSTypedArrayType = 10
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// ULInvalidFileHandle as declared in Ultralight/CAPI.h:1413
|
||||||
|
const ULInvalidFileHandle ULFileHandle = -1
|
||||||
const (
|
const (
|
||||||
// KJSPropertyAttributeNone as declared in JavaScriptCore/JSObjectRef.h:51
|
// KJSPropertyAttributeNone as declared in JavaScriptCore/JSObjectRef.h:51
|
||||||
KJSPropertyAttributeNone = iota
|
KJSPropertyAttributeNone = iota
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// THE AUTOGENERATED LICENSE. ALL THE RIGHTS ARE RESERVED BY ROBOTS.
|
// THE AUTOGENERATED LICENSE. ALL THE RIGHTS ARE RESERVED BY ROBOTS.
|
||||||
|
|
||||||
// WARNING: This file has automatically been generated on Mon, 07 Oct 2019 13:59:36 CDT.
|
// WARNING: This file has automatically been generated on Sun, 02 Oct 2022 19:40:55 PDT.
|
||||||
// Code generated by https://git.io/c-for-go. DO NOT EDIT.
|
// Code generated by https://git.io/c-for-go. DO NOT EDIT.
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,17 +1,13 @@
|
||||||
// THE AUTOGENERATED LICENSE. ALL THE RIGHTS ARE RESERVED BY ROBOTS.
|
// THE AUTOGENERATED LICENSE. ALL THE RIGHTS ARE RESERVED BY ROBOTS.
|
||||||
|
|
||||||
// WARNING: This file has automatically been generated on Mon, 07 Oct 2019 13:59:36 CDT.
|
// WARNING: This file has automatically been generated on Sun, 02 Oct 2022 19:40:55 PDT.
|
||||||
// Code generated by https://git.io/c-for-go. DO NOT EDIT.
|
// Code generated by https://git.io/c-for-go. DO NOT EDIT.
|
||||||
|
|
||||||
package ultralight
|
package ultralight
|
||||||
|
|
||||||
/*
|
/*
|
||||||
#cgo CFLAGS: -I../include
|
#cgo CFLAGS: -I../include
|
||||||
#cgo windows,386 LDFLAGS: -L${SRCDIR}/libs/windows/x32
|
#cgo LDFLAGS: -Wl,--allow-multiple-definition -L${SRCDIR}/libs/linux/x64 -Wl,-rpath,/home/co/code/Muon/ultralight/libs/linux/x64 -lUltralightCore -lAppCore -lUltralight -lWebCore
|
||||||
#cgo windows,amd64 LDFLAGS: -L${SRCDIR}/libs/windows/x64
|
|
||||||
#cgo darwin,amd64 LDFLAGS: -L${SRCDIR}/libs/darwin/x64
|
|
||||||
#cgo linux,amd64 LDFLAGS: -L${SRCDIR}/libs/linux/x64
|
|
||||||
#cgo LDFLAGS: -lUltralightCore -lWebCore -lUltralight -lAppCore
|
|
||||||
#include "AppCore/CAPI.h"
|
#include "AppCore/CAPI.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "cgo_helpers.h"
|
#include "cgo_helpers.h"
|
||||||
|
@ -34,14 +30,14 @@ type ULMonitor C.ULMonitor
|
||||||
// ULOverlay as declared in AppCore/CAPI.h:37
|
// ULOverlay as declared in AppCore/CAPI.h:37
|
||||||
type ULOverlay C.ULOverlay
|
type ULOverlay C.ULOverlay
|
||||||
|
|
||||||
// ULUpdateCallback type as declared in AppCore/CAPI.h:118
|
// ULUpdateCallback type as declared in AppCore/CAPI.h:148
|
||||||
type ULUpdateCallback func(user_data unsafe.Pointer)
|
type ULUpdateCallback func(userData unsafe.Pointer)
|
||||||
|
|
||||||
// ULCloseCallback type as declared in AppCore/CAPI.h:195
|
// ULCloseCallback type as declared in AppCore/CAPI.h:225
|
||||||
type ULCloseCallback func(user_data unsafe.Pointer)
|
type ULCloseCallback func(userData unsafe.Pointer)
|
||||||
|
|
||||||
// ULResizeCallback type as declared in AppCore/CAPI.h:205
|
// ULResizeCallback type as declared in AppCore/CAPI.h:235
|
||||||
type ULResizeCallback func(user_data unsafe.Pointer, width uint32, height uint32)
|
type ULResizeCallback func(userData unsafe.Pointer, width uint32, height uint32)
|
||||||
|
|
||||||
// ULChar16 type as declared in Ultralight/CAPI.h:43
|
// ULChar16 type as declared in Ultralight/CAPI.h:43
|
||||||
type ULChar16 uint16
|
type ULChar16 uint16
|
||||||
|
@ -52,21 +48,21 @@ type ULConfig C.ULConfig
|
||||||
// ULRenderer as declared in Ultralight/CAPI.h:51
|
// ULRenderer as declared in Ultralight/CAPI.h:51
|
||||||
type ULRenderer C.ULRenderer
|
type ULRenderer C.ULRenderer
|
||||||
|
|
||||||
// ULView as declared in Ultralight/CAPI.h:52
|
// ULSession as declared in Ultralight/CAPI.h:52
|
||||||
|
type ULSession C.ULSession
|
||||||
|
|
||||||
|
// ULView as declared in Ultralight/CAPI.h:53
|
||||||
type ULView C.ULView
|
type ULView C.ULView
|
||||||
|
|
||||||
// ULBitmap as declared in Ultralight/CAPI.h:53
|
// ULBitmap as declared in Ultralight/CAPI.h:54
|
||||||
type ULBitmap C.ULBitmap
|
type ULBitmap C.ULBitmap
|
||||||
|
|
||||||
// ULString as declared in Ultralight/CAPI.h:54
|
// ULString as declared in Ultralight/CAPI.h:55
|
||||||
type ULString C.ULString
|
type ULString C.ULString
|
||||||
|
|
||||||
// ULBuffer as declared in Ultralight/CAPI.h:55
|
// ULBuffer as declared in Ultralight/CAPI.h:56
|
||||||
type ULBuffer C.ULBuffer
|
type ULBuffer C.ULBuffer
|
||||||
|
|
||||||
// ULRenderTarget as declared in Ultralight/CAPI.h:56
|
|
||||||
type ULRenderTarget C.ULRenderTarget
|
|
||||||
|
|
||||||
// ULKeyEvent as declared in Ultralight/CAPI.h:57
|
// ULKeyEvent as declared in Ultralight/CAPI.h:57
|
||||||
type ULKeyEvent C.ULKeyEvent
|
type ULKeyEvent C.ULKeyEvent
|
||||||
|
|
||||||
|
@ -76,32 +72,359 @@ type ULMouseEvent C.ULMouseEvent
|
||||||
// ULScrollEvent as declared in Ultralight/CAPI.h:59
|
// ULScrollEvent as declared in Ultralight/CAPI.h:59
|
||||||
type ULScrollEvent C.ULScrollEvent
|
type ULScrollEvent C.ULScrollEvent
|
||||||
|
|
||||||
// ULChangeTitleCallback type as declared in Ultralight/CAPI.h:409
|
// ULSurface as declared in Ultralight/CAPI.h:60
|
||||||
type ULChangeTitleCallback func(user_data unsafe.Pointer, caller ULView, title ULString)
|
type ULSurface C.ULSurface
|
||||||
|
|
||||||
// ULChangeURLCallback type as declared in Ultralight/CAPI.h:419
|
// ULBitmapSurface as declared in Ultralight/CAPI.h:61
|
||||||
type ULChangeURLCallback func(user_data unsafe.Pointer, caller ULView, url ULString)
|
type ULBitmapSurface C.ULBitmapSurface
|
||||||
|
|
||||||
// ULChangeTooltipCallback type as declared in Ultralight/CAPI.h:429
|
// ULRect as declared in Ultralight/CAPI.h:232
|
||||||
type ULChangeTooltipCallback func(user_data unsafe.Pointer, caller ULView, tooltip ULString)
|
type ULRect struct {
|
||||||
|
Left float32
|
||||||
|
Top float32
|
||||||
|
Right float32
|
||||||
|
Bottom float32
|
||||||
|
ref4622ce0c *C.ULRect
|
||||||
|
allocs4622ce0c interface{}
|
||||||
|
}
|
||||||
|
|
||||||
// ULChangeCursorCallback type as declared in Ultralight/CAPI.h:439
|
// ULIntRect as declared in Ultralight/CAPI.h:239
|
||||||
type ULChangeCursorCallback func(user_data unsafe.Pointer, caller ULView, cursor ULCursor)
|
type ULIntRect struct {
|
||||||
|
Left int32
|
||||||
|
Top int32
|
||||||
|
Right int32
|
||||||
|
Bottom int32
|
||||||
|
ref79619c19 *C.ULIntRect
|
||||||
|
allocs79619c19 interface{}
|
||||||
|
}
|
||||||
|
|
||||||
// ULAddConsoleMessageCallback type as declared in Ultralight/CAPI.h:449
|
// ULRenderTarget as declared in Ultralight/CAPI.h:251
|
||||||
type ULAddConsoleMessageCallback func(user_data unsafe.Pointer, caller ULView, source ULMessageSource, level ULMessageLevel, message ULString, line_number uint32, column_number uint32, source_id ULString)
|
type ULRenderTarget struct {
|
||||||
|
IsEmpty bool
|
||||||
|
Width uint32
|
||||||
|
Height uint32
|
||||||
|
TextureId uint32
|
||||||
|
TextureWidth uint32
|
||||||
|
TextureHeight uint32
|
||||||
|
TextureFormat ULBitmapFormat
|
||||||
|
UvCoords ULRect
|
||||||
|
RenderBufferId uint32
|
||||||
|
ref79bb0a51 *C.ULRenderTarget
|
||||||
|
allocs79bb0a51 interface{}
|
||||||
|
}
|
||||||
|
|
||||||
// ULBeginLoadingCallback type as declared in Ultralight/CAPI.h:464
|
// ULChangeTitleCallback type as declared in Ultralight/CAPI.h:757
|
||||||
type ULBeginLoadingCallback func(user_data unsafe.Pointer, caller ULView)
|
type ULChangeTitleCallback func(userData unsafe.Pointer, caller ULView, title ULString)
|
||||||
|
|
||||||
// ULFinishLoadingCallback type as declared in Ultralight/CAPI.h:474
|
// ULChangeURLCallback type as declared in Ultralight/CAPI.h:767
|
||||||
type ULFinishLoadingCallback func(user_data unsafe.Pointer, caller ULView)
|
type ULChangeURLCallback func(userData unsafe.Pointer, caller ULView, url ULString)
|
||||||
|
|
||||||
// ULUpdateHistoryCallback type as declared in Ultralight/CAPI.h:484
|
// ULChangeTooltipCallback type as declared in Ultralight/CAPI.h:777
|
||||||
type ULUpdateHistoryCallback func(user_data unsafe.Pointer, caller ULView)
|
type ULChangeTooltipCallback func(userData unsafe.Pointer, caller ULView, tooltip ULString)
|
||||||
|
|
||||||
// ULDOMReadyCallback type as declared in Ultralight/CAPI.h:494
|
// ULChangeCursorCallback type as declared in Ultralight/CAPI.h:787
|
||||||
type ULDOMReadyCallback func(user_data unsafe.Pointer, caller ULView)
|
type ULChangeCursorCallback func(userData unsafe.Pointer, caller ULView, cursor ULCursor)
|
||||||
|
|
||||||
|
// ULAddConsoleMessageCallback type as declared in Ultralight/CAPI.h:797
|
||||||
|
type ULAddConsoleMessageCallback func(userData unsafe.Pointer, caller ULView, source ULMessageSource, level ULMessageLevel, message ULString, lineNumber uint32, columnNumber uint32, sourceId ULString)
|
||||||
|
|
||||||
|
// ULCreateChildViewCallback type as declared in Ultralight/CAPI.h:812
|
||||||
|
type ULCreateChildViewCallback func(userData unsafe.Pointer, caller ULView, openerUrl ULString, targetUrl ULString, isPopup bool, popupRect ULIntRect) ULView
|
||||||
|
|
||||||
|
// ULBeginLoadingCallback type as declared in Ultralight/CAPI.h:833
|
||||||
|
type ULBeginLoadingCallback func(userData unsafe.Pointer, caller ULView, frameId uint64, isMainFrame bool, url ULString)
|
||||||
|
|
||||||
|
// ULFinishLoadingCallback type as declared in Ultralight/CAPI.h:844
|
||||||
|
type ULFinishLoadingCallback func(userData unsafe.Pointer, caller ULView, frameId uint64, isMainFrame bool, url ULString)
|
||||||
|
|
||||||
|
// ULFailLoadingCallback type as declared in Ultralight/CAPI.h:855
|
||||||
|
type ULFailLoadingCallback func(userData unsafe.Pointer, caller ULView, frameId uint64, isMainFrame bool, url ULString, description ULString, errorDomain ULString, errorCode int32)
|
||||||
|
|
||||||
|
// ULWindowObjectReadyCallback type as declared in Ultralight/CAPI.h:867
|
||||||
|
type ULWindowObjectReadyCallback func(userData unsafe.Pointer, caller ULView, frameId uint64, isMainFrame bool, url ULString)
|
||||||
|
|
||||||
|
// ULDOMReadyCallback type as declared in Ultralight/CAPI.h:889
|
||||||
|
type ULDOMReadyCallback func(userData unsafe.Pointer, caller ULView, frameId uint64, isMainFrame bool, url ULString)
|
||||||
|
|
||||||
|
// ULUpdateHistoryCallback type as declared in Ultralight/CAPI.h:904
|
||||||
|
type ULUpdateHistoryCallback func(userData unsafe.Pointer, caller ULView)
|
||||||
|
|
||||||
|
// ULSurfaceDefinitionCreateCallback type as declared in Ultralight/CAPI.h:1311
|
||||||
|
type ULSurfaceDefinitionCreateCallback func(width uint32, height uint32) unsafe.Pointer
|
||||||
|
|
||||||
|
// ULSurfaceDefinitionDestroyCallback type as declared in Ultralight/CAPI.h:1320
|
||||||
|
type ULSurfaceDefinitionDestroyCallback func(userData unsafe.Pointer)
|
||||||
|
|
||||||
|
// ULSurfaceDefinitionGetWidthCallback type as declared in Ultralight/CAPI.h:1328
|
||||||
|
type ULSurfaceDefinitionGetWidthCallback func(userData unsafe.Pointer) uint32
|
||||||
|
|
||||||
|
// ULSurfaceDefinitionGetHeightCallback type as declared in Ultralight/CAPI.h:1336
|
||||||
|
type ULSurfaceDefinitionGetHeightCallback func(userData unsafe.Pointer) uint32
|
||||||
|
|
||||||
|
// ULSurfaceDefinitionGetRowBytesCallback type as declared in Ultralight/CAPI.h:1346
|
||||||
|
type ULSurfaceDefinitionGetRowBytesCallback func(userData unsafe.Pointer) uint32
|
||||||
|
|
||||||
|
// ULSurfaceDefinitionGetSizeCallback type as declared in Ultralight/CAPI.h:1354
|
||||||
|
type ULSurfaceDefinitionGetSizeCallback func(userData unsafe.Pointer) uint32
|
||||||
|
|
||||||
|
// ULSurfaceDefinitionLockPixelsCallback type as declared in Ultralight/CAPI.h:1362
|
||||||
|
type ULSurfaceDefinitionLockPixelsCallback func(userData unsafe.Pointer) unsafe.Pointer
|
||||||
|
|
||||||
|
// ULSurfaceDefinitionUnlockPixelsCallback type as declared in Ultralight/CAPI.h:1372
|
||||||
|
type ULSurfaceDefinitionUnlockPixelsCallback func(userData unsafe.Pointer)
|
||||||
|
|
||||||
|
// ULSurfaceDefinitionResizeCallback type as declared in Ultralight/CAPI.h:1383
|
||||||
|
type ULSurfaceDefinitionResizeCallback func(userData unsafe.Pointer, width uint32, height uint32)
|
||||||
|
|
||||||
|
// ULSurfaceDefinition as declared in Ultralight/CAPI.h:1395
|
||||||
|
type ULSurfaceDefinition struct {
|
||||||
|
Create ULSurfaceDefinitionCreateCallback
|
||||||
|
Destroy ULSurfaceDefinitionDestroyCallback
|
||||||
|
GetWidth ULSurfaceDefinitionGetWidthCallback
|
||||||
|
GetHeight ULSurfaceDefinitionGetHeightCallback
|
||||||
|
GetRowBytes ULSurfaceDefinitionGetRowBytesCallback
|
||||||
|
GetSize ULSurfaceDefinitionGetSizeCallback
|
||||||
|
LockPixels ULSurfaceDefinitionLockPixelsCallback
|
||||||
|
UnlockPixels ULSurfaceDefinitionUnlockPixelsCallback
|
||||||
|
Resize ULSurfaceDefinitionResizeCallback
|
||||||
|
ref13063f1a *C.ULSurfaceDefinition
|
||||||
|
allocs13063f1a interface{}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ULFileHandle type as declared in Ultralight/CAPI.h:1407
|
||||||
|
type ULFileHandle int32
|
||||||
|
|
||||||
|
// ULFileSystemFileExistsCallback type as declared in Ultralight/CAPI.h:1420
|
||||||
|
type ULFileSystemFileExistsCallback func(path ULString) bool
|
||||||
|
|
||||||
|
// ULFileSystemGetFileSizeCallback type as declared in Ultralight/CAPI.h:1427
|
||||||
|
type ULFileSystemGetFileSizeCallback func(handle ULFileHandle, result []int64) bool
|
||||||
|
|
||||||
|
// ULFileSystemGetFileMimeTypeCallback type as declared in Ultralight/CAPI.h:1434
|
||||||
|
type ULFileSystemGetFileMimeTypeCallback func(path ULString, result ULString) bool
|
||||||
|
|
||||||
|
// ULFileSystemOpenFileCallback type as declared in Ultralight/CAPI.h:1444
|
||||||
|
type ULFileSystemOpenFileCallback func(path ULString, openForWriting bool) ULFileHandle
|
||||||
|
|
||||||
|
// ULFileSystemCloseFileCallback type as declared in Ultralight/CAPI.h:1451
|
||||||
|
type ULFileSystemCloseFileCallback func(handle ULFileHandle)
|
||||||
|
|
||||||
|
// ULFileSystemReadFromFileCallback type as declared in Ultralight/CAPI.h:1458
|
||||||
|
type ULFileSystemReadFromFileCallback func(handle ULFileHandle, data []byte, length int64) int64
|
||||||
|
|
||||||
|
// ULFileSystem as declared in Ultralight/CAPI.h:1467
|
||||||
|
type ULFileSystem struct {
|
||||||
|
FileExists ULFileSystemFileExistsCallback
|
||||||
|
GetFileSize ULFileSystemGetFileSizeCallback
|
||||||
|
GetFileMimeType ULFileSystemGetFileMimeTypeCallback
|
||||||
|
OpenFile ULFileSystemOpenFileCallback
|
||||||
|
CloseFile ULFileSystemCloseFileCallback
|
||||||
|
ReadFromFile ULFileSystemReadFromFileCallback
|
||||||
|
ref41d243eb *C.ULFileSystem
|
||||||
|
allocs41d243eb interface{}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ULLoggerLogMessageCallback type as declared in Ultralight/CAPI.h:1483
|
||||||
|
type ULLoggerLogMessageCallback func(logLevel ULLogLevel, message ULString)
|
||||||
|
|
||||||
|
// ULLogger as declared in Ultralight/CAPI.h:1487
|
||||||
|
type ULLogger struct {
|
||||||
|
LogMessage ULLoggerLogMessageCallback
|
||||||
|
refd55f8aa0 *C.ULLogger
|
||||||
|
allocsd55f8aa0 interface{}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ULRenderBuffer as declared in Ultralight/CAPI.h:1503
|
||||||
|
type ULRenderBuffer struct {
|
||||||
|
TextureId uint32
|
||||||
|
Width uint32
|
||||||
|
Height uint32
|
||||||
|
HasStencilBuffer bool
|
||||||
|
HasDepthBuffer bool
|
||||||
|
refe8ed55f *C.ULRenderBuffer
|
||||||
|
allocse8ed55f interface{}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ULVertex2f4ub2f as declared in Ultralight/CAPI.h:1520
|
||||||
|
type ULVertex2f4ub2f struct {
|
||||||
|
Pos [2]float32
|
||||||
|
Color [4]byte
|
||||||
|
Obj [2]float32
|
||||||
|
ref2acaf525 *C.ULVertex_2f_4ub_2f
|
||||||
|
allocs2acaf525 interface{}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ULVertex2f4ub2f2f28f as declared in Ultralight/CAPI.h:1539
|
||||||
|
type ULVertex2f4ub2f2f28f struct {
|
||||||
|
Pos [2]float32
|
||||||
|
Color [4]byte
|
||||||
|
Tex [2]float32
|
||||||
|
Obj [2]float32
|
||||||
|
Data0 [4]float32
|
||||||
|
Data1 [4]float32
|
||||||
|
Data2 [4]float32
|
||||||
|
Data3 [4]float32
|
||||||
|
Data4 [4]float32
|
||||||
|
Data5 [4]float32
|
||||||
|
Data6 [4]float32
|
||||||
|
refa40e1546 *C.ULVertex_2f_4ub_2f_2f_28f
|
||||||
|
allocsa40e1546 interface{}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ULVertexBuffer as declared in Ultralight/CAPI.h:1561
|
||||||
|
type ULVertexBuffer struct {
|
||||||
|
Format ULVertexBufferFormat
|
||||||
|
Size uint32
|
||||||
|
Data []byte
|
||||||
|
ref38aa9279 *C.ULVertexBuffer
|
||||||
|
allocs38aa9279 interface{}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ULIndexType type as declared in Ultralight/CAPI.h:1566
|
||||||
|
type ULIndexType uint32
|
||||||
|
|
||||||
|
// ULIndexBuffer as declared in Ultralight/CAPI.h:1574
|
||||||
|
type ULIndexBuffer struct {
|
||||||
|
Size uint32
|
||||||
|
Data []byte
|
||||||
|
ref8da49f64 *C.ULIndexBuffer
|
||||||
|
allocs8da49f64 interface{}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ULMatrix4x4 as declared in Ultralight/CAPI.h:1592
|
||||||
|
type ULMatrix4x4 struct {
|
||||||
|
Data [16]float32
|
||||||
|
ref5420ec6b *C.ULMatrix4x4
|
||||||
|
allocs5420ec6b interface{}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ULvec4 as declared in Ultralight/CAPI.h:1599
|
||||||
|
type ULvec4 struct {
|
||||||
|
Value [4]float32
|
||||||
|
ref1faeb7f5 *C.ULvec4
|
||||||
|
allocs1faeb7f5 interface{}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ULGPUState as declared in Ultralight/CAPI.h:1652
|
||||||
|
type ULGPUState struct {
|
||||||
|
ViewportWidth uint32
|
||||||
|
ViewportHeight uint32
|
||||||
|
Transform ULMatrix4x4
|
||||||
|
EnableTexturing bool
|
||||||
|
EnableBlend bool
|
||||||
|
ShaderType byte
|
||||||
|
RenderBufferId uint32
|
||||||
|
Texture1Id uint32
|
||||||
|
Texture2Id uint32
|
||||||
|
Texture3Id uint32
|
||||||
|
UniformScalar [8]float32
|
||||||
|
UniformVector [8]ULvec4
|
||||||
|
ClipSize byte
|
||||||
|
Clip [8]ULMatrix4x4
|
||||||
|
EnableScissor bool
|
||||||
|
ScissorRect ULIntRect
|
||||||
|
ref7caf648c *C.ULGPUState
|
||||||
|
allocs7caf648c interface{}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ULCommand as declared in Ultralight/CAPI.h:1673
|
||||||
|
type ULCommand struct {
|
||||||
|
CommandType byte
|
||||||
|
GpuState ULGPUState
|
||||||
|
GeometryId uint32
|
||||||
|
IndicesCount uint32
|
||||||
|
IndicesOffset uint32
|
||||||
|
ref7ce5cb03 *C.ULCommand
|
||||||
|
allocs7ce5cb03 interface{}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ULCommandList as declared in Ultralight/CAPI.h:1680
|
||||||
|
type ULCommandList struct {
|
||||||
|
Size uint32
|
||||||
|
Commands []ULCommand
|
||||||
|
ref110fbbd7 *C.ULCommandList
|
||||||
|
allocs110fbbd7 interface{}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ULGPUDriverBeginSynchronizeCallback type as declared in Ultralight/CAPI.h:1688
|
||||||
|
type ULGPUDriverBeginSynchronizeCallback func()
|
||||||
|
|
||||||
|
// ULGPUDriverEndSynchronizeCallback type as declared in Ultralight/CAPI.h:1695
|
||||||
|
type ULGPUDriverEndSynchronizeCallback func()
|
||||||
|
|
||||||
|
// ULGPUDriverNextTextureIdCallback type as declared in Ultralight/CAPI.h:1702
|
||||||
|
type ULGPUDriverNextTextureIdCallback func() uint32
|
||||||
|
|
||||||
|
// ULGPUDriverCreateTextureCallback type as declared in Ultralight/CAPI.h:1713
|
||||||
|
type ULGPUDriverCreateTextureCallback func(textureId uint32, bitmap ULBitmap)
|
||||||
|
|
||||||
|
// ULGPUDriverUpdateTextureCallback type as declared in Ultralight/CAPI.h:1721
|
||||||
|
type ULGPUDriverUpdateTextureCallback func(textureId uint32, bitmap ULBitmap)
|
||||||
|
|
||||||
|
// ULGPUDriverDestroyTextureCallback type as declared in Ultralight/CAPI.h:1728
|
||||||
|
type ULGPUDriverDestroyTextureCallback func(textureId uint32)
|
||||||
|
|
||||||
|
// ULGPUDriverNextRenderBufferIdCallback type as declared in Ultralight/CAPI.h:1735
|
||||||
|
type ULGPUDriverNextRenderBufferIdCallback func() uint32
|
||||||
|
|
||||||
|
// ULGPUDriverCreateRenderBufferCallback type as declared in Ultralight/CAPI.h:1742
|
||||||
|
type ULGPUDriverCreateRenderBufferCallback func(renderBufferId uint32, buffer ULRenderBuffer)
|
||||||
|
|
||||||
|
// ULGPUDriverDestroyRenderBufferCallback type as declared in Ultralight/CAPI.h:1749
|
||||||
|
type ULGPUDriverDestroyRenderBufferCallback func(renderBufferId uint32)
|
||||||
|
|
||||||
|
// ULGPUDriverNextGeometryIdCallback type as declared in Ultralight/CAPI.h:1756
|
||||||
|
type ULGPUDriverNextGeometryIdCallback func() uint32
|
||||||
|
|
||||||
|
// ULGPUDriverCreateGeometryCallback type as declared in Ultralight/CAPI.h:1763
|
||||||
|
type ULGPUDriverCreateGeometryCallback func(geometryId uint32, vertices ULVertexBuffer, indices ULIndexBuffer)
|
||||||
|
|
||||||
|
// ULGPUDriverUpdateGeometryCallback type as declared in Ultralight/CAPI.h:1772
|
||||||
|
type ULGPUDriverUpdateGeometryCallback func(geometryId uint32, vertices ULVertexBuffer, indices ULIndexBuffer)
|
||||||
|
|
||||||
|
// ULGPUDriverDestroyGeometryCallback type as declared in Ultralight/CAPI.h:1780
|
||||||
|
type ULGPUDriverDestroyGeometryCallback func(geometryId uint32)
|
||||||
|
|
||||||
|
// ULGPUDriverUpdateCommandListCallback type as declared in Ultralight/CAPI.h:1787
|
||||||
|
type ULGPUDriverUpdateCommandListCallback func(list ULCommandList)
|
||||||
|
|
||||||
|
// ULGPUDriver as declared in Ultralight/CAPI.h:1804
|
||||||
|
type ULGPUDriver struct {
|
||||||
|
BeginSynchronize ULGPUDriverBeginSynchronizeCallback
|
||||||
|
EndSynchronize ULGPUDriverEndSynchronizeCallback
|
||||||
|
NextTextureId ULGPUDriverNextTextureIdCallback
|
||||||
|
CreateTexture ULGPUDriverCreateTextureCallback
|
||||||
|
UpdateTexture ULGPUDriverUpdateTextureCallback
|
||||||
|
DestroyTexture ULGPUDriverDestroyTextureCallback
|
||||||
|
NextRenderBufferId ULGPUDriverNextRenderBufferIdCallback
|
||||||
|
CreateRenderBuffer ULGPUDriverCreateRenderBufferCallback
|
||||||
|
DestroyRenderBuffer ULGPUDriverDestroyRenderBufferCallback
|
||||||
|
NextGeometryId ULGPUDriverNextGeometryIdCallback
|
||||||
|
CreateGeometry ULGPUDriverCreateGeometryCallback
|
||||||
|
UpdateGeometry ULGPUDriverUpdateGeometryCallback
|
||||||
|
DestroyGeometry ULGPUDriverDestroyGeometryCallback
|
||||||
|
UpdateCommandList ULGPUDriverUpdateCommandListCallback
|
||||||
|
refdfd8a4f0 *C.ULGPUDriver
|
||||||
|
allocsdfd8a4f0 interface{}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ULClipboardClearCallback type as declared in Ultralight/CAPI.h:1830
|
||||||
|
type ULClipboardClearCallback func()
|
||||||
|
|
||||||
|
// ULClipboardReadPlainTextCallback type as declared in Ultralight/CAPI.h:1839
|
||||||
|
type ULClipboardReadPlainTextCallback func(result ULString)
|
||||||
|
|
||||||
|
// ULClipboardWritePlainTextCallback type as declared in Ultralight/CAPI.h:1846
|
||||||
|
type ULClipboardWritePlainTextCallback func(text ULString)
|
||||||
|
|
||||||
|
// ULClipboard as declared in Ultralight/CAPI.h:1852
|
||||||
|
type ULClipboard struct {
|
||||||
|
Clear ULClipboardClearCallback
|
||||||
|
ReadPlainText ULClipboardReadPlainTextCallback
|
||||||
|
WritePlainText ULClipboardWritePlainTextCallback
|
||||||
|
refdcb753f *C.ULClipboard
|
||||||
|
allocsdcb753f interface{}
|
||||||
|
}
|
||||||
|
|
||||||
// JSContextGroupRef as declared in JavaScriptCore/JSBase.h:40
|
// JSContextGroupRef as declared in JavaScriptCore/JSBase.h:40
|
||||||
type JSContextGroupRef C.JSContextGroupRef
|
type JSContextGroupRef C.JSContextGroupRef
|
||||||
|
@ -142,37 +465,70 @@ type JSClassAttributes uint32
|
||||||
// JSObjectInitializeCallback type as declared in JavaScriptCore/JSObjectRef.h:92
|
// JSObjectInitializeCallback type as declared in JavaScriptCore/JSObjectRef.h:92
|
||||||
type JSObjectInitializeCallback func(ctx JSContextRef, object JSObjectRef)
|
type JSObjectInitializeCallback func(ctx JSContextRef, object JSObjectRef)
|
||||||
|
|
||||||
// JSObjectFinalizeCallback type as declared in JavaScriptCore/JSObjectRef.h:110
|
// JSObjectInitializeCallbackEx type as declared in JavaScriptCore/JSObjectRef.h:96
|
||||||
|
type JSObjectInitializeCallbackEx func(ctx JSContextRef, jsClass JSClassRef, object JSObjectRef)
|
||||||
|
|
||||||
|
// JSObjectFinalizeCallback type as declared in JavaScriptCore/JSObjectRef.h:114
|
||||||
type JSObjectFinalizeCallback func(object JSObjectRef)
|
type JSObjectFinalizeCallback func(object JSObjectRef)
|
||||||
|
|
||||||
// JSObjectHasPropertyCallback type as declared in JavaScriptCore/JSObjectRef.h:130
|
// JSObjectFinalizeCallbackEx type as declared in JavaScriptCore/JSObjectRef.h:118
|
||||||
|
type JSObjectFinalizeCallbackEx func(jsClass JSClassRef, object JSObjectRef)
|
||||||
|
|
||||||
|
// JSObjectHasPropertyCallback type as declared in JavaScriptCore/JSObjectRef.h:138
|
||||||
type JSObjectHasPropertyCallback func(ctx JSContextRef, object JSObjectRef, propertyName JSStringRef) bool
|
type JSObjectHasPropertyCallback func(ctx JSContextRef, object JSObjectRef, propertyName JSStringRef) bool
|
||||||
|
|
||||||
// JSObjectGetPropertyCallback type as declared in JavaScriptCore/JSObjectRef.h:147
|
// JSObjectHasPropertyCallbackEx type as declared in JavaScriptCore/JSObjectRef.h:142
|
||||||
|
type JSObjectHasPropertyCallbackEx func(ctx JSContextRef, jsClass JSClassRef, object JSObjectRef, propertyName JSStringRef) bool
|
||||||
|
|
||||||
|
// JSObjectGetPropertyCallback type as declared in JavaScriptCore/JSObjectRef.h:159
|
||||||
type JSObjectGetPropertyCallback func(ctx JSContextRef, object JSObjectRef, propertyName JSStringRef, exception []JSValueRef) JSValueRef
|
type JSObjectGetPropertyCallback func(ctx JSContextRef, object JSObjectRef, propertyName JSStringRef, exception []JSValueRef) JSValueRef
|
||||||
|
|
||||||
// JSObjectSetPropertyCallback type as declared in JavaScriptCore/JSObjectRef.h:165
|
// JSObjectGetPropertyCallbackEx type as declared in JavaScriptCore/JSObjectRef.h:163
|
||||||
|
type JSObjectGetPropertyCallbackEx func(ctx JSContextRef, jsClass JSClassRef, object JSObjectRef, propertyName JSStringRef, exception []JSValueRef) JSValueRef
|
||||||
|
|
||||||
|
// JSObjectSetPropertyCallback type as declared in JavaScriptCore/JSObjectRef.h:181
|
||||||
type JSObjectSetPropertyCallback func(ctx JSContextRef, object JSObjectRef, propertyName JSStringRef, value JSValueRef, exception []JSValueRef) bool
|
type JSObjectSetPropertyCallback func(ctx JSContextRef, object JSObjectRef, propertyName JSStringRef, value JSValueRef, exception []JSValueRef) bool
|
||||||
|
|
||||||
// JSObjectDeletePropertyCallback type as declared in JavaScriptCore/JSObjectRef.h:182
|
// JSObjectSetPropertyCallbackEx type as declared in JavaScriptCore/JSObjectRef.h:185
|
||||||
|
type JSObjectSetPropertyCallbackEx func(ctx JSContextRef, jsClass JSClassRef, object JSObjectRef, propertyName JSStringRef, value JSValueRef, exception []JSValueRef) bool
|
||||||
|
|
||||||
|
// JSObjectDeletePropertyCallback type as declared in JavaScriptCore/JSObjectRef.h:202
|
||||||
type JSObjectDeletePropertyCallback func(ctx JSContextRef, object JSObjectRef, propertyName JSStringRef, exception []JSValueRef) bool
|
type JSObjectDeletePropertyCallback func(ctx JSContextRef, object JSObjectRef, propertyName JSStringRef, exception []JSValueRef) bool
|
||||||
|
|
||||||
// JSObjectGetPropertyNamesCallback type as declared in JavaScriptCore/JSObjectRef.h:199
|
// JSObjectDeletePropertyCallbackEx type as declared in JavaScriptCore/JSObjectRef.h:206
|
||||||
|
type JSObjectDeletePropertyCallbackEx func(ctx JSContextRef, jsClass JSClassRef, object JSObjectRef, propertyName JSStringRef, exception []JSValueRef) bool
|
||||||
|
|
||||||
|
// JSObjectGetPropertyNamesCallback type as declared in JavaScriptCore/JSObjectRef.h:223
|
||||||
type JSObjectGetPropertyNamesCallback func(ctx JSContextRef, object JSObjectRef, propertyNames JSPropertyNameAccumulatorRef)
|
type JSObjectGetPropertyNamesCallback func(ctx JSContextRef, object JSObjectRef, propertyNames JSPropertyNameAccumulatorRef)
|
||||||
|
|
||||||
// JSObjectCallAsFunctionCallback type as declared in JavaScriptCore/JSObjectRef.h:220
|
// JSObjectGetPropertyNamesCallbackEx type as declared in JavaScriptCore/JSObjectRef.h:227
|
||||||
type JSObjectCallAsFunctionCallback func(ctx JSContextRef, function JSObjectRef, thisObject JSObjectRef, argumentCount uint, arguments []JSValueRef, exception []JSValueRef) JSValueRef
|
type JSObjectGetPropertyNamesCallbackEx func(ctx JSContextRef, jsClass JSClassRef, object JSObjectRef, propertyNames JSPropertyNameAccumulatorRef)
|
||||||
|
|
||||||
// JSObjectCallAsConstructorCallback type as declared in JavaScriptCore/JSObjectRef.h:240
|
// JSObjectCallAsFunctionCallback type as declared in JavaScriptCore/JSObjectRef.h:248
|
||||||
type JSObjectCallAsConstructorCallback func(ctx JSContextRef, constructor JSObjectRef, argumentCount uint, arguments []JSValueRef, exception []JSValueRef) JSObjectRef
|
type JSObjectCallAsFunctionCallback func(ctx JSContextRef, function JSObjectRef, thisObject JSObjectRef, argumentCount uint32, arguments []JSValueRef, exception []JSValueRef) JSValueRef
|
||||||
|
|
||||||
// JSObjectHasInstanceCallback type as declared in JavaScriptCore/JSObjectRef.h:261
|
// JSObjectCallAsFunctionCallbackEx type as declared in JavaScriptCore/JSObjectRef.h:254
|
||||||
|
type JSObjectCallAsFunctionCallbackEx func(ctx JSContextRef, jsClass JSClassRef, className JSStringRef, function JSObjectRef, thisObject JSObjectRef, argumentCount uint32, arguments []JSValueRef, exception []JSValueRef) JSValueRef
|
||||||
|
|
||||||
|
// JSObjectCallAsConstructorCallback type as declared in JavaScriptCore/JSObjectRef.h:274
|
||||||
|
type JSObjectCallAsConstructorCallback func(ctx JSContextRef, constructor JSObjectRef, argumentCount uint32, arguments []JSValueRef, exception []JSValueRef) JSObjectRef
|
||||||
|
|
||||||
|
// JSObjectCallAsConstructorCallbackEx type as declared in JavaScriptCore/JSObjectRef.h:278
|
||||||
|
type JSObjectCallAsConstructorCallbackEx func(ctx JSContextRef, jsClass JSClassRef, constructor JSObjectRef, argumentCount uint32, arguments []JSValueRef, exception []JSValueRef) JSObjectRef
|
||||||
|
|
||||||
|
// JSObjectHasInstanceCallback type as declared in JavaScriptCore/JSObjectRef.h:299
|
||||||
type JSObjectHasInstanceCallback func(ctx JSContextRef, constructor JSObjectRef, possibleInstance JSValueRef, exception []JSValueRef) bool
|
type JSObjectHasInstanceCallback func(ctx JSContextRef, constructor JSObjectRef, possibleInstance JSValueRef, exception []JSValueRef) bool
|
||||||
|
|
||||||
// JSObjectConvertToTypeCallback type as declared in JavaScriptCore/JSObjectRef.h:280
|
// JSObjectHasInstanceCallbackEx type as declared in JavaScriptCore/JSObjectRef.h:303
|
||||||
type JSObjectConvertToTypeCallback func(ctx JSContextRef, object JSObjectRef, _type JSType, exception []JSValueRef) JSValueRef
|
type JSObjectHasInstanceCallbackEx func(ctx JSContextRef, jsClass JSClassRef, constructor JSObjectRef, possibleInstance JSValueRef, exception []JSValueRef) bool
|
||||||
|
|
||||||
// JSStaticValue as declared in JavaScriptCore/JSObjectRef.h:295
|
// JSObjectConvertToTypeCallback type as declared in JavaScriptCore/JSObjectRef.h:322
|
||||||
|
type JSObjectConvertToTypeCallback func(ctx JSContextRef, object JSObjectRef, kind JSType, exception []JSValueRef) JSValueRef
|
||||||
|
|
||||||
|
// JSObjectConvertToTypeCallbackEx type as declared in JavaScriptCore/JSObjectRef.h:326
|
||||||
|
type JSObjectConvertToTypeCallbackEx func(ctx JSContextRef, jsClass JSClassRef, object JSObjectRef, kind JSType, exception []JSValueRef) JSValueRef
|
||||||
|
|
||||||
|
// JSStaticValue as declared in JavaScriptCore/JSObjectRef.h:341
|
||||||
type JSStaticValue struct {
|
type JSStaticValue struct {
|
||||||
Name string
|
Name string
|
||||||
GetProperty JSObjectGetPropertyCallback
|
GetProperty JSObjectGetPropertyCallback
|
||||||
|
@ -182,7 +538,17 @@ type JSStaticValue struct {
|
||||||
allocs34655956 interface{}
|
allocs34655956 interface{}
|
||||||
}
|
}
|
||||||
|
|
||||||
// JSStaticFunction as declared in JavaScriptCore/JSObjectRef.h:308
|
// JSStaticValueEx as declared in JavaScriptCore/JSObjectRef.h:349
|
||||||
|
type JSStaticValueEx struct {
|
||||||
|
Name string
|
||||||
|
GetPropertyEx JSObjectGetPropertyCallbackEx
|
||||||
|
SetPropertyEx JSObjectSetPropertyCallbackEx
|
||||||
|
Attributes JSPropertyAttributes
|
||||||
|
ref6c5f7756 *C.JSStaticValueEx
|
||||||
|
allocs6c5f7756 interface{}
|
||||||
|
}
|
||||||
|
|
||||||
|
// JSStaticFunction as declared in JavaScriptCore/JSObjectRef.h:362
|
||||||
type JSStaticFunction struct {
|
type JSStaticFunction struct {
|
||||||
Name string
|
Name string
|
||||||
CallAsFunction JSObjectCallAsFunctionCallback
|
CallAsFunction JSObjectCallAsFunctionCallback
|
||||||
|
@ -191,27 +557,24 @@ type JSStaticFunction struct {
|
||||||
allocs6b5f4953 interface{}
|
allocs6b5f4953 interface{}
|
||||||
}
|
}
|
||||||
|
|
||||||
// JSClassDefinition as declared in JavaScriptCore/JSObjectRef.h:364
|
// JSStaticFunctionEx as declared in JavaScriptCore/JSObjectRef.h:369
|
||||||
|
type JSStaticFunctionEx struct {
|
||||||
|
Name string
|
||||||
|
CallAsFunctionEx JSObjectCallAsFunctionCallbackEx
|
||||||
|
Attributes JSPropertyAttributes
|
||||||
|
refc9fcc4d *C.JSStaticFunctionEx
|
||||||
|
allocsc9fcc4d interface{}
|
||||||
|
}
|
||||||
|
|
||||||
|
// JSClassDefinition as declared in JavaScriptCore/JSObjectRef.h:448
|
||||||
type JSClassDefinition struct {
|
type JSClassDefinition struct {
|
||||||
Version int32
|
Version int32
|
||||||
Attributes JSClassAttributes
|
Attributes JSClassAttributes
|
||||||
ClassName string
|
ClassName string
|
||||||
ParentClass JSClassRef
|
ParentClass JSClassRef
|
||||||
StaticValues []JSStaticValue
|
PrivateData unsafe.Pointer
|
||||||
StaticFunctions []JSStaticFunction
|
ref192c18d5 *C.JSClassDefinition
|
||||||
Initialize JSObjectInitializeCallback
|
allocs192c18d5 interface{}
|
||||||
Finalize JSObjectFinalizeCallback
|
|
||||||
HasProperty JSObjectHasPropertyCallback
|
|
||||||
GetProperty JSObjectGetPropertyCallback
|
|
||||||
SetProperty JSObjectSetPropertyCallback
|
|
||||||
DeleteProperty JSObjectDeletePropertyCallback
|
|
||||||
GetPropertyNames JSObjectGetPropertyNamesCallback
|
|
||||||
CallAsFunction JSObjectCallAsFunctionCallback
|
|
||||||
CallAsConstructor JSObjectCallAsConstructorCallback
|
|
||||||
HasInstance JSObjectHasInstanceCallback
|
|
||||||
ConvertToType JSObjectConvertToTypeCallback
|
|
||||||
ref192c18d5 *C.JSClassDefinition
|
|
||||||
allocs192c18d5 interface{}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// JSChar type as declared in JavaScriptCore/JSStringRef.h:49
|
// JSChar type as declared in JavaScriptCore/JSStringRef.h:49
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue