mirror of
https://github.com/holub/mame
synced 2025-04-25 09:50:04 +03:00
Merge branch 'master' of https://github.com/mamedev/mame
This commit is contained in:
commit
487fd9591a
@ -2,7 +2,7 @@
|
||||
// File: vk_platform.h
|
||||
//
|
||||
/*
|
||||
** Copyright (c) 2014-2015 The Khronos Group Inc.
|
||||
** Copyright (c) 2014-2016 The Khronos Group Inc.
|
||||
**
|
||||
** Permission is hereby granted, free of charge, to any person obtaining a
|
||||
** copy of this software and/or associated documentation files (the
|
||||
@ -25,8 +25,8 @@
|
||||
*/
|
||||
|
||||
|
||||
#ifndef VK_PLATFORM_H_
|
||||
#define VK_PLATFORM_H_
|
||||
#ifndef __VK_PLATFORM_H__
|
||||
#define __VK_PLATFORM_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
@ -124,4 +124,4 @@ extern "C"
|
||||
#include <xcb/xcb.h>
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif // __VK_PLATFORM_H__
|
||||
|
14
3rdparty/bgfx/3rdparty/khronos/vulkan/vulkan.h
vendored
14
3rdparty/bgfx/3rdparty/khronos/vulkan/vulkan.h
vendored
@ -41,7 +41,7 @@ extern "C" {
|
||||
(((major) << 22) | ((minor) << 12) | (patch))
|
||||
|
||||
// Vulkan API version supported by this file
|
||||
#define VK_API_VERSION VK_MAKE_VERSION(1, 0, 4)
|
||||
#define VK_API_VERSION VK_MAKE_VERSION(1, 0, 5)
|
||||
|
||||
#define VK_VERSION_MAJOR(version) ((uint32_t)(version) >> 22)
|
||||
#define VK_VERSION_MINOR(version) (((uint32_t)(version) >> 12) & 0x3ff)
|
||||
@ -142,6 +142,7 @@ typedef enum VkResult {
|
||||
VK_ERROR_OUT_OF_DATE_KHR = -1000001004,
|
||||
VK_ERROR_INCOMPATIBLE_DISPLAY_KHR = -1000003001,
|
||||
VK_ERROR_VALIDATION_FAILED_EXT = -1000011001,
|
||||
VK_ERROR_INVALID_SHADER_NV = -1000012000,
|
||||
VK_RESULT_BEGIN_RANGE = VK_ERROR_FORMAT_NOT_SUPPORTED,
|
||||
VK_RESULT_END_RANGE = VK_INCOMPLETE,
|
||||
VK_RESULT_RANGE_SIZE = (VK_INCOMPLETE - VK_ERROR_FORMAT_NOT_SUPPORTED + 1),
|
||||
@ -979,7 +980,7 @@ typedef enum VkShaderStageFlagBits {
|
||||
VK_SHADER_STAGE_GEOMETRY_BIT = 0x00000008,
|
||||
VK_SHADER_STAGE_FRAGMENT_BIT = 0x00000010,
|
||||
VK_SHADER_STAGE_COMPUTE_BIT = 0x00000020,
|
||||
VK_SHADER_STAGE_ALL_GRAPHICS = 0x1F,
|
||||
VK_SHADER_STAGE_ALL_GRAPHICS = 0x0000001F,
|
||||
VK_SHADER_STAGE_ALL = 0x7FFFFFFF,
|
||||
} VkShaderStageFlagBits;
|
||||
typedef VkFlags VkPipelineVertexInputStateCreateFlags;
|
||||
@ -992,7 +993,7 @@ typedef enum VkCullModeFlagBits {
|
||||
VK_CULL_MODE_NONE = 0,
|
||||
VK_CULL_MODE_FRONT_BIT = 0x00000001,
|
||||
VK_CULL_MODE_BACK_BIT = 0x00000002,
|
||||
VK_CULL_MODE_FRONT_AND_BACK = 0x3,
|
||||
VK_CULL_MODE_FRONT_AND_BACK = 0x00000003,
|
||||
} VkCullModeFlagBits;
|
||||
typedef VkFlags VkCullModeFlags;
|
||||
typedef VkFlags VkPipelineMultisampleStateCreateFlags;
|
||||
@ -1083,7 +1084,7 @@ typedef VkFlags VkCommandBufferResetFlags;
|
||||
typedef enum VkStencilFaceFlagBits {
|
||||
VK_STENCIL_FACE_FRONT_BIT = 0x00000001,
|
||||
VK_STENCIL_FACE_BACK_BIT = 0x00000002,
|
||||
VK_STENCIL_FRONT_AND_BACK = 0x3,
|
||||
VK_STENCIL_FRONT_AND_BACK = 0x00000003,
|
||||
} VkStencilFaceFlagBits;
|
||||
typedef VkFlags VkStencilFaceFlags;
|
||||
|
||||
@ -3774,6 +3775,11 @@ VKAPI_ATTR void VKAPI_CALL vkDebugReportMessageEXT(
|
||||
const char* pMessage);
|
||||
#endif
|
||||
|
||||
#define VK_NV_glsl_shader 1
|
||||
#define VK_NV_GLSL_SHADER_SPEC_VERSION 1
|
||||
#define VK_NV_GLSL_SHADER_EXTENSION_NAME "VK_NV_glsl_shader"
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
263
3rdparty/bgfx/3rdparty/ocornut-imgui/imgui.cpp
vendored
263
3rdparty/bgfx/3rdparty/ocornut-imgui/imgui.cpp
vendored
@ -19,9 +19,10 @@
|
||||
- FREQUENTLY ASKED QUESTIONS (FAQ), TIPS
|
||||
- How can I help?
|
||||
- How do I update to a newer version of ImGui?
|
||||
- What is ImTextureID and how do I display an image?
|
||||
- Can I have multiple widgets with the same label? Can I have widget without a label? (Yes) / A primer on the use of labels/IDs in ImGui.
|
||||
- I integrated ImGui in my engine and the text or lines are blurry..
|
||||
- I integrated ImGui in my engine and some elements are disappearing when I move windows around..
|
||||
- I integrated ImGui in my engine and some elements are clipping or disappearing when I move windows around..
|
||||
- How can I load a different font than the default?
|
||||
- How can I load multiple fonts?
|
||||
- How can I display and input non-latin characters such as Chinese, Japanese, Korean, Cyrillic?
|
||||
@ -78,6 +79,7 @@
|
||||
- your code creates the UI, if your code doesn't run the UI is gone! == very dynamic UI, no construction/destructions steps, less data retention on your side, no state duplication, less sync, less bugs.
|
||||
- call and read ImGui::ShowTestWindow() for demo code demonstrating most features.
|
||||
- see examples/ folder for standalone sample applications. Prefer reading examples/opengl_example/ first at it is the simplest.
|
||||
you may be able to grab and copy a ready made imgui_impl_*** file from the examples/.
|
||||
- customization: PushStyleColor()/PushStyleVar() or the style editor to tweak the look of the interface (e.g. if you want a more compact UI or a different color scheme).
|
||||
|
||||
- getting started:
|
||||
@ -85,12 +87,13 @@
|
||||
- init: call io.Fonts->GetTexDataAsRGBA32(...) and load the font texture pixels into graphics memory.
|
||||
- every frame:
|
||||
1/ in your mainloop or right after you got your keyboard/mouse info, call ImGui::GetIO() and fill the fields marked 'Input'
|
||||
2/ call ImGui::NewFrame().
|
||||
2/ call ImGui::NewFrame() as early as you can!
|
||||
3/ use any ImGui function you want between NewFrame() and Render()
|
||||
4/ call ImGui::Render() to render all the accumulated command-lists. it will call your RenderDrawListFn handler that you set in the IO structure.
|
||||
4/ call ImGui::Render() as late as you can to end the frame and finalize render data. it will call your RenderDrawListFn handler that you set in the IO structure.
|
||||
(if you don't need to render, you still need to call Render() and ignore the callback, or call EndFrame() instead. if you call neither some aspects of windows focusing/moving will appear broken.)
|
||||
- all rendering information are stored into command-lists until ImGui::Render() is called.
|
||||
- ImGui never touches or know about your GPU state. the only function that knows about GPU is the RenderDrawListFn handler that you must provide.
|
||||
- effectively it means you can create widgets at any time in your code, regardless of considerations of being in "update" vs "render" phases.
|
||||
- ImGui never touches or know about your GPU state. the only function that knows about GPU is the RenderDrawListFn handler that you provide.
|
||||
- effectively it means you can create widgets at any time in your code, regardless of considerations of being in "update" vs "render" phases of your own application.
|
||||
- refer to the examples applications in the examples/ folder for instruction on how to setup your code.
|
||||
- a typical application skeleton may be:
|
||||
|
||||
@ -107,7 +110,7 @@
|
||||
unsigned char* pixels;
|
||||
int width, height;
|
||||
io.Fonts->GetTexDataAsRGBA32(pixels, &width, &height);
|
||||
// TODO: At this points you've got a texture pointed to by 'pixels' and you need to upload that your your graphic system
|
||||
// TODO: At this points you've got a texture pointed to by 'pixels' and you need to upload that your your graphic system
|
||||
// TODO: Store your texture pointer/identifier (whatever your engine uses) in 'io.Fonts->TexID'
|
||||
|
||||
// Application main loop
|
||||
@ -134,7 +137,7 @@
|
||||
|
||||
// 4) render & swap video buffers
|
||||
ImGui::Render();
|
||||
// swap video buffer, etc.
|
||||
SwapBuffers();
|
||||
}
|
||||
|
||||
- after calling ImGui::NewFrame() you can read back flags from the IO structure to tell how ImGui intends to use your inputs.
|
||||
@ -149,6 +152,7 @@
|
||||
Here is a change-log of API breaking changes, if you are using one of the functions listed, expect to have to fix some code.
|
||||
Also read releases logs https://github.com/ocornut/imgui/releases for more details.
|
||||
|
||||
- 2016/03/21 (1.48) - renamed GetWindowFont() to GetFont(), GetWindowFontSize() to GetFontSize(). Kept inline redirection function (will obsolete).
|
||||
- 2016/03/02 (1.48) - InputText() completion/history/always callbacks: if you modify the text buffer manually (without using DeleteChars()/InsertChars() helper) you need to maintain the BufTextLen field. added an assert.
|
||||
- 2016/01/23 (1.48) - fixed not honoring exact width passed to PushItemWidth(), previously it would add extra FramePadding.x*2 over that width. if you had manual pixel-perfect alignment in place it might affect you.
|
||||
- 2015/12/27 (1.48) - fixed ImDrawList::AddRect() which used to render a rectangle 1 px too large on each axis.
|
||||
@ -257,6 +261,18 @@
|
||||
Check the "API BREAKING CHANGES" sections for a list of occasional API breaking changes. If you have a problem with a function, search for its name
|
||||
in the code, there will likely be a comment about it. Please report any issue to the GitHub page!
|
||||
|
||||
|
||||
Q: What is ImTextureID and how do I display an image?
|
||||
A: ImTextureID is a void* used to pass renderer-agnostic texture references around until it hits your render function.
|
||||
ImGui knows nothing about what those bits represent, it just passes them around. It is up to you to decide what you want the void* to carry!
|
||||
It could be an identifier to your OpenGL texture (cast GLuint to void*), a pointer to your custom engine material (cast MyMaterial* to void*), etc.
|
||||
At the end of the chain, your renderer takes this void* to cast it back into whatever it needs to select a current texture to render.
|
||||
Refer to examples applications, where each renderer (in a imgui_impl_xxxx.cpp file) is treating ImTextureID as a different thing.
|
||||
(c++ tip: OpenGL uses integers to identify textures. You can safely store an integer into a void*, just cast it to void*, don't take it's address!)
|
||||
To display a custom image/texture within an ImGui window, you may use ImGui::Image(), ImGui::ImageButton(), ImDrawList::AddImage() functions.
|
||||
ImGui will generate the geometry and draw calls using the ImTextureID that you passed and which your renderer can use.
|
||||
It is your responsibility to get textures uploaded to your GPU.
|
||||
|
||||
Q: Can I have multiple widgets with the same label? Can I have widget without a label? (Yes)
|
||||
A: Yes. A primer on the use of labels/IDs in ImGui..
|
||||
|
||||
@ -295,7 +311,7 @@
|
||||
|
||||
Button("Hello###ID"; // Label = "Hello", ID = hash of "ID"
|
||||
Button("World###ID"; // Label = "World", ID = hash of "ID" (same as above)
|
||||
|
||||
|
||||
sprintf(buf, "My game (%f FPS)###MyGame");
|
||||
Begin(buf); // Variable label, ID = hash of "MyGame"
|
||||
|
||||
@ -354,8 +370,8 @@
|
||||
A: In your Render function, try translating your projection matrix by (0.5f,0.5f) or (0.375f,0.375f).
|
||||
Also make sure your orthographic projection matrix and io.DisplaySize matches your actual framebuffer dimension.
|
||||
|
||||
Q. I integrated ImGui in my engine and some elements are disappearing when I move windows around..
|
||||
Most likely you are mishandling the clipping rectangles in your render function. Rectangles provided by ImGui are defined as (x1,y1,x2,y2) and NOT as (x1,y1,width,height).
|
||||
Q: I integrated ImGui in my engine and some elements are clipping or disappearing when I move windows around..
|
||||
A: Most likely you are mishandling the clipping rectangles in your render function. Rectangles provided by ImGui are defined as (x1,y1,x2,y2) and NOT as (x1,y1,width,height).
|
||||
|
||||
Q: How can I load a different font than the default? (default is an embedded version of ProggyClean.ttf, rendered at size 13)
|
||||
A: Use the font atlas to load the TTF file you want:
|
||||
@ -424,7 +440,6 @@
|
||||
- window: get size/pos helpers given names (see discussion in #249)
|
||||
- window: a collapsed window can be stuck behind the main menu bar?
|
||||
- window: detect extra End() call that pop the "Debug" window out and assert at call site instead of later.
|
||||
- window: consider renaming "GetWindowFont" which conflict with old Windows #define (#340)
|
||||
- window/tooltip: allow to set the width of a tooltip to allow TextWrapped() etc. while keeping the height automatic.
|
||||
- window: increase minimum size of a window with menus or fix the menu rendering so that it doesn't look odd.
|
||||
- draw-list: maintaining bounding box per command would allow to merge draw command when clipping isn't relied on (typical non-scrolling window or non-overflowing column would merge with previous command).
|
||||
@ -434,7 +449,7 @@
|
||||
- widgets: clean up widgets internal toward exposing everything.
|
||||
- widgets: add disabled and read-only modes (#211)
|
||||
- main: considering adding EndFrame()/Init(). some constructs are awkward in the implementation because of the lack of them.
|
||||
- main: make it so that a frame with no window registered won't refocus every window on subsequent frames (~bump LastFrameActive of all windows).
|
||||
- main: make it so that a frame with no window registered won't refocus every window on subsequent frames (~bump LastFrameActive of all windows).
|
||||
- main: IsItemHovered() make it more consistent for various type of widgets, widgets with multiple components, etc. also effectively IsHovered() region sometimes differs from hot region, e.g tree nodes
|
||||
- main: IsItemHovered() info stored in a stack? so that 'if TreeNode() { Text; TreePop; } if IsHovered' return the hover state of the TreeNode?
|
||||
- input text: add ImGuiInputTextFlags_EnterToApply? (off #218)
|
||||
@ -591,7 +606,6 @@
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
static void LogRenderedText(const ImVec2& ref_pos, const char* text, const char* text_end = NULL);
|
||||
static const char* FindTextDisplayEnd(const char* text, const char* text_end = NULL);
|
||||
|
||||
static void PushMultiItemsWidths(int components, float w_full = 0.0f);
|
||||
static float GetDraggedColumnOffset(int column_index);
|
||||
@ -641,7 +655,7 @@ static ImVec2 InputTextCalcTextSizeW(const ImWchar* text_begin, const
|
||||
static inline void DataTypeFormatString(ImGuiDataType data_type, void* data_ptr, const char* display_format, char* buf, int buf_size);
|
||||
static inline void DataTypeFormatString(ImGuiDataType data_type, void* data_ptr, int decimal_precision, char* buf, int buf_size);
|
||||
static void DataTypeApplyOp(ImGuiDataType data_type, int op, void* value1, const void* value2);
|
||||
static void DataTypeApplyOpFromText(const char* buf, const char* initial_value_buf, ImGuiDataType data_type, void* data_ptr, const char* scalar_format);
|
||||
static bool DataTypeApplyOpFromText(const char* buf, const char* initial_value_buf, ImGuiDataType data_type, void* data_ptr, const char* scalar_format);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Platform dependent default implementations
|
||||
@ -973,7 +987,7 @@ int ImTextCharFromUtf8(unsigned int* out_char, const char* in_text, const char*
|
||||
if ((*str & 0xf0) == 0xe0)
|
||||
{
|
||||
*out_char = 0xFFFD; // will be invalid but not end of string
|
||||
if (in_text_end && in_text_end - (const char*)str < 3) return 1;
|
||||
if (in_text_end && in_text_end - (const char*)str < 3) return 1;
|
||||
if (*str == 0xe0 && (str[1] < 0xa0 || str[1] > 0xbf)) return 3;
|
||||
if (*str == 0xed && str[1] > 0x9f) return 3; // str[1] < 0x80 is checked below
|
||||
c = (unsigned int)((*str++ & 0x0f) << 12);
|
||||
@ -2377,7 +2391,7 @@ void ImGui::EndFrame()
|
||||
// Notify OS when our Input Method Editor cursor has moved (e.g. CJK inputs using Microsoft IME)
|
||||
if (g.IO.ImeSetInputScreenPosFn && ImLengthSqr(g.OsImePosRequest - g.OsImePosSet) > 0.0001f)
|
||||
{
|
||||
g.IO.ImeSetInputScreenPosFn((int)g.OsImePosRequest.x, (int)g.OsImePosRequest.y);
|
||||
g.IO.ImeSetInputScreenPosFn((int)g.OsImePosRequest.x, (int)g.OsImePosRequest.y);
|
||||
g.OsImePosSet = g.OsImePosRequest;
|
||||
}
|
||||
|
||||
@ -2510,8 +2524,7 @@ void ImGui::Render()
|
||||
}
|
||||
}
|
||||
|
||||
// Find the optional ## from which we stop displaying text.
|
||||
static const char* FindTextDisplayEnd(const char* text, const char* text_end)
|
||||
const char* ImGui::FindRenderedTextEnd(const char* text, const char* text_end)
|
||||
{
|
||||
const char* text_display_end = text;
|
||||
if (!text_end)
|
||||
@ -2550,7 +2563,7 @@ static void LogRenderedText(const ImVec2& ref_pos, const char* text, const char*
|
||||
ImGuiWindow* window = ImGui::GetCurrentWindowRead();
|
||||
|
||||
if (!text_end)
|
||||
text_end = FindTextDisplayEnd(text, text_end);
|
||||
text_end = ImGui::FindRenderedTextEnd(text, text_end);
|
||||
|
||||
const bool log_new_line = ref_pos.y > window->DC.LogLinePosY+1;
|
||||
window->DC.LogLinePosY = ref_pos.y;
|
||||
@ -2604,7 +2617,7 @@ void ImGui::RenderText(ImVec2 pos, const char* text, const char* text_end, bool
|
||||
const char* text_display_end;
|
||||
if (hide_text_after_hash)
|
||||
{
|
||||
text_display_end = FindTextDisplayEnd(text, text_end);
|
||||
text_display_end = FindRenderedTextEnd(text, text_end);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2643,7 +2656,7 @@ void ImGui::RenderTextWrapped(ImVec2 pos, const char* text, const char* text_end
|
||||
void ImGui::RenderTextClipped(const ImVec2& pos_min, const ImVec2& pos_max, const char* text, const char* text_end, const ImVec2* text_size_if_known, ImGuiAlign align, const ImVec2* clip_min, const ImVec2* clip_max)
|
||||
{
|
||||
// Hide anything after a '##' string
|
||||
const char* text_display_end = FindTextDisplayEnd(text, text_end);
|
||||
const char* text_display_end = FindRenderedTextEnd(text, text_end);
|
||||
const int text_len = (int)(text_display_end - text);
|
||||
if (text_len == 0)
|
||||
return;
|
||||
@ -2750,7 +2763,7 @@ ImVec2 ImGui::CalcTextSize(const char* text, const char* text_end, bool hide_tex
|
||||
|
||||
const char* text_display_end;
|
||||
if (hide_text_after_double_hash)
|
||||
text_display_end = FindTextDisplayEnd(text, text_end); // Hide anything after a '##' string
|
||||
text_display_end = FindRenderedTextEnd(text, text_end); // Hide anything after a '##' string
|
||||
else
|
||||
text_display_end = text_end;
|
||||
|
||||
@ -2829,13 +2842,13 @@ static ImGuiWindow* FindHoveredWindow(ImVec2 pos, bool excluding_childs)
|
||||
// Test if mouse cursor is hovering given rectangle
|
||||
// NB- Rectangle is clipped by our current clip setting
|
||||
// NB- Expand the rectangle to be generous on imprecise inputs systems (g.Style.TouchExtraPadding)
|
||||
bool ImGui::IsMouseHoveringRect(const ImVec2& pos_min, const ImVec2& pos_max, bool clip)
|
||||
bool ImGui::IsMouseHoveringRect(const ImVec2& r_min, const ImVec2& r_max, bool clip)
|
||||
{
|
||||
ImGuiState& g = *GImGui;
|
||||
ImGuiWindow* window = GetCurrentWindowRead();
|
||||
|
||||
// Clip
|
||||
ImRect rect_clipped(pos_min, pos_max);
|
||||
ImRect rect_clipped(r_min, r_max);
|
||||
if (clip)
|
||||
rect_clipped.Clip(window->ClipRect);
|
||||
|
||||
@ -3131,7 +3144,7 @@ static bool IsPopupOpen(ImGuiID id)
|
||||
return opened;
|
||||
}
|
||||
|
||||
// Mark popup as open (toggle toward open state).
|
||||
// Mark popup as open (toggle toward open state).
|
||||
// Popups are closed when user click outside, or activate a pressable item, or CloseCurrentPopup() is called within a BeginPopup()/EndPopup() block.
|
||||
// Popup identifiers are relative to the current ID-stack (so OpenPopup and BeginPopup needs to be at the same level).
|
||||
// One open popup per level of the popup hierarchy (NB: when assigning we reset the Window member of ImGuiPopupRef to NULL)
|
||||
@ -3309,11 +3322,11 @@ void ImGui::EndPopup()
|
||||
}
|
||||
|
||||
// This is a helper to handle the most simple case of associating one named popup to one given widget.
|
||||
// 1. If you have many possible popups (for different "instances" of a same widget, or for wholly different widgets), you may be better off handling
|
||||
// 1. If you have many possible popups (for different "instances" of a same widget, or for wholly different widgets), you may be better off handling
|
||||
// this yourself so you can store data relative to the widget that opened the popup instead of choosing different popup identifiers.
|
||||
// 2. If you want right-clicking on the same item to reopen the popup at new location, use the same code replacing IsItemHovered() with IsItemHoveredRect()
|
||||
// and passing true to the OpenPopupEx().
|
||||
// Because: hovering an item in a window below the popup won't normally trigger is hovering behavior/coloring. The pattern of ignoring the fact that
|
||||
// Because: hovering an item in a window below the popup won't normally trigger is hovering behavior/coloring. The pattern of ignoring the fact that
|
||||
// the item isn't interactable (because it is blocked by the active popup) may useful in some situation when e.g. large canvas as one item, content of menu
|
||||
// driven by click position.
|
||||
bool ImGui::BeginPopupContextItem(const char* str_id, int mouse_button)
|
||||
@ -3472,7 +3485,7 @@ static ImVec2 FindBestPopupWindowPos(const ImVec2& base_pos, const ImVec2& size,
|
||||
|
||||
ImGuiWindow* ImGui::FindWindowByName(const char* name)
|
||||
{
|
||||
// FIXME-OPT: Store sorted hashes -> pointers so we can do a bissection in a contiguous block
|
||||
// FIXME-OPT: Store sorted hashes -> pointers so we can do a bissection in a contiguous block
|
||||
ImGuiState& g = *GImGui;
|
||||
ImGuiID id = ImHash(name, 0);
|
||||
for (int i = 0; i < g.Windows.Size; i++)
|
||||
@ -3605,7 +3618,7 @@ bool ImGui::Begin(const char* name, bool* p_opened, const ImVec2& size_on_first_
|
||||
g.CurrentPopupStack.push_back(popup_ref);
|
||||
window->PopupID = popup_ref.PopupID;
|
||||
}
|
||||
|
||||
|
||||
const bool window_appearing_after_being_hidden = (window->HiddenFrames == 1);
|
||||
|
||||
// Process SetNextWindow***() calls
|
||||
@ -3753,7 +3766,7 @@ bool ImGui::Begin(const char* name, bool* p_opened, const ImVec2& size_on_first_
|
||||
else
|
||||
{
|
||||
size_auto_fit = ImClamp(window->SizeContents + window->WindowPadding, style.WindowMinSize, ImMax(style.WindowMinSize, g.IO.DisplaySize - g.Style.DisplaySafeAreaPadding));
|
||||
|
||||
|
||||
// Handling case of auto fit window not fitting in screen on one axis, we are growing auto fit size on the other axis to compensate for expected scrollbar. FIXME: Might turn bigger than DisplaySize-WindowPadding.
|
||||
if (size_auto_fit.x < window->SizeContents.x && !(flags & ImGuiWindowFlags_NoScrollbar) && (flags & ImGuiWindowFlags_HorizontalScrollbar))
|
||||
size_auto_fit.y += style.ScrollbarSize;
|
||||
@ -4832,16 +4845,19 @@ ImDrawList* ImGui::GetWindowDrawList()
|
||||
return window->DrawList;
|
||||
}
|
||||
|
||||
ImFont* ImGui::GetWindowFont()
|
||||
ImFont* ImGui::GetFont()
|
||||
{
|
||||
ImGuiState& g = *GImGui;
|
||||
return g.Font;
|
||||
return GImGui->Font;
|
||||
}
|
||||
|
||||
float ImGui::GetWindowFontSize()
|
||||
float ImGui::GetFontSize()
|
||||
{
|
||||
ImGuiState& g = *GImGui;
|
||||
return g.FontSize;
|
||||
return GImGui->FontSize;
|
||||
}
|
||||
|
||||
ImVec2 ImGui::GetFontTexUvWhitePixel()
|
||||
{
|
||||
return GImGui->FontTexUvWhitePixel;
|
||||
}
|
||||
|
||||
void ImGui::SetWindowFontScale(float scale)
|
||||
@ -5625,7 +5641,7 @@ bool ImGui::CollapsingHeader(const char* label, const char* str_id, bool display
|
||||
label = str_id;
|
||||
const bool label_hide_text_after_double_hash = (label == str_id); // Only search and hide text after ## if we have passed label and ID separately, otherwise allow "##" within format string.
|
||||
const ImGuiID id = window->GetID(str_id);
|
||||
const ImVec2 label_size = CalcTextSize(label, NULL, label_hide_text_after_double_hash);
|
||||
const ImVec2 label_size = CalcTextSize(label, NULL, label_hide_text_after_double_hash);
|
||||
|
||||
// We vertically grow up to current line height up the typical widget height.
|
||||
const float text_base_offset_y = ImMax(0.0f, window->DC.CurrentLineTextBaseOffset - padding.y); // Latch before ItemSize changes it
|
||||
@ -5919,7 +5935,7 @@ static void DataTypeApplyOp(ImGuiDataType data_type, int op, void* value1, const
|
||||
}
|
||||
|
||||
// User can input math operators (e.g. +100) to edit a numerical values.
|
||||
static void DataTypeApplyOpFromText(const char* buf, const char* initial_value_buf, ImGuiDataType data_type, void* data_ptr, const char* scalar_format)
|
||||
static bool DataTypeApplyOpFromText(const char* buf, const char* initial_value_buf, ImGuiDataType data_type, void* data_ptr, const char* scalar_format)
|
||||
{
|
||||
while (ImCharIsSpace(*buf))
|
||||
buf++;
|
||||
@ -5938,41 +5954,47 @@ static void DataTypeApplyOpFromText(const char* buf, const char* initial_value_b
|
||||
op = 0;
|
||||
}
|
||||
if (!buf[0])
|
||||
return;
|
||||
return false;
|
||||
|
||||
if (data_type == ImGuiDataType_Int)
|
||||
{
|
||||
if (!scalar_format)
|
||||
scalar_format = "%d";
|
||||
int* v = (int*)data_ptr;
|
||||
int ref_v = *v;
|
||||
if (op && sscanf(initial_value_buf, scalar_format, &ref_v) < 1)
|
||||
return;
|
||||
const int old_v = *v;
|
||||
int arg0 = *v;
|
||||
if (op && sscanf(initial_value_buf, scalar_format, &arg0) < 1)
|
||||
return false;
|
||||
|
||||
// Store operand in a float so we can use fractional value for multipliers (*1.1), but constant always parsed as integer so we can fit big integers (e.g. 2000000003) past float precision
|
||||
float op_v = 0.0f;
|
||||
if (op == '+') { if (sscanf(buf, "%f", &op_v) == 1) *v = (int)(ref_v + op_v); } // Add (use "+-" to subtract)
|
||||
else if (op == '*') { if (sscanf(buf, "%f", &op_v) == 1) *v = (int)(ref_v * op_v); } // Multiply
|
||||
else if (op == '/') { if (sscanf(buf, "%f", &op_v) == 1 && op_v != 0.0f) *v = (int)(ref_v / op_v); }// Divide
|
||||
else { if (sscanf(buf, scalar_format, &ref_v) == 1) *v = ref_v; } // Assign constant
|
||||
float arg1 = 0.0f;
|
||||
if (op == '+') { if (sscanf(buf, "%f", &arg1) == 1) *v = (int)(arg0 + arg1); } // Add (use "+-" to subtract)
|
||||
else if (op == '*') { if (sscanf(buf, "%f", &arg1) == 1) *v = (int)(arg0 * arg1); } // Multiply
|
||||
else if (op == '/') { if (sscanf(buf, "%f", &arg1) == 1 && arg1 != 0.0f) *v = (int)(arg0 / arg1); }// Divide
|
||||
else { if (sscanf(buf, scalar_format, &arg0) == 1) *v = arg0; } // Assign constant
|
||||
return (old_v != *v);
|
||||
}
|
||||
else if (data_type == ImGuiDataType_Float)
|
||||
{
|
||||
// For floats we have to ignore format with precision (e.g. "%.2f") because sscanf doesn't take them in
|
||||
scalar_format = "%f";
|
||||
float* v = (float*)data_ptr;
|
||||
float ref_v = *v;
|
||||
if (op && sscanf(initial_value_buf, scalar_format, &ref_v) < 1)
|
||||
return;
|
||||
float op_v = 0.0f;
|
||||
if (sscanf(buf, scalar_format, &op_v) < 1)
|
||||
return;
|
||||
const float old_v = *v;
|
||||
float arg0 = *v;
|
||||
if (op && sscanf(initial_value_buf, scalar_format, &arg0) < 1)
|
||||
return false;
|
||||
|
||||
if (op == '+') { *v = ref_v + op_v; } // Add (use "+-" to subtract)
|
||||
else if (op == '*') { *v = ref_v * op_v; } // Multiply
|
||||
else if (op == '/') { if (op_v != 0.0f) *v = ref_v / op_v; } // Divide
|
||||
else { *v = op_v; } // Assign constant
|
||||
float arg1 = 0.0f;
|
||||
if (sscanf(buf, scalar_format, &arg1) < 1)
|
||||
return false;
|
||||
if (op == '+') { *v = arg0 + arg1; } // Add (use "+-" to subtract)
|
||||
else if (op == '*') { *v = arg0 * arg1; } // Multiply
|
||||
else if (op == '/') { if (arg1 != 0.0f) *v = arg0 / arg1; } // Divide
|
||||
else { *v = arg1; } // Assign constant
|
||||
return (old_v != *v);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Create text input in place of a slider (when CTRL+Clicking on slider)
|
||||
@ -5988,7 +6010,7 @@ bool ImGui::InputScalarAsWidgetReplacement(const ImRect& aabb, const char* label
|
||||
|
||||
char buf[32];
|
||||
DataTypeFormatString(data_type, data_ptr, decimal_precision, buf, IM_ARRAYSIZE(buf));
|
||||
bool value_changed = InputTextEx(label, buf, IM_ARRAYSIZE(buf), aabb.GetSize(), ImGuiInputTextFlags_CharsDecimal | ImGuiInputTextFlags_AutoSelectAll);
|
||||
bool text_value_changed = InputTextEx(label, buf, IM_ARRAYSIZE(buf), aabb.GetSize(), ImGuiInputTextFlags_CharsDecimal | ImGuiInputTextFlags_AutoSelectAll);
|
||||
if (g.ScalarAsInputTextId == 0)
|
||||
{
|
||||
// First frame
|
||||
@ -6001,9 +6023,9 @@ bool ImGui::InputScalarAsWidgetReplacement(const ImRect& aabb, const char* label
|
||||
// Release
|
||||
g.ScalarAsInputTextId = 0;
|
||||
}
|
||||
if (value_changed)
|
||||
DataTypeApplyOpFromText(buf, GImGui->InputTextState.InitialText.begin(), data_type, data_ptr, NULL);
|
||||
return value_changed;
|
||||
if (text_value_changed)
|
||||
return DataTypeApplyOpFromText(buf, GImGui->InputTextState.InitialText.begin(), data_type, data_ptr, NULL);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Parse display precision back from the display format string
|
||||
@ -6336,7 +6358,7 @@ bool ImGui::SliderFloatN(const char* label, float* v, int components, float v_mi
|
||||
}
|
||||
ImGui::PopID();
|
||||
|
||||
ImGui::TextUnformatted(label, FindTextDisplayEnd(label));
|
||||
ImGui::TextUnformatted(label, FindRenderedTextEnd(label));
|
||||
ImGui::EndGroup();
|
||||
|
||||
return value_changed;
|
||||
@ -6378,7 +6400,7 @@ bool ImGui::SliderIntN(const char* label, int* v, int components, int v_min, int
|
||||
}
|
||||
ImGui::PopID();
|
||||
|
||||
ImGui::TextUnformatted(label, FindTextDisplayEnd(label));
|
||||
ImGui::TextUnformatted(label, FindRenderedTextEnd(label));
|
||||
ImGui::EndGroup();
|
||||
|
||||
return value_changed;
|
||||
@ -6558,7 +6580,7 @@ bool ImGui::DragFloatN(const char* label, float* v, int components, float v_spee
|
||||
}
|
||||
ImGui::PopID();
|
||||
|
||||
ImGui::TextUnformatted(label, FindTextDisplayEnd(label));
|
||||
ImGui::TextUnformatted(label, FindRenderedTextEnd(label));
|
||||
ImGui::EndGroup();
|
||||
|
||||
return value_changed;
|
||||
@ -6597,7 +6619,7 @@ bool ImGui::DragFloatRange2(const char* label, float* v_current_min, float* v_cu
|
||||
ImGui::PopItemWidth();
|
||||
ImGui::SameLine(0, g.Style.ItemInnerSpacing.x);
|
||||
|
||||
ImGui::TextUnformatted(label, FindTextDisplayEnd(label));
|
||||
ImGui::TextUnformatted(label, FindRenderedTextEnd(label));
|
||||
ImGui::EndGroup();
|
||||
ImGui::PopID();
|
||||
|
||||
@ -6636,7 +6658,7 @@ bool ImGui::DragIntN(const char* label, int* v, int components, float v_speed, i
|
||||
}
|
||||
ImGui::PopID();
|
||||
|
||||
ImGui::TextUnformatted(label, FindTextDisplayEnd(label));
|
||||
ImGui::TextUnformatted(label, FindRenderedTextEnd(label));
|
||||
ImGui::EndGroup();
|
||||
|
||||
return value_changed;
|
||||
@ -6675,7 +6697,7 @@ bool ImGui::DragIntRange2(const char* label, int* v_current_min, int* v_current_
|
||||
ImGui::PopItemWidth();
|
||||
ImGui::SameLine(0, g.Style.ItemInnerSpacing.x);
|
||||
|
||||
ImGui::TextUnformatted(label, FindTextDisplayEnd(label));
|
||||
ImGui::TextUnformatted(label, FindRenderedTextEnd(label));
|
||||
ImGui::EndGroup();
|
||||
ImGui::PopID();
|
||||
|
||||
@ -6853,7 +6875,7 @@ void ImGui::ProgressBar(float fraction, const ImVec2& size_arg, const char* over
|
||||
ImFormatString(overlay_buf, IM_ARRAYSIZE(overlay_buf), "%.0f%%", fraction*100+0.01f);
|
||||
overlay = overlay_buf;
|
||||
}
|
||||
|
||||
|
||||
ImVec2 overlay_size = CalcTextSize(overlay, NULL);
|
||||
if (overlay_size.x > 0.0f)
|
||||
RenderTextClipped(ImVec2(ImClamp(fill_br.x + style.ItemSpacing.x, bb.Min.x, bb.Max.x - overlay_size.x - style.ItemInnerSpacing.x), bb.Min.y), bb.Max, overlay, NULL, &overlay_size, ImGuiAlign_Left|ImGuiAlign_VCenter, &bb.Min, &bb.Max);
|
||||
@ -6909,12 +6931,16 @@ bool ImGui::Checkbox(const char* label, bool* v)
|
||||
|
||||
bool ImGui::CheckboxFlags(const char* label, unsigned int* flags, unsigned int flags_value)
|
||||
{
|
||||
bool v = (*flags & flags_value) ? true : false;
|
||||
bool v = ((*flags & flags_value) == flags_value);
|
||||
bool pressed = ImGui::Checkbox(label, &v);
|
||||
if (v)
|
||||
*flags |= flags_value;
|
||||
else
|
||||
*flags &= ~flags_value;
|
||||
if (pressed)
|
||||
{
|
||||
if (v)
|
||||
*flags |= flags_value;
|
||||
else
|
||||
*flags &= ~flags_value;
|
||||
}
|
||||
|
||||
return pressed;
|
||||
}
|
||||
|
||||
@ -7749,7 +7775,7 @@ bool ImGui::InputTextEx(const char* label, char* buf, int buf_size, const ImVec2
|
||||
|
||||
// Notify OS of text input position for advanced IME (-1 x offset so that Windows IME can cover our cursor. Bit of an extra nicety.)
|
||||
if (is_editable)
|
||||
g.OsImePosRequest = ImVec2(cursor_screen_pos.x - 1, cursor_screen_pos.y - g.FontSize);
|
||||
g.OsImePosRequest = ImVec2(cursor_screen_pos.x - 1, cursor_screen_pos.y - g.FontSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -7821,10 +7847,7 @@ bool ImGui::InputScalarEx(const char* label, ImGuiDataType data_type, void* data
|
||||
extra_flags |= ImGuiInputTextFlags_CharsDecimal;
|
||||
extra_flags |= ImGuiInputTextFlags_AutoSelectAll;
|
||||
if (ImGui::InputText("", buf, IM_ARRAYSIZE(buf), extra_flags))
|
||||
{
|
||||
DataTypeApplyOpFromText(buf, GImGui->InputTextState.InitialText.begin(), data_type, data_ptr, scalar_format);
|
||||
value_changed = true;
|
||||
}
|
||||
value_changed = DataTypeApplyOpFromText(buf, GImGui->InputTextState.InitialText.begin(), data_type, data_ptr, scalar_format);
|
||||
|
||||
// Step buttons
|
||||
if (step_ptr)
|
||||
@ -7895,7 +7918,7 @@ bool ImGui::InputFloatN(const char* label, float* v, int components, int decimal
|
||||
ImGui::PopID();
|
||||
|
||||
window->DC.CurrentLineTextBaseOffset = ImMax(window->DC.CurrentLineTextBaseOffset, g.Style.FramePadding.y);
|
||||
ImGui::TextUnformatted(label, FindTextDisplayEnd(label));
|
||||
ImGui::TextUnformatted(label, FindRenderedTextEnd(label));
|
||||
ImGui::EndGroup();
|
||||
|
||||
return value_changed;
|
||||
@ -7938,7 +7961,7 @@ bool ImGui::InputIntN(const char* label, int* v, int components, ImGuiInputTextF
|
||||
ImGui::PopID();
|
||||
|
||||
window->DC.CurrentLineTextBaseOffset = ImMax(window->DC.CurrentLineTextBaseOffset, g.Style.FramePadding.y);
|
||||
ImGui::TextUnformatted(label, FindTextDisplayEnd(label));
|
||||
ImGui::TextUnformatted(label, FindRenderedTextEnd(label));
|
||||
ImGui::EndGroup();
|
||||
|
||||
return value_changed;
|
||||
@ -8029,10 +8052,12 @@ bool ImGui::Combo(const char* label, int* current_item, bool (*items_getter)(voi
|
||||
|
||||
const float arrow_size = (g.FontSize + style.FramePadding.x * 2.0f);
|
||||
const bool hovered = IsHovered(frame_bb, id);
|
||||
bool popup_opened = IsPopupOpen(id);
|
||||
bool popup_opened_now = false;
|
||||
|
||||
const ImRect value_bb(frame_bb.Min, frame_bb.Max - ImVec2(arrow_size, 0.0f));
|
||||
RenderFrame(frame_bb.Min, frame_bb.Max, GetColorU32(ImGuiCol_FrameBg), true, style.FrameRounding);
|
||||
RenderFrame(ImVec2(frame_bb.Max.x-arrow_size, frame_bb.Min.y), frame_bb.Max, GetColorU32(hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button), true, style.FrameRounding); // FIXME-ROUNDING
|
||||
RenderFrame(ImVec2(frame_bb.Max.x-arrow_size, frame_bb.Min.y), frame_bb.Max, GetColorU32(popup_opened || hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button), true, style.FrameRounding); // FIXME-ROUNDING
|
||||
RenderCollapseTriangle(ImVec2(frame_bb.Max.x-arrow_size, frame_bb.Min.y) + style.FramePadding, true);
|
||||
|
||||
if (*current_item >= 0 && *current_item < items_count)
|
||||
@ -8045,7 +8070,6 @@ bool ImGui::Combo(const char* label, int* current_item, bool (*items_getter)(voi
|
||||
if (label_size.x > 0)
|
||||
RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, frame_bb.Min.y + style.FramePadding.y), label);
|
||||
|
||||
bool menu_toggled = false;
|
||||
if (hovered)
|
||||
{
|
||||
SetHoveredID(id);
|
||||
@ -8059,8 +8083,8 @@ bool ImGui::Combo(const char* label, int* current_item, bool (*items_getter)(voi
|
||||
else
|
||||
{
|
||||
FocusWindow(window);
|
||||
ImGui::OpenPopup(label);
|
||||
menu_toggled = true;
|
||||
OpenPopup(label);
|
||||
popup_opened = popup_opened_now = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -8073,8 +8097,15 @@ bool ImGui::Combo(const char* label, int* current_item, bool (*items_getter)(voi
|
||||
height_in_items = 7;
|
||||
|
||||
float popup_height = (label_size.y + style.ItemSpacing.y) * ImMin(items_count, height_in_items) + (style.FramePadding.y * 3);
|
||||
ImRect popup_rect(ImVec2(frame_bb.Min.x, frame_bb.Max.y), ImVec2(frame_bb.Max.x, frame_bb.Max.y + popup_height));
|
||||
popup_rect.Max.y = ImMin(popup_rect.Max.y, g.IO.DisplaySize.y - style.DisplaySafeAreaPadding.y); // Adhoc height limit for Combo. Ideally should be handled in Begin() along with other popups size, we want to have the possibility of moving the popup above as well.
|
||||
float popup_y1 = frame_bb.Max.y;
|
||||
float popup_y2 = ImClamp(popup_y1 + popup_height, popup_y1, g.IO.DisplaySize.y - style.DisplaySafeAreaPadding.y);
|
||||
if ((popup_y2 - popup_y1) < ImMin(popup_height, frame_bb.Min.y - style.DisplaySafeAreaPadding.y))
|
||||
{
|
||||
// Position our combo ABOVE because there's more space to fit! (FIXME: Handle in Begin() or use a shared helper. We have similar code in Begin() for popup placement)
|
||||
popup_y1 = ImClamp(frame_bb.Min.y - popup_height, style.DisplaySafeAreaPadding.y, frame_bb.Min.y);
|
||||
popup_y2 = frame_bb.Min.y;
|
||||
}
|
||||
ImRect popup_rect(ImVec2(frame_bb.Min.x, popup_y1), ImVec2(frame_bb.Max.x, popup_y2));
|
||||
ImGui::SetNextWindowPos(popup_rect.Min);
|
||||
ImGui::SetNextWindowSize(popup_rect.GetSize());
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, style.FramePadding);
|
||||
@ -8097,7 +8128,7 @@ bool ImGui::Combo(const char* label, int* current_item, bool (*items_getter)(voi
|
||||
value_changed = true;
|
||||
*current_item = i;
|
||||
}
|
||||
if (item_selected && menu_toggled)
|
||||
if (item_selected && popup_opened_now)
|
||||
ImGui::SetScrollHere();
|
||||
ImGui::PopID();
|
||||
}
|
||||
@ -8636,7 +8667,7 @@ bool ImGui::ColorEdit4(const char* label, float col[4], bool alpha)
|
||||
const ImVec4 col_display(col[0], col[1], col[2], 1.0f);
|
||||
if (ImGui::ColorButton(col_display))
|
||||
g.ColorEditModeStorage.SetInt(id, (edit_mode + 1) % 3); // Don't set local copy of 'edit_mode' right away!
|
||||
|
||||
|
||||
// Recreate our own tooltip over's ColorButton() one because we want to display correct alpha here
|
||||
if (ImGui::IsItemHovered())
|
||||
ImGui::SetTooltip("Color:\n(%.2f,%.2f,%.2f,%.2f)\n#%02X%02X%02X%02X", col[0], col[1], col[2], col[3], IM_F32_TO_INT8(col[0]), IM_F32_TO_INT8(col[1]), IM_F32_TO_INT8(col[2]), IM_F32_TO_INT8(col[3]));
|
||||
@ -8649,7 +8680,7 @@ bool ImGui::ColorEdit4(const char* label, float col[4], bool alpha)
|
||||
g.ColorEditModeStorage.SetInt(id, (edit_mode + 1) % 3); // Don't set local copy of 'edit_mode' right away!
|
||||
}
|
||||
|
||||
const char* label_display_end = FindTextDisplayEnd(label);
|
||||
const char* label_display_end = FindRenderedTextEnd(label);
|
||||
if (label != label_display_end)
|
||||
{
|
||||
ImGui::SameLine(0, (window->DC.ColorEditMode == ImGuiColorEditMode_UserSelectShowButton) ? -1.0f : style.ItemInnerSpacing.x);
|
||||
@ -8733,7 +8764,7 @@ void ImGui::Dummy(const ImVec2& size)
|
||||
ImGuiWindow* window = GetCurrentWindow();
|
||||
if (window->SkipItems)
|
||||
return;
|
||||
|
||||
|
||||
const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + size);
|
||||
ItemSize(bb);
|
||||
ItemAdd(bb, NULL);
|
||||
@ -8798,33 +8829,31 @@ void ImGui::EndGroup()
|
||||
}
|
||||
|
||||
// Gets back to previous line and continue with horizontal layout
|
||||
// local_pos_x == 0 : follow on previous item
|
||||
// local_pos_x != 0 : align to specified column
|
||||
// pos_x == 0 : follow on previous item
|
||||
// pos_x != 0 : align to specified column
|
||||
// spacing_w < 0 : use default spacing if column_x==0, no spacing if column_x!=0
|
||||
// spacing_w >= 0 : enforce spacing
|
||||
void ImGui::SameLine(float local_pos_x, float spacing_w)
|
||||
void ImGui::SameLine(float pos_x, float spacing_w)
|
||||
{
|
||||
ImGuiWindow* window = GetCurrentWindow();
|
||||
if (window->SkipItems)
|
||||
return;
|
||||
|
||||
ImGuiState& g = *GImGui;
|
||||
float x, y;
|
||||
if (local_pos_x != 0.0f)
|
||||
if (pos_x != 0.0f)
|
||||
{
|
||||
if (spacing_w < 0.0f) spacing_w = 0.0f;
|
||||
x = window->Pos.x - window->Scroll.x + local_pos_x + spacing_w;
|
||||
y = window->DC.CursorPosPrevLine.y;
|
||||
window->DC.CursorPos.x = window->Pos.x - window->Scroll.x + pos_x + spacing_w;
|
||||
window->DC.CursorPos.y = window->DC.CursorPosPrevLine.y;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (spacing_w < 0.0f) spacing_w = g.Style.ItemSpacing.x;
|
||||
x = window->DC.CursorPosPrevLine.x + spacing_w;
|
||||
y = window->DC.CursorPosPrevLine.y;
|
||||
window->DC.CursorPos.x = window->DC.CursorPosPrevLine.x + spacing_w;
|
||||
window->DC.CursorPos.y = window->DC.CursorPosPrevLine.y;
|
||||
}
|
||||
window->DC.CurrentLineHeight = window->DC.PrevLineHeight;
|
||||
window->DC.CurrentLineTextBaseOffset = window->DC.PrevLineTextBaseOffset;
|
||||
window->DC.CursorPos = ImVec2(x, y);
|
||||
}
|
||||
|
||||
void ImGui::NextColumn()
|
||||
@ -8997,9 +9026,9 @@ void ImGui::Columns(int columns_count, const char* id, bool border)
|
||||
}
|
||||
}
|
||||
|
||||
// Differentiate column ID with an arbitrary prefix for cases where users name their columns set the same as another widget.
|
||||
// Differentiate column ID with an arbitrary prefix for cases where users name their columns set the same as another widget.
|
||||
// In addition, when an identifier isn't explicitly provided we include the number of columns in the hash to make it uniquer.
|
||||
ImGui::PushID(0x11223347 + (id ? 0 : columns_count));
|
||||
ImGui::PushID(0x11223347 + (id ? 0 : columns_count));
|
||||
window->DC.ColumnsSetID = window->GetID(id ? id : "columns");
|
||||
ImGui::PopID();
|
||||
|
||||
@ -9264,10 +9293,14 @@ void ImGui::ShowMetricsWindow(bool* opened)
|
||||
{
|
||||
ImGui::SameLine();
|
||||
ImGui::TextColored(ImColor(255,100,100), "CURRENTLY APPENDING"); // Can't display stats for active draw list! (we don't have the data double-buffered)
|
||||
if (node_opened) ImGui::TreePop();
|
||||
return;
|
||||
}
|
||||
if (!node_opened)
|
||||
return;
|
||||
|
||||
ImDrawList* overlay_draw_list = &GImGui->OverlayDrawList; // Render additional visuals into the top-most draw list
|
||||
overlay_draw_list->PushClipRectFullScreen();
|
||||
int elem_offset = 0;
|
||||
for (const ImDrawCmd* pcmd = draw_list->CmdBuffer.begin(); pcmd < draw_list->CmdBuffer.end(); elem_offset += pcmd->ElemCount, pcmd++)
|
||||
{
|
||||
@ -9276,7 +9309,7 @@ void ImGui::ShowMetricsWindow(bool* opened)
|
||||
ImGui::BulletText("Callback %p, user_data %p", pcmd->UserCallback, pcmd->UserCallbackData);
|
||||
continue;
|
||||
}
|
||||
ImGui::BulletText("Draw %-4d %s vtx, tex = %p, clip_rect = (%.0f,%.0f)..(%.0f,%.0f)", pcmd->ElemCount, draw_list->IdxBuffer.Size > 0 ? "indexed" : "non-indexed", pcmd->TextureId, pcmd->ClipRect.x, pcmd->ClipRect.y, pcmd->ClipRect.z, pcmd->ClipRect.w);
|
||||
bool draw_opened = ImGui::TreeNode((void*)(pcmd - draw_list->CmdBuffer.begin()), "Draw %-4d %s vtx, tex = %p, clip_rect = (%.0f,%.0f)..(%.0f,%.0f)", pcmd->ElemCount, draw_list->IdxBuffer.Size > 0 ? "indexed" : "non-indexed", pcmd->TextureId, pcmd->ClipRect.x, pcmd->ClipRect.y, pcmd->ClipRect.z, pcmd->ClipRect.w);
|
||||
if (show_clip_rects && ImGui::IsItemHovered())
|
||||
{
|
||||
ImRect clip_rect = pcmd->ClipRect;
|
||||
@ -9284,12 +9317,28 @@ void ImGui::ShowMetricsWindow(bool* opened)
|
||||
ImDrawIdx* idx_buffer = (draw_list->IdxBuffer.Size > 0) ? draw_list->IdxBuffer.Data : NULL;
|
||||
for (int i = elem_offset; i < elem_offset + (int)pcmd->ElemCount; i++)
|
||||
vtxs_rect.Add(draw_list->VtxBuffer[idx_buffer ? idx_buffer[i] : i].pos);
|
||||
GImGui->OverlayDrawList.PushClipRectFullScreen();
|
||||
clip_rect.Round(); GImGui->OverlayDrawList.AddRect(clip_rect.Min, clip_rect.Max, ImColor(255,255,0));
|
||||
vtxs_rect.Round(); GImGui->OverlayDrawList.AddRect(vtxs_rect.Min, vtxs_rect.Max, ImColor(255,0,255));
|
||||
GImGui->OverlayDrawList.PopClipRect();
|
||||
clip_rect.Round(); overlay_draw_list->AddRect(clip_rect.Min, clip_rect.Max, ImColor(255,255,0));
|
||||
vtxs_rect.Round(); overlay_draw_list->AddRect(vtxs_rect.Min, vtxs_rect.Max, ImColor(255,0,255));
|
||||
}
|
||||
if (!draw_opened)
|
||||
continue;
|
||||
for (int i = elem_offset; i+2 < elem_offset + (int)pcmd->ElemCount; i += 3)
|
||||
{
|
||||
ImVec2 triangles_pos[3];
|
||||
char buf[300], *buf_p = buf;
|
||||
for (int n = 0; n < 3; n++)
|
||||
{
|
||||
ImDrawVert& v = draw_list->VtxBuffer[(draw_list->IdxBuffer.Size > 0) ? draw_list->IdxBuffer.Data[i+n] : i+n];
|
||||
triangles_pos[n] = v.pos;
|
||||
buf_p += sprintf(buf_p, "vtx %04d { pos = (%8.2f,%8.2f), uv = (%.6f,%.6f), col = %08X }\n", i+n, v.pos.x, v.pos.y, v.uv.x, v.uv.y, v.col);
|
||||
}
|
||||
ImGui::Selectable(buf, false);
|
||||
if (ImGui::IsItemHovered())
|
||||
overlay_draw_list->AddPolyline(triangles_pos, 3, ImColor(255,255,0), true, 1.0f, false); // Add triangle without AA, more readable for large-thin triangle
|
||||
}
|
||||
ImGui::TreePop();
|
||||
}
|
||||
overlay_draw_list->PopClipRect();
|
||||
ImGui::TreePop();
|
||||
}
|
||||
|
||||
|
64
3rdparty/bgfx/3rdparty/ocornut-imgui/imgui.h
vendored
64
3rdparty/bgfx/3rdparty/ocornut-imgui/imgui.h
vendored
@ -58,7 +58,7 @@ struct ImGuiListClipper; // Helper to manually clip large list of ite
|
||||
// Enumerations (declared as int for compatibility and to not pollute the top of this file)
|
||||
typedef unsigned int ImU32;
|
||||
typedef unsigned short ImWchar; // character for keyboard input/display
|
||||
typedef void* ImTextureID; // user data to refer to a texture (e.g. store your texture handle/id)
|
||||
typedef void* ImTextureID; // user data to identify a texture (this is whatever to you want it to be! read the FAQ about ImTextureID in imgui.cpp)
|
||||
typedef ImU32 ImGuiID; // unique ID used by widgets (typically hashed from a stack of string)
|
||||
typedef int ImGuiCol; // a color identifier for styling // enum ImGuiCol_
|
||||
typedef int ImGuiStyleVar; // a variable identifier for styling // enum ImGuiStyleVar_
|
||||
@ -103,14 +103,15 @@ namespace ImGui
|
||||
// Main
|
||||
IMGUI_API ImGuiIO& GetIO();
|
||||
IMGUI_API ImGuiStyle& GetStyle();
|
||||
IMGUI_API ImDrawData* GetDrawData(); // same value as passed to your RenderDrawListsFn() function. valid after Render() and until the next call to NewFrame()
|
||||
IMGUI_API void NewFrame();
|
||||
IMGUI_API void Render();
|
||||
IMGUI_API ImDrawData* GetDrawData(); // same value as passed to your io.RenderDrawListsFn() function. valid after Render() and until the next call to NewFrame()
|
||||
IMGUI_API void NewFrame(); // start a new ImGui frame, you can submit any command from this point until NewFrame()/Render().
|
||||
IMGUI_API void EndFrame(); // ends the ImGui frame. automatically called by Render()!
|
||||
IMGUI_API void Render(); // ends the ImGui frame, finalize rendering data, then call your io.RenderDrawListsFn() function if set.
|
||||
IMGUI_API void Shutdown();
|
||||
IMGUI_API void ShowUserGuide(); // help block
|
||||
IMGUI_API void ShowStyleEditor(ImGuiStyle* ref = NULL); // style editor block
|
||||
IMGUI_API void ShowTestWindow(bool* opened = NULL); // test window, demonstrate ImGui features
|
||||
IMGUI_API void ShowMetricsWindow(bool* opened = NULL); // metrics window for debugging imgui
|
||||
IMGUI_API void ShowTestWindow(bool* opened = NULL); // test window demonstrating ImGui features
|
||||
IMGUI_API void ShowMetricsWindow(bool* opened = NULL); // metrics window for debugging ImGui
|
||||
|
||||
// Window
|
||||
IMGUI_API bool Begin(const char* name, bool* p_opened = NULL, ImGuiWindowFlags flags = 0); // see .cpp for details. return false when window is collapsed, so you can early out in your code. 'bool* p_opened' creates a widget on the upper-right to close the window (which sets your bool to false).
|
||||
@ -124,22 +125,20 @@ namespace ImGui
|
||||
IMGUI_API float GetContentRegionAvailWidth(); //
|
||||
IMGUI_API ImVec2 GetWindowContentRegionMin(); // content boundaries min (roughly (0,0)-Scroll), in window coordinates
|
||||
IMGUI_API ImVec2 GetWindowContentRegionMax(); // content boundaries max (roughly (0,0)+Size-Scroll) where Size can be override with SetNextWindowContentSize(), in window coordinates
|
||||
IMGUI_API float GetWindowContentRegionWidth(); //
|
||||
IMGUI_API float GetWindowContentRegionWidth(); //
|
||||
IMGUI_API ImDrawList* GetWindowDrawList(); // get rendering command-list if you want to append your own draw primitives
|
||||
IMGUI_API ImFont* GetWindowFont();
|
||||
IMGUI_API float GetWindowFontSize(); // size (also height in pixels) of current font with current scale applied
|
||||
IMGUI_API void SetWindowFontScale(float scale); // per-window font scale. Adjust IO.FontGlobalScale if you want to scale all windows
|
||||
IMGUI_API ImVec2 GetWindowPos(); // get current window position in screen space (useful if you want to do your own drawing via the DrawList api)
|
||||
IMGUI_API ImVec2 GetWindowSize(); // get current window size
|
||||
IMGUI_API float GetWindowWidth();
|
||||
IMGUI_API float GetWindowHeight();
|
||||
IMGUI_API bool IsWindowCollapsed();
|
||||
IMGUI_API void SetWindowFontScale(float scale); // per-window font scale. Adjust IO.FontGlobalScale if you want to scale all windows
|
||||
|
||||
IMGUI_API void SetNextWindowPos(const ImVec2& pos, ImGuiSetCond cond = 0); // set next window position. call before Begin()
|
||||
IMGUI_API void SetNextWindowPosCenter(ImGuiSetCond cond = 0); // set next window position to be centered on screen. call before Begin()
|
||||
IMGUI_API void SetNextWindowSize(const ImVec2& size, ImGuiSetCond cond = 0); // set next window size. set axis to 0.0f to force an auto-fit on this axis. call before Begin()
|
||||
IMGUI_API void SetNextWindowContentSize(const ImVec2& size); // set next window content size (enforce the range of scrollbars). set axis to 0.0f to leave it automatic. call before Begin()
|
||||
IMGUI_API void SetNextWindowContentWidth(float width); // set next window content width (enforce the range of horizontal scrollbar). call before Begin()
|
||||
IMGUI_API void SetNextWindowContentWidth(float width); // set next window content width (enforce the range of horizontal scrollbar). call before Begin()
|
||||
IMGUI_API void SetNextWindowCollapsed(bool collapsed, ImGuiSetCond cond = 0); // set next window collapsed state. call before Begin()
|
||||
IMGUI_API void SetNextWindowFocus(); // set next window to be focused / front-most. call before Begin()
|
||||
IMGUI_API void SetWindowPos(const ImVec2& pos, ImGuiSetCond cond = 0); // set current window position - call within Begin()/End(). may incur tearing
|
||||
@ -171,6 +170,9 @@ namespace ImGui
|
||||
IMGUI_API void PushStyleVar(ImGuiStyleVar idx, float val);
|
||||
IMGUI_API void PushStyleVar(ImGuiStyleVar idx, const ImVec2& val);
|
||||
IMGUI_API void PopStyleVar(int count = 1);
|
||||
IMGUI_API ImFont* GetFont(); // get current font
|
||||
IMGUI_API float GetFontSize(); // get current font size (= height in pixels) of current font with current scale applied
|
||||
IMGUI_API ImVec2 GetFontTexUvWhitePixel(); // get UV coordinate for a while pixel, useful to draw custom shapes via the ImDrawList API
|
||||
IMGUI_API ImU32 GetColorU32(ImGuiCol idx, float alpha_mul = 1.0f); // retrieve given style color with style alpha applied and optional extra alpha multiplier
|
||||
IMGUI_API ImU32 GetColorU32(const ImVec4& col); // retrieve given color with style alpha applied
|
||||
|
||||
@ -189,18 +191,11 @@ namespace ImGui
|
||||
IMGUI_API void BeginGroup(); // lock horizontal starting position. once closing a group it is seen as a single item (so you can use IsItemHovered() on a group, SameLine() between groups, etc.
|
||||
IMGUI_API void EndGroup();
|
||||
IMGUI_API void Separator(); // horizontal line
|
||||
IMGUI_API void SameLine(float local_pos_x = 0.0f, float spacing_w = -1.0f); // call between widgets or groups to layout them horizontally
|
||||
IMGUI_API void SameLine(float pos_x = 0.0f, float spacing_w = -1.0f); // call between widgets or groups to layout them horizontally
|
||||
IMGUI_API void Spacing(); // add spacing
|
||||
IMGUI_API void Dummy(const ImVec2& size); // add a dummy item of given size
|
||||
IMGUI_API void Indent(); // move content position toward the right by style.IndentSpacing pixels
|
||||
IMGUI_API void Unindent(); // move content position back to the left (cancel Indent)
|
||||
IMGUI_API void Columns(int count = 1, const char* id = NULL, bool border = true); // setup number of columns. use an identifier to distinguish multiple column sets. close with Columns(1).
|
||||
IMGUI_API void NextColumn(); // next column
|
||||
IMGUI_API int GetColumnIndex(); // get current column index
|
||||
IMGUI_API float GetColumnOffset(int column_index = -1); // get position of column line (in pixels, from the left side of the contents region). pass -1 to use current column, otherwise 0..GetcolumnsCount() inclusive. column 0 is usually 0.0f and not resizable unless you call this
|
||||
IMGUI_API void SetColumnOffset(int column_index, float offset_x); // set position of column line (in pixels, from the left side of the contents region). pass -1 to use current column
|
||||
IMGUI_API float GetColumnWidth(int column_index = -1); // column width (== GetColumnOffset(GetColumnIndex()+1) - GetColumnOffset(GetColumnOffset())
|
||||
IMGUI_API int GetColumnsCount(); // number of columns (what was passed to Columns())
|
||||
IMGUI_API ImVec2 GetCursorPos(); // cursor position is relative to window position
|
||||
IMGUI_API float GetCursorPosX(); // "
|
||||
IMGUI_API float GetCursorPosY(); // "
|
||||
@ -215,6 +210,16 @@ namespace ImGui
|
||||
IMGUI_API float GetTextLineHeightWithSpacing(); // distance (in pixels) between 2 consecutive lines of text == GetWindowFontSize() + GetStyle().ItemSpacing.y
|
||||
IMGUI_API float GetItemsLineHeightWithSpacing(); // distance (in pixels) between 2 consecutive lines of standard height widgets == GetWindowFontSize() + GetStyle().FramePadding.y*2 + GetStyle().ItemSpacing.y
|
||||
|
||||
// Columns
|
||||
// You can also use SameLine(pos_x) for simplified columning. The columns API is still work-in-progress.
|
||||
IMGUI_API void Columns(int count = 1, const char* id = NULL, bool border = true); // setup number of columns. use an identifier to distinguish multiple column sets. close with Columns(1).
|
||||
IMGUI_API void NextColumn(); // next column
|
||||
IMGUI_API int GetColumnIndex(); // get current column index
|
||||
IMGUI_API float GetColumnOffset(int column_index = -1); // get position of column line (in pixels, from the left side of the contents region). pass -1 to use current column, otherwise 0..GetcolumnsCount() inclusive. column 0 is usually 0.0f and not resizable unless you call this
|
||||
IMGUI_API void SetColumnOffset(int column_index, float offset_x); // set position of column line (in pixels, from the left side of the contents region). pass -1 to use current column
|
||||
IMGUI_API float GetColumnWidth(int column_index = -1); // column width (== GetColumnOffset(GetColumnIndex()+1) - GetColumnOffset(GetColumnOffset())
|
||||
IMGUI_API int GetColumnsCount(); // number of columns (what was passed to Columns())
|
||||
|
||||
// ID scopes
|
||||
// If you are creating widgets in a loop you most likely want to push a unique identifier so ImGui can differentiate them.
|
||||
// You can also use the "##foobar" syntax within widget label to distinguish them from each others. Read "A primer on the use of labels/IDs" in the FAQ for more details.
|
||||
@ -330,7 +335,7 @@ namespace ImGui
|
||||
IMGUI_API void ValueColor(const char* prefix, const ImVec4& v);
|
||||
IMGUI_API void ValueColor(const char* prefix, unsigned int v);
|
||||
|
||||
// Tooltip
|
||||
// Tooltips
|
||||
IMGUI_API void SetTooltip(const char* fmt, ...) IM_PRINTFARGS(1); // set tooltip under mouse-cursor, typically use with ImGui::IsHovered(). last call wins
|
||||
IMGUI_API void SetTooltipV(const char* fmt, va_list args);
|
||||
IMGUI_API void BeginTooltip(); // use to create full-featured tooltip windows that aren't just text
|
||||
@ -346,8 +351,8 @@ namespace ImGui
|
||||
IMGUI_API bool MenuItem(const char* label, const char* shortcut = NULL, bool selected = false, bool enabled = true); // return true when activated. shortcuts are displayed for convenience but not processed by ImGui at the moment
|
||||
IMGUI_API bool MenuItem(const char* label, const char* shortcut, bool* p_selected, bool enabled = true); // return true when activated + toggle (*p_selected) if p_selected != NULL
|
||||
|
||||
// Popup
|
||||
IMGUI_API void OpenPopup(const char* str_id); // mark popup as open. popups are closed when user click outside, or activate a pressable item, or CloseCurrentPopup() is called within a BeginPopup()/EndPopup() block. popup identifiers are relative to the current ID-stack (so OpenPopup and BeginPopup needs to be at the same level).
|
||||
// Popups
|
||||
IMGUI_API void OpenPopup(const char* str_id); // mark popup as open. popups are closed when user click outside, or activate a pressable item, or CloseCurrentPopup() is called within a BeginPopup()/EndPopup() block. popup identifiers are relative to the current ID-stack (so OpenPopup and BeginPopup needs to be at the same level).
|
||||
IMGUI_API bool BeginPopup(const char* str_id); // return true if popup if opened and start outputting to it. only call EndPopup() if BeginPopup() returned true!
|
||||
IMGUI_API bool BeginPopupModal(const char* name, bool* p_opened = NULL, ImGuiWindowFlags extra_flags = 0); // modal dialog (can't close them by clicking outside)
|
||||
IMGUI_API bool BeginPopupContextItem(const char* str_id, int mouse_button = 1); // helper to open and begin popup when clicked on last item. read comments in .cpp!
|
||||
@ -407,7 +412,7 @@ namespace ImGui
|
||||
IMGUI_API bool IsMouseReleased(int button); // did mouse button released (went from Down to !Down)
|
||||
IMGUI_API bool IsMouseHoveringWindow(); // is mouse hovering current window ("window" in API names always refer to current window). disregarding of any consideration of being blocked by a popup. (unlike IsWindowHovered() this will return true even if the window is blocked because of a popup)
|
||||
IMGUI_API bool IsMouseHoveringAnyWindow(); // is mouse hovering any visible window
|
||||
IMGUI_API bool IsMouseHoveringRect(const ImVec2& pos_min, const ImVec2& pos_max, bool clip = true); // is mouse hovering given bounding rect (in screen space). clipped by current clipping settings. disregarding of consideration of focus/window ordering/blocked by a popup.
|
||||
IMGUI_API bool IsMouseHoveringRect(const ImVec2& r_min, const ImVec2& r_max, bool clip = true); // is mouse hovering given bounding rect (in screen space). clipped by current clipping settings. disregarding of consideration of focus/window ordering/blocked by a popup.
|
||||
IMGUI_API bool IsMouseDragging(int button = 0, float lock_threshold = -1.0f); // is mouse dragging. if lock_threshold < -1.0f uses io.MouseDraggingThreshold
|
||||
IMGUI_API ImVec2 GetMousePos(); // shortcut to ImGui::GetIO().MousePos provided by user, to be consistent with other calls
|
||||
IMGUI_API ImVec2 GetMousePosOnOpeningCurrentPopup(); // retrieve backup of mouse positioning at the time of opening popup we have BeginPopup() into
|
||||
@ -432,6 +437,8 @@ namespace ImGui
|
||||
|
||||
// Obsolete (will be removed)
|
||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
static inline ImFont* GetWindowFont() { return GetFont(); } // OBSOLETE 1.48+
|
||||
static inline float GetWindowFontSize() { return GetFontSize(); } // OBSOLETE 1.48+
|
||||
static inline void OpenNextNode(bool open) { ImGui::SetNextTreeNodeOpened(open, 0); } // OBSOLETE 1.34+
|
||||
static inline bool GetWindowIsFocused() { return ImGui::IsWindowFocused(); } // OBSOLETE 1.36+
|
||||
static inline bool GetWindowCollapsed() { return ImGui::IsWindowCollapsed(); } // OBSOLETE 1.39+
|
||||
@ -707,7 +714,7 @@ struct ImGuiIO
|
||||
// User Functions
|
||||
//------------------------------------------------------------------
|
||||
|
||||
// Rendering function, will be called in Render().
|
||||
// Rendering function, will be called in Render().
|
||||
// Alternatively you can keep this to NULL and call GetDrawData() after Render() to get the same pointer.
|
||||
// See example applications if you are unsure of how to implement this.
|
||||
void (*RenderDrawListsFn)(ImDrawData* data);
|
||||
@ -1124,11 +1131,12 @@ struct ImDrawList
|
||||
|
||||
// Primitives
|
||||
IMGUI_API void AddLine(const ImVec2& a, const ImVec2& b, ImU32 col, float thickness = 1.0f);
|
||||
IMGUI_API void AddRect(const ImVec2& a, const ImVec2& b, ImU32 col, float rounding = 0.0f, int rounding_corners = 0x0F); // a: upper-left, b: lower-right
|
||||
IMGUI_API void AddRectFilled(const ImVec2& a, const ImVec2& b, ImU32 col, float rounding = 0.0f, int rounding_corners = 0x0F); // a: upper-left, b: lower-right
|
||||
IMGUI_API void AddRect(const ImVec2& a, const ImVec2& b, ImU32 col, float rounding = 0.0f, int rounding_corners = 0x0F, float thickness = 1.0f); // a: upper-left, b: lower-right
|
||||
IMGUI_API void AddRectFilled(const ImVec2& a, const ImVec2& b, ImU32 col, float rounding = 0.0f, int rounding_corners = 0x0F); // a: upper-left, b: lower-right
|
||||
IMGUI_API void AddRectFilledMultiColor(const ImVec2& a, const ImVec2& b, ImU32 col_upr_left, ImU32 col_upr_right, ImU32 col_bot_right, ImU32 col_bot_left);
|
||||
IMGUI_API void AddTriangle(const ImVec2& a, const ImVec2& b, const ImVec2& c, ImU32 col, float thickness = 1.0f);
|
||||
IMGUI_API void AddTriangleFilled(const ImVec2& a, const ImVec2& b, const ImVec2& c, ImU32 col);
|
||||
IMGUI_API void AddCircle(const ImVec2& centre, float radius, ImU32 col, int num_segments = 12);
|
||||
IMGUI_API void AddCircle(const ImVec2& centre, float radius, ImU32 col, int num_segments = 12, float thickness = 1.0f);
|
||||
IMGUI_API void AddCircleFilled(const ImVec2& centre, float radius, ImU32 col, int num_segments = 12);
|
||||
IMGUI_API void AddText(const ImVec2& pos, ImU32 col, const char* text_begin, const char* text_end = NULL);
|
||||
IMGUI_API void AddText(const ImFont* font, float font_size, const ImVec2& pos, ImU32 col, const char* text_begin, const char* text_end = NULL, float wrap_width = 0.0f, const ImVec4* cpu_fine_clip_rect = NULL);
|
||||
@ -1258,7 +1266,7 @@ struct ImFontAtlas
|
||||
int TexWidth; // Texture width calculated during Build().
|
||||
int TexHeight; // Texture height calculated during Build().
|
||||
int TexDesiredWidth; // Texture width desired by user before Build(). Must be a power-of-two. If have many glyphs your graphics API have texture size restrictions you may want to increase texture width to decrease height.
|
||||
ImVec2 TexUvWhitePixel; // Texture coordinates to a white pixel (part of the TexExtraData block)
|
||||
ImVec2 TexUvWhitePixel; // Texture coordinates to a white pixel
|
||||
ImVector<ImFont*> Fonts; // Hold all the fonts returned by AddFont*. Fonts[0] is the default font upon calling ImGui::NewFrame(), use ImGui::PushFont()/PopFont() to change the current font.
|
||||
|
||||
// Private
|
||||
|
@ -443,7 +443,7 @@ void ImGui::ShowTestWindow(bool* p_opened)
|
||||
static char buf6[64] = ""; ImGui::InputText("\"imgui\" letters", buf6, 64, ImGuiInputTextFlags_CallbackCharFilter, TextFilters::FilterImGuiLetters);
|
||||
|
||||
ImGui::Text("Password input");
|
||||
static char bufpass[64] = "password123";
|
||||
static char bufpass[64] = "password123";
|
||||
ImGui::InputText("password", bufpass, 64, ImGuiInputTextFlags_Password | ImGuiInputTextFlags_CharsNoBlank);
|
||||
ImGui::SameLine(); ShowHelpMarker("Display all characters as '*'.\nDisable clipboard cut and copy.\nDisable logging.\n");
|
||||
ImGui::InputText("password (clear)", bufpass, 64, ImGuiInputTextFlags_CharsNoBlank);
|
||||
@ -454,7 +454,7 @@ void ImGui::ShowTestWindow(bool* p_opened)
|
||||
if (ImGui::TreeNode("Multi-line Text Input"))
|
||||
{
|
||||
static bool read_only = false;
|
||||
static char text[1024*16] =
|
||||
static char text[1024*16] =
|
||||
"/*\n"
|
||||
" The Pentium F00F bug, shorthand for F0 0F C7 C8,\n"
|
||||
" the hexadecimal encoding of one offending instruction,\n"
|
||||
@ -816,7 +816,7 @@ void ImGui::ShowTestWindow(bool* p_opened)
|
||||
if (ImGui::TreeNode("Widgets Width"))
|
||||
{
|
||||
static float f = 0.0f;
|
||||
ImGui::Text("PushItemWidth(100)");
|
||||
ImGui::Text("PushItemWidth(100)");
|
||||
ImGui::SameLine(); ShowHelpMarker("Fixed width.");
|
||||
ImGui::PushItemWidth(100);
|
||||
ImGui::DragFloat("float##1", &f);
|
||||
@ -996,8 +996,8 @@ void ImGui::ShowTestWindow(bool* p_opened)
|
||||
|
||||
// Tree
|
||||
const float spacing = ImGui::GetStyle().ItemInnerSpacing.x;
|
||||
ImGui::Button("Button##1");
|
||||
ImGui::SameLine(0.0f, spacing);
|
||||
ImGui::Button("Button##1");
|
||||
ImGui::SameLine(0.0f, spacing);
|
||||
if (ImGui::TreeNode("Node##1")) { for (int i = 0; i < 6; i++) ImGui::BulletText("Item %d..", i); ImGui::TreePop(); } // Dummy tree data
|
||||
|
||||
ImGui::AlignFirstTextHeightToWidgets(); // Vertically align text node a bit lower so it'll be vertically centered with upcoming widget. Otherwise you can use SmallButton (smaller fit).
|
||||
@ -1006,8 +1006,8 @@ void ImGui::ShowTestWindow(bool* p_opened)
|
||||
if (tree_opened) { for (int i = 0; i < 6; i++) ImGui::BulletText("Item %d..", i); ImGui::TreePop(); } // Dummy tree data
|
||||
|
||||
// Bullet
|
||||
ImGui::Button("Button##3");
|
||||
ImGui::SameLine(0.0f, spacing);
|
||||
ImGui::Button("Button##3");
|
||||
ImGui::SameLine(0.0f, spacing);
|
||||
ImGui::BulletText("Bullet text");
|
||||
|
||||
ImGui::AlignFirstTextHeightToWidgets();
|
||||
@ -1086,7 +1086,7 @@ void ImGui::ShowTestWindow(bool* p_opened)
|
||||
ImGui::PopStyleVar(2);
|
||||
float scroll_x_delta = 0.0f;
|
||||
ImGui::SmallButton("<<"); if (ImGui::IsItemActive()) scroll_x_delta = -ImGui::GetIO().DeltaTime * 1000.0f;
|
||||
ImGui::SameLine(); ImGui::Text("Scroll from code"); ImGui::SameLine();
|
||||
ImGui::SameLine(); ImGui::Text("Scroll from code"); ImGui::SameLine();
|
||||
ImGui::SmallButton(">>"); if (ImGui::IsItemActive()) scroll_x_delta = +ImGui::GetIO().DeltaTime * 1000.0f;
|
||||
if (scroll_x_delta != 0.0f)
|
||||
{
|
||||
@ -1108,7 +1108,7 @@ void ImGui::ShowTestWindow(bool* p_opened)
|
||||
ImGui::InvisibleButton("##dummy", size);
|
||||
if (ImGui::IsItemActive() && ImGui::IsMouseDragging()) { offset.x += ImGui::GetIO().MouseDelta.x; offset.y += ImGui::GetIO().MouseDelta.y; }
|
||||
ImGui::GetWindowDrawList()->AddRectFilled(pos, ImVec2(pos.x+size.x,pos.y+size.y), ImColor(90,90,120,255));
|
||||
ImGui::GetWindowDrawList()->AddText(ImGui::GetWindowFont(), ImGui::GetWindowFontSize()*2.0f, ImVec2(pos.x+offset.x,pos.y+offset.y), ImColor(255,255,255,255), "Line 1 hello\nLine 2 clip me!", NULL, 0.0f, &clip_rect);
|
||||
ImGui::GetWindowDrawList()->AddText(ImGui::GetFont(), ImGui::GetFontSize()*2.0f, ImVec2(pos.x+offset.x,pos.y+offset.y), ImColor(255,255,255,255), "Line 1 hello\nLine 2 clip me!", NULL, 0.0f, &clip_rect);
|
||||
ImGui::TreePop();
|
||||
}
|
||||
}
|
||||
@ -1181,7 +1181,7 @@ void ImGui::ShowTestWindow(bool* p_opened)
|
||||
ImGui::Spacing();
|
||||
ImGui::TextWrapped("Below we are testing adding menu items to a regular window. It's rather unusual but should work!");
|
||||
ImGui::Separator();
|
||||
// NB: As a quirk in this very specific example, we want to differentiate the parent of this menu from the parent of the various popup menus above.
|
||||
// NB: As a quirk in this very specific example, we want to differentiate the parent of this menu from the parent of the various popup menus above.
|
||||
// To do so we are encloding the items in a PushID()/PopID() block to make them two different menusets. If we don't, opening any popup above and hovering our menu here
|
||||
// would open it. This is because once a menu is active, we allow to switch to a sibling menu by just hovering on it, which is the desired behavior for regular menus.
|
||||
ImGui::PushID("foo");
|
||||
@ -1396,7 +1396,7 @@ void ImGui::ShowTestWindow(bool* p_opened)
|
||||
ImGui::SameLine(); ShowHelpMarker("NB: Tree node must be poped before ending the cell.\nThere's no storage of state per-cell.");
|
||||
if (node_opened)
|
||||
{
|
||||
ImGui::Columns(2, "tree items");
|
||||
ImGui::Columns(2, "tree items");
|
||||
ImGui::Separator();
|
||||
if (ImGui::TreeNode("Hello")) { ImGui::BulletText("Sailor"); ImGui::TreePop(); } ImGui::NextColumn();
|
||||
if (ImGui::TreeNode("Bonjour")) { ImGui::BulletText("Marin"); ImGui::TreePop(); } ImGui::NextColumn();
|
||||
@ -1513,7 +1513,7 @@ void ImGui::ShowTestWindow(bool* p_opened)
|
||||
ImGui::Button("Holding me clears the\nthe keyboard capture flag");
|
||||
if (ImGui::IsItemActive())
|
||||
ImGui::CaptureKeyboardFromApp(false);
|
||||
|
||||
|
||||
ImGui::TreePop();
|
||||
}
|
||||
|
||||
@ -1798,30 +1798,32 @@ static void ShowExampleAppCustomRendering(bool* opened)
|
||||
ImGui::Text("Primitives");
|
||||
static float sz = 36.0f;
|
||||
static ImVec4 col = ImVec4(1.0f,1.0f,0.4f,1.0f);
|
||||
ImGui::DragFloat("Size", &sz, 0.2f, 2.0f, 72.0f, "%.0f");
|
||||
ImGui::DragFloat("Size", &sz, 0.2f, 2.0f, 72.0f, "%.0f");
|
||||
ImGui::ColorEdit3("Color", &col.x);
|
||||
{
|
||||
const ImVec2 p = ImGui::GetCursorScreenPos();
|
||||
const ImU32 col32 = ImColor(col);
|
||||
float x = p.x + 4.0f, y = p.y + 4.0f, spacing = 8.0f;
|
||||
draw_list->AddCircle(ImVec2(x+sz*0.5f, y+sz*0.5f), sz*0.5f, col32, 32); x += sz+spacing;
|
||||
draw_list->AddRect(ImVec2(x, y), ImVec2(x+sz, y+sz), col32); x += sz+spacing;
|
||||
draw_list->AddRect(ImVec2(x, y), ImVec2(x+sz, y+sz), col32, 10.0f); x += sz+spacing;
|
||||
draw_list->AddLine(ImVec2(x, y), ImVec2(x+sz, y ), col32); x += sz+spacing;
|
||||
draw_list->AddLine(ImVec2(x, y), ImVec2(x+sz, y+sz), col32); x += sz+spacing;
|
||||
draw_list->AddLine(ImVec2(x, y), ImVec2(x, y+sz), col32); x += spacing;
|
||||
draw_list->AddBezierCurve(ImVec2(x, y), ImVec2(x+sz*1.3f,y+sz*0.3f), ImVec2(x+sz-sz*1.3f,y+sz-sz*0.3f), ImVec2(x+sz, y+sz), col32, 1.0f);
|
||||
x = p.x + 4;
|
||||
y += sz+spacing;
|
||||
for (int n = 0; n < 2; n++)
|
||||
{
|
||||
float thickness = (n == 0) ? 1.0f : 4.0f;
|
||||
draw_list->AddCircle(ImVec2(x+sz*0.5f, y+sz*0.5f), sz*0.5f, col32, 20, thickness); x += sz+spacing;
|
||||
draw_list->AddRect(ImVec2(x, y), ImVec2(x+sz, y+sz), col32, 0.0f, ~0, thickness); x += sz+spacing;
|
||||
draw_list->AddRect(ImVec2(x, y), ImVec2(x+sz, y+sz), col32, 10.0f, ~0, thickness); x += sz+spacing;
|
||||
draw_list->AddTriangle(ImVec2(x+sz*0.5f, y), ImVec2(x+sz,y+sz-0.5f), ImVec2(x,y+sz-0.5f), col32, thickness); x += sz+spacing;
|
||||
draw_list->AddLine(ImVec2(x, y), ImVec2(x+sz, y ), col32, thickness); x += sz+spacing;
|
||||
draw_list->AddLine(ImVec2(x, y), ImVec2(x+sz, y+sz), col32, thickness); x += sz+spacing;
|
||||
draw_list->AddLine(ImVec2(x, y), ImVec2(x, y+sz), col32, thickness); x += spacing;
|
||||
draw_list->AddBezierCurve(ImVec2(x, y), ImVec2(x+sz*1.3f,y+sz*0.3f), ImVec2(x+sz-sz*1.3f,y+sz-sz*0.3f), ImVec2(x+sz, y+sz), col32, thickness);
|
||||
x = p.x + 4;
|
||||
y += sz+spacing;
|
||||
}
|
||||
draw_list->AddCircleFilled(ImVec2(x+sz*0.5f, y+sz*0.5f), sz*0.5f, col32, 32); x += sz+spacing;
|
||||
draw_list->AddRectFilled(ImVec2(x, y), ImVec2(x+sz, y+sz), col32); x += sz+spacing;
|
||||
draw_list->AddRectFilled(ImVec2(x, y), ImVec2(x+sz, y+sz), col32, 10.0f); x += sz+spacing;
|
||||
draw_list->AddLine(ImVec2(x, y), ImVec2(x+sz, y ), col32, 4.0f); x += sz+spacing;
|
||||
draw_list->AddLine(ImVec2(x, y), ImVec2(x+sz, y+sz), col32, 4.0f); x += sz+spacing;
|
||||
draw_list->AddLine(ImVec2(x, y), ImVec2(x, y+sz), col32, 4.0f); x += spacing;
|
||||
draw_list->AddBezierCurve(ImVec2(x, y), ImVec2(x+sz*1.3f,y+sz*0.3f), ImVec2(x+sz-sz*1.3f,y+sz-sz*0.3f), ImVec2(x+sz, y+sz), col32, 4.0f); x += sz+spacing;
|
||||
draw_list->AddTriangleFilled(ImVec2(x+sz*0.5f, y), ImVec2(x+sz,y+sz-0.5f), ImVec2(x,y+sz-0.5f), col32); x += sz+spacing;
|
||||
draw_list->AddRectFilledMultiColor(ImVec2(x, y), ImVec2(x+sz, y+sz), ImColor(0,0,0), ImColor(255,0,0), ImColor(255,255,0), ImColor(0,255,0));
|
||||
ImGui::Dummy(ImVec2((sz+spacing)*8, (sz+spacing)*2));
|
||||
ImGui::Dummy(ImVec2((sz+spacing)*8, (sz+spacing)*3));
|
||||
}
|
||||
ImGui::Separator();
|
||||
{
|
||||
@ -2303,7 +2305,7 @@ static void ShowExampleAppPropertyEditor(bool* p_opened)
|
||||
ImGui::AlignFirstTextHeightToWidgets();
|
||||
ImGui::Text("my sailor is rich");
|
||||
ImGui::NextColumn();
|
||||
if (opened)
|
||||
if (opened)
|
||||
{
|
||||
static float dummy_members[8] = { 0.0f,0.0f,1.0f,3.1416f,100.0f,999.0f };
|
||||
for (int i = 0; i < 8; i++)
|
||||
@ -2336,7 +2338,7 @@ static void ShowExampleAppPropertyEditor(bool* p_opened)
|
||||
ImGui::TreePop();
|
||||
}
|
||||
ImGui::PopID();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Iterate dummy objects with dummy members (all the same data)
|
||||
|
@ -18,7 +18,7 @@
|
||||
#include "imgui_internal.h"
|
||||
|
||||
#include <stdio.h> // vsnprintf, sscanf, printf
|
||||
#if !defined(alloca) && !defined(__FreeBSD__)
|
||||
#if !defined(alloca) && !defined(__FreeBSD__) && !defined(__DragonFly__)
|
||||
#ifdef _WIN32
|
||||
#include <malloc.h> // alloca
|
||||
#else
|
||||
@ -203,7 +203,7 @@ void ImDrawList::UpdateTextureID()
|
||||
AddDrawCmd();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Try to merge with previous command if it matches, else use current command
|
||||
ImDrawCmd* prev_cmd = CmdBuffer.Size > 1 ? curr_cmd - 1 : NULL;
|
||||
if (prev_cmd && prev_cmd->TextureId == curr_texture_id && memcmp(&prev_cmd->ClipRect, &GetCurrentClipRect(), sizeof(ImVec4)) == 0 && prev_cmd->UserCallback == NULL)
|
||||
@ -704,11 +704,11 @@ static void PathBezierToCasteljau(ImVector<ImVec2>* path, float x1, float y1, fl
|
||||
{
|
||||
float dx = x4 - x1;
|
||||
float dy = y4 - y1;
|
||||
float d2 = ((x2 - x4) * dy - (y2 - y4) * dx);
|
||||
float d3 = ((x3 - x4) * dy - (y3 - y4) * dx);
|
||||
float d2 = ((x2 - x4) * dy - (y2 - y4) * dx);
|
||||
float d3 = ((x3 - x4) * dy - (y3 - y4) * dx);
|
||||
d2 = (d2 >= 0) ? d2 : -d2;
|
||||
d3 = (d3 >= 0) ? d3 : -d3;
|
||||
if ((d2+d3) * (d2+d3) < tess_tol * (dx*dx + dy*dy))
|
||||
if ((d2+d3) * (d2+d3) < tess_tol * (dx*dx + dy*dy))
|
||||
{
|
||||
path->push_back(ImVec2(x4, y4));
|
||||
}
|
||||
@ -721,8 +721,8 @@ static void PathBezierToCasteljau(ImVector<ImVec2>* path, float x1, float y1, fl
|
||||
float x234 = (x23+x34)*0.5f, y234 = (y23+y34)*0.5f;
|
||||
float x1234 = (x123+x234)*0.5f, y1234 = (y123+y234)*0.5f;
|
||||
|
||||
PathBezierToCasteljau(path, x1,y1, x12,y12, x123,y123, x1234,y1234, tess_tol, level+1);
|
||||
PathBezierToCasteljau(path, x1234,y1234, x234,y234, x34,y34, x4,y4, tess_tol, level+1);
|
||||
PathBezierToCasteljau(path, x1,y1, x12,y12, x123,y123, x1234,y1234, tess_tol, level+1);
|
||||
PathBezierToCasteljau(path, x1234,y1234, x234,y234, x34,y34, x4,y4, tess_tol, level+1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -786,12 +786,12 @@ void ImDrawList::AddLine(const ImVec2& a, const ImVec2& b, ImU32 col, float thic
|
||||
}
|
||||
|
||||
// a: upper-left, b: lower-right. we don't render 1 px sized rectangles properly.
|
||||
void ImDrawList::AddRect(const ImVec2& a, const ImVec2& b, ImU32 col, float rounding, int rounding_corners)
|
||||
void ImDrawList::AddRect(const ImVec2& a, const ImVec2& b, ImU32 col, float rounding, int rounding_corners, float thickness)
|
||||
{
|
||||
if ((col >> 24) == 0)
|
||||
return;
|
||||
PathRect(a + ImVec2(0.5f,0.5f), b - ImVec2(0.5f,0.5f), rounding, rounding_corners);
|
||||
PathStroke(col, true);
|
||||
PathStroke(col, true, thickness);
|
||||
}
|
||||
|
||||
void ImDrawList::AddRectFilled(const ImVec2& a, const ImVec2& b, ImU32 col, float rounding, int rounding_corners)
|
||||
@ -825,6 +825,17 @@ void ImDrawList::AddRectFilledMultiColor(const ImVec2& a, const ImVec2& c, ImU32
|
||||
PrimWriteVtx(ImVec2(a.x, c.y), uv, col_bot_left);
|
||||
}
|
||||
|
||||
void ImDrawList::AddTriangle(const ImVec2& a, const ImVec2& b, const ImVec2& c, ImU32 col, float thickness)
|
||||
{
|
||||
if ((col >> 24) == 0)
|
||||
return;
|
||||
|
||||
PathLineTo(a);
|
||||
PathLineTo(b);
|
||||
PathLineTo(c);
|
||||
PathStroke(col, true, thickness);
|
||||
}
|
||||
|
||||
void ImDrawList::AddTriangleFilled(const ImVec2& a, const ImVec2& b, const ImVec2& c, ImU32 col)
|
||||
{
|
||||
if ((col >> 24) == 0)
|
||||
@ -836,14 +847,14 @@ void ImDrawList::AddTriangleFilled(const ImVec2& a, const ImVec2& b, const ImVec
|
||||
PathFill(col);
|
||||
}
|
||||
|
||||
void ImDrawList::AddCircle(const ImVec2& centre, float radius, ImU32 col, int num_segments)
|
||||
void ImDrawList::AddCircle(const ImVec2& centre, float radius, ImU32 col, int num_segments, float thickness)
|
||||
{
|
||||
if ((col >> 24) == 0)
|
||||
return;
|
||||
|
||||
const float a_max = IM_PI*2.0f * ((float)num_segments - 1.0f) / (float)num_segments;
|
||||
PathArcTo(centre, radius-0.5f, 0.0f, a_max, num_segments);
|
||||
PathStroke(col, true);
|
||||
PathStroke(col, true, thickness);
|
||||
}
|
||||
|
||||
void ImDrawList::AddCircleFilled(const ImVec2& centre, float radius, ImU32 col, int num_segments)
|
||||
@ -856,14 +867,14 @@ void ImDrawList::AddCircleFilled(const ImVec2& centre, float radius, ImU32 col,
|
||||
PathFill(col);
|
||||
}
|
||||
|
||||
void ImDrawList::AddBezierCurve(const ImVec2& pos0, const ImVec2& cp0, const ImVec2& cp1, const ImVec2& pos1, ImU32 col, float thickness, int num_segments)
|
||||
{
|
||||
void ImDrawList::AddBezierCurve(const ImVec2& pos0, const ImVec2& cp0, const ImVec2& cp1, const ImVec2& pos1, ImU32 col, float thickness, int num_segments)
|
||||
{
|
||||
if ((col >> 24) == 0)
|
||||
return;
|
||||
|
||||
PathLineTo(pos0);
|
||||
PathBezierCurveTo(cp0, cp1, pos1, num_segments);
|
||||
PathStroke(col, false, thickness);
|
||||
PathLineTo(pos0);
|
||||
PathBezierCurveTo(cp0, cp1, pos1, num_segments);
|
||||
PathStroke(col, false, thickness);
|
||||
}
|
||||
|
||||
void ImDrawList::AddText(const ImFont* font, float font_size, const ImVec2& pos, ImU32 col, const char* text_begin, const char* text_end, float wrap_width, const ImVec4* cpu_fine_clip_rect)
|
||||
@ -876,6 +887,13 @@ void ImDrawList::AddText(const ImFont* font, float font_size, const ImVec2& pos,
|
||||
if (text_begin == text_end)
|
||||
return;
|
||||
|
||||
// Note: This is one of the few instance of breaking the encapsulation of ImDrawList, as we pull this from ImGui state, but it is just SO useful.
|
||||
// Might just move Font/FontSize to ImDrawList?
|
||||
if (font == NULL)
|
||||
font = GImGui->Font;
|
||||
if (font_size == 0.0f)
|
||||
font_size = GImGui->FontSize;
|
||||
|
||||
IM_ASSERT(font->ContainerAtlas->TexID == _TextureIdStack.back()); // Use high-level ImGui::PushFont() or low-level ImDrawList::PushTextureId() to change font.
|
||||
|
||||
// reserve vertices for worse case (over-reserving is useful and easily amortized)
|
||||
@ -908,12 +926,8 @@ void ImDrawList::AddText(const ImFont* font, float font_size, const ImVec2& pos,
|
||||
_VtxCurrentIdx = (unsigned int)VtxBuffer.Size;
|
||||
}
|
||||
|
||||
// This is one of the few function breaking the encapsulation of ImDrawLst, but it is just so useful.
|
||||
void ImDrawList::AddText(const ImVec2& pos, ImU32 col, const char* text_begin, const char* text_end)
|
||||
{
|
||||
if ((col >> 24) == 0)
|
||||
return;
|
||||
|
||||
AddText(GImGui->Font, GImGui->FontSize, pos, col, text_begin, text_end);
|
||||
}
|
||||
|
||||
@ -1123,7 +1137,7 @@ static unsigned int stb_decompress_length(unsigned char *input);
|
||||
static unsigned int stb_decompress(unsigned char *output, unsigned char *i, unsigned int length);
|
||||
static const char* GetDefaultCompressedFontDataTTFBase85();
|
||||
static unsigned int Decode85Byte(char c) { return c >= '\\' ? c-36 : c-35; }
|
||||
static void Decode85(const unsigned char* src, unsigned char* dst)
|
||||
static void Decode85(const unsigned char* src, unsigned char* dst)
|
||||
{
|
||||
while (*src)
|
||||
{
|
||||
@ -1994,10 +2008,10 @@ void ImFont::RenderText(float size, ImVec2 pos, ImU32 col, const ImVec4& clip_re
|
||||
{
|
||||
char_width = glyph->XAdvance * scale;
|
||||
|
||||
// Clipping on Y is more likely
|
||||
// Arbitrarily assume that both space and tabs are empty glyphs as an optimization
|
||||
if (c != ' ' && c != '\t')
|
||||
{
|
||||
// We don't do a second finer clipping test on the Y axis (TODO: do some measurement see if it is worth it, probably not)
|
||||
// We don't do a second finer clipping test on the Y axis as we've already skipped anything before clip_rect.y and exit once we pass clip_rect.w
|
||||
float y1 = (float)(y + glyph->Y0 * scale);
|
||||
float y2 = (float)(y + glyph->Y1 * scale);
|
||||
|
||||
@ -2041,8 +2055,8 @@ void ImFont::RenderText(float size, ImVec2 pos, ImU32 col, const ImVec4& clip_re
|
||||
}
|
||||
}
|
||||
|
||||
// NB: we are not calling PrimRectUV() here because non-inlined causes too much overhead in a debug build.
|
||||
// inlined:
|
||||
// We are NOT calling PrimRectUV() here because non-inlined causes too much overhead in a debug build.
|
||||
// Inlined here:
|
||||
{
|
||||
idx_write[0] = (ImDrawIdx)(vtx_current_idx); idx_write[1] = (ImDrawIdx)(vtx_current_idx+1); idx_write[2] = (ImDrawIdx)(vtx_current_idx+2);
|
||||
idx_write[3] = (ImDrawIdx)(vtx_current_idx); idx_write[4] = (ImDrawIdx)(vtx_current_idx+2); idx_write[5] = (ImDrawIdx)(vtx_current_idx+3);
|
||||
|
@ -356,7 +356,7 @@ struct ImGuiState
|
||||
ImFont* Font; // (Shortcut) == FontStack.empty() ? IO.Font : FontStack.back()
|
||||
float FontSize; // (Shortcut) == FontBaseSize * g.CurrentWindow->FontWindowScale == window->FontSize()
|
||||
float FontBaseSize; // (Shortcut) == IO.FontGlobalScale * Font->Scale * Font->FontSize. Size of characters.
|
||||
ImVec2 FontTexUvWhitePixel; // (Shortcut) == Font->TexUvForWhite
|
||||
ImVec2 FontTexUvWhitePixel; // (Shortcut) == Font->TexUvWhitePixel
|
||||
|
||||
float Time;
|
||||
int FrameCount;
|
||||
@ -683,8 +683,6 @@ namespace ImGui
|
||||
IMGUI_API void SetHoveredID(ImGuiID id);
|
||||
IMGUI_API void KeepAliveID(ImGuiID id);
|
||||
|
||||
IMGUI_API void EndFrame(); // Automatically called by Render()
|
||||
|
||||
IMGUI_API void ItemSize(const ImVec2& size, float text_offset_y = 0.0f);
|
||||
IMGUI_API void ItemSize(const ImRect& bb, float text_offset_y = 0.0f);
|
||||
IMGUI_API bool ItemAdd(const ImRect& bb, const ImGuiID* id);
|
||||
@ -708,6 +706,7 @@ namespace ImGui
|
||||
IMGUI_API void RenderFrame(ImVec2 p_min, ImVec2 p_max, ImU32 fill_col, bool border = true, float rounding = 0.0f);
|
||||
IMGUI_API void RenderCollapseTriangle(ImVec2 p_min, bool opened, float scale = 1.0f, bool shadow = false);
|
||||
IMGUI_API void RenderCheckMark(ImVec2 pos, ImU32 col);
|
||||
IMGUI_API const char* FindRenderedTextEnd(const char* text, const char* text_end = NULL); // Find the optional ## from which we stop displaying text.
|
||||
|
||||
IMGUI_API void PushClipRect(const ImVec2& clip_rect_min, const ImVec2& clip_rect_max, bool intersect_with_existing_clip_rect = true);
|
||||
IMGUI_API void PopClipRect();
|
||||
|
6
3rdparty/bgfx/CONTRUBUTING.md
vendored
6
3rdparty/bgfx/CONTRUBUTING.md
vendored
@ -4,6 +4,12 @@ Everyone is welcome to contribute to bgfx by submitting bug reports, testing on
|
||||
different platforms, writing examples, improving documentation, profiling and
|
||||
optimizing, helping newcomers, telling others about bgfx, etc.
|
||||
|
||||
## Submitting bugs
|
||||
|
||||
Unless bug is trivial, and easy to explain and understand, the fastest way to
|
||||
fix bug is to get repro case. In most of cases it's enough to modify existing
|
||||
example (with minimal number of changes) and reproduce bug there.
|
||||
|
||||
## Contributing code
|
||||
|
||||
**When contributing to the bgfx project you must agree to the BSD 2-clause
|
||||
|
8
3rdparty/bgfx/README.md
vendored
8
3rdparty/bgfx/README.md
vendored
@ -21,6 +21,7 @@ Supported rendering backends:
|
||||
* OpenGL ES 2
|
||||
* OpenGL ES 3.1
|
||||
* WebGL 1.0
|
||||
* WebGL 2.0
|
||||
|
||||
Supported HMD:
|
||||
|
||||
@ -128,6 +129,13 @@ http://makingartstudios.itch.io/dls - DLS the digital logic simulator game.
|
||||

|
||||
|
||||
https://github.com/mamedev/mame MAME - Multiple Arcade Machine Emulator
|
||||
[Try MAME in Browser!](http://fos.textfiles.com/dfjustin/pacman/pacman/)
|
||||

|
||||
|
||||
https://blackshift.itch.io/blackshift - Blackshift is a grid-based, space-themed
|
||||
action puzzle game which isn't afraid of complexity — think Chip's Challenge on
|
||||
crack.
|
||||

|
||||
|
||||
[License (BSD 2-clause)](https://bkaradzic.github.io/bgfx/license.html)
|
||||
-----------------------------------------------------------------------
|
||||
|
189
3rdparty/bgfx/examples/00-helloworld/helloworld.cpp
vendored
189
3rdparty/bgfx/examples/00-helloworld/helloworld.cpp
vendored
@ -7,6 +7,7 @@
|
||||
#include "common.h"
|
||||
#include "bgfx_utils.h"
|
||||
#include "logo.h"
|
||||
#include "imgui/imgui.h"
|
||||
|
||||
class ExampleHelloWorld : public entry::AppI
|
||||
{
|
||||
@ -28,23 +29,111 @@ class ExampleHelloWorld : public entry::AppI
|
||||
// Set view 0 clear state.
|
||||
bgfx::setViewClear(0
|
||||
, BGFX_CLEAR_COLOR|BGFX_CLEAR_DEPTH
|
||||
, 0x303030ff
|
||||
, 0x000000ff
|
||||
, 1.0f
|
||||
, 0
|
||||
);
|
||||
imguiCreate();
|
||||
ImGui::GetIO().FontGlobalScale = 1.5;
|
||||
}
|
||||
|
||||
virtual int shutdown() BX_OVERRIDE
|
||||
{
|
||||
// Cleanup.
|
||||
imguiDestroy();
|
||||
|
||||
// Shutdown bgfx.
|
||||
bgfx::shutdown();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void displayMainMenu()
|
||||
{
|
||||
if (ImGui::BeginMainMenuBar())
|
||||
{
|
||||
if (ImGui::BeginMenu("Left"))
|
||||
{
|
||||
if (ImGui::MenuItem("Brief", "CTRL+1")) {}
|
||||
if (ImGui::MenuItem("Medium", "CTRL+2")) {}
|
||||
if (ImGui::MenuItem("Two columns", "CTRL+3")) {}
|
||||
if (ImGui::MenuItem("Full (name)", "CTRL+4")) {}
|
||||
if (ImGui::MenuItem("Full (size, time)", "CTRL+5")) {}
|
||||
if (ImGui::MenuItem("Full (access)", "CTRL+6")) {}
|
||||
ImGui::Separator();
|
||||
if (ImGui::BeginMenu("Sort mode"))
|
||||
{
|
||||
ImGui::MenuItem("Name");
|
||||
ImGui::MenuItem("Extension");
|
||||
ImGui::MenuItem("Modif. Time");
|
||||
ImGui::MenuItem("Size");
|
||||
ImGui::MenuItem("Unsorted");
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
if (ImGui::MenuItem("Change source")) {}
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
if (ImGui::BeginMenu("Files"))
|
||||
{
|
||||
if (ImGui::MenuItem("User menu", "F2")) {}
|
||||
if (ImGui::MenuItem("View", "F3")) {}
|
||||
if (ImGui::MenuItem("Edit", "F4")) {}
|
||||
if (ImGui::MenuItem("Copy", "F5")) {}
|
||||
if (ImGui::MenuItem("Rename or move", "F6")) {}
|
||||
if (ImGui::MenuItem("Make directory", "F7")) {}
|
||||
if (ImGui::MenuItem("Delete", "F8")) {}
|
||||
ImGui::Separator();
|
||||
if (ImGui::MenuItem("File attributes", "CTRL+A")) {}
|
||||
if (ImGui::MenuItem("Apply command", "CTRL+G")) {}
|
||||
ImGui::Separator();
|
||||
if (ImGui::MenuItem("Select group")) {}
|
||||
if (ImGui::MenuItem("Unselect group")) {}
|
||||
if (ImGui::MenuItem("Invert selection")) {}
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
if (ImGui::BeginMenu("Commands"))
|
||||
{
|
||||
if (ImGui::MenuItem("Find file", "ALT+F7")) {}
|
||||
if (ImGui::MenuItem("History", "ALT+F8")) {}
|
||||
if (ImGui::MenuItem("Maximize window", "ALT+F9")) {}
|
||||
ImGui::Separator();
|
||||
if (ImGui::MenuItem("Panel on/off", "CTRL+O")) {}
|
||||
if (ImGui::MenuItem("Equal panels", "CTRL+=")) {}
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
if (ImGui::BeginMenu("Options"))
|
||||
{
|
||||
if (ImGui::MenuItem("Settings")) {}
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
if (ImGui::BeginMenu("Right"))
|
||||
{
|
||||
if (ImGui::MenuItem("Brief", "CTRL+1")) {}
|
||||
if (ImGui::MenuItem("Medium", "CTRL+2")) {}
|
||||
if (ImGui::MenuItem("Two columns", "CTRL+3")) {}
|
||||
if (ImGui::MenuItem("Full (name)", "CTRL+4")) {}
|
||||
if (ImGui::MenuItem("Full (size, time)", "CTRL+5")) {}
|
||||
if (ImGui::MenuItem("Full (access)", "CTRL+6")) {}
|
||||
ImGui::Separator();
|
||||
if (ImGui::BeginMenu("Sort mode"))
|
||||
{
|
||||
ImGui::MenuItem("Name");
|
||||
ImGui::MenuItem("Extension");
|
||||
ImGui::MenuItem("Modif. Time");
|
||||
ImGui::MenuItem("Size");
|
||||
ImGui::MenuItem("Unsorted");
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
if (ImGui::MenuItem("Change source")) {}
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
ImGui::EndMainMenuBar();
|
||||
}
|
||||
}
|
||||
|
||||
bool update() BX_OVERRIDE
|
||||
{
|
||||
if (!entry::processEvents(m_width, m_height, m_debug, m_reset) )
|
||||
if (!entry::processEvents(m_width, m_height, m_debug, m_reset, &m_mouseState) )
|
||||
{
|
||||
// Set view 0 default viewport.
|
||||
bgfx::setViewRect(0, 0, 0, m_width, m_height);
|
||||
@ -53,18 +142,91 @@ class ExampleHelloWorld : public entry::AppI
|
||||
// if no other draw calls are submitted to view 0.
|
||||
bgfx::touch(0);
|
||||
|
||||
// Use debug font to print information about this example.
|
||||
bgfx::dbgTextClear();
|
||||
bgfx::dbgTextImage(bx::uint16_max(m_width /2/8, 20)-20
|
||||
, bx::uint16_max(m_height/2/16, 6)-6
|
||||
, 40
|
||||
, 12
|
||||
, s_logo
|
||||
, 160
|
||||
);
|
||||
bgfx::dbgTextPrintf(0, 1, 0x4f, "bgfx/examples/00-helloworld");
|
||||
bgfx::dbgTextPrintf(0, 2, 0x6f, "Description: Initialization and debug text.");
|
||||
imguiBeginFrame(m_mouseState.m_mx
|
||||
, m_mouseState.m_my
|
||||
, (m_mouseState.m_buttons[entry::MouseButton::Left] ? IMGUI_MBUT_LEFT : 0)
|
||||
| (m_mouseState.m_buttons[entry::MouseButton::Right] ? IMGUI_MBUT_RIGHT : 0)
|
||||
, m_mouseState.m_mz
|
||||
, m_width
|
||||
, m_height
|
||||
);
|
||||
displayMainMenu();
|
||||
ImGui::SetNextWindowPos(ImVec2(0, 32));
|
||||
ImGui::SetNextWindowSize(ImVec2(m_width/2, m_height - 32));
|
||||
if (ImGui::Begin("Window1", nullptr, ImVec2(m_width/2, m_height-32), 1.0f, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoScrollbar))
|
||||
{
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_ChildWindowRounding, 5.0f);
|
||||
ImGui::BeginChild("Sub1", ImVec2(0, m_height - 48), true);
|
||||
|
||||
|
||||
ImGui::Columns(4, "mycolumns");
|
||||
ImGui::Separator();
|
||||
ImGui::Text("ID"); ImGui::NextColumn();
|
||||
ImGui::Text("Name"); ImGui::NextColumn();
|
||||
ImGui::Text("Path"); ImGui::NextColumn();
|
||||
ImGui::Text("Flags"); ImGui::NextColumn();
|
||||
ImGui::Separator();
|
||||
const char* names[3] = { "One", "Two", "Three" };
|
||||
const char* paths[3] = { "/path/one", "/path/two", "/path/three" };
|
||||
static int selected = -1;
|
||||
for (int i = 0; i < 50; i++)
|
||||
{
|
||||
char label[32];
|
||||
sprintf(label, "%04d", i);
|
||||
if (ImGui::Selectable(label, selected == i, ImGuiSelectableFlags_SpanAllColumns))
|
||||
selected = i;
|
||||
ImGui::NextColumn();
|
||||
ImGui::Text(names[i%3]); ImGui::NextColumn();
|
||||
ImGui::Text(paths[i % 3]); ImGui::NextColumn();
|
||||
ImGui::Text("...."); ImGui::NextColumn();
|
||||
}
|
||||
ImGui::Columns(1);
|
||||
ImGui::Separator();
|
||||
|
||||
|
||||
|
||||
ImGui::EndChild();
|
||||
ImGui::PopStyleVar();
|
||||
}
|
||||
ImGui::End();
|
||||
ImGui::SameLine();
|
||||
ImGui::SetNextWindowPos(ImVec2(m_width / 2, 32));
|
||||
ImGui::SetNextWindowSize(ImVec2(m_width / 2, m_height - 32));
|
||||
if (ImGui::Begin("Window2", nullptr, ImVec2(m_width/2, m_height - 32), 1.0f, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoScrollbar))
|
||||
{
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_ChildWindowRounding, 5.0f);
|
||||
ImGui::BeginChild("Sub2", ImVec2(0, m_height - 48), true);
|
||||
|
||||
ImGui::Columns(4, "mycolumns");
|
||||
ImGui::Separator();
|
||||
ImGui::Text("ID"); ImGui::NextColumn();
|
||||
ImGui::Text("Name"); ImGui::NextColumn();
|
||||
ImGui::Text("Path"); ImGui::NextColumn();
|
||||
ImGui::Text("Flags"); ImGui::NextColumn();
|
||||
ImGui::Separator();
|
||||
const char* names[3] = { "One", "Two", "Three" };
|
||||
const char* paths[3] = { "/path/one", "/path/two", "/path/three" };
|
||||
static int selected = -1;
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
char label[32];
|
||||
sprintf(label, "%04d", i);
|
||||
if (ImGui::Selectable(label, selected == i, ImGuiSelectableFlags_SpanAllColumns))
|
||||
selected = i;
|
||||
ImGui::NextColumn();
|
||||
ImGui::Text(names[i]); ImGui::NextColumn();
|
||||
ImGui::Text(paths[i]); ImGui::NextColumn();
|
||||
ImGui::Text("...."); ImGui::NextColumn();
|
||||
}
|
||||
ImGui::Columns(1);
|
||||
ImGui::Separator();
|
||||
|
||||
|
||||
ImGui::EndChild();
|
||||
ImGui::PopStyleVar();
|
||||
}
|
||||
ImGui::End();
|
||||
imguiEndFrame();
|
||||
// Advance to next frame. Rendering thread will be kicked to
|
||||
// process submitted rendering primitives.
|
||||
bgfx::frame();
|
||||
@ -79,6 +241,7 @@ class ExampleHelloWorld : public entry::AppI
|
||||
uint32_t m_height;
|
||||
uint32_t m_debug;
|
||||
uint32_t m_reset;
|
||||
entry::MouseState m_mouseState;
|
||||
};
|
||||
|
||||
ENTRY_IMPLEMENT_MAIN(ExampleHelloWorld);
|
||||
|
200
3rdparty/bgfx/examples/29-debugdraw/debugdraw.cpp
vendored
Normal file
200
3rdparty/bgfx/examples/29-debugdraw/debugdraw.cpp
vendored
Normal file
@ -0,0 +1,200 @@
|
||||
/*
|
||||
* Copyright 2011-2015 Branimir Karadzic. All rights reserved.
|
||||
* License: http://www.opensource.org/licenses/BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include "common.h"
|
||||
#include "bgfx_utils.h"
|
||||
#include <entry/cmd.h>
|
||||
#include <entry/input.h>
|
||||
#include "camera.h"
|
||||
|
||||
#include <bx/uint32_t.h>
|
||||
|
||||
#include "../common/debugdraw/debugdraw.h"
|
||||
|
||||
class DebugDrawApp : public entry::AppI
|
||||
{
|
||||
void init(int _argc, char** _argv) BX_OVERRIDE
|
||||
{
|
||||
Args args(_argc, _argv);
|
||||
|
||||
m_width = 1280;
|
||||
m_height = 720;
|
||||
m_debug = BGFX_DEBUG_TEXT;
|
||||
m_reset = BGFX_RESET_VSYNC | BGFX_RESET_MSAA_X16;
|
||||
|
||||
bgfx::init(args.m_type, args.m_pciId);
|
||||
bgfx::reset(m_width, m_height, m_reset);
|
||||
|
||||
// Enable m_debug text.
|
||||
bgfx::setDebug(m_debug);
|
||||
|
||||
// Set view 0 clear state.
|
||||
bgfx::setViewClear(0
|
||||
, BGFX_CLEAR_COLOR|BGFX_CLEAR_DEPTH
|
||||
, 0x303030ff
|
||||
, 1.0f
|
||||
, 0
|
||||
);
|
||||
|
||||
m_timeOffset = bx::getHPCounter();
|
||||
|
||||
cameraCreate();
|
||||
|
||||
const float initialPos[3] = { 0.0f, 2.0f, -12.0f };
|
||||
cameraSetPosition(initialPos);
|
||||
cameraSetVerticalAngle(0.0f);
|
||||
|
||||
ddInit();
|
||||
}
|
||||
|
||||
virtual int shutdown() BX_OVERRIDE
|
||||
{
|
||||
ddShutdown();
|
||||
|
||||
cameraDestroy();
|
||||
|
||||
// Shutdown bgfx.
|
||||
bgfx::shutdown();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool update() BX_OVERRIDE
|
||||
{
|
||||
if (!entry::processEvents(m_width, m_height, m_debug, m_reset, &m_mouseState) )
|
||||
{
|
||||
// Set view 0 default viewport.
|
||||
bgfx::setViewRect(0, 0, 0, m_width, m_height);
|
||||
|
||||
int64_t now = bx::getHPCounter() - m_timeOffset;
|
||||
static int64_t last = now;
|
||||
const int64_t frameTime = now - last;
|
||||
last = now;
|
||||
const double freq = double(bx::getHPFrequency() );
|
||||
const double toMs = 1000.0/freq;
|
||||
const float deltaTime = float(frameTime/freq);
|
||||
|
||||
// Use debug font to print information about this example.
|
||||
bgfx::dbgTextClear();
|
||||
bgfx::dbgTextPrintf(0, 1, 0x4f, "bgfx/examples/29-debugdraw");
|
||||
bgfx::dbgTextPrintf(0, 2, 0x6f, "Description: Debug draw.");
|
||||
bgfx::dbgTextPrintf(0, 3, 0x0f, "Frame: % 7.3f[ms]", double(frameTime)*toMs);
|
||||
|
||||
// Update camera.
|
||||
cameraUpdate(deltaTime, m_mouseState);
|
||||
|
||||
float view[16];
|
||||
cameraGetViewMtx(view);
|
||||
|
||||
float proj[16];
|
||||
bx::mtxProj(proj, 60.0f, float(m_width)/float(m_height), 0.1f, 100.0f);
|
||||
|
||||
bgfx::setViewTransform(0, view, proj);
|
||||
|
||||
float zero[3] = {};
|
||||
|
||||
float mvp[16];
|
||||
float eye[] = { 5.0f, 10.0f, 5.0f };
|
||||
bx::mtxLookAt(view, eye, zero);
|
||||
bx::mtxProj(proj, 45.0f, float(m_width)/float(m_height), 1.0f, 15.0f);
|
||||
bx::mtxMul(mvp, view, proj);
|
||||
|
||||
ddBegin(0);
|
||||
ddDrawAxis(0.0f, 0.0f, 0.0f);
|
||||
|
||||
ddPush();
|
||||
ddSetColor(0xff00ff00);
|
||||
|
||||
Aabb aabb =
|
||||
{
|
||||
{ 5.0f, 1.0f, 1.0f },
|
||||
{ 10.0f, 5.0f, 5.0f },
|
||||
};
|
||||
ddDraw(aabb);
|
||||
ddPop();
|
||||
|
||||
float time = float(now/freq);
|
||||
|
||||
Obb obb;
|
||||
bx::mtxRotateX(obb.m_mtx, time);
|
||||
ddSetWireframe(true);
|
||||
ddDraw(obb);
|
||||
|
||||
ddSetColor(0xffffffff);
|
||||
bx::mtxSRT(obb.m_mtx, 1.0f, 1.0f, 1.0f, 0.0f, time, 0.0f, 3.0f, 0.0f, 0.0f);
|
||||
ddSetWireframe(false);
|
||||
ddDraw(obb);
|
||||
|
||||
ddSetTranslate(0.0f, -2.0f, 0.0f);
|
||||
ddDrawGrid(Axis::Y, zero, 20, 1.0f);
|
||||
ddSetTransform(NULL);
|
||||
|
||||
ddDrawFrustum(mvp);
|
||||
|
||||
ddPush();
|
||||
Sphere sphere = { { 0.0f, 5.0f, 0.0f }, 1.0f };
|
||||
ddSetColor(0xfff0c0ff);
|
||||
ddSetWireframe(true);
|
||||
ddSetLod(3);
|
||||
ddDraw(sphere);
|
||||
ddSetWireframe(false);
|
||||
|
||||
ddSetColor(0xf0ffc0ff);
|
||||
sphere.m_center[0] = -2.0f;
|
||||
ddSetLod(2);
|
||||
ddDraw(sphere);
|
||||
|
||||
ddSetColor(0xc0f0ffff);
|
||||
sphere.m_center[0] = -4.0f;
|
||||
ddSetLod(1);
|
||||
ddDraw(sphere);
|
||||
|
||||
ddSetColor(0xffc0ff00);
|
||||
sphere.m_center[0] = -6.0f;
|
||||
ddSetLod(0);
|
||||
ddDraw(sphere);
|
||||
ddPop();
|
||||
|
||||
ddSetColor(0xffffffff);
|
||||
|
||||
ddPush();
|
||||
ddSetStipple(true, 1.0f, time*0.1f);
|
||||
ddSetColor(0xff0000ff);
|
||||
{
|
||||
float normal[3] = { 0.0f, 0.0f, 1.0f };
|
||||
float center[3] = { -8.0f, 0.0f, 0.0f };
|
||||
ddDrawCircle(normal, center, 1.0f, 0.5f + bx::fsin(time*10.0f) );
|
||||
}
|
||||
ddPop();
|
||||
|
||||
ddPush();
|
||||
ddSetStipple(true, 1.0f, -time*0.1f);
|
||||
ddDrawCircle(Axis::Z, -8.0f, 0.0f, 0.0f, 1.25f, 2.0f);
|
||||
ddPop();
|
||||
|
||||
ddDrawOrb(-11.0f, 0.0f, 0.0f, 1.0f);
|
||||
ddEnd();
|
||||
|
||||
// Advance to next frame. Rendering thread will be kicked to
|
||||
// process submitted rendering primitives.
|
||||
bgfx::frame();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
entry::MouseState m_mouseState;
|
||||
|
||||
int64_t m_timeOffset;
|
||||
|
||||
uint32_t m_width;
|
||||
uint32_t m_height;
|
||||
uint32_t m_debug;
|
||||
uint32_t m_reset;
|
||||
};
|
||||
|
||||
ENTRY_IMPLEMENT_MAIN(DebugDrawApp);
|
BIN
3rdparty/bgfx/examples/assets/textures/normalmap.png
vendored
Normal file
BIN
3rdparty/bgfx/examples/assets/textures/normalmap.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 225 KiB |
@ -324,13 +324,15 @@ static bgfx::ShaderHandle createEmbeddedShader(bgfx::RendererType::Enum _type, u
|
||||
struct DebugDraw
|
||||
{
|
||||
DebugDraw()
|
||||
: m_state(State::Count)
|
||||
: m_depthTestLess(true)
|
||||
, m_state(State::Count)
|
||||
{
|
||||
}
|
||||
|
||||
void init(bx::AllocatorI* _allocator)
|
||||
void init(bool _depthTestLess, bx::AllocatorI* _allocator)
|
||||
{
|
||||
m_allocator = _allocator;
|
||||
m_depthTestLess = _depthTestLess;
|
||||
|
||||
#if BX_CONFIG_ALLOCATOR_CRT
|
||||
if (NULL == _allocator)
|
||||
@ -502,9 +504,9 @@ struct DebugDraw
|
||||
Attrib& attrib = m_attrib[0];
|
||||
attrib.m_state = 0
|
||||
| BGFX_STATE_RGB_WRITE
|
||||
| BGFX_STATE_DEPTH_TEST_LESS
|
||||
| BGFX_STATE_DEPTH_WRITE
|
||||
| (m_depthTestLess ? BGFX_STATE_DEPTH_TEST_LESS : BGFX_STATE_DEPTH_TEST_GREATER)
|
||||
| BGFX_STATE_CULL_CW
|
||||
| BGFX_STATE_DEPTH_WRITE
|
||||
;
|
||||
attrib.m_scale = 1.0f;
|
||||
attrib.m_offset = 0.0f;
|
||||
@ -533,7 +535,10 @@ struct DebugDraw
|
||||
void pop()
|
||||
{
|
||||
BX_CHECK(State::Count != m_state);
|
||||
if (m_attrib[m_stack].m_stipple != m_attrib[m_stack-1].m_stipple)
|
||||
const Attrib& curr = m_attrib[m_stack];
|
||||
const Attrib& prev = m_attrib[m_stack-1];
|
||||
if (curr.m_stipple != prev.m_stipple
|
||||
|| curr.m_state != prev.m_state)
|
||||
{
|
||||
flush();
|
||||
}
|
||||
@ -570,15 +575,20 @@ struct DebugDraw
|
||||
|
||||
void setState(bool _depthTest, bool _depthWrite, bool _clockwise)
|
||||
{
|
||||
const uint64_t depthTest = m_depthTestLess
|
||||
? BGFX_STATE_DEPTH_TEST_LESS
|
||||
: BGFX_STATE_DEPTH_TEST_GREATER
|
||||
;
|
||||
|
||||
m_attrib[m_stack].m_state &= ~(0
|
||||
| BGFX_STATE_DEPTH_TEST_LESS
|
||||
| BGFX_STATE_DEPTH_TEST_MASK
|
||||
| BGFX_STATE_DEPTH_WRITE
|
||||
| BGFX_STATE_CULL_CW
|
||||
| BGFX_STATE_CULL_CCW
|
||||
);
|
||||
|
||||
m_attrib[m_stack].m_state |= _depthTest
|
||||
? BGFX_STATE_DEPTH_TEST_LESS
|
||||
? depthTest
|
||||
: 0
|
||||
;
|
||||
|
||||
@ -1266,7 +1276,7 @@ private:
|
||||
bgfx::setState(0
|
||||
| BGFX_STATE_RGB_WRITE
|
||||
| BGFX_STATE_PT_LINES
|
||||
| BGFX_STATE_DEPTH_TEST_LEQUAL
|
||||
| (m_depthTestLess ? BGFX_STATE_DEPTH_TEST_LEQUAL : BGFX_STATE_DEPTH_TEST_GEQUAL)
|
||||
| BGFX_STATE_DEPTH_WRITE
|
||||
| BGFX_STATE_LINEAA
|
||||
| BGFX_STATE_BLEND_ALPHA
|
||||
@ -1306,6 +1316,7 @@ private:
|
||||
uint16_t m_vertexPos;
|
||||
uint8_t m_viewId;
|
||||
uint8_t m_stack;
|
||||
bool m_depthTestLess;
|
||||
|
||||
struct Attrib
|
||||
{
|
||||
@ -1335,9 +1346,9 @@ private:
|
||||
|
||||
static DebugDraw s_dd;
|
||||
|
||||
void ddInit(bx::AllocatorI* _allocator)
|
||||
void ddInit(bool _depthTestLess, bx::AllocatorI* _allocator)
|
||||
{
|
||||
s_dd.init(_allocator);
|
||||
s_dd.init(_depthTestLess, _allocator);
|
||||
}
|
||||
|
||||
void ddShutdown()
|
||||
|
@ -22,7 +22,7 @@ struct Axis
|
||||
};
|
||||
|
||||
///
|
||||
void ddInit(bx::AllocatorI* _allocator = NULL);
|
||||
void ddInit(bool _depthTestLess = true, bx::AllocatorI* _allocator = NULL);
|
||||
|
||||
///
|
||||
void ddShutdown();
|
||||
|
9
3rdparty/bgfx/include/bgfx/bgfx.h
vendored
9
3rdparty/bgfx/include/bgfx/bgfx.h
vendored
@ -2361,7 +2361,14 @@ namespace bgfx
|
||||
, uint32_t _flags = UINT32_MAX
|
||||
);
|
||||
|
||||
/// Touch view.
|
||||
/// Submit an empty primitive for rendering. Uniforms and draw state
|
||||
/// will be applied but no geometry will be submitted.
|
||||
///
|
||||
/// These empty draw calls will sort before ordinary draw calls.
|
||||
///
|
||||
/// @param[in] _id View id.
|
||||
/// @returns Number of draw calls.
|
||||
///
|
||||
uint32_t touch(uint8_t _id);
|
||||
|
||||
/// Submit primitive for rendering.
|
||||
|
1
3rdparty/bgfx/scripts/genie.lua
vendored
1
3rdparty/bgfx/scripts/genie.lua
vendored
@ -422,6 +422,7 @@ exampleProject("24-nbody")
|
||||
exampleProject("26-occlusion")
|
||||
exampleProject("27-terrain")
|
||||
exampleProject("28-wireframe")
|
||||
exampleProject("29-debugdraw")
|
||||
|
||||
-- C99 source doesn't compile under WinRT settings
|
||||
if not premake.vstudio.iswinrt() then
|
||||
|
22
3rdparty/bgfx/scripts/shader.mk
vendored
22
3rdparty/bgfx/scripts/shader.mk
vendored
@ -25,38 +25,38 @@ all:
|
||||
else
|
||||
|
||||
ifeq ($(TARGET), 0)
|
||||
VS_FLAGS=--platform windows -p vs_3_0 -O 3 --debug
|
||||
FS_FLAGS=--platform windows -p ps_3_0 -O 3 --debug
|
||||
SHADER_PATH=bgfx/shaders/dx9
|
||||
VS_FLAGS=--platform windows -p vs_3_0 -O 3
|
||||
FS_FLAGS=--platform windows -p ps_3_0 -O 3
|
||||
SHADER_PATH=shaders/dx9
|
||||
else
|
||||
ifeq ($(TARGET), 1)
|
||||
VS_FLAGS=--platform windows -p vs_4_0 -O 3 --debug
|
||||
FS_FLAGS=--platform windows -p ps_4_0 -O 3 --debug
|
||||
CS_FLAGS=--platform windows -p cs_5_0 -O 1 --debug
|
||||
SHADER_PATH=bgfx/shaders/dx11
|
||||
VS_FLAGS=--platform windows -p vs_4_0 -O 3
|
||||
FS_FLAGS=--platform windows -p ps_4_0 -O 3
|
||||
CS_FLAGS=--platform windows -p cs_5_0 -O 1
|
||||
SHADER_PATH=shaders/dx11
|
||||
else
|
||||
ifeq ($(TARGET), 2)
|
||||
VS_FLAGS=--platform nacl
|
||||
FS_FLAGS=--platform nacl
|
||||
SHADER_PATH=bgfx/shaders/gles
|
||||
SHADER_PATH=shaders/gles
|
||||
else
|
||||
ifeq ($(TARGET), 3)
|
||||
VS_FLAGS=--platform android
|
||||
FS_FLAGS=--platform android
|
||||
CS_FLAGS=--platform android
|
||||
SHADER_PATH=bgfx/shaders/gles
|
||||
SHADER_PATH=shaders/gles
|
||||
else
|
||||
ifeq ($(TARGET), 4)
|
||||
VS_FLAGS=--platform linux -p 120
|
||||
FS_FLAGS=--platform linux -p 120
|
||||
CS_FLAGS=--platform linux -p 430
|
||||
SHADER_PATH=bgfx/shaders/glsl
|
||||
SHADER_PATH=shaders/glsl
|
||||
else
|
||||
ifeq ($(TARGET), 5)
|
||||
VS_FLAGS=--platform osx -p metal
|
||||
FS_FLAGS=--platform osx -p metal
|
||||
CS_FLAGS=--platform osx -p metal
|
||||
SHADER_PATH=bgfx/shaders/metal
|
||||
SHADER_PATH=shaders/metal
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
34
3rdparty/bgfx/src/bgfx_shader.sh
vendored
34
3rdparty/bgfx/src/bgfx_shader.sh
vendored
@ -29,6 +29,7 @@
|
||||
#endif // BGFX_SHADER_LANGUAGE_HLSL > 3 && BGFX_SHADER_TYPE_FRAGMENT
|
||||
|
||||
#if BGFX_SHADER_LANGUAGE_HLSL
|
||||
# define CONST(_x) static const _x
|
||||
# define dFdx(_x) ddx(_x)
|
||||
# define dFdy(_y) ddy(-_y)
|
||||
# define inversesqrt(_x) rsqrt(_x)
|
||||
@ -109,6 +110,12 @@ vec4 bgfxTexture2DProj(BgfxSampler2D _sampler, vec4 _coord)
|
||||
return _sampler.m_texture.Sample(_sampler.m_sampler, coord);
|
||||
}
|
||||
|
||||
struct BgfxSampler2DMS
|
||||
{
|
||||
SamplerState m_sampler;
|
||||
Texture2DMS m_texture;
|
||||
};
|
||||
|
||||
struct BgfxSampler2DShadow
|
||||
{
|
||||
SamplerComparisonState m_sampler;
|
||||
@ -182,6 +189,21 @@ vec4 bgfxTextureCubeLod(BgfxSamplerCube _sampler, vec3 _coord, float _level)
|
||||
return _sampler.m_texture.SampleLevel(_sampler.m_sampler, _coord, _level);
|
||||
}
|
||||
|
||||
vec4 bgfxTexelFetch(BgfxSampler2D _sampler, ivec2 _coord, int _lod)
|
||||
{
|
||||
return _sampler.m_texture.Load(ivec3(_coord, _lod) );
|
||||
}
|
||||
|
||||
vec4 bgfxTexelFetch(BgfxSampler2DMS _sampler, ivec2 _coord, int _sampleIdx)
|
||||
{
|
||||
return _sampler.m_texture.Load(_coord, _sampleIdx);
|
||||
}
|
||||
|
||||
vec4 bgfxTexelFetch(BgfxSampler3D _sampler, ivec3 _coord, int _lod)
|
||||
{
|
||||
return _sampler.m_texture.Load(ivec4(_coord, _lod) );
|
||||
}
|
||||
|
||||
# define SAMPLER2D(_name, _reg) \
|
||||
uniform SamplerState _name ## Sampler : register(s[_reg]); \
|
||||
uniform Texture2D _name ## Texture : register(t[_reg]); \
|
||||
@ -191,6 +213,13 @@ vec4 bgfxTextureCubeLod(BgfxSamplerCube _sampler, vec3 _coord, float _level)
|
||||
# define texture2DLod(_sampler, _coord, _level) bgfxTexture2DLod(_sampler, _coord, _level)
|
||||
# define texture2DProj(_sampler, _coord) bgfxTexture2DProj(_sampler, _coord)
|
||||
|
||||
# define SAMPLER2DMS(_name, _reg) \
|
||||
uniform SamplerState _name ## Sampler : register(s[_reg]); \
|
||||
uniform Texture2DMS _name ## Texture : register(t[_reg]); \
|
||||
static BgfxSampler2DMS _name = { _name ## Sampler, _name ## Texture }
|
||||
# define sampler2DMS BgfxSampler2DMS
|
||||
# define texture2DMS(_sampler, _coord, _idx) bgfxTexture2DMS(_sampler, _coord, _idx)
|
||||
|
||||
# define SAMPLER2DSHADOW(_name, _reg) \
|
||||
uniform SamplerComparisonState _name ## Sampler : register(s[_reg]); \
|
||||
uniform Texture2D _name ## Texture : register(t[_reg]); \
|
||||
@ -220,6 +249,8 @@ vec4 bgfxTextureCubeLod(BgfxSamplerCube _sampler, vec3 _coord, float _level)
|
||||
# define samplerCube BgfxSamplerCube
|
||||
# define textureCube(_sampler, _coord) bgfxTextureCube(_sampler, _coord)
|
||||
# define textureCubeLod(_sampler, _coord, _level) bgfxTextureCubeLod(_sampler, _coord, _level)
|
||||
|
||||
# define texelFetch(_sampler, _coord, _lod) bgfxTexelFetch(_sampler, _coord, _lod)
|
||||
# else
|
||||
|
||||
# define sampler2DShadow sampler2D
|
||||
@ -256,6 +287,7 @@ float bgfxShadow2DProj(sampler2DShadow _sampler, vec4 _coord)
|
||||
}
|
||||
|
||||
# define SAMPLER2D(_name, _reg) uniform sampler2D _name : register(s ## _reg)
|
||||
# define SAMPLER2DMS(_name, _reg) uniform sampler2DMS _name : register(s ## _reg)
|
||||
# define texture2D(_sampler, _coord) tex2D(_sampler, _coord)
|
||||
# define texture2DProj(_sampler, _coord) bgfxTexture2DProj(_sampler, _coord)
|
||||
|
||||
@ -321,10 +353,12 @@ vec3 mod(vec3 _a, vec3 _b) { return _a - _b * floor(_a / _b); }
|
||||
vec4 mod(vec4 _a, vec4 _b) { return _a - _b * floor(_a / _b); }
|
||||
|
||||
#else
|
||||
# define CONST(_x) const _x
|
||||
# define atan2(_x, _y) atan(_x, _y)
|
||||
# define mul(_a, _b) ( (_a) * (_b) )
|
||||
# define saturate(_x) clamp(_x, 0.0, 1.0)
|
||||
# define SAMPLER2D(_name, _reg) uniform sampler2D _name
|
||||
# define SAMPLER2DMS(_name, _reg) uniform sampler2DMS _name
|
||||
# define SAMPLER3D(_name, _reg) uniform sampler3D _name
|
||||
# define SAMPLERCUBE(_name, _reg) uniform samplerCube _name
|
||||
# define SAMPLER2DSHADOW(_name, _reg) uniform sampler2DShadow _name
|
||||
|
2
3rdparty/bgfx/src/config.h
vendored
2
3rdparty/bgfx/src/config.h
vendored
@ -266,7 +266,7 @@
|
||||
#endif // BGFX_CONFIG_MAX_TEXTURE_SAMPLERS
|
||||
|
||||
#ifndef BGFX_CONFIG_MAX_FRAME_BUFFERS
|
||||
# define BGFX_CONFIG_MAX_FRAME_BUFFERS 64
|
||||
# define BGFX_CONFIG_MAX_FRAME_BUFFERS 128
|
||||
#endif // BGFX_CONFIG_MAX_FRAME_BUFFERS
|
||||
|
||||
#ifndef BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS
|
||||
|
6
3rdparty/bgfx/src/glcontext_egl.cpp
vendored
6
3rdparty/bgfx/src/glcontext_egl.cpp
vendored
@ -252,6 +252,8 @@ EGL_IMPORT
|
||||
const bool hasEglKhrCreateContext = !!bx::findIdentifierMatch(extensions, "EGL_KHR_create_context");
|
||||
const bool hasEglKhrNoError = !!bx::findIdentifierMatch(extensions, "EGL_KHR_create_context_no_error");
|
||||
|
||||
const uint32_t gles = BGFX_CONFIG_RENDERER_OPENGLES;
|
||||
|
||||
for (uint32_t ii = 0; ii < 2; ++ii)
|
||||
{
|
||||
bx::StaticMemoryBlockWriter writer(s_contextAttrs, sizeof(s_contextAttrs) );
|
||||
@ -264,10 +266,10 @@ EGL_IMPORT
|
||||
if (hasEglKhrCreateContext)
|
||||
{
|
||||
bx::write(&writer, EGLint(EGL_CONTEXT_MAJOR_VERSION_KHR) );
|
||||
bx::write(&writer, EGLint(BGFX_CONFIG_RENDERER_OPENGLES / 10) );
|
||||
bx::write(&writer, EGLint(gles / 10) );
|
||||
|
||||
bx::write(&writer, EGLint(EGL_CONTEXT_MINOR_VERSION_KHR) );
|
||||
bx::write(&writer, EGLint(BGFX_CONFIG_RENDERER_OPENGLES % 10) );
|
||||
bx::write(&writer, EGLint(gles % 10) );
|
||||
|
||||
flags |= BGFX_CONFIG_DEBUG && hasEglKhrNoError ? 0
|
||||
| EGL_CONTEXT_FLAG_NO_ERROR_BIT_KHR
|
||||
|
8
3rdparty/bgfx/src/glimports.h
vendored
8
3rdparty/bgfx/src/glimports.h
vendored
@ -65,6 +65,7 @@ typedef void (GL_APIENTRYP PFNGLCLEARCOLORPROC) (GLfloat red, GLfloat
|
||||
typedef void (GL_APIENTRYP PFNGLCLEARDEPTHPROC) (GLdouble d);
|
||||
typedef void (GL_APIENTRYP PFNGLCLEARDEPTHFPROC) (GLfloat d);
|
||||
typedef void (GL_APIENTRYP PFNGLCLEARSTENCILPROC) (GLint s);
|
||||
typedef void (GL_APIENTRYP PFNGLCLIPCONTROLPROC) (GLenum origin, GLenum depth);
|
||||
typedef void (GL_APIENTRYP PFNGLCOLORMASKPROC) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
|
||||
typedef void (GL_APIENTRYP PFNGLCOMPILESHADERPROC) (GLuint shader);
|
||||
typedef void (GL_APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data);
|
||||
@ -169,6 +170,7 @@ typedef void (GL_APIENTRYP PFNGLREADBUFFERPROC) (GLenum mode);
|
||||
typedef void (GL_APIENTRYP PFNGLREADPIXELSPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void *pixels);
|
||||
typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
|
||||
typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
|
||||
typedef void (GL_APIENTRYP PFNGLSAMPLEMASKIPROC) (GLuint maskNumber, GLbitfield mask);
|
||||
typedef void (GL_APIENTRYP PFNGLSAMPLERPARAMETERIPROC) (GLuint sampler, GLenum pname, GLint param);
|
||||
typedef void (GL_APIENTRYP PFNGLSAMPLERPARAMETERFPROC) (GLuint sampler, GLenum pname, GLfloat param);
|
||||
typedef void (GL_APIENTRYP PFNGLSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, const GLfloat *param);
|
||||
@ -181,7 +183,9 @@ typedef void (GL_APIENTRYP PFNGLSTENCILMASKSEPARATEPROC) (GLenum face,
|
||||
typedef void (GL_APIENTRYP PFNGLSTENCILOPPROC) (GLenum fail, GLenum zfail, GLenum zpass);
|
||||
typedef void (GL_APIENTRYP PFNGLSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass);
|
||||
typedef void (GL_APIENTRYP PFNGLTEXIMAGE2DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels);
|
||||
typedef void (GL_APIENTRYP PFNGLTEXIMAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations);
|
||||
typedef void (GL_APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels);
|
||||
typedef void (GL_APIENTRYP PFNGLTEXIMAGE3DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations);
|
||||
typedef void (GL_APIENTRYP PFNGLTEXPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat param);
|
||||
typedef void (GL_APIENTRYP PFNGLTEXPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat* param);
|
||||
typedef void (GL_APIENTRYP PFNGLTEXPARAMETERIPROC) (GLenum target, GLenum pname, GLint param);
|
||||
@ -249,6 +253,7 @@ GL_IMPORT______(false, PFNGLCLEARPROC, glClear);
|
||||
GL_IMPORT______(true, PFNGLCLEARBUFFERFVPROC, glClearBufferfv);
|
||||
GL_IMPORT______(false, PFNGLCLEARCOLORPROC, glClearColor);
|
||||
GL_IMPORT______(false, PFNGLCLEARSTENCILPROC, glClearStencil);
|
||||
GL_IMPORT______(true, PFNGLCLIPCONTROLPROC, glClipControl);
|
||||
GL_IMPORT______(false, PFNGLCOLORMASKPROC, glColorMask);
|
||||
GL_IMPORT______(false, PFNGLCOMPILESHADERPROC, glCompileShader);
|
||||
GL_IMPORT______(false, PFNGLCOMPRESSEDTEXIMAGE2DPROC, glCompressedTexImage2D);
|
||||
@ -354,6 +359,7 @@ GL_IMPORT______(true, PFNGLREADBUFFERPROC, glReadBuffer)
|
||||
GL_IMPORT______(false, PFNGLREADPIXELSPROC, glReadPixels);
|
||||
GL_IMPORT______(true, PFNGLRENDERBUFFERSTORAGEPROC, glRenderbufferStorage);
|
||||
GL_IMPORT______(true, PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC, glRenderbufferStorageMultisample);
|
||||
GL_IMPORT______(true, PFNGLSAMPLEMASKIPROC, glSampleMaski);
|
||||
GL_IMPORT______(true, PFNGLSAMPLERPARAMETERIPROC, glSamplerParameteri);
|
||||
GL_IMPORT______(true, PFNGLSAMPLERPARAMETERFPROC, glSamplerParameterf);
|
||||
GL_IMPORT______(true, PFNGLSAMPLERPARAMETERFVPROC, glSamplerParameterfv);
|
||||
@ -366,7 +372,9 @@ GL_IMPORT______(true, PFNGLSTENCILMASKSEPARATEPROC, glStencilMask
|
||||
GL_IMPORT______(false, PFNGLSTENCILOPPROC, glStencilOp);
|
||||
GL_IMPORT______(true, PFNGLSTENCILOPSEPARATEPROC, glStencilOpSeparate);
|
||||
GL_IMPORT______(false, PFNGLTEXIMAGE2DPROC, glTexImage2D);
|
||||
GL_IMPORT______(true, PFNGLTEXIMAGE2DMULTISAMPLEPROC, glTexImage2DMultisample);
|
||||
GL_IMPORT______(true, PFNGLTEXIMAGE3DPROC, glTexImage3D);
|
||||
GL_IMPORT______(true, PFNGLTEXIMAGE3DMULTISAMPLEPROC, glTexImage3DMultisample);
|
||||
GL_IMPORT______(false, PFNGLTEXPARAMETERIPROC, glTexParameteri);
|
||||
GL_IMPORT______(false, PFNGLTEXPARAMETERIVPROC, glTexParameteriv);
|
||||
GL_IMPORT______(false, PFNGLTEXPARAMETERFPROC, glTexParameterf);
|
||||
|
12
3rdparty/bgfx/src/renderer_d3d11.cpp
vendored
12
3rdparty/bgfx/src/renderer_d3d11.cpp
vendored
@ -2705,11 +2705,15 @@ BX_PRAGMA_DIAGNOSTIC_POP();
|
||||
m_blendStateCache.add(hash, bs);
|
||||
}
|
||||
|
||||
const uint64_t f0 = BGFX_STATE_BLEND_FUNC(BGFX_STATE_BLEND_FACTOR, BGFX_STATE_BLEND_FACTOR);
|
||||
const uint64_t f1 = BGFX_STATE_BLEND_FUNC(BGFX_STATE_BLEND_INV_FACTOR, BGFX_STATE_BLEND_INV_FACTOR);
|
||||
bool hasFactor = false
|
||||
const uint64_t f0 = BGFX_STATE_BLEND_FACTOR;
|
||||
const uint64_t f1 = BGFX_STATE_BLEND_INV_FACTOR;
|
||||
const uint64_t f2 = BGFX_STATE_BLEND_FACTOR<<4;
|
||||
const uint64_t f3 = BGFX_STATE_BLEND_INV_FACTOR<<4;
|
||||
bool hasFactor = 0
|
||||
|| f0 == (_state & f0)
|
||||
|| f1 == (_state & f1)
|
||||
|| f2 == (_state & f2)
|
||||
|| f3 == (_state & f3)
|
||||
;
|
||||
|
||||
float blendFactor[4] = { 1.0f, 1.0f, 1.0f, 1.0f };
|
||||
@ -2798,6 +2802,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
|
||||
{
|
||||
uint32_t cull = (_state&BGFX_STATE_CULL_MASK)>>BGFX_STATE_CULL_SHIFT;
|
||||
|
||||
#if BX_PLATFORM_WINDOWS
|
||||
if (m_deviceInterfaceVersion >= 3)
|
||||
{
|
||||
D3D11_RASTERIZER_DESC2 desc;
|
||||
@ -2821,6 +2826,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
|
||||
DX_CHECK(device3->CreateRasterizerState2(&desc, reinterpret_cast<ID3D11RasterizerState2**>(&rs) ) );
|
||||
}
|
||||
else
|
||||
#endif // BX_PLATFORM_WINDOWS
|
||||
{
|
||||
D3D11_RASTERIZER_DESC desc;
|
||||
desc.FillMode = _wireframe ? D3D11_FILL_WIREFRAME : D3D11_FILL_SOLID;
|
||||
|
8
3rdparty/bgfx/src/renderer_d3d12.cpp
vendored
8
3rdparty/bgfx/src/renderer_d3d12.cpp
vendored
@ -4629,8 +4629,10 @@ data.NumQualityLevels = 0;
|
||||
m_backBufferColorIdx = m_swapChain->GetCurrentBackBufferIndex();
|
||||
#endif // BX_PLATFORM_WINDOWS
|
||||
|
||||
const uint64_t f0 = BGFX_STATE_BLEND_FUNC(BGFX_STATE_BLEND_FACTOR, BGFX_STATE_BLEND_FACTOR);
|
||||
const uint64_t f1 = BGFX_STATE_BLEND_FUNC(BGFX_STATE_BLEND_INV_FACTOR, BGFX_STATE_BLEND_INV_FACTOR);
|
||||
const uint64_t f0 = BGFX_STATE_BLEND_FACTOR;
|
||||
const uint64_t f1 = BGFX_STATE_BLEND_INV_FACTOR;
|
||||
const uint64_t f2 = BGFX_STATE_BLEND_FACTOR<<4;
|
||||
const uint64_t f3 = BGFX_STATE_BLEND_INV_FACTOR<<4;
|
||||
|
||||
D3D12_GPU_DESCRIPTOR_HANDLE gpuHandle;
|
||||
ScratchBufferD3D12& scratchBuffer = m_scratchBuffer[m_backBufferColorIdx];
|
||||
@ -5029,6 +5031,8 @@ data.NumQualityLevels = 0;
|
||||
bool hasFactor = 0
|
||||
|| f0 == (state & f0)
|
||||
|| f1 == (state & f1)
|
||||
|| f2 == (state & f2)
|
||||
|| f3 == (state & f3)
|
||||
;
|
||||
|
||||
const VertexBufferD3D12& vb = m_vertexBuffers[draw.m_vertexBuffer.idx];
|
||||
|
48
3rdparty/bgfx/src/renderer_gl.cpp
vendored
48
3rdparty/bgfx/src/renderer_gl.cpp
vendored
@ -186,9 +186,9 @@ namespace bgfx { namespace gl
|
||||
|
||||
static const GLenum s_textureFilterMin[][3] =
|
||||
{
|
||||
{ GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, GL_NEAREST_MIPMAP_LINEAR },
|
||||
{ GL_NEAREST, GL_LINEAR_MIPMAP_NEAREST, GL_NEAREST_MIPMAP_NEAREST },
|
||||
{ GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, GL_NEAREST_MIPMAP_LINEAR },
|
||||
{ GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR_MIPMAP_NEAREST },
|
||||
{ GL_NEAREST, GL_NEAREST_MIPMAP_LINEAR, GL_NEAREST_MIPMAP_NEAREST },
|
||||
{ GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR_MIPMAP_NEAREST },
|
||||
};
|
||||
|
||||
struct TextureFormatInfo
|
||||
@ -465,6 +465,7 @@ namespace bgfx { namespace gl
|
||||
APPLE_texture_format_BGRA8888,
|
||||
APPLE_texture_max_level,
|
||||
|
||||
ARB_clip_control,
|
||||
ARB_compute_shader,
|
||||
ARB_conservative_depth,
|
||||
ARB_copy_image,
|
||||
@ -540,6 +541,7 @@ namespace bgfx { namespace gl
|
||||
EXT_framebuffer_blit,
|
||||
EXT_framebuffer_object,
|
||||
EXT_framebuffer_sRGB,
|
||||
EXT_gpu_shader4,
|
||||
EXT_multi_draw_indirect,
|
||||
EXT_occlusion_query_boolean,
|
||||
EXT_packed_float,
|
||||
@ -673,6 +675,7 @@ namespace bgfx { namespace gl
|
||||
{ "APPLE_texture_format_BGRA8888", false, true },
|
||||
{ "APPLE_texture_max_level", false, true },
|
||||
|
||||
{ "ARB_clip_control", BGFX_CONFIG_RENDERER_OPENGL >= 43, true },
|
||||
{ "ARB_compute_shader", BGFX_CONFIG_RENDERER_OPENGL >= 43, true },
|
||||
{ "ARB_conservative_depth", BGFX_CONFIG_RENDERER_OPENGL >= 42, true },
|
||||
{ "ARB_copy_image", BGFX_CONFIG_RENDERER_OPENGL >= 42, true },
|
||||
@ -748,6 +751,7 @@ namespace bgfx { namespace gl
|
||||
{ "EXT_framebuffer_blit", BGFX_CONFIG_RENDERER_OPENGL >= 30, true },
|
||||
{ "EXT_framebuffer_object", BGFX_CONFIG_RENDERER_OPENGL >= 30, true },
|
||||
{ "EXT_framebuffer_sRGB", BGFX_CONFIG_RENDERER_OPENGL >= 30, true },
|
||||
{ "EXT_gpu_shader4", false, true },
|
||||
{ "EXT_multi_draw_indirect", false, true }, // GLES3.1 extension.
|
||||
{ "EXT_occlusion_query_boolean", false, true }, // GLES2 extension.
|
||||
{ "EXT_packed_float", BGFX_CONFIG_RENDERER_OPENGL >= 33, true },
|
||||
@ -899,6 +903,21 @@ namespace bgfx { namespace gl
|
||||
NULL
|
||||
};
|
||||
|
||||
static const char* s_texelFetch[] =
|
||||
{
|
||||
"texelFetch",
|
||||
"texelFetchOffset",
|
||||
NULL
|
||||
};
|
||||
|
||||
static const char* s_ARB_texture_multisample[] =
|
||||
{
|
||||
"sampler2DMS",
|
||||
"isampler2DMS",
|
||||
"usampler2DMS",
|
||||
NULL
|
||||
};
|
||||
|
||||
static void GL_APIENTRY stubVertexAttribDivisor(GLuint /*_index*/, GLuint /*_divisor*/)
|
||||
{
|
||||
}
|
||||
@ -4437,11 +4456,11 @@ namespace bgfx { namespace gl
|
||||
&& !s_textureFilter[m_textureFormat])
|
||||
{
|
||||
// Force point sampling when texture format doesn't support linear sampling.
|
||||
_flags &= 0
|
||||
_flags &= ~(0
|
||||
| BGFX_TEXTURE_MIN_MASK
|
||||
| BGFX_TEXTURE_MAG_MASK
|
||||
| BGFX_TEXTURE_MIP_MASK
|
||||
;
|
||||
);
|
||||
_flags |= 0
|
||||
| BGFX_TEXTURE_MIN_POINT
|
||||
| BGFX_TEXTURE_MAG_POINT
|
||||
@ -4819,16 +4838,18 @@ namespace bgfx { namespace gl
|
||||
else if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL)
|
||||
&& BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL <= 21) )
|
||||
{
|
||||
bool usesTextureLod = true
|
||||
const bool usesTextureLod = true
|
||||
&& s_extension[Extension::ARB_shader_texture_lod].m_supported
|
||||
&& bx::findIdentifierMatch(code, s_ARB_shader_texture_lod)
|
||||
;
|
||||
const bool usesIUsamplers = !!bx::findIdentifierMatch(code, s_uisamplers);
|
||||
const bool usesTexelFetch = !!bx::findIdentifierMatch(code, s_texelFetch);
|
||||
const bool usesTextureMS = !!bx::findIdentifierMatch(code, s_ARB_texture_multisample);
|
||||
|
||||
bool usesIUsamplers = !!bx::findIdentifierMatch(code, s_uisamplers);
|
||||
|
||||
uint32_t version = usesIUsamplers
|
||||
? 130
|
||||
: (usesTextureLod ? 120 : 0)
|
||||
uint32_t version =
|
||||
usesIUsamplers || usesTexelFetch || usesTextureMS ? 130
|
||||
: usesTextureLod ? 120
|
||||
: 0
|
||||
;
|
||||
|
||||
if (0 != version)
|
||||
@ -4844,6 +4865,11 @@ namespace bgfx { namespace gl
|
||||
}
|
||||
}
|
||||
|
||||
if (usesTextureMS)
|
||||
{
|
||||
writeString(&writer, "#extension GL_ARB_texture_multisample : enable\n");
|
||||
}
|
||||
|
||||
if (130 <= version)
|
||||
{
|
||||
if (m_type == GL_FRAGMENT_SHADER)
|
||||
|
4
3rdparty/bgfx/src/shader.cpp
vendored
4
3rdparty/bgfx/src/shader.cpp
vendored
@ -42,13 +42,13 @@ namespace bgfx
|
||||
uint32_t magic;
|
||||
bx::peek(_reader, magic);
|
||||
|
||||
if (magic == 0x07230203)
|
||||
if (magic == SPV_CHUNK_HEADER)
|
||||
{
|
||||
SpirV spirv;
|
||||
read(_reader, spirv, _err);
|
||||
parse(spirv.shader, printAsm, _writer, _err);
|
||||
}
|
||||
else if (magic == BX_MAKEFOURCC('D', 'X', 'B', 'C') )
|
||||
else if (magic == DXBC_CHUNK_HEADER)
|
||||
{
|
||||
DxbcContext dxbc;
|
||||
read(_reader, dxbc, _err);
|
||||
|
1
3rdparty/bgfx/src/shader_dxbc.cpp
vendored
1
3rdparty/bgfx/src/shader_dxbc.cpp
vendored
@ -1735,7 +1735,6 @@ namespace bgfx
|
||||
return size;
|
||||
}
|
||||
|
||||
#define DXBC_CHUNK_HEADER BX_MAKEFOURCC('D', 'X', 'B', 'C')
|
||||
#define DXBC_CHUNK_SHADER BX_MAKEFOURCC('S', 'H', 'D', 'R')
|
||||
#define DXBC_CHUNK_SHADER_EX BX_MAKEFOURCC('S', 'H', 'E', 'X')
|
||||
|
||||
|
2
3rdparty/bgfx/src/shader_dxbc.h
vendored
2
3rdparty/bgfx/src/shader_dxbc.h
vendored
@ -8,6 +8,8 @@
|
||||
|
||||
#include <bx/readerwriter.h>
|
||||
|
||||
#define DXBC_CHUNK_HEADER BX_MAKEFOURCC('D', 'X', 'B', 'C')
|
||||
|
||||
namespace bgfx
|
||||
{
|
||||
struct DxbcOpcode
|
||||
|
115
3rdparty/bgfx/src/shader_spirv.cpp
vendored
115
3rdparty/bgfx/src/shader_spirv.cpp
vendored
@ -706,54 +706,54 @@ namespace bgfx
|
||||
SpvOperand::Enum operands[2];
|
||||
};
|
||||
|
||||
// static const SpvDecorationInfo s_spvDecorationInfo[] =
|
||||
// {
|
||||
// { /* RelaxedPrecision */ SPV_OPERAND(_) },
|
||||
// { /* SpecId */ SPV_OPERAND(LiteralNumber) },
|
||||
// { /* Block */ SPV_OPERAND(_) },
|
||||
// { /* BufferBlock */ SPV_OPERAND(_) },
|
||||
// { /* RowMajor */ SPV_OPERAND(_) },
|
||||
// { /* ColMajor */ SPV_OPERAND(_) },
|
||||
// { /* ArrayStride */ SPV_OPERAND(LiteralNumber) },
|
||||
// { /* MatrixStride */ SPV_OPERAND(LiteralNumber) },
|
||||
// { /* GLSLShared */ SPV_OPERAND(_) },
|
||||
// { /* GLSLPacked */ SPV_OPERAND(_) },
|
||||
// { /* CPacked */ SPV_OPERAND(_) },
|
||||
// { /* BuiltIn */ SPV_OPERAND(LiteralNumber) },
|
||||
// { /* Unknown12 */ SPV_OPERAND(_) },
|
||||
// { /* NoPerspective */ SPV_OPERAND(_) },
|
||||
// { /* Flat */ SPV_OPERAND(_) },
|
||||
// { /* Patch */ SPV_OPERAND(_) },
|
||||
// { /* Centroid */ SPV_OPERAND(_) },
|
||||
// { /* Sample */ SPV_OPERAND(_) },
|
||||
// { /* Invariant */ SPV_OPERAND(_) },
|
||||
// { /* Restrict */ SPV_OPERAND(_) },
|
||||
// { /* Aliased */ SPV_OPERAND(_) },
|
||||
// { /* Volatile */ SPV_OPERAND(_) },
|
||||
// { /* Constant */ SPV_OPERAND(_) },
|
||||
// { /* Coherent */ SPV_OPERAND(_) },
|
||||
// { /* NonWritable */ SPV_OPERAND(_) },
|
||||
// { /* NonReadable */ SPV_OPERAND(_) },
|
||||
// { /* Uniform */ SPV_OPERAND(_) },
|
||||
// { /* Unknown27 */ SPV_OPERAND(_) },
|
||||
// { /* SaturatedConversion */ SPV_OPERAND(_) },
|
||||
// { /* Stream */ SPV_OPERAND(LiteralNumber) },
|
||||
// { /* Location */ SPV_OPERAND(LiteralNumber) },
|
||||
// { /* Component */ SPV_OPERAND(LiteralNumber) },
|
||||
// { /* Index */ SPV_OPERAND(LiteralNumber) },
|
||||
// { /* Binding */ SPV_OPERAND(LiteralNumber) },
|
||||
// { /* DescriptorSet */ SPV_OPERAND(LiteralNumber) },
|
||||
// { /* Offset */ SPV_OPERAND(LiteralNumber) },
|
||||
// { /* XfbBuffer */ SPV_OPERAND(LiteralNumber) },
|
||||
// { /* XfbStride */ SPV_OPERAND(LiteralNumber) },
|
||||
// { /* FuncParamAttr */ SPV_OPERAND(_) },
|
||||
// { /* FPRoundingMode */ SPV_OPERAND(_) },
|
||||
// { /* FPFastMathMode */ SPV_OPERAND(_) },
|
||||
// { /* LinkageAttributes */ SPV_OPERAND(LiteralString, LinkageType) },
|
||||
// { /* NoContraction */ SPV_OPERAND(_) },
|
||||
// { /* InputAttachmentIndex */ SPV_OPERAND(LiteralNumber) },
|
||||
// { /* Alignment */ SPV_OPERAND(LiteralNumber) },
|
||||
// };
|
||||
static const SpvDecorationInfo s_spvDecorationInfo[] =
|
||||
{
|
||||
{ /* RelaxedPrecision */ SPV_OPERAND(_) },
|
||||
{ /* SpecId */ SPV_OPERAND(LiteralNumber) },
|
||||
{ /* Block */ SPV_OPERAND(_) },
|
||||
{ /* BufferBlock */ SPV_OPERAND(_) },
|
||||
{ /* RowMajor */ SPV_OPERAND(_) },
|
||||
{ /* ColMajor */ SPV_OPERAND(_) },
|
||||
{ /* ArrayStride */ SPV_OPERAND(LiteralNumber) },
|
||||
{ /* MatrixStride */ SPV_OPERAND(LiteralNumber) },
|
||||
{ /* GLSLShared */ SPV_OPERAND(_) },
|
||||
{ /* GLSLPacked */ SPV_OPERAND(_) },
|
||||
{ /* CPacked */ SPV_OPERAND(_) },
|
||||
{ /* BuiltIn */ SPV_OPERAND(LiteralNumber) },
|
||||
{ /* Unknown12 */ SPV_OPERAND(_) },
|
||||
{ /* NoPerspective */ SPV_OPERAND(_) },
|
||||
{ /* Flat */ SPV_OPERAND(_) },
|
||||
{ /* Patch */ SPV_OPERAND(_) },
|
||||
{ /* Centroid */ SPV_OPERAND(_) },
|
||||
{ /* Sample */ SPV_OPERAND(_) },
|
||||
{ /* Invariant */ SPV_OPERAND(_) },
|
||||
{ /* Restrict */ SPV_OPERAND(_) },
|
||||
{ /* Aliased */ SPV_OPERAND(_) },
|
||||
{ /* Volatile */ SPV_OPERAND(_) },
|
||||
{ /* Constant */ SPV_OPERAND(_) },
|
||||
{ /* Coherent */ SPV_OPERAND(_) },
|
||||
{ /* NonWritable */ SPV_OPERAND(_) },
|
||||
{ /* NonReadable */ SPV_OPERAND(_) },
|
||||
{ /* Uniform */ SPV_OPERAND(_) },
|
||||
{ /* Unknown27 */ SPV_OPERAND(_) },
|
||||
{ /* SaturatedConversion */ SPV_OPERAND(_) },
|
||||
{ /* Stream */ SPV_OPERAND(LiteralNumber) },
|
||||
{ /* Location */ SPV_OPERAND(LiteralNumber) },
|
||||
{ /* Component */ SPV_OPERAND(LiteralNumber) },
|
||||
{ /* Index */ SPV_OPERAND(LiteralNumber) },
|
||||
{ /* Binding */ SPV_OPERAND(LiteralNumber) },
|
||||
{ /* DescriptorSet */ SPV_OPERAND(LiteralNumber) },
|
||||
{ /* Offset */ SPV_OPERAND(LiteralNumber) },
|
||||
{ /* XfbBuffer */ SPV_OPERAND(LiteralNumber) },
|
||||
{ /* XfbStride */ SPV_OPERAND(LiteralNumber) },
|
||||
{ /* FuncParamAttr */ SPV_OPERAND(_) },
|
||||
{ /* FPRoundingMode */ SPV_OPERAND(_) },
|
||||
{ /* FPFastMathMode */ SPV_OPERAND(_) },
|
||||
{ /* LinkageAttributes */ SPV_OPERAND(LiteralString, LinkageType) },
|
||||
{ /* NoContraction */ SPV_OPERAND(_) },
|
||||
{ /* InputAttachmentIndex */ SPV_OPERAND(LiteralNumber) },
|
||||
{ /* Alignment */ SPV_OPERAND(LiteralNumber) },
|
||||
};
|
||||
|
||||
static const char* s_spvDecoration[] =
|
||||
{
|
||||
@ -808,6 +808,7 @@ namespace bgfx
|
||||
|
||||
const char* getName(SpvDecoration::Enum _enum)
|
||||
{
|
||||
BX_UNUSED(s_spvDecorationInfo);
|
||||
BX_CHECK(_enum <= SpvDecoration::Count, "Unknown decoration id %d.", _enum);
|
||||
return _enum <= SpvDecoration::Count
|
||||
? s_spvDecoration[_enum]
|
||||
@ -920,7 +921,7 @@ namespace bgfx
|
||||
break;
|
||||
|
||||
default:
|
||||
size += bx::read(_reader, _operand.data[0], _err);
|
||||
size += bx::read(_reader, _operand.data, _err);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1046,7 +1047,7 @@ namespace bgfx
|
||||
size += bx::snprintf(&_out[size], bx::uint32_imax(0, _size-size)
|
||||
, "%sAddressingModel(%d)"
|
||||
, 0 == ii ? " " : ", "
|
||||
, operand.data[0]
|
||||
, operand.data
|
||||
);
|
||||
break;
|
||||
|
||||
@ -1054,7 +1055,7 @@ namespace bgfx
|
||||
size += bx::snprintf(&_out[size], bx::uint32_imax(0, _size-size)
|
||||
, "%s%s"
|
||||
, 0 == ii ? " " : ", "
|
||||
, getName(SpvDecoration::Enum(operand.data[0]) )
|
||||
, getName(SpvDecoration::Enum(operand.data) )
|
||||
);
|
||||
break;
|
||||
|
||||
@ -1062,7 +1063,7 @@ namespace bgfx
|
||||
size += bx::snprintf(&_out[size], bx::uint32_imax(0, _size-size)
|
||||
, "%s0x%08x"
|
||||
, 0 == ii ? " " : ", "
|
||||
, operand.data[0]
|
||||
, operand.data
|
||||
);
|
||||
break;
|
||||
|
||||
@ -1070,7 +1071,7 @@ namespace bgfx
|
||||
size += bx::snprintf(&_out[size], bx::uint32_imax(0, _size-size)
|
||||
, "%s%d"
|
||||
, 0 == ii ? " " : ", "
|
||||
, operand.data[0]
|
||||
, operand.data
|
||||
);
|
||||
break;
|
||||
|
||||
@ -1086,7 +1087,7 @@ namespace bgfx
|
||||
size += bx::snprintf(&_out[size], bx::uint32_imax(0, _size-size)
|
||||
, "%sMemoryModel(%d)"
|
||||
, 0 == ii ? " " : ", "
|
||||
, operand.data[0]
|
||||
, operand.data
|
||||
);
|
||||
break;
|
||||
|
||||
@ -1094,7 +1095,7 @@ namespace bgfx
|
||||
size += bx::snprintf(&_out[size], bx::uint32_imax(0, _size-size)
|
||||
, "%s%s"
|
||||
, 0 == ii ? " " : ", "
|
||||
, getName(SpvStorageClass::Enum(operand.data[0]) )
|
||||
, getName(SpvStorageClass::Enum(operand.data) )
|
||||
);
|
||||
break;
|
||||
|
||||
@ -1102,7 +1103,7 @@ namespace bgfx
|
||||
size += bx::snprintf(&_out[size], bx::uint32_imax(0, _size-size)
|
||||
, "%s__%d__"
|
||||
, 0 == ii ? " " : ", "
|
||||
, operand.data[0]
|
||||
, operand.data
|
||||
);
|
||||
break;
|
||||
|
||||
@ -1110,7 +1111,7 @@ namespace bgfx
|
||||
size += bx::snprintf(&_out[size], bx::uint32_imax(0, _size-size)
|
||||
, "%sr%d"
|
||||
, 0 == ii ? " " : ", "
|
||||
, operand.data[0]
|
||||
, operand.data
|
||||
);
|
||||
break;
|
||||
|
||||
|
5
3rdparty/bgfx/src/shader_spirv.h
vendored
5
3rdparty/bgfx/src/shader_spirv.h
vendored
@ -11,6 +11,8 @@
|
||||
BX_ERROR_RESULT(BGFX_SHADER_SPIRV_INVALID_HEADER, BX_MAKEFOURCC('S', 'H', 0, 1) );
|
||||
BX_ERROR_RESULT(BGFX_SHADER_SPIRV_INVALID_INSTRUCTION, BX_MAKEFOURCC('S', 'H', 0, 2) );
|
||||
|
||||
#define SPV_CHUNK_HEADER BX_MAKEFOURCC(0x03, 0x02, 0x23, 0x07)
|
||||
|
||||
namespace bgfx
|
||||
{
|
||||
// Reference: https://www.khronos.org/registry/spir-v/specs/1.0/SPIRV.html
|
||||
@ -581,9 +583,8 @@ namespace bgfx
|
||||
};
|
||||
|
||||
Enum type;
|
||||
uint32_t data[4];
|
||||
uint32_t data;
|
||||
|
||||
uint32_t target;
|
||||
stl::string literalString;
|
||||
};
|
||||
|
||||
|
45
3rdparty/bgfx/tools/shaderc/shaderc.cpp
vendored
45
3rdparty/bgfx/tools/shaderc/shaderc.cpp
vendored
@ -98,6 +98,14 @@ namespace bgfx
|
||||
NULL
|
||||
};
|
||||
|
||||
static const char* s_ARB_texture_multisample[] =
|
||||
{
|
||||
"sampler2DMS",
|
||||
"isampler2DMS",
|
||||
"usampler2DMS",
|
||||
NULL
|
||||
};
|
||||
|
||||
const char* s_uniformTypeName[UniformType::Count] =
|
||||
{
|
||||
"int",
|
||||
@ -1058,6 +1066,20 @@ namespace bgfx
|
||||
memset(&data[size+1], 0, padding);
|
||||
fclose(file);
|
||||
|
||||
if (!raw)
|
||||
{
|
||||
// To avoid commented code being recognized as used feature,
|
||||
// first preprocess pass is used to strip all comments before
|
||||
// substituting code.
|
||||
preprocessor.run(data);
|
||||
delete [] data;
|
||||
|
||||
size = (uint32_t)preprocessor.m_preprocessed.size();
|
||||
data = new char[size+padding+1];
|
||||
memcpy(data, preprocessor.m_preprocessed.c_str(), size);
|
||||
memset(&data[size], 0, padding+1);
|
||||
}
|
||||
|
||||
strNormalizeEol(data);
|
||||
|
||||
input = const_cast<char*>(bx::strws(data) );
|
||||
@ -1090,21 +1112,6 @@ namespace bgfx
|
||||
|
||||
input = const_cast<char*>(bx::strws(input) );
|
||||
}
|
||||
|
||||
if (!raw)
|
||||
{
|
||||
// To avoid commented code being recognized as used feature,
|
||||
// first preprocess pass is used to strip all comments before
|
||||
// substituting code.
|
||||
preprocessor.run(input);
|
||||
delete [] data;
|
||||
|
||||
size = (uint32_t)preprocessor.m_preprocessed.size();
|
||||
data = new char[size+padding+1];
|
||||
memcpy(data, preprocessor.m_preprocessed.c_str(), size);
|
||||
memset(&data[size], 0, padding+1);
|
||||
input = data;
|
||||
}
|
||||
}
|
||||
|
||||
if (raw)
|
||||
@ -1726,6 +1733,7 @@ namespace bgfx
|
||||
const bool hasTextureLod = NULL != bx::findIdentifierMatch(input, s_ARB_shader_texture_lod /*EXT_shader_texture_lod*/);
|
||||
const bool hasShader5 = NULL != bx::findIdentifierMatch(input, s_ARB_gpu_shader5);
|
||||
const bool hasShaderPacking = NULL != bx::findIdentifierMatch(input, s_ARB_shading_language_packing);
|
||||
const bool hasTextureMS = NULL != bx::findIdentifierMatch(input, s_ARB_texture_multisample);
|
||||
|
||||
if (0 == essl)
|
||||
{
|
||||
@ -1768,6 +1776,13 @@ namespace bgfx
|
||||
, "#extension GL_ARB_shader_texture_lod : enable\n"
|
||||
);
|
||||
}
|
||||
|
||||
if (hasTextureMS)
|
||||
{
|
||||
bx::stringPrintf(code
|
||||
, "#extension GL_ARB_texture_multisample : enable\n"
|
||||
);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
3
3rdparty/bx/3rdparty/UnitTest++/src/Config.h
vendored
3
3rdparty/bx/3rdparty/UnitTest++/src/Config.h
vendored
@ -22,7 +22,8 @@
|
||||
|| defined(__NetBSD__) \
|
||||
|| defined(__OpenBSD__) \
|
||||
|| defined(__FreeBSD__) \
|
||||
|| defined(__native_client__)
|
||||
|| defined(__native_client__) \
|
||||
|| defined(__riscv)
|
||||
# define UNITTEST_POSIX
|
||||
#endif
|
||||
|
||||
|
9
3rdparty/bx/include/bx/config.h
vendored
9
3rdparty/bx/include/bx/config.h
vendored
@ -24,6 +24,15 @@
|
||||
# define BX_CONFIG_CRT_FILE_READER_WRITER !(BX_PLATFORM_NACL)
|
||||
#endif // BX_CONFIG_CRT_FILE_READER_WRITER
|
||||
|
||||
#ifndef BX_CONFIG_CRT_PROCESS
|
||||
# define BX_CONFIG_CRT_PROCESS !(0 \
|
||||
|| BX_PLATFORM_EMSCRIPTEN \
|
||||
|| BX_PLATFORM_NACL \
|
||||
|| BX_PLATFORM_WINRT \
|
||||
|| BX_PLATFORM_XBOXONE \
|
||||
)
|
||||
#endif // BX_CONFIG_CRT_PROCESS
|
||||
|
||||
#ifndef BX_CONFIG_SEMAPHORE_PTHREAD
|
||||
# define BX_CONFIG_SEMAPHORE_PTHREAD (BX_PLATFORM_OSX || BX_PLATFORM_IOS)
|
||||
#endif // BX_CONFIG_SEMAPHORE_PTHREAD
|
||||
|
111
3rdparty/bx/include/bx/crtimpl.h
vendored
111
3rdparty/bx/include/bx/crtimpl.h
vendored
@ -192,6 +192,117 @@ namespace bx
|
||||
};
|
||||
#endif // BX_CONFIG_CRT_FILE_READER_WRITER
|
||||
|
||||
#if BX_CONFIG_CRT_PROCESS
|
||||
|
||||
#if BX_COMPILER_MSVC_COMPATIBLE
|
||||
# define popen _popen
|
||||
# define pclose _pclose
|
||||
#endif // BX_COMPILER_MSVC_COMPATIBLE
|
||||
|
||||
class ProcessReader : public ReaderOpenI, public CloserI, public ReaderI
|
||||
{
|
||||
public:
|
||||
ProcessReader()
|
||||
: m_file(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
~ProcessReader()
|
||||
{
|
||||
BX_CHECK(NULL == m_file, "Process not closed!");
|
||||
}
|
||||
|
||||
virtual bool open(const char* _command, Error* _err) BX_OVERRIDE
|
||||
{
|
||||
BX_CHECK(NULL != _err, "Reader/Writer interface calling functions must handle errors.");
|
||||
|
||||
m_file = popen(_command, "r");
|
||||
if (NULL == m_file)
|
||||
{
|
||||
BX_ERROR_SET(_err, BX_ERROR_READERWRITER_OPEN, "ProcessReader: Failed to open process.");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual void close() BX_OVERRIDE
|
||||
{
|
||||
BX_CHECK(NULL != m_file, "Process not open!");
|
||||
pclose(m_file);
|
||||
m_file = NULL;
|
||||
}
|
||||
|
||||
virtual int32_t read(void* _data, int32_t _size, Error* _err) BX_OVERRIDE
|
||||
{
|
||||
BX_CHECK(NULL != _err, "Reader/Writer interface calling functions must handle errors."); BX_UNUSED(_err);
|
||||
|
||||
int32_t size = (int32_t)fread(_data, 1, _size, m_file);
|
||||
if (size != _size)
|
||||
{
|
||||
return size >= 0 ? size : 0;
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
private:
|
||||
FILE* m_file;
|
||||
};
|
||||
|
||||
class ProcessWriter : public WriterOpenI, public CloserI, public WriterI
|
||||
{
|
||||
public:
|
||||
ProcessWriter()
|
||||
: m_file(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
~ProcessWriter()
|
||||
{
|
||||
BX_CHECK(NULL == m_file, "Process not closed!");
|
||||
}
|
||||
|
||||
virtual bool open(const char* _command, bool, Error* _err) BX_OVERRIDE
|
||||
{
|
||||
BX_CHECK(NULL != _err, "Reader/Writer interface calling functions must handle errors.");
|
||||
|
||||
m_file = popen(_command, "w");
|
||||
if (NULL == m_file)
|
||||
{
|
||||
BX_ERROR_SET(_err, BX_ERROR_READERWRITER_OPEN, "ProcessWriter: Failed to open process.");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual void close() BX_OVERRIDE
|
||||
{
|
||||
BX_CHECK(NULL != m_file, "Process not open!");
|
||||
pclose(m_file);
|
||||
m_file = NULL;
|
||||
}
|
||||
|
||||
virtual int32_t write(const void* _data, int32_t _size, Error* _err) BX_OVERRIDE
|
||||
{
|
||||
BX_CHECK(NULL != _err, "Reader/Writer interface calling functions must handle errors."); BX_UNUSED(_err);
|
||||
|
||||
int32_t size = (int32_t)fwrite(_data, 1, _size, m_file);
|
||||
if (size != _size)
|
||||
{
|
||||
return size >= 0 ? size : 0;
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
private:
|
||||
FILE* m_file;
|
||||
};
|
||||
|
||||
#endif // BX_CONFIG_CRT_PROCESS
|
||||
|
||||
} // namespace bx
|
||||
|
||||
#endif // BX_CRTIMPL_H_HEADER_GUARD
|
||||
|
290
3rdparty/bx/include/bx/fpumath.h
vendored
290
3rdparty/bx/include/bx/fpumath.h
vendored
@ -14,10 +14,28 @@
|
||||
|
||||
namespace bx
|
||||
{
|
||||
static const float pi = 3.14159265358979323846f;
|
||||
static const float invPi = 1.0f/3.14159265358979323846f;
|
||||
static const float piHalf = 1.57079632679489661923f;
|
||||
static const float sqrt2 = 1.41421356237309504880f;
|
||||
static const float pi = 3.14159265358979323846f;
|
||||
static const float invPi = 1.0f/3.14159265358979323846f;
|
||||
static const float piHalf = 1.57079632679489661923f;
|
||||
static const float sqrt2 = 1.41421356237309504880f;
|
||||
|
||||
struct Handness
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
Left,
|
||||
Right,
|
||||
};
|
||||
};
|
||||
|
||||
struct NearFar
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
Default,
|
||||
Reverse,
|
||||
};
|
||||
};
|
||||
|
||||
inline float toRad(float _deg)
|
||||
{
|
||||
@ -631,7 +649,8 @@ namespace bx
|
||||
mtxLookAtLh(_result, _eye, _at, _up);
|
||||
}
|
||||
|
||||
inline void mtxProjRhXYWH(float* _result, float _x, float _y, float _width, float _height, float _near, float _far, bool _oglNdc = false)
|
||||
template <Handness::Enum HandnessT>
|
||||
inline void mtxProjXYWH(float* _result, float _x, float _y, float _width, float _height, float _near, float _far, bool _oglNdc = false)
|
||||
{
|
||||
const float diff = _far-_near;
|
||||
const float aa = _oglNdc ? (_far+_near)/diff : _far/diff;
|
||||
@ -640,14 +659,15 @@ namespace bx
|
||||
memset(_result, 0, sizeof(float)*16);
|
||||
_result[ 0] = _width;
|
||||
_result[ 5] = _height;
|
||||
_result[ 8] = _x;
|
||||
_result[ 9] = _y;
|
||||
_result[10] = -aa;
|
||||
_result[11] = -1.0f;
|
||||
_result[ 8] = (Handness::Right == HandnessT) ? _x : -_x;
|
||||
_result[ 9] = (Handness::Right == HandnessT) ? _y : -_y;
|
||||
_result[10] = (Handness::Right == HandnessT) ? -aa : aa;
|
||||
_result[11] = (Handness::Right == HandnessT) ? -1.0f : 1.0f;
|
||||
_result[14] = -bb;
|
||||
}
|
||||
|
||||
inline void mtxProjRh(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, float _far, bool _oglNdc = false)
|
||||
template <Handness::Enum HandnessT>
|
||||
inline void mtxProj_impl(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, float _far, bool _oglNdc = false)
|
||||
{
|
||||
const float invDiffRl = 1.0f/(_rt - _lt);
|
||||
const float invDiffUd = 1.0f/(_ut - _dt);
|
||||
@ -655,76 +675,197 @@ namespace bx
|
||||
const float height = 2.0f*_near * invDiffUd;
|
||||
const float xx = (_rt + _lt) * invDiffRl;
|
||||
const float yy = (_ut + _dt) * invDiffUd;
|
||||
mtxProjRhXYWH(_result, xx, yy, width, height, _near, _far, _oglNdc);
|
||||
mtxProjXYWH<HandnessT>(_result, xx, yy, width, height, _near, _far, _oglNdc);
|
||||
}
|
||||
|
||||
inline void mtxProjRh(float* _result, const float _fov[4], float _near, float _far, bool _oglNdc = false)
|
||||
template <Handness::Enum HandnessT>
|
||||
inline void mtxProj_impl(float* _result, const float _fov[4], float _near, float _far, bool _oglNdc = false)
|
||||
{
|
||||
mtxProjRh(_result, _fov[0], _fov[1], _fov[2], _fov[3], _near, _far, _oglNdc);
|
||||
mtxProj_impl<HandnessT>(_result, _fov[0], _fov[1], _fov[2], _fov[3], _near, _far, _oglNdc);
|
||||
}
|
||||
|
||||
inline void mtxProjRh(float* _result, float _fovy, float _aspect, float _near, float _far, bool _oglNdc = false)
|
||||
template <Handness::Enum HandnessT>
|
||||
inline void mtxProj_impl(float* _result, float _fovy, float _aspect, float _near, float _far, bool _oglNdc = false)
|
||||
{
|
||||
const float height = 1.0f/tanf(toRad(_fovy)*0.5f);
|
||||
const float width = height * 1.0f/_aspect;
|
||||
mtxProjRhXYWH(_result, 0.0f, 0.0f, width, height, _near, _far, _oglNdc);
|
||||
}
|
||||
|
||||
inline void mtxProjLhXYWH(float* _result, float _x, float _y, float _width, float _height, float _near, float _far, bool _oglNdc = false)
|
||||
{
|
||||
const float diff = _far-_near;
|
||||
const float aa = _oglNdc ? (_far+_near)/diff : _far/diff;
|
||||
const float bb = _oglNdc ? (2.0f*_far*_near)/diff : _near*aa;
|
||||
|
||||
memset(_result, 0, sizeof(float)*16);
|
||||
_result[ 0] = _width;
|
||||
_result[ 5] = _height;
|
||||
_result[ 8] = -_x;
|
||||
_result[ 9] = -_y;
|
||||
_result[10] = aa;
|
||||
_result[11] = 1.0f;
|
||||
_result[14] = -bb;
|
||||
}
|
||||
|
||||
inline void mtxProjLh(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, float _far, bool _oglNdc = false)
|
||||
{
|
||||
const float invDiffRl = 1.0f/(_rt - _lt);
|
||||
const float invDiffUd = 1.0f/(_ut - _dt);
|
||||
const float width = 2.0f*_near * invDiffRl;
|
||||
const float height = 2.0f*_near * invDiffUd;
|
||||
const float xx = (_rt + _lt) * invDiffRl;
|
||||
const float yy = (_ut + _dt) * invDiffUd;
|
||||
mtxProjLhXYWH(_result, xx, yy, width, height, _near, _far, _oglNdc);
|
||||
}
|
||||
|
||||
inline void mtxProjLh(float* _result, const float _fov[4], float _near, float _far, bool _oglNdc = false)
|
||||
{
|
||||
mtxProjLh(_result, _fov[0], _fov[1], _fov[2], _fov[3], _near, _far, _oglNdc);
|
||||
}
|
||||
|
||||
inline void mtxProjLh(float* _result, float _fovy, float _aspect, float _near, float _far, bool _oglNdc = false)
|
||||
{
|
||||
const float height = 1.0f/tanf(toRad(_fovy)*0.5f);
|
||||
const float width = height * 1.0f/_aspect;
|
||||
mtxProjLhXYWH(_result, 0.0f, 0.0f, width, height, _near, _far, _oglNdc);
|
||||
mtxProjXYWH<HandnessT>(_result, 0.0f, 0.0f, width, height, _near, _far, _oglNdc);
|
||||
}
|
||||
|
||||
inline void mtxProj(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, float _far, bool _oglNdc = false)
|
||||
{
|
||||
mtxProjLh(_result, _ut, _dt, _lt, _rt, _near, _far, _oglNdc);
|
||||
mtxProj_impl<Handness::Left>(_result, _ut, _dt, _lt, _rt, _near, _far, _oglNdc);
|
||||
}
|
||||
|
||||
inline void mtxProj(float* _result, const float _fov[4], float _near, float _far, bool _oglNdc = false)
|
||||
{
|
||||
mtxProjLh(_result, _fov, _near, _far, _oglNdc);
|
||||
mtxProj_impl<Handness::Left>(_result, _fov, _near, _far, _oglNdc);
|
||||
}
|
||||
|
||||
inline void mtxProj(float* _result, float _fovy, float _aspect, float _near, float _far, bool _oglNdc = false)
|
||||
{
|
||||
mtxProjLh(_result, _fovy, _aspect, _near, _far, _oglNdc);
|
||||
mtxProj_impl<Handness::Left>(_result, _fovy, _aspect, _near, _far, _oglNdc);
|
||||
}
|
||||
|
||||
inline void mtxOrthoLh(float* _result, float _left, float _right, float _bottom, float _top, float _near, float _far, float _offset = 0.0f, bool _oglNdc = false)
|
||||
inline void mtxProjLh(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, float _far, bool _oglNdc = false)
|
||||
{
|
||||
mtxProj_impl<Handness::Left>(_result, _ut, _dt, _lt, _rt, _near, _far, _oglNdc);
|
||||
}
|
||||
|
||||
inline void mtxProjLh(float* _result, const float _fov[4], float _near, float _far, bool _oglNdc = false)
|
||||
{
|
||||
mtxProj_impl<Handness::Left>(_result, _fov, _near, _far, _oglNdc);
|
||||
}
|
||||
|
||||
inline void mtxProjLh(float* _result, float _fovy, float _aspect, float _near, float _far, bool _oglNdc = false)
|
||||
{
|
||||
mtxProj_impl<Handness::Left>(_result, _fovy, _aspect, _near, _far, _oglNdc);
|
||||
}
|
||||
|
||||
inline void mtxProjRh(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, float _far, bool _oglNdc = false)
|
||||
{
|
||||
mtxProj_impl<Handness::Right>(_result, _ut, _dt, _lt, _rt, _near, _far, _oglNdc);
|
||||
}
|
||||
|
||||
inline void mtxProjRh(float* _result, const float _fov[4], float _near, float _far, bool _oglNdc = false)
|
||||
{
|
||||
mtxProj_impl<Handness::Right>(_result, _fov, _near, _far, _oglNdc);
|
||||
}
|
||||
|
||||
inline void mtxProjRh(float* _result, float _fovy, float _aspect, float _near, float _far, bool _oglNdc = false)
|
||||
{
|
||||
mtxProj_impl<Handness::Right>(_result, _fovy, _aspect, _near, _far, _oglNdc);
|
||||
}
|
||||
|
||||
template <NearFar::Enum NearFarT, Handness::Enum HandnessT>
|
||||
inline void mtxProjInfXYWH(float* _result, float _x, float _y, float _width, float _height, float _near, bool _oglNdc = false)
|
||||
{
|
||||
float aa;
|
||||
float bb;
|
||||
if (BX_ENABLED(NearFar::Reverse == NearFarT) )
|
||||
{
|
||||
aa = _oglNdc ? -1.0f : 0.0f;
|
||||
bb = _oglNdc ? -2.0f*_near : -_near;
|
||||
}
|
||||
else
|
||||
{
|
||||
aa = 1.0f;
|
||||
bb = _oglNdc ? 2.0f*_near : _near;
|
||||
}
|
||||
|
||||
memset(_result, 0, sizeof(float)*16);
|
||||
_result[ 0] = _width;
|
||||
_result[ 5] = _height;
|
||||
_result[ 8] = (Handness::Right == HandnessT) ? _x : -_x;
|
||||
_result[ 9] = (Handness::Right == HandnessT) ? _y : -_y;
|
||||
_result[10] = (Handness::Right == HandnessT) ? -aa : aa;
|
||||
_result[11] = (Handness::Right == HandnessT) ? -1.0f : 1.0f;
|
||||
_result[14] = -bb;
|
||||
}
|
||||
|
||||
template <NearFar::Enum NearFarT, Handness::Enum HandnessT>
|
||||
inline void mtxProjInf_impl(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, bool _oglNdc = false)
|
||||
{
|
||||
const float invDiffRl = 1.0f/(_rt - _lt);
|
||||
const float invDiffUd = 1.0f/(_ut - _dt);
|
||||
const float width = 2.0f*_near * invDiffRl;
|
||||
const float height = 2.0f*_near * invDiffUd;
|
||||
const float xx = (_rt + _lt) * invDiffRl;
|
||||
const float yy = (_ut + _dt) * invDiffUd;
|
||||
mtxProjInfXYWH<NearFarT,HandnessT>(_result, xx, yy, width, height, _near, _oglNdc);
|
||||
}
|
||||
|
||||
template <NearFar::Enum NearFarT, Handness::Enum HandnessT>
|
||||
inline void mtxProjInf_impl(float* _result, const float _fov[4], float _near, bool _oglNdc = false)
|
||||
{
|
||||
mtxProjInf_impl<NearFarT,HandnessT>(_result, _fov[0], _fov[1], _fov[2], _fov[3], _near, _oglNdc);
|
||||
}
|
||||
|
||||
template <NearFar::Enum NearFarT, Handness::Enum HandnessT>
|
||||
inline void mtxProjInf_impl(float* _result, float _fovy, float _aspect, float _near, bool _oglNdc = false)
|
||||
{
|
||||
const float height = 1.0f/tanf(toRad(_fovy)*0.5f);
|
||||
const float width = height * 1.0f/_aspect;
|
||||
mtxProjInfXYWH<NearFarT,HandnessT>(_result, 0.0f, 0.0f, width, height, _near, _oglNdc);
|
||||
}
|
||||
|
||||
inline void mtxProjInf(float* _result, const float _fov[4], float _near, bool _oglNdc = false)
|
||||
{
|
||||
mtxProjInf_impl<NearFar::Default,Handness::Left>(_result, _fov, _near, _oglNdc);
|
||||
}
|
||||
|
||||
inline void mtxProjInf(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, bool _oglNdc = false)
|
||||
{
|
||||
mtxProjInf_impl<NearFar::Default,Handness::Left>(_result, _ut, _dt, _lt, _rt, _near, _oglNdc);
|
||||
}
|
||||
|
||||
inline void mtxProjInf(float* _result, float _fovy, float _aspect, float _near, bool _oglNdc = false)
|
||||
{
|
||||
mtxProjInf_impl<NearFar::Default,Handness::Left>(_result, _fovy, _aspect, _near, _oglNdc);
|
||||
}
|
||||
|
||||
inline void mtxProjInfLh(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, bool _oglNdc = false)
|
||||
{
|
||||
mtxProjInf_impl<NearFar::Default,Handness::Left>(_result, _ut, _dt, _lt, _rt, _near, _oglNdc);
|
||||
}
|
||||
|
||||
inline void mtxProjInfLh(float* _result, const float _fov[4], float _near, bool _oglNdc = false)
|
||||
{
|
||||
mtxProjInf_impl<NearFar::Default,Handness::Left>(_result, _fov, _near, _oglNdc);
|
||||
}
|
||||
|
||||
inline void mtxProjInfLh(float* _result, float _fovy, float _aspect, float _near, bool _oglNdc = false)
|
||||
{
|
||||
mtxProjInf_impl<NearFar::Default,Handness::Left>(_result, _fovy, _aspect, _near, _oglNdc);
|
||||
}
|
||||
|
||||
inline void mtxProjInfRh(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, bool _oglNdc = false)
|
||||
{
|
||||
mtxProjInf_impl<NearFar::Default,Handness::Right>(_result, _ut, _dt, _lt, _rt, _near, _oglNdc);
|
||||
}
|
||||
|
||||
inline void mtxProjInfRh(float* _result, const float _fov[4], float _near, bool _oglNdc = false)
|
||||
{
|
||||
mtxProjInf_impl<NearFar::Default,Handness::Right>(_result, _fov, _near, _oglNdc);
|
||||
}
|
||||
|
||||
inline void mtxProjInfRh(float* _result, float _fovy, float _aspect, float _near, bool _oglNdc = false)
|
||||
{
|
||||
mtxProjInf_impl<NearFar::Default,Handness::Right>(_result, _fovy, _aspect, _near, _oglNdc);
|
||||
}
|
||||
|
||||
inline void mtxProjRevInfLh(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, bool _oglNdc = false)
|
||||
{
|
||||
mtxProjInf_impl<NearFar::Reverse,Handness::Left>(_result, _ut, _dt, _lt, _rt, _near, _oglNdc);
|
||||
}
|
||||
|
||||
inline void mtxProjRevInfLh(float* _result, const float _fov[4], float _near, bool _oglNdc = false)
|
||||
{
|
||||
mtxProjInf_impl<NearFar::Reverse,Handness::Left>(_result, _fov, _near, _oglNdc);
|
||||
}
|
||||
|
||||
inline void mtxProjRevInfLh(float* _result, float _fovy, float _aspect, float _near, bool _oglNdc = false)
|
||||
{
|
||||
mtxProjInf_impl<NearFar::Reverse,Handness::Left>(_result, _fovy, _aspect, _near, _oglNdc);
|
||||
}
|
||||
|
||||
inline void mtxProjRevInfRh(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, bool _oglNdc = false)
|
||||
{
|
||||
mtxProjInf_impl<NearFar::Reverse,Handness::Right>(_result, _ut, _dt, _lt, _rt, _near, _oglNdc);
|
||||
}
|
||||
|
||||
inline void mtxProjRevInfRh(float* _result, const float _fov[4], float _near, bool _oglNdc = false)
|
||||
{
|
||||
mtxProjInf_impl<NearFar::Reverse,Handness::Right>(_result, _fov, _near, _oglNdc);
|
||||
}
|
||||
|
||||
inline void mtxProjRevInfRh(float* _result, float _fovy, float _aspect, float _near, bool _oglNdc = false)
|
||||
{
|
||||
mtxProjInf_impl<NearFar::Reverse,Handness::Right>(_result, _fovy, _aspect, _near, _oglNdc);
|
||||
}
|
||||
|
||||
template <Handness::Enum HandnessT>
|
||||
inline void mtxOrtho_impl(float* _result, float _left, float _right, float _bottom, float _top, float _near, float _far, float _offset = 0.0f, bool _oglNdc = false)
|
||||
{
|
||||
const float aa = 2.0f/(_right - _left);
|
||||
const float bb = 2.0f/(_top - _bottom);
|
||||
@ -736,26 +877,7 @@ namespace bx
|
||||
memset(_result, 0, sizeof(float)*16);
|
||||
_result[ 0] = aa;
|
||||
_result[ 5] = bb;
|
||||
_result[10] = cc;
|
||||
_result[12] = dd + _offset;
|
||||
_result[13] = ee;
|
||||
_result[14] = ff;
|
||||
_result[15] = 1.0f;
|
||||
}
|
||||
|
||||
inline void mtxOrthoRh(float* _result, float _left, float _right, float _bottom, float _top, float _near, float _far, float _offset = 0.0f, bool _oglNdc = false)
|
||||
{
|
||||
const float aa = 2.0f/(_right - _left);
|
||||
const float bb = 2.0f/(_top - _bottom);
|
||||
const float cc = (_oglNdc ? 2.0f : 1.0f) / (_far - _near);
|
||||
const float dd = (_left + _right)/(_left - _right);
|
||||
const float ee = (_top + _bottom)/(_bottom - _top);
|
||||
const float ff = _oglNdc ? (_near + _far)/(_near - _far) : _near/(_near - _far);
|
||||
|
||||
memset(_result, 0, sizeof(float)*16);
|
||||
_result[ 0] = aa;
|
||||
_result[ 5] = bb;
|
||||
_result[10] = -cc;
|
||||
_result[10] = (Handness::Right == HandnessT) ? -cc : cc;
|
||||
_result[12] = dd + _offset;
|
||||
_result[13] = ee;
|
||||
_result[14] = ff;
|
||||
@ -764,7 +886,17 @@ namespace bx
|
||||
|
||||
inline void mtxOrtho(float* _result, float _left, float _right, float _bottom, float _top, float _near, float _far, float _offset = 0.0f, bool _oglNdc = false)
|
||||
{
|
||||
return mtxOrthoLh(_result, _left, _right, _bottom, _top, _near, _far, _offset, _oglNdc);
|
||||
mtxOrtho_impl<Handness::Left>(_result, _left, _right, _bottom, _top, _near, _far, _offset, _oglNdc);
|
||||
}
|
||||
|
||||
inline void mtxOrthoLh(float* _result, float _left, float _right, float _bottom, float _top, float _near, float _far, float _offset = 0.0f, bool _oglNdc = false)
|
||||
{
|
||||
mtxOrtho_impl<Handness::Left>(_result, _left, _right, _bottom, _top, _near, _far, _offset, _oglNdc);
|
||||
}
|
||||
|
||||
inline void mtxOrthoRh(float* _result, float _left, float _right, float _bottom, float _top, float _near, float _far, float _offset = 0.0f, bool _oglNdc = false)
|
||||
{
|
||||
mtxOrtho_impl<Handness::Right>(_result, _left, _right, _bottom, _top, _near, _far, _offset, _oglNdc);
|
||||
}
|
||||
|
||||
inline void mtxRotateX(float* _result, float _ax)
|
||||
|
34
3rdparty/bx/include/bx/platform.h
vendored
34
3rdparty/bx/include/bx/platform.h
vendored
@ -28,11 +28,12 @@
|
||||
#define BX_PLATFORM_XBOX360 0
|
||||
#define BX_PLATFORM_XBOXONE 0
|
||||
|
||||
#define BX_CPU_ARM 0
|
||||
#define BX_CPU_JIT 0
|
||||
#define BX_CPU_MIPS 0
|
||||
#define BX_CPU_PPC 0
|
||||
#define BX_CPU_X86 0
|
||||
#define BX_CPU_ARM 0
|
||||
#define BX_CPU_JIT 0
|
||||
#define BX_CPU_MIPS 0
|
||||
#define BX_CPU_PPC 0
|
||||
#define BX_CPU_RISCV 0
|
||||
#define BX_CPU_X86 0
|
||||
|
||||
#define BX_ARCH_32BIT 0
|
||||
#define BX_ARCH_64BIT 0
|
||||
@ -84,6 +85,12 @@
|
||||
# undef BX_CPU_PPC
|
||||
# define BX_CPU_PPC 1
|
||||
# define BX_CACHE_LINE_SIZE 128
|
||||
#elif defined(__riscv) || \
|
||||
defined(__riscv__) || \
|
||||
defined(RISCVEL)
|
||||
# undef BX_CPU_RISCV
|
||||
# define BX_CPU_RISCV 1
|
||||
# define BX_CACHE_LINE_SIZE 64
|
||||
#elif defined(_M_IX86) || \
|
||||
defined(_M_X64) || \
|
||||
defined(__i386__) || \
|
||||
@ -103,7 +110,8 @@
|
||||
defined(__64BIT__) || \
|
||||
defined(__mips64) || \
|
||||
defined(__powerpc64__) || \
|
||||
defined(__ppc64__)
|
||||
defined(__ppc64__) || \
|
||||
defined(__LP64__)
|
||||
# undef BX_ARCH_64BIT
|
||||
# define BX_ARCH_64BIT 64
|
||||
#else
|
||||
@ -171,10 +179,12 @@
|
||||
// RaspberryPi compiler defines __linux__
|
||||
# undef BX_PLATFORM_RPI
|
||||
# define BX_PLATFORM_RPI 1
|
||||
#elif defined(__linux__)
|
||||
#elif defined(__linux__) \
|
||||
|| defined(__riscv__)
|
||||
# undef BX_PLATFORM_LINUX
|
||||
# define BX_PLATFORM_LINUX 1
|
||||
#elif defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) || defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__)
|
||||
#elif defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) \
|
||||
|| defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__)
|
||||
# undef BX_PLATFORM_IOS
|
||||
# define BX_PLATFORM_IOS 1
|
||||
#elif defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__)
|
||||
@ -183,7 +193,7 @@
|
||||
# define BX_PLATFORM_OSX __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__
|
||||
# else
|
||||
# define BX_PLATFORM_OSX 1
|
||||
# endif // defined(MAC_OS_X_VERSION_MAX_ALLOWED)
|
||||
# endif // defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__)
|
||||
#elif defined(__EMSCRIPTEN__)
|
||||
# undef BX_PLATFORM_EMSCRIPTEN
|
||||
# define BX_PLATFORM_EMSCRIPTEN 1
|
||||
@ -283,12 +293,14 @@
|
||||
|
||||
#if BX_CPU_ARM
|
||||
# define BX_CPU_NAME "ARM"
|
||||
#elif BX_CPU_JIT
|
||||
# define BX_CPU_NAME "JIT-VM"
|
||||
#elif BX_CPU_MIPS
|
||||
# define BX_CPU_NAME "MIPS"
|
||||
#elif BX_CPU_PPC
|
||||
# define BX_CPU_NAME "PowerPC"
|
||||
#elif BX_CPU_JIT
|
||||
# define BX_CPU_NAME "JIT-VM"
|
||||
#elif BX_CPU_RISCV
|
||||
# define BX_CPU_NAME "RISC-V"
|
||||
#elif BX_CPU_X86
|
||||
# define BX_CPU_NAME "x86"
|
||||
#endif // BX_CPU_
|
||||
|
45
3rdparty/bx/include/bx/readerwriter.h
vendored
45
3rdparty/bx/include/bx/readerwriter.h
vendored
@ -230,38 +230,59 @@ namespace bx
|
||||
{
|
||||
};
|
||||
|
||||
struct BX_NO_VTABLE FileReaderI : public ReaderSeekerI
|
||||
struct BX_NO_VTABLE ReaderOpenI
|
||||
{
|
||||
virtual ~ReaderOpenI() = 0;
|
||||
virtual bool open(const char* _filePath, Error* _err) = 0;
|
||||
virtual void close() = 0;
|
||||
};
|
||||
|
||||
struct BX_NO_VTABLE FileWriterI : public WriterSeekerI
|
||||
inline ReaderOpenI::~ReaderOpenI()
|
||||
{
|
||||
}
|
||||
|
||||
struct BX_NO_VTABLE WriterOpenI
|
||||
{
|
||||
virtual ~WriterOpenI() = 0;
|
||||
virtual bool open(const char* _filePath, bool _append, Error* _err) = 0;
|
||||
};
|
||||
|
||||
inline WriterOpenI::~WriterOpenI()
|
||||
{
|
||||
}
|
||||
|
||||
struct BX_NO_VTABLE CloserI
|
||||
{
|
||||
virtual ~CloserI() = 0;
|
||||
virtual void close() = 0;
|
||||
};
|
||||
|
||||
inline bool open(FileReaderI* _reader, const char* _filePath, Error* _err = NULL)
|
||||
inline CloserI::~CloserI()
|
||||
{
|
||||
}
|
||||
|
||||
struct BX_NO_VTABLE FileReaderI : public ReaderOpenI, public CloserI, public ReaderSeekerI
|
||||
{
|
||||
};
|
||||
|
||||
struct BX_NO_VTABLE FileWriterI : public WriterOpenI, public CloserI, public WriterSeekerI
|
||||
{
|
||||
};
|
||||
|
||||
inline bool open(ReaderOpenI* _reader, const char* _filePath, Error* _err = NULL)
|
||||
{
|
||||
BX_ERROR_USE_TEMP_WHEN_NULL(_err);
|
||||
return _reader->open(_filePath, _err);
|
||||
}
|
||||
|
||||
inline void close(FileReaderI* _reader)
|
||||
{
|
||||
_reader->close();
|
||||
}
|
||||
|
||||
inline bool open(FileWriterI* _writer, const char* _filePath, bool _append = false, Error* _err = NULL)
|
||||
inline bool open(WriterOpenI* _writer, const char* _filePath, bool _append = false, Error* _err = NULL)
|
||||
{
|
||||
BX_ERROR_USE_TEMP_WHEN_NULL(_err);
|
||||
return _writer->open(_filePath, _append, _err);
|
||||
}
|
||||
|
||||
inline void close(FileWriterI* _writer)
|
||||
inline void close(CloserI* _reader)
|
||||
{
|
||||
_writer->close();
|
||||
_reader->close();
|
||||
}
|
||||
|
||||
struct BX_NO_VTABLE MemoryBlockI
|
||||
|
20
3rdparty/bx/scripts/toolchain.lua
vendored
20
3rdparty/bx/scripts/toolchain.lua
vendored
@ -37,6 +37,7 @@ function toolchain(_buildDir, _libDir)
|
||||
{ "ps4", "PS4" },
|
||||
{ "qnx-arm", "QNX/Blackberry - ARM" },
|
||||
{ "rpi", "RaspberryPi" },
|
||||
{ "riscv", "RISC-V" },
|
||||
},
|
||||
}
|
||||
|
||||
@ -336,6 +337,13 @@ function toolchain(_buildDir, _libDir)
|
||||
|
||||
elseif "rpi" == _OPTIONS["gcc"] then
|
||||
location (path.join(_buildDir, "projects", _ACTION .. "-rpi"))
|
||||
|
||||
elseif "riscv" == _OPTIONS["gcc"] then
|
||||
premake.gcc.cc = "/opt/riscv/bin/riscv64-unknown-elf-gcc"
|
||||
premake.gcc.cxx = "/opt/riscv/bin/riscv64-unknown-elf-g++"
|
||||
premake.gcc.ar = "/opt/riscv/bin/riscv64-unknown-elf-ar"
|
||||
location (path.join(_buildDir, "projects", _ACTION .. "-riscv"))
|
||||
|
||||
end
|
||||
elseif _ACTION == "vs2012" or _ACTION == "vs2013" or _ACTION == "vs2015" then
|
||||
|
||||
@ -1128,6 +1136,17 @@ function toolchain(_buildDir, _libDir)
|
||||
"-Wl,--gc-sections",
|
||||
}
|
||||
|
||||
configuration { "riscv" }
|
||||
targetdir (path.join(_buildDir, "riscv/bin"))
|
||||
objdir (path.join(_buildDir, "riscv/obj"))
|
||||
buildoptions {
|
||||
"-Wunused-value",
|
||||
"-Wundef",
|
||||
}
|
||||
buildoptions_cpp {
|
||||
"-std=c++0x",
|
||||
}
|
||||
|
||||
configuration {} -- reset configuration
|
||||
|
||||
return true
|
||||
@ -1191,6 +1210,7 @@ function strip()
|
||||
-- .. "-s EMTERPRETIFY_ASYNC=1 "
|
||||
.. "-s TOTAL_MEMORY=268435456 "
|
||||
-- .. "-s ALLOW_MEMORY_GROWTH=1 "
|
||||
-- .. "-s USE_WEBGL2=1 "
|
||||
.. "--memory-init-file 1 "
|
||||
.. "\"$(TARGET)\" -o \"$(TARGET)\".html "
|
||||
-- .. "--preload-file ../../../examples/runtime@/"
|
||||
|
2
3rdparty/bx/scripts/unittest++.lua
vendored
2
3rdparty/bx/scripts/unittest++.lua
vendored
@ -15,7 +15,7 @@ project "UnitTest++"
|
||||
"../3rdparty/UnitTest++/src/*.h",
|
||||
}
|
||||
|
||||
configuration { "linux or osx or android-* or *nacl* or ps4" }
|
||||
configuration { "linux or osx or android-* or *nacl* or ps4 or rpi or riscv" }
|
||||
files {
|
||||
"../3rdparty/UnitTest++/src/Posix/**.cpp",
|
||||
"../3rdparty/UnitTest++/src/Posix/**.h",
|
||||
|
BIN
3rdparty/bx/tools/bin/darwin/genie
vendored
BIN
3rdparty/bx/tools/bin/darwin/genie
vendored
Binary file not shown.
BIN
3rdparty/bx/tools/bin/darwin/ninja
vendored
Normal file
BIN
3rdparty/bx/tools/bin/darwin/ninja
vendored
Normal file
Binary file not shown.
BIN
3rdparty/bx/tools/bin/linux/genie
vendored
BIN
3rdparty/bx/tools/bin/linux/genie
vendored
Binary file not shown.
BIN
3rdparty/bx/tools/bin/linux/ninja
vendored
Normal file
BIN
3rdparty/bx/tools/bin/linux/ninja
vendored
Normal file
Binary file not shown.
BIN
3rdparty/bx/tools/bin/windows/genie.exe
vendored
BIN
3rdparty/bx/tools/bin/windows/genie.exe
vendored
Binary file not shown.
BIN
3rdparty/bx/tools/bin/windows/ninja.exe
vendored
Normal file
BIN
3rdparty/bx/tools/bin/windows/ninja.exe
vendored
Normal file
Binary file not shown.
22
3rdparty/genie/LICENSE
vendored
22
3rdparty/genie/LICENSE
vendored
@ -85,3 +85,25 @@ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
# profiler.lua
|
||||
|
||||
Lua profiler - Copyright Pepperfish 2002,2003,2004
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to
|
||||
deal in the Software without restriction, including without limitation the
|
||||
rights to use, copy, modify, merge, publish, distribute, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to
|
||||
do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
IN THE SOFTWARE.
|
||||
|
2
3rdparty/genie/README.md
vendored
2
3rdparty/genie/README.md
vendored
@ -37,7 +37,7 @@ Download (stable)
|
||||
|
||||
[](https://travis-ci.org/bkaradzic/GENie)
|
||||
|
||||
version 405 (commit 8f8ab7d903a1495180175784adb7d3b5657c68bb)
|
||||
version 415 (commit 53635be7264271a6d6c95b059c420251b7eb3280)
|
||||
|
||||
Linux:
|
||||
https://github.com/bkaradzic/bx/raw/master/tools/bin/linux/genie
|
||||
|
1
3rdparty/genie/src/_manifest.lua
vendored
1
3rdparty/genie/src/_manifest.lua
vendored
@ -26,6 +26,7 @@
|
||||
"base/api.lua",
|
||||
"base/cmdline.lua",
|
||||
"base/inspect.lua",
|
||||
"base/profiler.lua",
|
||||
"tools/dotnet.lua",
|
||||
"tools/gcc.lua",
|
||||
"tools/ghs.lua",
|
||||
|
67
3rdparty/genie/src/_premake_main.lua
vendored
67
3rdparty/genie/src/_premake_main.lua
vendored
@ -16,28 +16,28 @@
|
||||
local function injectplatform(platform)
|
||||
if not platform then return true end
|
||||
platform = premake.checkvalue(platform, premake.fields.platforms.allowed)
|
||||
|
||||
|
||||
for sln in premake.solution.each() do
|
||||
local platforms = sln.platforms or { }
|
||||
|
||||
|
||||
-- an empty table is equivalent to a native build
|
||||
if #platforms == 0 then
|
||||
table.insert(platforms, "Native")
|
||||
end
|
||||
|
||||
|
||||
-- the solution must provide a native build in order to support this feature
|
||||
if not table.contains(platforms, "Native") then
|
||||
return false, sln.name .. " does not target native platform\nNative platform settings are required for the --platform feature."
|
||||
end
|
||||
|
||||
|
||||
-- add it to the end of the list, if it isn't in there already
|
||||
if not table.contains(platforms, platform) then
|
||||
table.insert(platforms, platform)
|
||||
end
|
||||
|
||||
|
||||
sln.platforms = platforms
|
||||
end
|
||||
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
@ -46,22 +46,22 @@
|
||||
--
|
||||
|
||||
function _premake_main(scriptpath)
|
||||
|
||||
-- if running off the disk (in debug mode), load everything
|
||||
|
||||
-- if running off the disk (in debug mode), load everything
|
||||
-- listed in _manifest.lua; the list divisions make sure
|
||||
-- everything gets initialized in the proper order.
|
||||
|
||||
|
||||
if (scriptpath) then
|
||||
local scripts = dofile(scriptpath .. "/_manifest.lua")
|
||||
for _,v in ipairs(scripts) do
|
||||
dofile(scriptpath .. "/" .. v)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
-- Now that the scripts are loaded, I can use path.getabsolute() to properly
|
||||
-- canonicalize the executable path.
|
||||
|
||||
|
||||
_PREMAKE_COMMAND = path.getabsolute(_PREMAKE_COMMAND)
|
||||
|
||||
|
||||
@ -70,15 +70,15 @@
|
||||
|
||||
premake.action.set(_ACTION)
|
||||
|
||||
|
||||
|
||||
-- Seed the random number generator so actions don't have to do it themselves
|
||||
|
||||
|
||||
math.randomseed(os.time())
|
||||
|
||||
|
||||
|
||||
|
||||
-- If there is a project script available, run it to get the
|
||||
-- project information, available options and actions, etc.
|
||||
|
||||
|
||||
|
||||
if (nil ~= _OPTIONS["file"]) then
|
||||
local fname = _OPTIONS["file"]
|
||||
@ -96,10 +96,10 @@
|
||||
end
|
||||
|
||||
-- Process special options
|
||||
|
||||
|
||||
if (_OPTIONS["version"] or _OPTIONS["help"] or not _ACTION) then
|
||||
printf("GENie - Project generator tool %s", _GENIE_VERSION_STR)
|
||||
printf("https://github.com/bkaradzic/genie")
|
||||
printf("https://github.com/bkaradzic/GENie")
|
||||
if (not _OPTIONS["version"]) then
|
||||
premake.showhelp()
|
||||
end
|
||||
@ -108,7 +108,7 @@
|
||||
|
||||
-- Validate the command-line arguments. This has to happen after the
|
||||
-- script has run to allow for project-specific options
|
||||
|
||||
|
||||
action = premake.action.current()
|
||||
if (not action) then
|
||||
error("Error: no such action '" .. _ACTION .. "'", 0)
|
||||
@ -116,28 +116,42 @@
|
||||
|
||||
ok, err = premake.option.validate(_OPTIONS)
|
||||
if (not ok) then error("Error: " .. err, 0) end
|
||||
|
||||
|
||||
|
||||
-- Sanity check the current project setup
|
||||
|
||||
ok, err = premake.checktools()
|
||||
if (not ok) then error("Error: " .. err, 0) end
|
||||
|
||||
|
||||
|
||||
|
||||
-- If a platform was specified on the command line, inject it now
|
||||
|
||||
ok, err = injectplatform(_OPTIONS["platform"])
|
||||
if (not ok) then error("Error: " .. err, 0) end
|
||||
|
||||
|
||||
local profiler = newProfiler()
|
||||
if (nil ~= _OPTIONS["debug-profiler"]) then
|
||||
profiler:start()
|
||||
end
|
||||
|
||||
-- work-in-progress: build the configurations
|
||||
print("Building configurations...")
|
||||
premake.bake.buildconfigs()
|
||||
|
||||
|
||||
if (nil ~= _OPTIONS["debug-profiler"]) then
|
||||
profiler:stop()
|
||||
|
||||
local filePath = path.getabsolute("GENie-profiler-bake.txt")
|
||||
print("Writing debug-profiler report " .. filePath .. ".")
|
||||
|
||||
local outfile = io.open(filePath, "w+")
|
||||
profiler:report(outfile)
|
||||
outfile:close()
|
||||
end
|
||||
|
||||
ok, err = premake.checkprojects()
|
||||
if (not ok) then error("Error: " .. err, 0) end
|
||||
|
||||
|
||||
|
||||
-- Hand over control to the action
|
||||
printf("Running action '%s'...", action.trigger)
|
||||
premake.action.call(action.trigger)
|
||||
@ -146,4 +160,3 @@
|
||||
return 0
|
||||
|
||||
end
|
||||
|
||||
|
10
3rdparty/genie/src/base/api.lua
vendored
10
3rdparty/genie/src/base/api.lua
vendored
@ -1146,3 +1146,13 @@
|
||||
function newoption(opt)
|
||||
premake.option.add(opt)
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Enable file level configuration
|
||||
-- this makes project generation slower for large projects
|
||||
--
|
||||
|
||||
function enablefilelevelconfig()
|
||||
premake._filelevelconfig = true
|
||||
end
|
||||
|
13
3rdparty/genie/src/base/bake.lua
vendored
13
3rdparty/genie/src/base/bake.lua
vendored
@ -728,11 +728,16 @@
|
||||
-- step of building it later?
|
||||
cfg.__fileconfigs = { }
|
||||
for _, fname in ipairs(cfg.files) do
|
||||
cfg.terms.required = fname:lower()
|
||||
local fcfg = {}
|
||||
for _, blk in ipairs(cfg.project.blocks) do
|
||||
if (premake.iskeywordsmatch(blk.keywords, cfg.terms)) then
|
||||
mergeobject(fcfg, blk)
|
||||
|
||||
-- Only do this if the script has called enablefilelevelconfig()
|
||||
if premake._filelevelconfig then
|
||||
cfg.terms.required = fname:lower()
|
||||
for _, blk in ipairs(cfg.project.blocks) do
|
||||
-- BK - `iskeywordsmatch` call is super slow for large projects...
|
||||
if (premake.iskeywordsmatch(blk.keywords, cfg.terms)) then
|
||||
mergeobject(fcfg, blk)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
7
3rdparty/genie/src/base/cmdline.lua
vendored
7
3rdparty/genie/src/base/cmdline.lua
vendored
@ -87,9 +87,14 @@
|
||||
description = "Search for additional scripts on the given path"
|
||||
}
|
||||
|
||||
newoption
|
||||
{
|
||||
trigger = "debug-profiler",
|
||||
description = "GENie script generation profiler."
|
||||
}
|
||||
|
||||
newoption
|
||||
{
|
||||
trigger = "version",
|
||||
description = "Display version information"
|
||||
}
|
||||
|
||||
|
1
3rdparty/genie/src/base/globals.lua
vendored
1
3rdparty/genie/src/base/globals.lua
vendored
@ -71,7 +71,6 @@
|
||||
{
|
||||
cfgsuffix = "orbis",
|
||||
iscrosscompiler = true,
|
||||
nosharedlibs = true, -- @thendrix, Fix this to allow SPRXs
|
||||
namestyle = "Orbis",
|
||||
},
|
||||
Durango =
|
||||
|
3
3rdparty/genie/src/base/premake.lua
vendored
3
3rdparty/genie/src/base/premake.lua
vendored
@ -4,6 +4,7 @@
|
||||
-- Copyright (c) 2002-2009 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
premake._filelevelconfig = false
|
||||
|
||||
--
|
||||
-- Open a file for output, and call a function to actually do the writing.
|
||||
@ -70,4 +71,4 @@
|
||||
end
|
||||
|
||||
return nil, nil
|
||||
end
|
||||
end
|
||||
|
613
3rdparty/genie/src/base/profiler.lua
vendored
Normal file
613
3rdparty/genie/src/base/profiler.lua
vendored
Normal file
@ -0,0 +1,613 @@
|
||||
--
|
||||
-- http://lua-users.org/wiki/PepperfishProfiler
|
||||
--
|
||||
-- == Introduction ==
|
||||
--
|
||||
-- Note that this requires os.clock(), debug.sethook(),
|
||||
-- and debug.getinfo() or your equivalent replacements to
|
||||
-- be available if this is an embedded application.
|
||||
--
|
||||
-- Example usage:
|
||||
--
|
||||
-- profiler = newProfiler()
|
||||
-- profiler:start()
|
||||
--
|
||||
-- < call some functions that take time >
|
||||
--
|
||||
-- profiler:stop()
|
||||
--
|
||||
-- local outfile = io.open( "profile.txt", "w+" )
|
||||
-- profiler:report( outfile )
|
||||
-- outfile:close()
|
||||
--
|
||||
-- == Optionally choosing profiling method ==
|
||||
--
|
||||
-- The rest of this comment can be ignored if you merely want a good profiler.
|
||||
--
|
||||
-- newProfiler(method, sampledelay):
|
||||
--
|
||||
-- If method is omitted or "time", will profile based on real performance.
|
||||
-- optionally, frequency can be provided to control the number of opcodes
|
||||
-- per profiling tick. By default this is 100000, which (on my system) provides
|
||||
-- one tick approximately every 2ms and reduces system performance by about 10%.
|
||||
-- This can be reduced to increase accuracy at the cost of performance, or
|
||||
-- increased for the opposite effect.
|
||||
--
|
||||
-- If method is "call", will profile based on function calls. Frequency is
|
||||
-- ignored.
|
||||
--
|
||||
--
|
||||
-- "time" may bias profiling somewhat towards large areas with "simple opcodes",
|
||||
-- as the profiling function (which introduces a certain amount of unavoidable
|
||||
-- overhead) will be called more often. This can be minimized by using a larger
|
||||
-- sample delay - the default should leave any error largely overshadowed by
|
||||
-- statistical noise. With a delay of 1000 I was able to achieve inaccuray of
|
||||
-- approximately 25%. Increasing the delay to 100000 left inaccuracy below my
|
||||
-- testing error.
|
||||
--
|
||||
-- "call" may bias profiling heavily towards areas with many function calls.
|
||||
-- Testing found a degenerate case giving a figure inaccurate by approximately
|
||||
-- 20,000%. (Yes, a multiple of 200.) This is, however, more directly comparable
|
||||
-- to common profilers (such as gprof) and also gives accurate function call
|
||||
-- counts, which cannot be retrieved from "time".
|
||||
--
|
||||
-- I strongly recommend "time" mode, and it is now the default.
|
||||
--
|
||||
-- == History ==
|
||||
--
|
||||
-- 2008-09-16 - Time-based profiling and conversion to Lua 5.1
|
||||
-- by Ben Wilhelm ( zorba-pepperfish@pavlovian.net ).
|
||||
-- Added the ability to optionally choose profiling methods, along with a new
|
||||
-- profiling method.
|
||||
--
|
||||
-- Converted to Lua 5, a few improvements, and
|
||||
-- additional documentation by Tom Spilman ( tom@sickheadgames.com )
|
||||
--
|
||||
-- Additional corrections and tidying by original author
|
||||
-- Daniel Silverstone ( dsilvers@pepperfish.net )
|
||||
--
|
||||
-- == Status ==
|
||||
--
|
||||
-- Daniel Silverstone is no longer using this code, and judging by how long it's
|
||||
-- been waiting for Lua 5.1 support, I don't think Tom Spilman is either. I'm
|
||||
-- perfectly willing to take on maintenance, so if you have problems or
|
||||
-- questions, go ahead and email me :)
|
||||
-- -- Ben Wilhelm ( zorba-pepperfish@pavlovian.net ) '
|
||||
--
|
||||
-- == Copyright ==
|
||||
--
|
||||
-- Lua profiler - Copyright Pepperfish 2002,2003,2004
|
||||
--
|
||||
-- Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
-- of this software and associated documentation files (the "Software"), to
|
||||
-- deal in the Software without restriction, including without limitation the
|
||||
-- rights to use, copy, modify, merge, publish, distribute, and/or sell copies
|
||||
-- of the Software, and to permit persons to whom the Software is furnished to
|
||||
-- do so, subject to the following conditions:
|
||||
--
|
||||
-- The above copyright notice and this permission notice shall be included in
|
||||
-- all copies or substantial portions of the Software.
|
||||
--
|
||||
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
-- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
-- IN THE SOFTWARE.
|
||||
--
|
||||
|
||||
--
|
||||
-- All profiler related stuff is stored in the top level table '_profiler'
|
||||
--
|
||||
_profiler = {}
|
||||
|
||||
|
||||
--
|
||||
-- newProfiler() creates a new profiler object for managing
|
||||
-- the profiler and storing state. Note that only one profiler
|
||||
-- object can be executing at one time.
|
||||
--
|
||||
function newProfiler(variant, sampledelay)
|
||||
if _profiler.running then
|
||||
print("Profiler already running.")
|
||||
return
|
||||
end
|
||||
|
||||
variant = variant or "time"
|
||||
|
||||
if variant ~= "time" and variant ~= "call" then
|
||||
print("Profiler method must be 'time' or 'call'.")
|
||||
return
|
||||
end
|
||||
|
||||
local newprof = {}
|
||||
for k,v in pairs(_profiler) do
|
||||
newprof[k] = v
|
||||
end
|
||||
newprof.variant = variant
|
||||
newprof.sampledelay = sampledelay or 100000
|
||||
return newprof
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- This function starts the profiler. It will do nothing
|
||||
-- if this (or any other) profiler is already running.
|
||||
--
|
||||
function _profiler.start(self)
|
||||
if _profiler.running then
|
||||
return
|
||||
end
|
||||
-- Start the profiler. This begins by setting up internal profiler state
|
||||
_profiler.running = self
|
||||
self.rawstats = {}
|
||||
self.callstack = {}
|
||||
if self.variant == "time" then
|
||||
self.lastclock = os.clock()
|
||||
debug.sethook( _profiler_hook_wrapper_by_time, "", self.sampledelay )
|
||||
elseif self.variant == "call" then
|
||||
debug.sethook( _profiler_hook_wrapper_by_call, "cr" )
|
||||
else
|
||||
print("Profiler method must be 'time' or 'call'.")
|
||||
sys.exit(1)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- This function stops the profiler. It will do nothing
|
||||
-- if a profiler is not running, and nothing if it isn't
|
||||
-- the currently running profiler.
|
||||
--
|
||||
function _profiler.stop(self)
|
||||
if _profiler.running ~= self then
|
||||
return
|
||||
end
|
||||
-- Stop the profiler.
|
||||
debug.sethook( nil )
|
||||
_profiler.running = nil
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Simple wrapper to handle the hook. You should not
|
||||
-- be calling this directly. Duplicated to reduce overhead.
|
||||
--
|
||||
function _profiler_hook_wrapper_by_call(action)
|
||||
if _profiler.running == nil then
|
||||
debug.sethook( nil )
|
||||
end
|
||||
_profiler.running:_internal_profile_by_call(action)
|
||||
end
|
||||
function _profiler_hook_wrapper_by_time(action)
|
||||
if _profiler.running == nil then
|
||||
debug.sethook( nil )
|
||||
end
|
||||
_profiler.running:_internal_profile_by_time(action)
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- This is the main by-function-call function of the profiler and should not
|
||||
-- be called except by the hook wrapper
|
||||
--
|
||||
function _profiler._internal_profile_by_call(self,action)
|
||||
-- Since we can obtain the 'function' for the item we've had call us, we
|
||||
-- can use that...
|
||||
local caller_info = debug.getinfo( 3 )
|
||||
if caller_info == nil then
|
||||
print "No caller_info"
|
||||
return
|
||||
end
|
||||
|
||||
--SHG_LOG("[_profiler._internal_profile] "..(caller_info.name or "<nil>"))
|
||||
|
||||
-- Retrieve the most recent activation record...
|
||||
local latest_ar = nil
|
||||
if table.getn(self.callstack) > 0 then
|
||||
latest_ar = self.callstack[table.getn(self.callstack)]
|
||||
end
|
||||
|
||||
-- Are we allowed to profile this function?
|
||||
local should_not_profile = 0
|
||||
for k,v in pairs(self.prevented_functions) do
|
||||
if k == caller_info.func then
|
||||
should_not_profile = v
|
||||
end
|
||||
end
|
||||
-- Also check the top activation record...
|
||||
if latest_ar then
|
||||
if latest_ar.should_not_profile == 2 then
|
||||
should_not_profile = 2
|
||||
end
|
||||
end
|
||||
|
||||
-- Now then, are we in 'call' or 'return' ?
|
||||
-- print("Profile:", caller_info.name, "SNP:", should_not_profile,
|
||||
-- "Action:", action )
|
||||
if action == "call" then
|
||||
-- Making a call...
|
||||
local this_ar = {}
|
||||
this_ar.should_not_profile = should_not_profile
|
||||
this_ar.parent_ar = latest_ar
|
||||
this_ar.anon_child = 0
|
||||
this_ar.name_child = 0
|
||||
this_ar.children = {}
|
||||
this_ar.children_time = {}
|
||||
this_ar.clock_start = os.clock()
|
||||
-- Last thing to do on a call is to insert this onto the ar stack...
|
||||
table.insert( self.callstack, this_ar )
|
||||
else
|
||||
local this_ar = latest_ar
|
||||
if this_ar == nil then
|
||||
return -- No point in doing anything if no upper activation record
|
||||
end
|
||||
|
||||
-- Right, calculate the time in this function...
|
||||
this_ar.clock_end = os.clock()
|
||||
this_ar.this_time = this_ar.clock_end - this_ar.clock_start
|
||||
|
||||
-- Now, if we have a parent, update its call info...
|
||||
if this_ar.parent_ar then
|
||||
this_ar.parent_ar.children[caller_info.func] =
|
||||
(this_ar.parent_ar.children[caller_info.func] or 0) + 1
|
||||
this_ar.parent_ar.children_time[caller_info.func] =
|
||||
(this_ar.parent_ar.children_time[caller_info.func] or 0 ) +
|
||||
this_ar.this_time
|
||||
if caller_info.name == nil then
|
||||
this_ar.parent_ar.anon_child =
|
||||
this_ar.parent_ar.anon_child + this_ar.this_time
|
||||
else
|
||||
this_ar.parent_ar.name_child =
|
||||
this_ar.parent_ar.name_child + this_ar.this_time
|
||||
end
|
||||
end
|
||||
-- Now if we're meant to record information about ourselves, do so...
|
||||
if this_ar.should_not_profile == 0 then
|
||||
local inforec = self:_get_func_rec(caller_info.func,1)
|
||||
inforec.count = inforec.count + 1
|
||||
inforec.time = inforec.time + this_ar.this_time
|
||||
inforec.anon_child_time = inforec.anon_child_time + this_ar.anon_child
|
||||
inforec.name_child_time = inforec.name_child_time + this_ar.name_child
|
||||
inforec.func_info = caller_info
|
||||
for k,v in pairs(this_ar.children) do
|
||||
inforec.children[k] = (inforec.children[k] or 0) + v
|
||||
inforec.children_time[k] =
|
||||
(inforec.children_time[k] or 0) + this_ar.children_time[k]
|
||||
end
|
||||
end
|
||||
|
||||
-- Last thing to do on return is to drop the last activation record...
|
||||
table.remove( self.callstack, table.getn( self.callstack ) )
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- This is the main by-time internal function of the profiler and should not
|
||||
-- be called except by the hook wrapper
|
||||
--
|
||||
function _profiler._internal_profile_by_time(self,action)
|
||||
-- we do this first so we add the minimum amount of extra time to this call
|
||||
local timetaken = os.clock() - self.lastclock
|
||||
|
||||
local depth = 3
|
||||
local at_top = true
|
||||
local last_caller
|
||||
local caller = debug.getinfo(depth)
|
||||
while caller do
|
||||
if not caller.func then caller.func = "(tail call)" end
|
||||
if self.prevented_functions[caller.func] == nil then
|
||||
local info = self:_get_func_rec(caller.func, 1, caller)
|
||||
info.count = info.count + 1
|
||||
info.time = info.time + timetaken
|
||||
if last_caller then
|
||||
-- we're not the head, so update the "children" times also
|
||||
if last_caller.name then
|
||||
info.name_child_time = info.name_child_time + timetaken
|
||||
else
|
||||
info.anon_child_time = info.anon_child_time + timetaken
|
||||
end
|
||||
info.children[last_caller.func] =
|
||||
(info.children[last_caller.func] or 0) + 1
|
||||
info.children_time[last_caller.func] =
|
||||
(info.children_time[last_caller.func] or 0) + timetaken
|
||||
end
|
||||
end
|
||||
depth = depth + 1
|
||||
last_caller = caller
|
||||
caller = debug.getinfo(depth)
|
||||
end
|
||||
|
||||
self.lastclock = os.clock()
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- This returns a (possibly empty) function record for
|
||||
-- the specified function. It is for internal profiler use.
|
||||
--
|
||||
function _profiler._get_func_rec(self,func,force,info)
|
||||
-- Find the function ref for 'func' (if force and not present, create one)
|
||||
local ret = self.rawstats[func]
|
||||
if ret == nil and force ~= 1 then
|
||||
return nil
|
||||
end
|
||||
if ret == nil then
|
||||
-- Build a new function statistics table
|
||||
ret = {}
|
||||
ret.func = func
|
||||
ret.count = 0
|
||||
ret.time = 0
|
||||
ret.anon_child_time = 0
|
||||
ret.name_child_time = 0
|
||||
ret.children = {}
|
||||
ret.children_time = {}
|
||||
ret.func_info = info
|
||||
self.rawstats[func] = ret
|
||||
end
|
||||
return ret
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- This writes a profile report to the output file object. If
|
||||
-- sort_by_total_time is nil or false the output is sorted by
|
||||
-- the function time minus the time in it's children.
|
||||
--
|
||||
function _profiler.report( self, outfile, sort_by_total_time )
|
||||
|
||||
outfile:write
|
||||
[[Lua Profile output created by profiler.lua. Copyright Pepperfish 2002+
|
||||
|
||||
]]
|
||||
|
||||
-- This is pretty awful.
|
||||
local terms = {}
|
||||
if self.variant == "time" then
|
||||
terms.capitalized = "Sample"
|
||||
terms.single = "sample"
|
||||
terms.pastverb = "sampled"
|
||||
elseif self.variant == "call" then
|
||||
terms.capitalized = "Call"
|
||||
terms.single = "call"
|
||||
terms.pastverb = "called"
|
||||
else
|
||||
assert(false)
|
||||
end
|
||||
|
||||
local total_time = 0
|
||||
local ordering = {}
|
||||
for func,record in pairs(self.rawstats) do
|
||||
table.insert(ordering, func)
|
||||
end
|
||||
|
||||
if sort_by_total_time then
|
||||
table.sort( ordering,
|
||||
function(a,b) return self.rawstats[a].time > self.rawstats[b].time end
|
||||
)
|
||||
else
|
||||
table.sort( ordering,
|
||||
function(a,b)
|
||||
local arec = self.rawstats[a]
|
||||
local brec = self.rawstats[b]
|
||||
local atime = arec.time - (arec.anon_child_time + arec.name_child_time)
|
||||
local btime = brec.time - (brec.anon_child_time + brec.name_child_time)
|
||||
return atime > btime
|
||||
end
|
||||
)
|
||||
end
|
||||
|
||||
for i=1,#ordering do
|
||||
local func = ordering[i]
|
||||
local record = self.rawstats[func]
|
||||
local thisfuncname = " " .. self:_pretty_name(func) .. " "
|
||||
if string.len( thisfuncname ) < 42 then
|
||||
thisfuncname = string.rep( "-", math.floor((42 - string.len(thisfuncname))/2) ) .. thisfuncname
|
||||
thisfuncname = thisfuncname .. string.rep( "-", 42 - string.len(thisfuncname) )
|
||||
end
|
||||
|
||||
total_time = total_time + ( record.time - ( record.anon_child_time +
|
||||
record.name_child_time ) )
|
||||
outfile:write( string.rep( "-", 19 ) .. thisfuncname ..
|
||||
string.rep( "-", 19 ) .. "\n" )
|
||||
outfile:write( terms.capitalized.." count: " ..
|
||||
string.format( "%4d", record.count ) .. "\n" )
|
||||
outfile:write( "Time spend total: " ..
|
||||
string.format( "%4.3f", record.time ) .. "s\n" )
|
||||
outfile:write( "Time spent in children: " ..
|
||||
string.format("%4.3f",record.anon_child_time+record.name_child_time) ..
|
||||
"s\n" )
|
||||
local timeinself =
|
||||
record.time - (record.anon_child_time + record.name_child_time)
|
||||
outfile:write( "Time spent in self: " ..
|
||||
string.format("%4.3f", timeinself) .. "s\n" )
|
||||
outfile:write( "Time spent per " .. terms.single .. ": " ..
|
||||
string.format("%4.5f", record.time/record.count) ..
|
||||
"s/" .. terms.single .. "\n" )
|
||||
outfile:write( "Time spent in self per "..terms.single..": " ..
|
||||
string.format( "%4.5f", timeinself/record.count ) .. "s/" ..
|
||||
terms.single.."\n" )
|
||||
|
||||
-- Report on each child in the form
|
||||
-- Child <funcname> called n times and took a.bs
|
||||
local added_blank = 0
|
||||
for k,v in pairs(record.children) do
|
||||
if self.prevented_functions[k] == nil or
|
||||
self.prevented_functions[k] == 0
|
||||
then
|
||||
if added_blank == 0 then
|
||||
outfile:write( "\n" ) -- extra separation line
|
||||
added_blank = 1
|
||||
end
|
||||
outfile:write( "Child " .. self:_pretty_name(k) ..
|
||||
string.rep( " ", 41-string.len(self:_pretty_name(k)) ) .. " " ..
|
||||
terms.pastverb.." " .. string.format("%6d", v) )
|
||||
outfile:write( " times. Took " ..
|
||||
string.format("%4.2f", record.children_time[k] ) .. "s\n" )
|
||||
end
|
||||
end
|
||||
|
||||
outfile:write( "\n" ) -- extra separation line
|
||||
outfile:flush()
|
||||
end
|
||||
outfile:write( "\n\n" )
|
||||
outfile:write( "Total time spent in profiled functions: " ..
|
||||
string.format("%5.3g",total_time) .. "s\n" )
|
||||
outfile:write( [[
|
||||
|
||||
END
|
||||
]] )
|
||||
outfile:flush()
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- This writes the profile to the output file object as
|
||||
-- loadable Lua source.
|
||||
--
|
||||
function _profiler.lua_report(self,outfile)
|
||||
-- Purpose: Write out the entire raw state in a cross-referenceable form.
|
||||
local ordering = {}
|
||||
local functonum = {}
|
||||
for func,record in pairs(self.rawstats) do
|
||||
table.insert(ordering, func)
|
||||
functonum[func] = table.getn(ordering)
|
||||
end
|
||||
|
||||
outfile:write(
|
||||
"-- Profile generated by profiler.lua Copyright Pepperfish 2002+\n\n" )
|
||||
outfile:write( "-- Function names\nfuncnames = {}\n" )
|
||||
for i=1,table.getn(ordering) do
|
||||
local thisfunc = ordering[i]
|
||||
outfile:write( "funcnames[" .. i .. "] = " ..
|
||||
string.format("%q", self:_pretty_name(thisfunc)) .. "\n" )
|
||||
end
|
||||
outfile:write( "\n" )
|
||||
outfile:write( "-- Function times\nfunctimes = {}\n" )
|
||||
for i=1,table.getn(ordering) do
|
||||
local thisfunc = ordering[i]
|
||||
local record = self.rawstats[thisfunc]
|
||||
outfile:write( "functimes[" .. i .. "] = { " )
|
||||
outfile:write( "tot=" .. record.time .. ", " )
|
||||
outfile:write( "achild=" .. record.anon_child_time .. ", " )
|
||||
outfile:write( "nchild=" .. record.name_child_time .. ", " )
|
||||
outfile:write( "count=" .. record.count .. " }\n" )
|
||||
end
|
||||
outfile:write( "\n" )
|
||||
outfile:write( "-- Child links\nchildren = {}\n" )
|
||||
for i=1,table.getn(ordering) do
|
||||
local thisfunc = ordering[i]
|
||||
local record = self.rawstats[thisfunc]
|
||||
outfile:write( "children[" .. i .. "] = { " )
|
||||
for k,v in pairs(record.children) do
|
||||
if functonum[k] then -- non-recorded functions will be ignored now
|
||||
outfile:write( functonum[k] .. ", " )
|
||||
end
|
||||
end
|
||||
outfile:write( "}\n" )
|
||||
end
|
||||
outfile:write( "\n" )
|
||||
outfile:write( "-- Child call counts\nchildcounts = {}\n" )
|
||||
for i=1,table.getn(ordering) do
|
||||
local thisfunc = ordering[i]
|
||||
local record = self.rawstats[thisfunc]
|
||||
outfile:write( "children[" .. i .. "] = { " )
|
||||
for k,v in record.children do
|
||||
if functonum[k] then -- non-recorded functions will be ignored now
|
||||
outfile:write( v .. ", " )
|
||||
end
|
||||
end
|
||||
outfile:write( "}\n" )
|
||||
end
|
||||
outfile:write( "\n" )
|
||||
outfile:write( "-- Child call time\nchildtimes = {}\n" )
|
||||
for i=1,table.getn(ordering) do
|
||||
local thisfunc = ordering[i]
|
||||
local record = self.rawstats[thisfunc];
|
||||
outfile:write( "children[" .. i .. "] = { " )
|
||||
for k,v in pairs(record.children) do
|
||||
if functonum[k] then -- non-recorded functions will be ignored now
|
||||
outfile:write( record.children_time[k] .. ", " )
|
||||
end
|
||||
end
|
||||
outfile:write( "}\n" )
|
||||
end
|
||||
outfile:write( "\n\n-- That is all.\n\n" )
|
||||
outfile:flush()
|
||||
end
|
||||
|
||||
-- Internal function to calculate a pretty name for the profile output
|
||||
function _profiler._pretty_name(self,func)
|
||||
|
||||
-- Only the data collected during the actual
|
||||
-- run seems to be correct.... why?
|
||||
local info = self.rawstats[ func ].func_info
|
||||
-- local info = debug.getinfo( func )
|
||||
|
||||
local name = ""
|
||||
if info.what == "Lua" then
|
||||
name = "L:"
|
||||
end
|
||||
if info.what == "C" then
|
||||
name = "C:"
|
||||
end
|
||||
if info.what == "main" then
|
||||
name = " :"
|
||||
end
|
||||
|
||||
if info.name == nil then
|
||||
name = name .. "<"..tostring(func) .. ">"
|
||||
else
|
||||
name = name .. info.name
|
||||
end
|
||||
|
||||
if info.source then
|
||||
name = name .. "@" .. info.source
|
||||
else
|
||||
if info.what == "C" then
|
||||
name = name .. "@?"
|
||||
else
|
||||
name = name .. "@<string>"
|
||||
end
|
||||
end
|
||||
name = name .. ":"
|
||||
if info.what == "C" then
|
||||
name = name .. "?"
|
||||
else
|
||||
name = name .. info.linedefined
|
||||
end
|
||||
|
||||
return name
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- This allows you to specify functions which you do
|
||||
-- not want profiled. Setting level to 1 keeps the
|
||||
-- function from being profiled. Setting level to 2
|
||||
-- keeps both the function and its children from
|
||||
-- being profiled.
|
||||
--
|
||||
-- BUG: 2 will probably act exactly like 1 in "time" mode.
|
||||
-- If anyone cares, let me (zorba) know and it can be fixed.
|
||||
--
|
||||
function _profiler.prevent(self, func, level)
|
||||
self.prevented_functions[func] = (level or 1)
|
||||
end
|
||||
|
||||
|
||||
_profiler.prevented_functions = {
|
||||
[_profiler.start] = 2,
|
||||
[_profiler.stop] = 2,
|
||||
[_profiler._internal_profile_by_time] = 2,
|
||||
[_profiler._internal_profile_by_call] = 2,
|
||||
[_profiler_hook_wrapper_by_time] = 2,
|
||||
[_profiler_hook_wrapper_by_call] = 2,
|
||||
[_profiler.prevent] = 2,
|
||||
[_profiler._get_func_rec] = 2,
|
||||
[_profiler.report] = 2,
|
||||
[_profiler.lua_report] = 2,
|
||||
[_profiler._pretty_name] = 2
|
||||
}
|
2
3rdparty/genie/src/base/project.lua
vendored
2
3rdparty/genie/src/base/project.lua
vendored
@ -529,6 +529,8 @@
|
||||
elseif kind == "StaticLib" then
|
||||
prefix = "lib"
|
||||
ext = ".a"
|
||||
elseif kind == "SharedLib" then
|
||||
ext = ".prx"
|
||||
end
|
||||
end
|
||||
|
||||
|
37
3rdparty/genie/src/host/scripts.c
vendored
37
3rdparty/genie/src/host/scripts.c
vendored
@ -28,9 +28,8 @@ const char* builtin_scripts[] = {
|
||||
"function io.capture()\nio.captured = ''\nend\nfunction io.endcapture()\nlocal captured = io.captured\nio.captured = nil\nreturn captured\nend\nlocal builtin_open = io.open\nfunction io.open(fname, mode)\nif (mode) then\nif (mode:find(\"w\")) then\nlocal dir = path.getdirectory(fname)\nok, err = os.mkdir(dir)\nif (not ok) then\nerror(err, 0)\nend\nend\nend\nreturn builtin_open(fname, mode)\nend\nfunction io.printf(msg, ...)\nlocal arg={...}\nif not io.eol then\nio.eol = \"\\n\"\nend\nif not io.indent then\nio.indent = \"\\t\"\nend\nif type(msg) == \"number\" then\ns = string.rep(io.indent, msg) .. string.format(table.unpack(arg))\nelse\ns = string.format(msg, table.unpack(arg))\nend\nif io.captured then\nio.captured = io.captured .. s .. io.eol\nelse\nio.write(s)\nio.write(io.eol)\nend\nend\n_p = io.printf\n",
|
||||
|
||||
/* base/globals.lua */
|
||||
"premake = { }\npremake.platforms =\n{\nNative =\n{\ncfgsuffix = \"\",\n},\nx32 =\n{\ncfgsuffix = \"32\",\n},\nx64 =\n{\ncfgsuffix = \"64\",\n},\nUniversal =\n{\ncfgsuffix = \"univ\",\n},\nUniversal32 =\n{\ncfgsuffix = \"univ32\",\n},\nUniversal64 =\n{\ncfgsuffix = \"univ64\",\n},\nPS3 =\n{\ncfgsuffix = \"ps3\",\niscrosscompiler = true,\nnosharedlibs = true,\nnamestyle = \"PS3\",\n},\nWiiDev =\n{\ncfgsuffix = \"wii\",\niscrosscompiler = true,\nnamestyle = \"PS3\",\n},\nXbox360 =\n{\ncfgsuffix = \"xbox360\",\niscrosscompiler = true,\nnamestyle = \"windows\",\n},\nPowerPC =\n{\ncfgsuffix = \"ppc\",\niscrosscompiler = true,\n},\nARM =\n{\ncfgsuffix = \"ARM\",\niscrosscompiler = true,\n},\nOrbis =\n{\ncfgsuffix = \"orbis\",\niscrosscompiler = true,\nnosharedlibs = true, -- @thendrix, Fix this to allow SPRXs\nnamestyle = \"Orbis\",\n},\nDurango =\n{\ncfgsuffix = \"durango\",\niscrosscompiler = true,\nnoshared"
|
||||
"libs = true,\nnamestyle = \"windows\",\n},\n}\nlocal builtin_dofile = dofile\nfunction dofile(fname)\nlocal oldcwd = os.getcwd()\nlocal oldfile = _SCRIPT\nif (not os.isfile(fname)) then\nlocal path = os.pathsearch(fname, _OPTIONS[\"scripts\"], os.getenv(\"PREMAKE_PATH\"))\nif (path) then\nfname = path..\"/\"..fname\nend\nend\n_SCRIPT = path.getabsolute(fname)\nlocal newcwd = path.getdirectory(_SCRIPT)\nos.chdir(newcwd)\nlocal a, b, c, d, e, f = builtin_dofile(_SCRIPT)\n_SCRIPT = oldfile\nos.chdir(oldcwd)\nreturn a, b, c, d, e, f\nend\nfunction iif(expr, trueval, falseval)\nif (expr) then\nreturn trueval\nelse\nreturn falseval\nend\nend\nfunction include(fname)\nlocal dir, name = premake.findDefaultScript(fname, false)\nif dir ~= nil then\nreturn dofile(dir .. \"/\" .. name)\nend\nreturn nil\nend\nfunction printf(msg, ...)\nlocal arg={...}\nprint(string.format(msg, table.unpack(arg)))\nend\nlocal builtin_type = type\nfunction type(t)\nlocal mt = getmetatable(t)\nif (mt) then\nif (mt.__type) then\nretur"
|
||||
"n mt.__type\nend\nend\nreturn builtin_type(t)\nend\n",
|
||||
"premake = { }\npremake.platforms =\n{\nNative =\n{\ncfgsuffix = \"\",\n},\nx32 =\n{\ncfgsuffix = \"32\",\n},\nx64 =\n{\ncfgsuffix = \"64\",\n},\nUniversal =\n{\ncfgsuffix = \"univ\",\n},\nUniversal32 =\n{\ncfgsuffix = \"univ32\",\n},\nUniversal64 =\n{\ncfgsuffix = \"univ64\",\n},\nPS3 =\n{\ncfgsuffix = \"ps3\",\niscrosscompiler = true,\nnosharedlibs = true,\nnamestyle = \"PS3\",\n},\nWiiDev =\n{\ncfgsuffix = \"wii\",\niscrosscompiler = true,\nnamestyle = \"PS3\",\n},\nXbox360 =\n{\ncfgsuffix = \"xbox360\",\niscrosscompiler = true,\nnamestyle = \"windows\",\n},\nPowerPC =\n{\ncfgsuffix = \"ppc\",\niscrosscompiler = true,\n},\nARM =\n{\ncfgsuffix = \"ARM\",\niscrosscompiler = true,\n},\nOrbis =\n{\ncfgsuffix = \"orbis\",\niscrosscompiler = true,\nnamestyle = \"Orbis\",\n},\nDurango =\n{\ncfgsuffix = \"durango\",\niscrosscompiler = true,\nnosharedlibs = true,\nnamestyle = \"windows\",\n},\n}\nlocal bu"
|
||||
"iltin_dofile = dofile\nfunction dofile(fname)\nlocal oldcwd = os.getcwd()\nlocal oldfile = _SCRIPT\nif (not os.isfile(fname)) then\nlocal path = os.pathsearch(fname, _OPTIONS[\"scripts\"], os.getenv(\"PREMAKE_PATH\"))\nif (path) then\nfname = path..\"/\"..fname\nend\nend\n_SCRIPT = path.getabsolute(fname)\nlocal newcwd = path.getdirectory(_SCRIPT)\nos.chdir(newcwd)\nlocal a, b, c, d, e, f = builtin_dofile(_SCRIPT)\n_SCRIPT = oldfile\nos.chdir(oldcwd)\nreturn a, b, c, d, e, f\nend\nfunction iif(expr, trueval, falseval)\nif (expr) then\nreturn trueval\nelse\nreturn falseval\nend\nend\nfunction include(fname)\nlocal dir, name = premake.findDefaultScript(fname, false)\nif dir ~= nil then\nreturn dofile(dir .. \"/\" .. name)\nend\nreturn nil\nend\nfunction printf(msg, ...)\nlocal arg={...}\nprint(string.format(msg, table.unpack(arg)))\nend\nlocal builtin_type = type\nfunction type(t)\nlocal mt = getmetatable(t)\nif (mt) then\nif (mt.__type) then\nreturn mt.__type\nend\nend\nreturn builtin_type(t)\nend\n",
|
||||
|
||||
/* base/action.lua */
|
||||
"premake.action = { }\npremake.action.list = { }\nfunction premake.action.add(a)\nlocal missing\nfor _, field in ipairs({\"description\", \"trigger\"}) do\nif (not a[field]) then\nmissing = field\nend\nend\nif (missing) then\nerror(\"action needs a \" .. missing, 3)\nend\npremake.action.list[a.trigger] = a\nend\nfunction premake.action.call(name)\nlocal a = premake.action.list[name]\nfor sln in premake.solution.each() do\nif a.onsolution then\na.onsolution(sln)\nend\nfor prj in premake.solution.eachproject(sln) do\nif a.onproject then\na.onproject(prj)\nend\nend\nend\nif a.execute then\na.execute()\nend\nend\nfunction premake.action.current()\nreturn premake.action.get(_ACTION)\nend\nfunction premake.action.get(name)\nreturn premake.action.list[name]\nend\nfunction premake.action.each()\nlocal keys = { }\nfor _, action in pairs(premake.action.list) do\ntable.insert(keys, action.trigger)\nend\ntable.sort(keys)\nlocal i = 0\nreturn function()\ni = i + 1\nreturn premake.action.list[keys[i]]\nend\nend\nfunction pre"
|
||||
@ -57,9 +56,9 @@ const char* builtin_scripts[] = {
|
||||
"fig(prj, cfgname, cfg.platform)\nif kind == \"dependencies\" or canlink(cfg, prjcfg) then\nif (part == \"directory\") then\nitem = path.rebase(prjcfg.linktarget.directory, prjcfg.location, cfg.location)\nelseif (part == \"basename\") then\nitem = prjcfg.linktarget.basename\nelseif (part == \"fullpath\") then\nitem = path.rebase(prjcfg.linktarget.fullpath, prjcfg.location, cfg.location)\nelseif (part == \"object\") then\nitem = prjcfg\nend\nend\nelseif not prj and (kind == \"system\" or kind == \"all\") then\nif (part == \"directory\") then\nitem = path.getdirectory(link)\nelseif (part == \"fullpath\") then\nitem = link\nif namestyle == \"windows\" then\nif premake.iscppproject(cfg) then\nitem = item .. \".lib\"\nelseif premake.isdotnetproject(cfg) then\nitem = item .. \".dll\"\nend\nend\nelseif part == \"name\" then\nitem = path.getname(link)\nelseif part == \"basename\" then\nitem = path.getbasename(link)\nelse\nitem = link\nend\nif item:find(\"/\", nil, true) then\nitem = path.getrelative(cfg.project.locatio"
|
||||
"n, item)\nend\nend\nif item then\nif pathstyle == \"windows\" and part ~= \"object\" then\nitem = path.translate(item, \"\\\\\")\nend\nif not table.contains(result, item) then\ntable.insert(result, item)\nend\nend\nend\nreturn result\nend\nfunction premake.getnamestyle(cfg)\nreturn premake.platforms[cfg.platform].namestyle or premake.gettool(cfg).namestyle or \"posix\"\nend\nfunction premake.getpathstyle(cfg)\nif premake.action.current().os == \"windows\" then\nreturn \"windows\"\nelse\nreturn \"posix\"\nend\nend\nfunction premake.gettarget(cfg, direction, pathstyle, namestyle, system)\nif system == \"bsd\" then\nsystem = \"linux\"\nend\nlocal kind = cfg.kind\nif premake.iscppproject(cfg) then\nif (namestyle == \"windows\" or system == \"windows\")\nand kind == \"SharedLib\" and direction == \"link\"\nand not cfg.flags.NoImportLib\nthen\nkind = \"StaticLib\"\nend\nif namestyle == \"posix\" and system == \"windows\" and kind ~= \"StaticLib\" then\nnamestyle = \"windows\"\nend\nend\nlocal field = \"build\"\nif"
|
||||
" direction == \"link\" and cfg.kind == \"SharedLib\" then\nfield = \"implib\"\nend\nlocal name = cfg[field..\"name\"] or cfg.targetname or cfg.project.name\nlocal dir = cfg[field..\"dir\"] or cfg.targetdir or path.getrelative(cfg.location, cfg.basedir)\nlocal subdir = cfg[field..\"subdir\"] or cfg.targetsubdir or \".\"\nlocal prefix = \"\"\nlocal suffix = \"\"\nlocal ext = \"\"\nlocal bundlepath, bundlename\ndir = path.join(dir, subdir)\nif namestyle == \"windows\" then\nif kind == \"ConsoleApp\" or kind == \"WindowedApp\" then\next = \".exe\"\nelseif kind == \"SharedLib\" then\next = \".dll\"\nelseif kind == \"StaticLib\" then\next = \".lib\"\nend\nelseif namestyle == \"posix\" then\nif kind == \"WindowedApp\" and system == \"macosx\" then\nbundlename = name .. \".app\"\nbundlepath = path.join(dir, bundlename)\ndir = path.join(bundlepath, \"Contents/MacOS\")\nelseif (kind == \"ConsoleApp\" or kind == \"WindowedApp\") and system == \"os2\" then\next = \".exe\"\nelseif kind == \"SharedLib\" then\n"
|
||||
"prefix = \"lib\"\next = iif(system == \"macosx\", \".dylib\", \".so\")\nelseif kind == \"StaticLib\" then\nprefix = \"lib\"\next = \".a\"\nend\nelseif namestyle == \"PS3\" then\nif kind == \"ConsoleApp\" or kind == \"WindowedApp\" then\next = \".elf\"\nelseif kind == \"StaticLib\" then\nprefix = \"lib\"\next = \".a\"\nend\nelseif namestyle == \"Orbis\" then\nif kind == \"ConsoleApp\" or kind == \"WindowedApp\" then\next = \".elf\"\nelseif kind == \"StaticLib\" then\nprefix = \"lib\"\next = \".a\"\nend\nend\nprefix = cfg[field..\"prefix\"] or cfg.targetprefix or prefix\nsuffix = cfg[field..\"suffix\"] or cfg.targetsuffix or suffix\next = cfg[field..\"extension\"] or cfg.targetextension or ext\nlocal result = { }\nresult.basename = name .. suffix\nresult.name = prefix .. name .. suffix .. ext\nresult.directory = dir\nresult.subdirectory = subdir\nresult.prefix = prefix\nresult.suffix = suffix\nresult.fullpath = path.join(result.directory, result.name)\nresult.bundlepath = bund"
|
||||
"lepath or result.fullpath\nif pathstyle == \"windows\" then\nresult.directory = path.translate(result.directory, \"\\\\\")\nresult.subdirectory = path.translate(result.subdirectory, \"\\\\\")\nresult.fullpath = path.translate(result.fullpath, \"\\\\\")\nend\nreturn result\nend\nfunction premake.gettool(cfg)\nif premake.iscppproject(cfg) then\nif _OPTIONS.cc then\nreturn premake[_OPTIONS.cc]\nend\nlocal action = premake.action.current()\nif action.valid_tools then\nreturn premake[action.valid_tools.cc[1]]\nend\nreturn premake.gcc\nelse\nreturn premake.dotnet\nend\nend\nfunction premake.project.getvpath(prj, abspath)\nlocal vpath = abspath\nlocal fname = path.getname(abspath)\nlocal max = abspath:len() - fname:len()\nfor replacement, patterns in pairs(prj.vpaths or {}) do\nfor _, pattern in ipairs(patterns) do\nlocal i = abspath:find(path.wildcards(pattern))\nif i == 1 then\ni = pattern:find(\"*\", 1, true) or (pattern:len() + 1)\nlocal leaf\nif i < max then\nleaf = abspath:sub(i)\nelse\nleaf = fname\nen"
|
||||
"d\nif leaf:startswith(\"/\") then\nleaf = leaf:sub(2)\nend\nlocal stem = \"\"\nif replacement:len() > 0 then\nstem, stars = replacement:gsub(\"%*\", \"\")\nif stars == 0 then\nleaf = path.getname(leaf)\nend\nelse\nleaf = path.getname(leaf)\nend\nvpath = path.join(stem, leaf)\nend\nend\nend\nreturn path.trimdots(vpath)\nend\nfunction premake.hascppproject(sln)\nfor prj in premake.solution.eachproject(sln) do\nif premake.iscppproject(prj) then\nreturn true\nend\nend\nend\nfunction premake.hasdotnetproject(sln)\nfor prj in premake.solution.eachproject(sln) do\nif premake.isdotnetproject(prj) then\nreturn true\nend\nend\nend\nfunction premake.project.iscproject(prj)\nreturn prj.language == \"C\"\nend\nfunction premake.iscppproject(prj)\nreturn (prj.language == \"C\" or prj.language == \"C++\")\nend\nfunction premake.isdotnetproject(prj)\nreturn (prj.language == \"C#\")\nend\n",
|
||||
"prefix = \"lib\"\next = iif(system == \"macosx\", \".dylib\", \".so\")\nelseif kind == \"StaticLib\" then\nprefix = \"lib\"\next = \".a\"\nend\nelseif namestyle == \"PS3\" then\nif kind == \"ConsoleApp\" or kind == \"WindowedApp\" then\next = \".elf\"\nelseif kind == \"StaticLib\" then\nprefix = \"lib\"\next = \".a\"\nend\nelseif namestyle == \"Orbis\" then\nif kind == \"ConsoleApp\" or kind == \"WindowedApp\" then\next = \".elf\"\nelseif kind == \"StaticLib\" then\nprefix = \"lib\"\next = \".a\"\nelseif kind == \"SharedLib\" then\next = \".prx\"\nend\nend\nprefix = cfg[field..\"prefix\"] or cfg.targetprefix or prefix\nsuffix = cfg[field..\"suffix\"] or cfg.targetsuffix or suffix\next = cfg[field..\"extension\"] or cfg.targetextension or ext\nlocal result = { }\nresult.basename = name .. suffix\nresult.name = prefix .. name .. suffix .. ext\nresult.directory = dir\nresult.subdirectory = subdir\nresult.prefix = prefix\nresult.suffix = suffix\nresult.fullpath = path.join(result."
|
||||
"directory, result.name)\nresult.bundlepath = bundlepath or result.fullpath\nif pathstyle == \"windows\" then\nresult.directory = path.translate(result.directory, \"\\\\\")\nresult.subdirectory = path.translate(result.subdirectory, \"\\\\\")\nresult.fullpath = path.translate(result.fullpath, \"\\\\\")\nend\nreturn result\nend\nfunction premake.gettool(cfg)\nif premake.iscppproject(cfg) then\nif _OPTIONS.cc then\nreturn premake[_OPTIONS.cc]\nend\nlocal action = premake.action.current()\nif action.valid_tools then\nreturn premake[action.valid_tools.cc[1]]\nend\nreturn premake.gcc\nelse\nreturn premake.dotnet\nend\nend\nfunction premake.project.getvpath(prj, abspath)\nlocal vpath = abspath\nlocal fname = path.getname(abspath)\nlocal max = abspath:len() - fname:len()\nfor replacement, patterns in pairs(prj.vpaths or {}) do\nfor _, pattern in ipairs(patterns) do\nlocal i = abspath:find(path.wildcards(pattern))\nif i == 1 then\ni = pattern:find(\"*\", 1, true) or (pattern:len() + 1)\nlocal leaf\nif i < max "
|
||||
"then\nleaf = abspath:sub(i)\nelse\nleaf = fname\nend\nif leaf:startswith(\"/\") then\nleaf = leaf:sub(2)\nend\nlocal stem = \"\"\nif replacement:len() > 0 then\nstem, stars = replacement:gsub(\"%*\", \"\")\nif stars == 0 then\nleaf = path.getname(leaf)\nend\nelse\nleaf = path.getname(leaf)\nend\nvpath = path.join(stem, leaf)\nend\nend\nend\nreturn path.trimdots(vpath)\nend\nfunction premake.hascppproject(sln)\nfor prj in premake.solution.eachproject(sln) do\nif premake.iscppproject(prj) then\nreturn true\nend\nend\nend\nfunction premake.hasdotnetproject(sln)\nfor prj in premake.solution.eachproject(sln) do\nif premake.isdotnetproject(prj) then\nreturn true\nend\nend\nend\nfunction premake.project.iscproject(prj)\nreturn prj.language == \"C\"\nend\nfunction premake.iscppproject(prj)\nreturn (prj.language == \"C\" or prj.language == \"C++\")\nend\nfunction premake.isdotnetproject(prj)\nreturn (prj.language == \"C#\")\nend\n",
|
||||
|
||||
/* base/config.lua */
|
||||
"premake.config = { }\nlocal config = premake.config\nfunction premake.config.isdebugbuild(cfg)\nif cfg.flags.DebugRuntime then\nreturn true\nend\nif cfg.flags.ReleaseRuntime then\nreturn false\nend\nif cfg.flags.Optimize or cfg.flags.OptimizeSize or cfg.flags.OptimizeSpeed then\nreturn false\nend\nif not cfg.flags.Symbols then\nreturn false\nend\nreturn true\nend\nfunction premake.config.isincrementallink(cfg)\nif cfg.kind == \"StaticLib\" \nor config.isoptimizedbuild(cfg.flags)\nor cfg.flags.NoIncrementalLink then\nreturn false\nend\nreturn true\nend\nfunction premake.config.isoptimizedbuild(flags)\nreturn flags.Optimize or flags.OptimizeSize or flags.OptimizeSpeed\nend\n",
|
||||
@ -78,7 +77,7 @@ const char* builtin_scripts[] = {
|
||||
" entries and apply their usage project data\n -- to the given configuration. It will copy compiling information for the projects that are\n -- not listed as linkage-only. It will copy the linking information for projects only if\n -- the source project is not a static library. It won't copy linking information\n -- if the project is in this solution; instead it will add that project to the configuration's\n -- links field, expecting that Premake will handle the rest.\n --\n local function copyusagedata(cfg, cfgname, linkToProjs)\n local myPrj = cfg.project;\n local bIsStaticLib = (getCfgKind(cfg) == \"StaticLib\");\n for prjName, prjEntry in pairs(linkToProjs) do\n local srcPrj = prjEntry.usageProj;\n local srcCfg = srcPrj.__configs[cfgname];\n for name, field in pairs(premake.fields) do\n if(srcCfg[name]) then\n if(field.usagecopy) then\n if(not prjEntry.bLinkageOnly) then\n copydependentfield(srcCfg, cfg, name)\n end\n elseif(field.linkagecopy) then\n --Copy the linkage data if we're buil"
|
||||
"ding a non-static thing\n --and this is a pure usage project. If it's not pure-usage, then\n --we will simply put the project's name in the links field later.\n if((not bIsStaticLib) and (not prjEntry.proj)) then\n copydependentfield(srcCfg, cfg, name)\n end\n end\n end\n end\n if((not bIsStaticLib) and prjEntry.proj) then\n table.insert(cfg.links, prjEntry.proj.name);\n end\n end\n end\nfunction premake.bake.buildconfigs()\nfor sln in premake.solution.each() do\nfor _, prj in ipairs(sln.projects) do\nprj.location = prj.location or sln.location or prj.basedir\nadjustpaths(prj.location, prj)\nfor _, blk in ipairs(prj.blocks) do\nadjustpaths(prj.location, blk)\nend\nend\nsln.location = sln.location or sln.basedir\nend\nfor sln in premake.solution.each() do\nlocal basis = collapse(sln)\nfor _, prj in ipairs(sln.projects) do\nprj.__configs = collapse(prj, basis)\nfor _, cfg in pairs(prj.__configs) do\nbake.postprocess(prj, cfg)\nend\nend\nend\nfor sln in premake.solution.each() do\nfor prjIx, prj in i"
|
||||
"pairs(sln.projects) do\nif(not prj.usage) then\nfor cfgname, cfg in pairs(prj.__configs) do\nlocal usesPrjs = getprojectsconnections(cfg, cfgname);\ncopyusagedata(cfg, cfgname, usesPrjs)\nend\nend\nend\nend\nfor sln in premake.solution.each() do\nlocal removeList = {};\nfor index, prj in ipairs(sln.projects) do\nif(prj.usage) then\ntable.insert(removeList, 1, index); --Add in reverse order.\nend\nend\nfor _, index in ipairs(removeList) do\ntable.remove(sln.projects, index);\nend\nend\nbuilduniquedirs()\nbuildtargets(cfg)\nend\nfunction premake.bake.postprocess(prj, cfg)\ncfg.project = prj\ncfg.shortname = premake.getconfigname(cfg.name, cfg.platform, true)\ncfg.longname = premake.getconfigname(cfg.name, cfg.platform)\ncfg.location = cfg.location or cfg.basedir\nlocal platform = premake.platforms[cfg.platform]\nif platform.iscrosscompiler then\ncfg.system = cfg.platform\nelse\ncfg.system = os.get()\nend\nif cfg.kind == \"SharedLib\" and platform.nosharedlibs then\ncfg.kind = \"StaticLib\"\nend\nlocal removef"
|
||||
"iles = cfg.removefiles\nif _ACTION == 'gmake' then\nremovefiles = table.join(removefiles, cfg.excludes)\nend\nlocal files = {}\nfor _, fname in ipairs(cfg.files) do\nif not table.icontains(removefiles, fname) then\ntable.insert(files, fname)\nend\nend\ncfg.files = files\nfor name, field in pairs(premake.fields) do\nif field.isflags then\nlocal values = cfg[name]\nfor _, flag in ipairs(values) do values[flag] = true end\nend\nend\ncfg.__fileconfigs = { }\nfor _, fname in ipairs(cfg.files) do\ncfg.terms.required = fname:lower()\nlocal fcfg = {}\nfor _, blk in ipairs(cfg.project.blocks) do\nif (premake.iskeywordsmatch(blk.keywords, cfg.terms)) then\nmergeobject(fcfg, blk)\nend\nend\nfcfg.name = fname\ncfg.__fileconfigs[fname] = fcfg\ntable.insert(cfg.__fileconfigs, fcfg)\nend\nend\n",
|
||||
"iles = cfg.removefiles\nif _ACTION == 'gmake' then\nremovefiles = table.join(removefiles, cfg.excludes)\nend\nlocal files = {}\nfor _, fname in ipairs(cfg.files) do\nif not table.icontains(removefiles, fname) then\ntable.insert(files, fname)\nend\nend\ncfg.files = files\nfor name, field in pairs(premake.fields) do\nif field.isflags then\nlocal values = cfg[name]\nfor _, flag in ipairs(values) do values[flag] = true end\nend\nend\ncfg.__fileconfigs = { }\nfor _, fname in ipairs(cfg.files) do\nlocal fcfg = {}\nif premake._filelevelconfig then\ncfg.terms.required = fname:lower()\nfor _, blk in ipairs(cfg.project.blocks) do\nif (premake.iskeywordsmatch(blk.keywords, cfg.terms)) then\nmergeobject(fcfg, blk)\nend\nend\nend\nfcfg.name = fname\ncfg.__fileconfigs[fname] = fcfg\ntable.insert(cfg.__fileconfigs, fcfg)\nend\nend\n",
|
||||
|
||||
/* base/api.lua */
|
||||
"premake.fields =\n{\narchivesplit_size =\n{\nkind = \"string\",\nscope = \"config\",\n},\nbasedir =\n{\nkind = \"path\",\nscope = \"container\",\n},\nbuildaction =\n{\nkind = \"string\",\nscope = \"config\",\nallowed = {\n\"Compile\",\n\"Copy\",\n\"Embed\",\n\"None\"\n}\n},\nbuildoptions =\n{\nkind = \"list\",\nscope = \"config\",\n},\nbuildoptions_c =\n{\nkind = \"list\",\nscope = \"config\",\n},\nbuildoptions_cpp =\n{\nkind = \"list\",\nscope = \"config\",\n},\nbuildoptions_objc =\n{\nkind = \"list\",\nscope = \"config\",\n},\nconfigurations =\n{\nkind = \"list\",\nscope = \"solution\",\n},\ncustombuildtask =\n{\nkind = \"table\",\nscope = \"config\",\n},\ndebugargs =\n{\nkind = \"list\",\nscope = \"config\",\n},\ndebugdir =\n{\nkind = \"path\",\nscope = \"config\",\n},\ndebugenvs =\n{\nkind = \"list\",\nscope = \"config\",\n},\ndefines =\n{\nkind = \"list\",\nscope = \"config\",\n},\ndeploymentoptions =\n{\nkind = \"list\",\nscope = \"config\",\nusagecopy = true,\n},\ndependency =\n{\nkind = \""
|
||||
@ -96,11 +95,11 @@ const char* builtin_scripts[] = {
|
||||
"ontainer, err = premake.getobject(\"container\")\nif (not container) then\nerror(err, 2)\nend\nlocal cfg = { }\ncfg.terms = table.flatten({terms})\ntable.insert(container.blocks, cfg)\npremake.CurrentConfiguration = cfg\ncfg.keywords = { }\nfor _, word in ipairs(cfg.terms) do\ntable.insert(cfg.keywords, path.wildcards(word):lower())\nend\nfor name, field in pairs(premake.fields) do\nif (field.kind ~= \"string\" and field.kind ~= \"path\") then\ncfg[name] = { }\nend\nend\nreturn cfg\nend\nlocal function creategroup(name, sln, curpath, parent, inpath)\nlocal group = {}\nsetmetatable(group, {\n__type = \"group\"\n})\ntable.insert(sln.groups, group)\nsln.groups[inpath] = group\ngroup.solution = sln\ngroup.name = name\ngroup.uuid = os.uuid(curpath)\ngroup.parent = parent\nreturn group\nend\nlocal function creategroupsfrompath(inpath, sln)\nif inpath == nil then return nil end\ninpath = path.translate(inpath, \"/\")\nlocal groups = string.explode(inpath, \"/\")\nlocal curpath = \"\"\nlocal lastgroup = nil\nfor i, v "
|
||||
"in ipairs(groups) do\ncurpath = curpath .. \"/\" .. v:lower()\nlocal group = sln.groups[curpath]\nif group == nil then\ngroup = creategroup(v, sln, curpath, lastgroup, curpath)\nend\nlastgroup = group\nend\nreturn lastgroup\nend\nlocal function createproject(name, sln, isUsage)\nlocal prj = {}\nsetmetatable(prj, {\n__type = \"project\",\n})\ntable.insert(sln.projects, prj)\nif(isUsage) then\nif(sln.projects[name]) then\nsln.projects[name].usageProj = prj;\nelse\nsln.projects[name] = prj\nend\nelse\nif(sln.projects[name]) then\nprj.usageProj = sln.projects[name];\nend\nsln.projects[name] = prj\nend\nlocal group = creategroupsfrompath(premake.CurrentGroup, sln)\nprj.solution = sln\nprj.name = name\nprj.basedir = os.getcwd()\nprj.uuid = os.uuid(prj.name)\nprj.blocks = { }\nprj.usage = isUsage\nprj.group = group\nreturn prj;\nend\nfunction usage(name)\nif (not name) then\nif(type(premake.CurrentContainer) ~= \"project\") then return nil end\nif(not premake"
|
||||
".CurrentContainer.usage) then return nil end\nreturn premake.CurrentContainer\nend\nlocal sln\nif (type(premake.CurrentContainer) == \"project\") then\nsln = premake.CurrentContainer.solution\nelse\nsln = premake.CurrentContainer\nend\nif (type(sln) ~= \"solution\") then\nerror(\"no active solution\", 2)\nend\nif((not sln.projects[name]) or\n((not sln.projects[name].usage) and (not sln.projects[name].usageProj))) then\npremake.CurrentContainer = createproject(name, sln, true)\nelse\npremake.CurrentContainer = iff(sln.projects[name].usage,\nsln.projects[name], sln.projects[name].usageProj)\nend\nconfiguration { }\nreturn premake.CurrentContainer\nend\nfunction project(name)\nif (not name) then\nif(type(premake.CurrentContainer) ~= \"project\") then return nil end\nif(premake.CurrentContainer.usage) then return nil end\nreturn premake.CurrentContainer\nend\nlocal sln\nif (type(premake.CurrentContainer) == \"project\") then\nsln = premake.CurrentContainer.solution\nelse\nsln = premake.CurrentContainer\nend\nif (t"
|
||||
"ype(sln) ~= \"solution\") then\nerror(\"no active solution\", 2)\nend\nif((not sln.projects[name]) or sln.projects[name].usage) then\npremake.CurrentContainer = createproject(name, sln)\nelse\npremake.CurrentContainer = sln.projects[name];\nend\nconfiguration { }\nreturn premake.CurrentContainer\nend\nfunction solution(name)\nif not name then\nif type(premake.CurrentContainer) == \"project\" then\nreturn premake.CurrentContainer.solution\nelse\nreturn premake.CurrentContainer\nend\nend\npremake.CurrentContainer = premake.solution.get(name)\nif (not premake.CurrentContainer) then\npremake.CurrentContainer = premake.solution.new(name)\nend\nconfiguration { }\nreturn premake.CurrentContainer\nend\nfunction group(name)\nif not name then\nreturn premake.CurrentGroup\nend\npremake.CurrentGroup = name\nreturn premake.CurrentGroup\nend\nfunction newaction(a)\npremake.action.add(a)\nend\nfunction newoption(opt)\npremake.option.add(opt)\nend\n",
|
||||
"ype(sln) ~= \"solution\") then\nerror(\"no active solution\", 2)\nend\nif((not sln.projects[name]) or sln.projects[name].usage) then\npremake.CurrentContainer = createproject(name, sln)\nelse\npremake.CurrentContainer = sln.projects[name];\nend\nconfiguration { }\nreturn premake.CurrentContainer\nend\nfunction solution(name)\nif not name then\nif type(premake.CurrentContainer) == \"project\" then\nreturn premake.CurrentContainer.solution\nelse\nreturn premake.CurrentContainer\nend\nend\npremake.CurrentContainer = premake.solution.get(name)\nif (not premake.CurrentContainer) then\npremake.CurrentContainer = premake.solution.new(name)\nend\nconfiguration { }\nreturn premake.CurrentContainer\nend\nfunction group(name)\nif not name then\nreturn premake.CurrentGroup\nend\npremake.CurrentGroup = name\nreturn premake.CurrentGroup\nend\nfunction newaction(a)\npremake.action.add(a)\nend\nfunction newoption(opt)\npremake.option.add(opt)\nend\nfunction enablefilelevelconfig()\npremake._filelevelconfig = true\nend\n",
|
||||
|
||||
/* base/cmdline.lua */
|
||||
"newoption\n{\ntrigger = \"cc\",\nvalue = \"VALUE\",\ndescription = \"Choose a C/C++ compiler set\",\nallowed = {\n{ \"gcc\", \"GNU GCC (gcc/g++)\" },\n{ \"ow\", \"OpenWatcom\" },\n{ \"ghs\", \"Green Hills Software\" },\n}\n}\nnewoption\n{\ntrigger = \"dotnet\",\nvalue = \"VALUE\",\ndescription = \"Choose a .NET compiler set\",\nallowed = {\n{ \"msnet\", \"Microsoft .NET (csc)\" },\n{ \"mono\", \"Novell Mono (mcs)\" },\n{ \"pnet\", \"Portable.NET (cscc)\" },\n}\n}\nnewoption\n{\ntrigger = \"file\",\nvalue = \"FILE\",\ndescription = \"Read FILE as a Premake script; default is 'premake4.lua'\"\n}\nnewoption\n{\ntrigger = \"help\",\ndescription = \"Display this information\"\n}\nnewoption\n{\ntrigger = \"os\",\nvalue = \"VALUE\",\ndescription = \"Generate files for a different operating system\",\nallowed = {\n{ \"bsd\", \"OpenBSD, NetBSD, or FreeBSD\" },\n{ \"linux\", \"Linux\" },\n{ \"macosx\", \"Apple Mac OS X\" },\n{ \"solaris\", \"Sola"
|
||||
"ris\" },\n{ \"windows\", \"Microsoft Windows\" },\n}\n}\nnewoption\n{\ntrigger = \"platform\",\nvalue = \"VALUE\",\ndescription = \"Add target architecture (if supported by action)\",\nallowed = {\n{ \"x32\", \"32-bit\" },\n{ \"x64\", \"64-bit\" },\n{ \"universal\", \"Mac OS X Universal, 32- and 64-bit\" },\n{ \"universal32\", \"Mac OS X Universal, 32-bit only\" },\n{ \"universal64\", \"Mac OS X Universal, 64-bit only\" },\n{ \"ps3\", \"Playstation 3\" },\n{ \"orbis\", \"Playstation 4\" },\n{ \"xbox360\", \"Xbox 360\" },\n{ \"durango\", \"Xbox One\" },\n{ \"ARM\", \"ARM\" },\n{ \"PowerPC\", \"PowerPC\" },\n}\n}\nnewoption\n{\ntrigger = \"scripts\",\nvalue = \"path\",\ndescription = \"Search for additional scripts on the given path\"\n}\nnewoption\n{\ntrigger = \"version\",\ndescription = \"Display version information\"\n}\n",
|
||||
"ris\" },\n{ \"windows\", \"Microsoft Windows\" },\n}\n}\nnewoption\n{\ntrigger = \"platform\",\nvalue = \"VALUE\",\ndescription = \"Add target architecture (if supported by action)\",\nallowed = {\n{ \"x32\", \"32-bit\" },\n{ \"x64\", \"64-bit\" },\n{ \"universal\", \"Mac OS X Universal, 32- and 64-bit\" },\n{ \"universal32\", \"Mac OS X Universal, 32-bit only\" },\n{ \"universal64\", \"Mac OS X Universal, 64-bit only\" },\n{ \"ps3\", \"Playstation 3\" },\n{ \"orbis\", \"Playstation 4\" },\n{ \"xbox360\", \"Xbox 360\" },\n{ \"durango\", \"Xbox One\" },\n{ \"ARM\", \"ARM\" },\n{ \"PowerPC\", \"PowerPC\" },\n}\n}\nnewoption\n{\ntrigger = \"scripts\",\nvalue = \"path\",\ndescription = \"Search for additional scripts on the given path\"\n}\nnewoption\n{\ntrigger = \"debug-profiler\",\ndescription = \"GENie script generation profiler.\"\n}\nnewoption\n{\ntrigger = \"version\",\ndescription = \"Display version information\"\n}\n",
|
||||
|
||||
/* base/inspect.lua */
|
||||
"-- Copyright (c) 2013 Enrique García Cota\nlocal function smartQuote(str)\n if str:match('\"') and not str:match(\"'\") then\n return \"'\" .. str .. \"'\"\n end\n return '\"' .. str:gsub('\"', '\\\\\"') .. '\"'\nend\nlocal controlCharsTranslation = {\n [\"\\a\"] = \"\\\\a\", [\"\\b\"] = \"\\\\b\", [\"\\f\"] = \"\\\\f\", [\"\\n\"] = \"\\\\n\",\n [\"\\r\"] = \"\\\\r\", [\"\\t\"] = \"\\\\t\", [\"\\v\"] = \"\\\\v\"\n}\nlocal function escapeChar(c) return controlCharsTranslation[c] end\nlocal function escape(str)\n local result = str:gsub(\"\\\\\", \"\\\\\\\\\"):gsub(\"(%c)\", escapeChar)\n return result\nend\nlocal function isIdentifier(str)\n return type(str) == 'string' and str:match( \"^[_%a][_%a%d]*$\" )\nend\nlocal function isArrayKey(k, length)\n return type(k) == 'number' and 1 <= k and k <= length\nend\nlocal function isDictionaryKey(k, length)\n return not isArrayKey(k, length)\nend\nlocal defaultTypeOrders = {\n ['number'] = 1, ['boolean'] = 2, ['string'] = 3, ['table'] = 4,\n ['fu"
|
||||
@ -111,6 +110,20 @@ const char* builtin_scripts[] = {
|
||||
"puts('{...}')\n else\n if tableAppearances[t] > 1 then puts('<', getId(t), '>') end\n local dictKeys = getDictionaryKeys(t)\n local length = #t\n local mt = getmetatable(t)\n local to_string_result = getToStringResultSafely(t, mt)\n puts('{')\n down(function()\n if to_string_result then\n puts(' -- ', escape(to_string_result))\n if length >= 1 then tabify() end -- tabify the array values\n end\n local needsComma = false\n for i=1, length do\n needsComma = commaControl(needsComma)\n puts(' ')\n putValue(t[i], makePath(path, i))\n end\n for _,k in ipairs(dictKeys) do\n needsComma = commaControl(needsComma)\n tabify()\n putKey(k)\n puts(' = ')\n putValue(t[k], makePath(path, k))\n end\n if mt then\n needsComma = commaControl(needsComma)\n tabify()\n puts('<metatable> = '"
|
||||
")\n putValue(mt, makePath(path, '<metatable>'))\n end\n end)\n if #dictKeys > 0 or mt then -- dictionary table. Justify closing }\n tabify()\n elseif length > 0 then -- array tables have one extra space before closing }\n puts(' ')\n end\n puts('}')\n end\n end\n -- putvalue is forward-declared before putTable & putKey\n putValue = function(v, path)\n if filter(v, path) then\n puts('<filtered>')\n else\n local tv = type(v)\n if tv == 'string' then\n puts(smartQuote(escape(v)))\n elseif tv == 'number' or tv == 'boolean' or tv == 'nil' then\n puts(tostring(v))\n elseif tv == 'table' then\n putTable(v, path)\n else\n puts('<',tv,' ',getId(v),'>')\n end\n end\n end\n putValue(rootObject, {})\n return table.concat(buffer)\nend\nfunction printtable(name, table)\nprint(\"table: \", name, inspect(table), \"\\n\")\nend\nfunction printstack()\nprint(debug.traceback(), \"\\n\")\nend\n",
|
||||
|
||||
/* base/profiler.lua */
|
||||
"_profiler = {}\nfunction newProfiler(variant, sampledelay)\nif _profiler.running then\nprint(\"Profiler already running.\")\nreturn\nend\nvariant = variant or \"time\"\nif variant ~= \"time\" and variant ~= \"call\" then\nprint(\"Profiler method must be 'time' or 'call'.\")\nreturn\nend\nlocal newprof = {}\nfor k,v in pairs(_profiler) do\nnewprof[k] = v\nend\nnewprof.variant = variant\nnewprof.sampledelay = sampledelay or 100000\nreturn newprof\nend\nfunction _profiler.start(self)\nif _profiler.running then\nreturn\nend\n_profiler.running = self\nself.rawstats = {}\nself.callstack = {}\nif self.variant == \"time\" then\nself.lastclock = os.clock()\ndebug.sethook( _profiler_hook_wrapper_by_time, \"\", self.sampledelay )\nelseif self.variant == \"call\" then\ndebug.sethook( _profiler_hook_wrapper_by_call, \"cr\" )\nelse\nprint(\"Profiler method must be 'time' or 'call'.\")\nsys.exit(1)\nend\nend\nfunction _profiler.stop(self)\nif _profiler.running ~= self then\nreturn\nend\ndebug.sethook( nil )\n_profiler.runnin"
|
||||
"g = nil\nend\nfunction _profiler_hook_wrapper_by_call(action)\nif _profiler.running == nil then\ndebug.sethook( nil )\nend\n_profiler.running:_internal_profile_by_call(action)\nend\nfunction _profiler_hook_wrapper_by_time(action)\nif _profiler.running == nil then\ndebug.sethook( nil )\nend\n_profiler.running:_internal_profile_by_time(action)\nend\nfunction _profiler._internal_profile_by_call(self,action)\nlocal caller_info = debug.getinfo( 3 )\nif caller_info == nil then\nprint \"No caller_info\"\nreturn\nend\nlocal latest_ar = nil\nif table.getn(self.callstack) > 0 then\nlatest_ar = self.callstack[table.getn(self.callstack)]\nend\nlocal should_not_profile = 0\nfor k,v in pairs(self.prevented_functions) do\nif k == caller_info.func then\nshould_not_profile = v\nend\nend\nif latest_ar then\nif latest_ar.should_not_profile == 2 then\nshould_not_profile = 2\nend\nend\nif action == \"call\" then\nlocal this_ar = {}\nthis_ar.should_not_profile = should_not_profile\nthis_ar.parent_ar = latest_ar\nthis_ar.anon_child "
|
||||
"= 0\nthis_ar.name_child = 0\nthis_ar.children = {}\nthis_ar.children_time = {}\nthis_ar.clock_start = os.clock()\ntable.insert( self.callstack, this_ar )\nelse\nlocal this_ar = latest_ar\nif this_ar == nil then\nreturn -- No point in doing anything if no upper activation record\nend\nthis_ar.clock_end = os.clock()\nthis_ar.this_time = this_ar.clock_end - this_ar.clock_start\nif this_ar.parent_ar then\nthis_ar.parent_ar.children[caller_info.func] =\n(this_ar.parent_ar.children[caller_info.func] or 0) + 1\nthis_ar.parent_ar.children_time[caller_info.func] =\n(this_ar.parent_ar.children_time[caller_info.func] or 0 ) +\nthis_ar.this_time\nif caller_info.name == nil then\nthis_ar.parent_ar.anon_child =\nthis_ar.parent_ar.anon_child + this_ar.this_time\nelse\nthis_ar.parent_ar.name_child =\nthis_ar.parent_ar.name_child + this_ar.this_time\nend\nend\nif this_ar.should_not_profile == 0 then\nlocal inforec = self:_get_func_rec(caller_info.func,1)\ninforec.count = inforec.count + 1\ninforec.time = inforec.time + this_ar"
|
||||
".this_time\ninforec.anon_child_time = inforec.anon_child_time + this_ar.anon_child\ninforec.name_child_time = inforec.name_child_time + this_ar.name_child\ninforec.func_info = caller_info\nfor k,v in pairs(this_ar.children) do\ninforec.children[k] = (inforec.children[k] or 0) + v\ninforec.children_time[k] =\n(inforec.children_time[k] or 0) + this_ar.children_time[k]\nend\nend\ntable.remove( self.callstack, table.getn( self.callstack ) )\nend\nend\nfunction _profiler._internal_profile_by_time(self,action)\nlocal timetaken = os.clock() - self.lastclock\nlocal depth = 3\nlocal at_top = true\nlocal last_caller\nlocal caller = debug.getinfo(depth)\nwhile caller do\nif not caller.func then caller.func = \"(tail call)\" end\nif self.prevented_functions[caller.func] == nil then\nlocal info = self:_get_func_rec(caller.func, 1, caller)\ninfo.count = info.count + 1\ninfo.time = info.time + timetaken\nif last_caller then\nif last_caller.name then\ninfo.name_child_time = info.name_child_time + timetaken\nelse\ninfo.anon_ch"
|
||||
"ild_time = info.anon_child_time + timetaken\nend\ninfo.children[last_caller.func] =\n(info.children[last_caller.func] or 0) + 1\ninfo.children_time[last_caller.func] =\n(info.children_time[last_caller.func] or 0) + timetaken\nend\nend\ndepth = depth + 1\nlast_caller = caller\ncaller = debug.getinfo(depth)\nend\nself.lastclock = os.clock()\nend\nfunction _profiler._get_func_rec(self,func,force,info)\nlocal ret = self.rawstats[func]\nif ret == nil and force ~= 1 then\nreturn nil\nend\nif ret == nil then\nret = {}\nret.func = func\nret.count = 0\nret.time = 0\nret.anon_child_time = 0\nret.name_child_time = 0\nret.children = {}\nret.children_time = {}\nret.func_info = info\nself.rawstats[func] = ret\nend\nreturn ret\nend\nfunction _profiler.report( self, outfile, sort_by_total_time )\noutfile:write\n[[Lua Profile output created by profiler.lua. Copyright Pepperfish 2002+\n]]\nlocal terms = {}\nif self.variant == \"time\" then\nterms.capitalized = \"Sample\"\nterms.single = \"sample\"\nterms.pastverb = \"sampled\""
|
||||
"\nelseif self.variant == \"call\" then\nterms.capitalized = \"Call\"\nterms.single = \"call\"\nterms.pastverb = \"called\"\nelse\nassert(false)\nend\nlocal total_time = 0\nlocal ordering = {}\nfor func,record in pairs(self.rawstats) do\ntable.insert(ordering, func)\nend\nif sort_by_total_time then\ntable.sort( ordering,\nfunction(a,b) return self.rawstats[a].time > self.rawstats[b].time end\n)\nelse\ntable.sort( ordering,\nfunction(a,b)\nlocal arec = self.rawstats[a]\nlocal brec = self.rawstats[b]\nlocal atime = arec.time - (arec.anon_child_time + arec.name_child_time)\nlocal btime = brec.time - (brec.anon_child_time + brec.name_child_time)\nreturn atime > btime\nend\n)\nend\nfor i=1,#ordering do\nlocal func = ordering[i]\nlocal record = self.rawstats[func]\nlocal thisfuncname = \" \" .. self:_pretty_name(func) .. \" \"\nif string.len( thisfuncname ) < 42 then\nthisfuncname = string.rep( \"-\", math.floor((42 - string.len(thisfuncname))/2) ) .. thisfuncname\nthisfuncname = thisfuncname .. string.rep( \"-\", 42"
|
||||
" - string.len(thisfuncname) )\nend\ntotal_time = total_time + ( record.time - ( record.anon_child_time +\nrecord.name_child_time ) )\noutfile:write( string.rep( \"-\", 19 ) .. thisfuncname ..\nstring.rep( \"-\", 19 ) .. \"\\n\" )\noutfile:write( terms.capitalized..\" count: \" ..\nstring.format( \"%4d\", record.count ) .. \"\\n\" )\noutfile:write( \"Time spend total: \" ..\nstring.format( \"%4.3f\", record.time ) .. \"s\\n\" )\noutfile:write( \"Time spent in children: \" ..\nstring.format(\"%4.3f\",record.anon_child_time+record.name_child_time) ..\n\"s\\n\" )\nlocal timeinself =\nrecord.time - (record.anon_child_time + record.name_child_time)\noutfile:write( \"Time spent in self: \" ..\nstring.format(\"%4.3f\", timeinself) .. \"s\\n\" )\noutfile:write( \"Time spent per \" .. terms.single .. \": \" ..\nstring.format(\"%4.5f\", record.time/record.count) ..\n\"s/\" .. terms.single .. \"\\n\" )\noutfile:write( \"Time spent in self per \"..terms.single..\": \" ..\nstring.format( \"%4.5f\", timein"
|
||||
"self/record.count ) .. \"s/\" ..\nterms.single..\"\\n\" )\nlocal added_blank = 0\nfor k,v in pairs(record.children) do\nif self.prevented_functions[k] == nil or\nself.prevented_functions[k] == 0\nthen\nif added_blank == 0 then\noutfile:write( \"\\n\" ) -- extra separation line\nadded_blank = 1\nend\noutfile:write( \"Child \" .. self:_pretty_name(k) ..\nstring.rep( \" \", 41-string.len(self:_pretty_name(k)) ) .. \" \" ..\nterms.pastverb..\" \" .. string.format(\"%6d\", v) )\noutfile:write( \" times. Took \" ..\nstring.format(\"%4.2f\", record.children_time[k] ) .. \"s\\n\" )\nend\nend\noutfile:write( \"\\n\" ) -- extra separation line\noutfile:flush()\nend\noutfile:write( \"\\n\\n\" )\noutfile:write( \"Total time spent in profiled functions: \" ..\nstring.format(\"%5.3g\",total_time) .. \"s\\n\" )\noutfile:write( [[\nEND\n]] )\noutfile:flush()\nend\nfunction _profiler.lua_report(self,outfile)\nlocal ordering = {}\nlocal functonum = {}\nfor func,record in pairs(self.rawstats) do\ntable.insert(ordering, func)\nfu"
|
||||
"nctonum[func] = table.getn(ordering)\nend\noutfile:write(\n\"-- Profile generated by profiler.lua Copyright Pepperfish 2002+\\n\\n\" )\noutfile:write( \"-- Function names\\nfuncnames = {}\\n\" )\nfor i=1,table.getn(ordering) do\nlocal thisfunc = ordering[i]\noutfile:write( \"funcnames[\" .. i .. \"] = \" ..\nstring.format(\"%q\", self:_pretty_name(thisfunc)) .. \"\\n\" )\nend\noutfile:write( \"\\n\" )\noutfile:write( \"-- Function times\\nfunctimes = {}\\n\" )\nfor i=1,table.getn(ordering) do\nlocal thisfunc = ordering[i]\nlocal record = self.rawstats[thisfunc]\noutfile:write( \"functimes[\" .. i .. \"] = { \" )\noutfile:write( \"tot=\" .. record.time .. \", \" )\noutfile:write( \"achild=\" .. record.anon_child_time .. \", \" )\noutfile:write( \"nchild=\" .. record.name_child_time .. \", \" )\noutfile:write( \"count=\" .. record.count .. \" }\\n\" )\nend\noutfile:write( \"\\n\" )\noutfile:write( \"-- Child links\\nchildren = {}\\n\" )\nfor i=1,table.getn(ordering) do\nlocal thisfunc = ordering[i]\nlocal record"
|
||||
" = self.rawstats[thisfunc]\noutfile:write( \"children[\" .. i .. \"] = { \" )\nfor k,v in pairs(record.children) do\nif functonum[k] then -- non-recorded functions will be ignored now\noutfile:write( functonum[k] .. \", \" )\nend\nend\noutfile:write( \"}\\n\" )\nend\noutfile:write( \"\\n\" )\noutfile:write( \"-- Child call counts\\nchildcounts = {}\\n\" )\nfor i=1,table.getn(ordering) do\nlocal thisfunc = ordering[i]\nlocal record = self.rawstats[thisfunc]\noutfile:write( \"children[\" .. i .. \"] = { \" )\nfor k,v in record.children do\nif functonum[k] then -- non-recorded functions will be ignored now\noutfile:write( v .. \", \" )\nend\nend\noutfile:write( \"}\\n\" )\nend\noutfile:write( \"\\n\" )\noutfile:write( \"-- Child call time\\nchildtimes = {}\\n\" )\nfor i=1,table.getn(ordering) do\nlocal thisfunc = ordering[i]\nlocal record = self.rawstats[thisfunc];\noutfile:write( \"children[\" .. i .. \"] = { \" )\nfor k,v in pairs(record.children) do\nif functonum[k] then -- non-recorded functions will be ignor"
|
||||
"ed now\noutfile:write( record.children_time[k] .. \", \" )\nend\nend\noutfile:write( \"}\\n\" )\nend\noutfile:write( \"\\n\\n-- That is all.\\n\\n\" )\noutfile:flush()\nend\nfunction _profiler._pretty_name(self,func)\nlocal info = self.rawstats[ func ].func_info\nlocal name = \"\"\nif info.what == \"Lua\" then\nname = \"L:\"\nend\nif info.what == \"C\" then\nname = \"C:\"\nend\nif info.what == \"main\" then\nname = \" :\"\nend\nif info.name == nil then\nname = name .. \"<\"..tostring(func) .. \">\"\nelse\nname = name .. info.name\nend\nif info.source then\nname = name .. \"@\" .. info.source\nelse\nif info.what == \"C\" then\nname = name .. \"@?\"\nelse\nname = name .. \"@<string>\"\nend\nend\nname = name .. \":\"\nif info.what == \"C\" then\nname = name .. \"?\"\nelse\nname = name .. info.linedefined\nend\nreturn name\nend\nfunction _profiler.prevent(self, func, level)\nself.prevented_functions[func] = (level or 1)\nend\n_profiler.prevented_functions = {\n[_profiler.start] = 2,\n[_profiler.stop] = 2,\n[_profi"
|
||||
"ler._internal_profile_by_time] = 2,\n[_profiler._internal_profile_by_call] = 2,\n[_profiler_hook_wrapper_by_time] = 2,\n[_profiler_hook_wrapper_by_call] = 2,\n[_profiler.prevent] = 2,\n[_profiler._get_func_rec] = 2,\n[_profiler.report] = 2,\n[_profiler.lua_report] = 2,\n[_profiler._pretty_name] = 2\n}\n",
|
||||
|
||||
/* tools/dotnet.lua */
|
||||
"premake.dotnet = { }\npremake.dotnet.namestyle = \"windows\"\nlocal flags =\n{\nFatalWarning = \"/warnaserror\",\nOptimize = \"/optimize\",\nOptimizeSize = \"/optimize\",\nOptimizeSpeed = \"/optimize\",\nSymbols = \"/debug\",\nUnsafe = \"/unsafe\"\n}\nfunction premake.dotnet.getbuildaction(fcfg)\nlocal ext = path.getextension(fcfg.name):lower()\nif fcfg.buildaction == \"Compile\" or ext == \".cs\" then\nreturn \"Compile\"\nelseif fcfg.buildaction == \"Embed\" or ext == \".resx\" then\nreturn \"EmbeddedResource\"\nelseif fcfg.buildaction == \"Copy\" or ext == \".asax\" or ext == \".aspx\" then\nreturn \"Content\"\nelse\nreturn \"None\"\nend\nend\nfunction premake.dotnet.getcompilervar(cfg)\nif (_OPTIONS.dotnet == \"msnet\") then\nreturn \"csc\"\nelseif (_OPTIONS.dotnet == \"mono\") then\nif (cfg.framework <= \"1.1\") then\nreturn \"mcs\"\nelseif (cfg.framework >= \"4.0\") then\nreturn \"dmcs\"\nelse \nreturn \"gmcs\"\nend\nelse\nreturn \"cscc\"\nend\nend\nfunction premake.dotnet.getfla"
|
||||
"gs(cfg)\nlocal result = table.translate(cfg.flags, flags)\nreturn result\nend\nfunction premake.dotnet.getkind(cfg)\nif (cfg.kind == \"ConsoleApp\") then\nreturn \"Exe\"\nelseif (cfg.kind == \"WindowedApp\") then\nreturn \"WinExe\"\nelseif (cfg.kind == \"SharedLib\") then\nreturn \"Library\"\nend\nend",
|
||||
@ -148,7 +161,7 @@ const char* builtin_scripts[] = {
|
||||
"function premake.showhelp()\nprintf(\"\")\nprintf(\"Usage: genie [options] action [arguments]\")\nprintf(\"\")\nprintf(\"OPTIONS\")\nprintf(\"\")\nfor option in premake.option.each() do\nlocal trigger = option.trigger\nlocal description = option.description\nif (option.value) then trigger = trigger .. \"=\" .. option.value end\nif (option.allowed) then description = description .. \"; one of:\" end\nprintf(\" --%-15s %s\", trigger, description)\nif (option.allowed) then\nfor _, value in ipairs(option.allowed) do\nprintf(\" %-14s %s\", value[1], value[2])\nend\nend\nprintf(\"\")\nend\nprintf(\"ACTIONS\")\nprintf(\"\")\nfor action in premake.action.each() do\nprintf(\" %-17s %s\", action.trigger, action.description)\nend\nprintf(\"\")\nprintf(\"For additional information, see https://github.com/bkaradzic/genie\")\nend\n",
|
||||
|
||||
/* base/premake.lua */
|
||||
"function premake.generate(obj, filename, callback)\nfilename = premake.project.getfilename(obj, filename)\nprintf(\"Generating %s...\", filename)\nlocal f, err = io.open(filename, \"wb\")\nif (not f) then\nerror(err, 0)\nend\nio.output(f)\ncallback(obj)\nf:close()\nend\nfunction premake.findDefaultScript(dir, search_upwards)\nsearch_upwards = search_upwards or true\nlocal last = \"\"\nwhile dir ~= last do\nfor _, name in ipairs({ \"genie.lua\", \"solution.lua\", \"premake4.lua\" }) do\nlocal script0 = dir .. \"/\" .. name\nif (os.isfile(script0)) then\nreturn dir, name\nend\nlocal script1 = dir .. \"/scripts/\" .. name\nif (os.isfile(script1)) then\nreturn dir .. \"/scripts/\", name\nend\nend\nlast = dir\ndir = path.getabsolute(dir .. \"/..\")\nif dir == \".\" or not search_upwards then break end\nend\nreturn nil, nil\nend",
|
||||
"premake._filelevelconfig = false\nfunction premake.generate(obj, filename, callback)\nfilename = premake.project.getfilename(obj, filename)\nprintf(\"Generating %s...\", filename)\nlocal f, err = io.open(filename, \"wb\")\nif (not f) then\nerror(err, 0)\nend\nio.output(f)\ncallback(obj)\nf:close()\nend\nfunction premake.findDefaultScript(dir, search_upwards)\nsearch_upwards = search_upwards or true\nlocal last = \"\"\nwhile dir ~= last do\nfor _, name in ipairs({ \"genie.lua\", \"solution.lua\", \"premake4.lua\" }) do\nlocal script0 = dir .. \"/\" .. name\nif (os.isfile(script0)) then\nreturn dir, name\nend\nlocal script1 = dir .. \"/scripts/\" .. name\nif (os.isfile(script1)) then\nreturn dir .. \"/scripts/\", name\nend\nend\nlast = dir\ndir = path.getabsolute(dir .. \"/..\")\nif dir == \".\" or not search_upwards then break end\nend\nreturn nil, nil\nend\n",
|
||||
|
||||
/* actions/codeblocks/_codeblocks.lua */
|
||||
"premake.codeblocks = { }\nnewaction {\ntrigger = \"codeblocks\",\nshortname = \"Code::Blocks\",\ndescription = \"Generate Code::Blocks project files\",\nvalid_kinds = { \"ConsoleApp\", \"WindowedApp\", \"StaticLib\", \"SharedLib\" },\nvalid_languages = { \"C\", \"C++\" },\nvalid_tools = {\ncc = { \"gcc\", \"ow\" },\n},\nonsolution = function(sln)\npremake.generate(sln, \"%%.workspace\", premake.codeblocks.workspace)\nend,\nonproject = function(prj)\npremake.generate(prj, \"%%.cbp\", premake.codeblocks.cbp)\nend,\noncleansolution = function(sln)\npremake.clean.file(sln, \"%%.workspace\")\nend,\noncleanproject = function(prj)\npremake.clean.file(prj, \"%%.cbp\")\npremake.clean.file(prj, \"%%.depend\")\npremake.clean.file(prj, \"%%.layout\")\nend\n}\n",
|
||||
@ -364,8 +377,8 @@ const char* builtin_scripts[] = {
|
||||
|
||||
/* _premake_main.lua */
|
||||
"_WORKING_DIR = os.getcwd()\nlocal function injectplatform(platform)\nif not platform then return true end\nplatform = premake.checkvalue(platform, premake.fields.platforms.allowed)\nfor sln in premake.solution.each() do\nlocal platforms = sln.platforms or { }\nif #platforms == 0 then\ntable.insert(platforms, \"Native\")\nend\nif not table.contains(platforms, \"Native\") then\nreturn false, sln.name .. \" does not target native platform\\nNative platform settings are required for the --platform feature.\"\nend\nif not table.contains(platforms, platform) then\ntable.insert(platforms, platform)\nend\nsln.platforms = platforms\nend\nreturn true\nend\nfunction _premake_main(scriptpath)\nif (scriptpath) then\nlocal scripts = dofile(scriptpath .. \"/_manifest.lua\")\nfor _,v in ipairs(scripts) do\ndofile(scriptpath .. \"/\" .. v)\nend\nend\n_PREMAKE_COMMAND = path.getabsolute(_PREMAKE_COMMAND)\npremake.action.set(_ACTION)\nmath.randomseed(os.time())\nif (nil ~= _OPTIONS[\"file\"]) then\nlocal fname = _OPTIONS"
|
||||
"[\"file\"]\nif (os.isfile(fname)) then\ndofile(fname)\nelse\nerror(\"No genie script '\" .. fname .. \"' found!\", 2)\nend\nelse\nlocal dir, name = premake.findDefaultScript(path.getabsolute(\"./\"))\nif dir ~= nil then\nos.chdir(dir)\ndofile(name)\nend\nend\nif (_OPTIONS[\"version\"] or _OPTIONS[\"help\"] or not _ACTION) then\nprintf(\"GENie - Project generator tool %s\", _GENIE_VERSION_STR)\nprintf(\"https://github.com/bkaradzic/genie\")\nif (not _OPTIONS[\"version\"]) then\npremake.showhelp()\nend\nreturn 1\nend\naction = premake.action.current()\nif (not action) then\nerror(\"Error: no such action '\" .. _ACTION .. \"'\", 0)\nend\nok, err = premake.option.validate(_OPTIONS)\nif (not ok) then error(\"Error: \" .. err, 0) end\nok, err = premake.checktools()\nif (not ok) then error(\"Error: \" .. err, 0) end\nok, err = injectplatform(_OPTIONS[\"platform\"])\nif (not ok) then error(\"Error: \" .. err, 0) end\nprint(\"Building configurations...\")\npremake.bake.buildconfigs()\nok, err = premake.checkprojects()"
|
||||
"\nif (not ok) then error(\"Error: \" .. err, 0) end\nprintf(\"Running action '%s'...\", action.trigger)\npremake.action.call(action.trigger)\nprint(\"Done.\")\nreturn 0\nend\n",
|
||||
"[\"file\"]\nif (os.isfile(fname)) then\ndofile(fname)\nelse\nerror(\"No genie script '\" .. fname .. \"' found!\", 2)\nend\nelse\nlocal dir, name = premake.findDefaultScript(path.getabsolute(\"./\"))\nif dir ~= nil then\nos.chdir(dir)\ndofile(name)\nend\nend\nif (_OPTIONS[\"version\"] or _OPTIONS[\"help\"] or not _ACTION) then\nprintf(\"GENie - Project generator tool %s\", _GENIE_VERSION_STR)\nprintf(\"https://github.com/bkaradzic/GENie\")\nif (not _OPTIONS[\"version\"]) then\npremake.showhelp()\nend\nreturn 1\nend\naction = premake.action.current()\nif (not action) then\nerror(\"Error: no such action '\" .. _ACTION .. \"'\", 0)\nend\nok, err = premake.option.validate(_OPTIONS)\nif (not ok) then error(\"Error: \" .. err, 0) end\nok, err = premake.checktools()\nif (not ok) then error(\"Error: \" .. err, 0) end\nok, err = injectplatform(_OPTIONS[\"platform\"])\nif (not ok) then error(\"Error: \" .. err, 0) end\nlocal profiler = newProfiler()\nif (nil ~= _OPTIONS[\"debug-profiler\"]) then\nprofiler:start()\nend\n"
|
||||
"print(\"Building configurations...\")\npremake.bake.buildconfigs()\nif (nil ~= _OPTIONS[\"debug-profiler\"]) then\nprofiler:stop()\nlocal filePath = path.getabsolute(\"GENie-profiler-bake.txt\")\nprint(\"Writing debug-profiler report \" .. filePath .. \".\")\nlocal outfile = io.open(filePath, \"w+\")\nprofiler:report(outfile)\noutfile:close()\nend\nok, err = premake.checkprojects()\nif (not ok) then error(\"Error: \" .. err, 0) end\nprintf(\"Running action '%s'...\", action.trigger)\npremake.action.call(action.trigger)\nprint(\"Done.\")\nreturn 0\nend\n",
|
||||
|
||||
0
|
||||
};
|
||||
|
@ -2103,7 +2103,7 @@ For better readability, Google Mock also gives you:
|
||||
* `WithArg<N>(action)` (no `s` after `Arg`) when the inner `action` takes _one_ argument.
|
||||
|
||||
As you may have realized, `InvokeWithoutArgs(...)` is just syntactic
|
||||
sugar for `WithoutArgs(Inovke(...))`.
|
||||
sugar for `WithoutArgs(Invoke(...))`.
|
||||
|
||||
Here are more tips:
|
||||
|
||||
|
@ -1571,15 +1571,14 @@ For technical reasons, there are some caveats:
|
||||
1. _statement_ in `EXPECT_FATAL_FAILURE()` cannot reference local non-static variables or non-static members of `this` object.
|
||||
1. _statement_ in `EXPECT_FATAL_FAILURE()` cannot return a value.
|
||||
|
||||
_Note:_ Google Test is designed with threads in mind. Once the
|
||||
_Note:_ Google Test is designed with threads in mind. Once the
|
||||
synchronization primitives in `"gtest/internal/gtest-port.h"` have
|
||||
been implemented, Google Test will become thread-safe, meaning that
|
||||
you can then use assertions in multiple threads concurrently. Before
|
||||
|
||||
that, however, Google Test only supports single-threaded usage. Once
|
||||
you can then use assertions in multiple threads concurrently. Before
|
||||
that, however, Google Test only supports single-threaded usage. Once
|
||||
thread-safe, `EXPECT_FATAL_FAILURE()` and `EXPECT_NONFATAL_FAILURE()`
|
||||
will capture failures in the current thread only. If _statement_
|
||||
creates new threads, failures in these threads will be ignored. If
|
||||
creates new threads, failures in these threads will be ignored. If
|
||||
you want to capture failures from all threads instead, you should use
|
||||
the following macros:
|
||||
|
||||
|
@ -2546,10 +2546,9 @@ bool ParseInt32(const Message& src_text, const char* str, Int32* value);
|
||||
// corresponding to the given Google Test flag.
|
||||
bool BoolFromGTestEnv(const char* flag, bool default_val);
|
||||
GTEST_API_ Int32 Int32FromGTestEnv(const char* flag, Int32 default_val);
|
||||
const char* StringFromGTestEnv(const char* flag, const char* default_val);
|
||||
std::string StringFromGTestEnv(const char* flag, const char* default_val);
|
||||
|
||||
} // namespace internal
|
||||
} // namespace testing
|
||||
|
||||
#endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_
|
||||
|
||||
|
26
3rdparty/googletest/googletest/src/gtest-port.cc
vendored
26
3rdparty/googletest/googletest/src/gtest-port.cc
vendored
@ -1226,13 +1226,33 @@ Int32 Int32FromGTestEnv(const char* flag, Int32 default_value) {
|
||||
|
||||
// Reads and returns the string environment variable corresponding to
|
||||
// the given flag; if it's not set, returns default_value.
|
||||
const char* StringFromGTestEnv(const char* flag, const char* default_value) {
|
||||
std::string StringFromGTestEnv(const char* flag, const char* default_value) {
|
||||
#if defined(GTEST_GET_STRING_FROM_ENV_)
|
||||
return GTEST_GET_STRING_FROM_ENV_(flag, default_value);
|
||||
#endif // defined(GTEST_GET_STRING_FROM_ENV_)
|
||||
const std::string env_var = FlagToEnvVar(flag);
|
||||
const char* const value = posix::GetEnv(env_var.c_str());
|
||||
return value == NULL ? default_value : value;
|
||||
const char* value = posix::GetEnv(env_var.c_str());
|
||||
if (value != NULL) {
|
||||
return value;
|
||||
}
|
||||
|
||||
// As a special case for the 'output' flag, if GTEST_OUTPUT is not
|
||||
// set, we look for XML_OUTPUT_FILE, which is set by the Bazel build
|
||||
// system. The value of XML_OUTPUT_FILE is a filename without the
|
||||
// "xml:" prefix of GTEST_OUTPUT.
|
||||
//
|
||||
// The net priority order after flag processing is thus:
|
||||
// --gtest_output command line flag
|
||||
// GTEST_OUTPUT environment variable
|
||||
// XML_OUTPUT_FILE environment variable
|
||||
// 'default_value'
|
||||
if (strcmp(flag, "output") == 0) {
|
||||
value = posix::GetEnv("XML_OUTPUT_FILE");
|
||||
if (value != NULL) {
|
||||
return std::string("xml:") + value;
|
||||
}
|
||||
}
|
||||
return default_value;
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
|
@ -87,6 +87,7 @@ class GTestEnvVarTest(gtest_test_utils.TestCase):
|
||||
TestFlag('break_on_failure', '1', '0')
|
||||
TestFlag('color', 'yes', 'auto')
|
||||
TestFlag('filter', 'FooTest.Bar', '*')
|
||||
SetEnvVar('XML_OUTPUT_FILE', None) # For 'output' test
|
||||
TestFlag('output', 'xml:tmp/foo.xml', '')
|
||||
TestFlag('print_time', '0', '1')
|
||||
TestFlag('repeat', '999', '1')
|
||||
@ -98,6 +99,19 @@ class GTestEnvVarTest(gtest_test_utils.TestCase):
|
||||
TestFlag('death_test_use_fork', '1', '0')
|
||||
TestFlag('stack_trace_depth', '0', '100')
|
||||
|
||||
def testXmlOutputFile(self):
|
||||
"""Tests that $XML_OUTPUT_FILE affects the output flag."""
|
||||
|
||||
SetEnvVar('GTEST_OUTPUT', None)
|
||||
SetEnvVar('XML_OUTPUT_FILE', 'tmp/bar.xml')
|
||||
AssertEq('xml:tmp/bar.xml', GetFlag('output'))
|
||||
|
||||
def testXmlOutputFileOverride(self):
|
||||
"""Tests that $XML_OUTPUT_FILE is overridden by $GTEST_OUTPUT"""
|
||||
|
||||
SetEnvVar('GTEST_OUTPUT', 'xml:tmp/foo.xml')
|
||||
SetEnvVar('XML_OUTPUT_FILE', 'tmp/bar.xml')
|
||||
AssertEq('xml:tmp/foo.xml', GetFlag('output'))
|
||||
|
||||
if __name__ == '__main__':
|
||||
gtest_test_utils.Main()
|
||||
|
@ -1,3 +1,3 @@
|
||||
{
|
||||
"type": "integer"
|
||||
{
|
||||
"type": "integer"
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
{
|
||||
"type": "integer"
|
||||
{
|
||||
"type": "integer"
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
{
|
||||
"integer": {
|
||||
"type": "integer"
|
||||
},
|
||||
"refToInteger": {
|
||||
"$ref": "#/integer"
|
||||
}
|
||||
{
|
||||
"integer": {
|
||||
"type": "integer"
|
||||
},
|
||||
"refToInteger": {
|
||||
"$ref": "#/integer"
|
||||
}
|
||||
}
|
@ -1,82 +1,82 @@
|
||||
[
|
||||
{
|
||||
"description": "additionalItems as schema",
|
||||
"schema": {
|
||||
"items": [],
|
||||
"additionalItems": {"type": "integer"}
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "additional items match schema",
|
||||
"data": [ 1, 2, 3, 4 ],
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "additional items do not match schema",
|
||||
"data": [ 1, 2, 3, "foo" ],
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "items is schema, no additionalItems",
|
||||
"schema": {
|
||||
"items": {},
|
||||
"additionalItems": false
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "all items match schema",
|
||||
"data": [ 1, 2, 3, 4, 5 ],
|
||||
"valid": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "array of items with no additionalItems",
|
||||
"schema": {
|
||||
"items": [{}, {}, {}],
|
||||
"additionalItems": false
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "no additional items present",
|
||||
"data": [ 1, 2, 3 ],
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "additional items are not permitted",
|
||||
"data": [ 1, 2, 3, 4 ],
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "additionalItems as false without items",
|
||||
"schema": {"additionalItems": false},
|
||||
"tests": [
|
||||
{
|
||||
"description":
|
||||
"items defaults to empty schema so everything is valid",
|
||||
"data": [ 1, 2, 3, 4, 5 ],
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "ignores non-arrays",
|
||||
"data": {"foo" : "bar"},
|
||||
"valid": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "additionalItems are allowed by default",
|
||||
"schema": {"items": []},
|
||||
"tests": [
|
||||
{
|
||||
"description": "only the first items are validated",
|
||||
"data": [1, "foo", false],
|
||||
"valid": true
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
[
|
||||
{
|
||||
"description": "additionalItems as schema",
|
||||
"schema": {
|
||||
"items": [],
|
||||
"additionalItems": {"type": "integer"}
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "additional items match schema",
|
||||
"data": [ 1, 2, 3, 4 ],
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "additional items do not match schema",
|
||||
"data": [ 1, 2, 3, "foo" ],
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "items is schema, no additionalItems",
|
||||
"schema": {
|
||||
"items": {},
|
||||
"additionalItems": false
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "all items match schema",
|
||||
"data": [ 1, 2, 3, 4, 5 ],
|
||||
"valid": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "array of items with no additionalItems",
|
||||
"schema": {
|
||||
"items": [{}, {}, {}],
|
||||
"additionalItems": false
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "no additional items present",
|
||||
"data": [ 1, 2, 3 ],
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "additional items are not permitted",
|
||||
"data": [ 1, 2, 3, 4 ],
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "additionalItems as false without items",
|
||||
"schema": {"additionalItems": false},
|
||||
"tests": [
|
||||
{
|
||||
"description":
|
||||
"items defaults to empty schema so everything is valid",
|
||||
"data": [ 1, 2, 3, 4, 5 ],
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "ignores non-arrays",
|
||||
"data": {"foo" : "bar"},
|
||||
"valid": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "additionalItems are allowed by default",
|
||||
"schema": {"items": []},
|
||||
"tests": [
|
||||
{
|
||||
"description": "only the first items are validated",
|
||||
"data": [1, "foo", false],
|
||||
"valid": true
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
@ -1,88 +1,88 @@
|
||||
[
|
||||
{
|
||||
"description":
|
||||
"additionalProperties being false does not allow other properties",
|
||||
"schema": {
|
||||
"properties": {"foo": {}, "bar": {}},
|
||||
"patternProperties": { "^v": {} },
|
||||
"additionalProperties": false
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "no additional properties is valid",
|
||||
"data": {"foo": 1},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "an additional property is invalid",
|
||||
"data": {"foo" : 1, "bar" : 2, "quux" : "boom"},
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "ignores non-objects",
|
||||
"data": [1, 2, 3],
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "patternProperties are not additional properties",
|
||||
"data": {"foo":1, "vroom": 2},
|
||||
"valid": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description":
|
||||
"additionalProperties allows a schema which should validate",
|
||||
"schema": {
|
||||
"properties": {"foo": {}, "bar": {}},
|
||||
"additionalProperties": {"type": "boolean"}
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "no additional properties is valid",
|
||||
"data": {"foo": 1},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "an additional valid property is valid",
|
||||
"data": {"foo" : 1, "bar" : 2, "quux" : true},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "an additional invalid property is invalid",
|
||||
"data": {"foo" : 1, "bar" : 2, "quux" : 12},
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description":
|
||||
"additionalProperties can exist by itself",
|
||||
"schema": {
|
||||
"additionalProperties": {"type": "boolean"}
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "an additional valid property is valid",
|
||||
"data": {"foo" : true},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "an additional invalid property is invalid",
|
||||
"data": {"foo" : 1},
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "additionalProperties are allowed by default",
|
||||
"schema": {"properties": {"foo": {}, "bar": {}}},
|
||||
"tests": [
|
||||
{
|
||||
"description": "additional properties are allowed",
|
||||
"data": {"foo": 1, "bar": 2, "quux": true},
|
||||
"valid": true
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
[
|
||||
{
|
||||
"description":
|
||||
"additionalProperties being false does not allow other properties",
|
||||
"schema": {
|
||||
"properties": {"foo": {}, "bar": {}},
|
||||
"patternProperties": { "^v": {} },
|
||||
"additionalProperties": false
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "no additional properties is valid",
|
||||
"data": {"foo": 1},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "an additional property is invalid",
|
||||
"data": {"foo" : 1, "bar" : 2, "quux" : "boom"},
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "ignores non-objects",
|
||||
"data": [1, 2, 3],
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "patternProperties are not additional properties",
|
||||
"data": {"foo":1, "vroom": 2},
|
||||
"valid": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description":
|
||||
"additionalProperties allows a schema which should validate",
|
||||
"schema": {
|
||||
"properties": {"foo": {}, "bar": {}},
|
||||
"additionalProperties": {"type": "boolean"}
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "no additional properties is valid",
|
||||
"data": {"foo": 1},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "an additional valid property is valid",
|
||||
"data": {"foo" : 1, "bar" : 2, "quux" : true},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "an additional invalid property is invalid",
|
||||
"data": {"foo" : 1, "bar" : 2, "quux" : 12},
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description":
|
||||
"additionalProperties can exist by itself",
|
||||
"schema": {
|
||||
"additionalProperties": {"type": "boolean"}
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "an additional valid property is valid",
|
||||
"data": {"foo" : true},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "an additional invalid property is invalid",
|
||||
"data": {"foo" : 1},
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "additionalProperties are allowed by default",
|
||||
"schema": {"properties": {"foo": {}, "bar": {}}},
|
||||
"tests": [
|
||||
{
|
||||
"description": "additional properties are allowed",
|
||||
"data": {"foo": 1, "bar": 2, "quux": true},
|
||||
"valid": true
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
@ -1,49 +1,49 @@
|
||||
[
|
||||
{
|
||||
"description": "invalid type for default",
|
||||
"schema": {
|
||||
"properties": {
|
||||
"foo": {
|
||||
"type": "integer",
|
||||
"default": []
|
||||
}
|
||||
}
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "valid when property is specified",
|
||||
"data": {"foo": 13},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "still valid when the invalid default is used",
|
||||
"data": {},
|
||||
"valid": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "invalid string value for default",
|
||||
"schema": {
|
||||
"properties": {
|
||||
"bar": {
|
||||
"type": "string",
|
||||
"minLength": 4,
|
||||
"default": "bad"
|
||||
}
|
||||
}
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "valid when property is specified",
|
||||
"data": {"bar": "good"},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "still valid when the invalid default is used",
|
||||
"data": {},
|
||||
"valid": true
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
[
|
||||
{
|
||||
"description": "invalid type for default",
|
||||
"schema": {
|
||||
"properties": {
|
||||
"foo": {
|
||||
"type": "integer",
|
||||
"default": []
|
||||
}
|
||||
}
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "valid when property is specified",
|
||||
"data": {"foo": 13},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "still valid when the invalid default is used",
|
||||
"data": {},
|
||||
"valid": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "invalid string value for default",
|
||||
"schema": {
|
||||
"properties": {
|
||||
"bar": {
|
||||
"type": "string",
|
||||
"minLength": 4,
|
||||
"default": "bad"
|
||||
}
|
||||
}
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "valid when property is specified",
|
||||
"data": {"bar": "good"},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "still valid when the invalid default is used",
|
||||
"data": {},
|
||||
"valid": true
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
@ -1,108 +1,108 @@
|
||||
[
|
||||
{
|
||||
"description": "dependencies",
|
||||
"schema": {
|
||||
"dependencies": {"bar": "foo"}
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "neither",
|
||||
"data": {},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "nondependant",
|
||||
"data": {"foo": 1},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "with dependency",
|
||||
"data": {"foo": 1, "bar": 2},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "missing dependency",
|
||||
"data": {"bar": 2},
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "ignores non-objects",
|
||||
"data": "foo",
|
||||
"valid": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "multiple dependencies",
|
||||
"schema": {
|
||||
"dependencies": {"quux": ["foo", "bar"]}
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "neither",
|
||||
"data": {},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "nondependants",
|
||||
"data": {"foo": 1, "bar": 2},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "with dependencies",
|
||||
"data": {"foo": 1, "bar": 2, "quux": 3},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "missing dependency",
|
||||
"data": {"foo": 1, "quux": 2},
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "missing other dependency",
|
||||
"data": {"bar": 1, "quux": 2},
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "missing both dependencies",
|
||||
"data": {"quux": 1},
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "multiple dependencies subschema",
|
||||
"schema": {
|
||||
"dependencies": {
|
||||
"bar": {
|
||||
"properties": {
|
||||
"foo": {"type": "integer"},
|
||||
"bar": {"type": "integer"}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "valid",
|
||||
"data": {"foo": 1, "bar": 2},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "wrong type",
|
||||
"data": {"foo": "quux", "bar": 2},
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "wrong type other",
|
||||
"data": {"foo": 2, "bar": "quux"},
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "wrong type both",
|
||||
"data": {"foo": "quux", "bar": "quux"},
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
[
|
||||
{
|
||||
"description": "dependencies",
|
||||
"schema": {
|
||||
"dependencies": {"bar": "foo"}
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "neither",
|
||||
"data": {},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "nondependant",
|
||||
"data": {"foo": 1},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "with dependency",
|
||||
"data": {"foo": 1, "bar": 2},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "missing dependency",
|
||||
"data": {"bar": 2},
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "ignores non-objects",
|
||||
"data": "foo",
|
||||
"valid": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "multiple dependencies",
|
||||
"schema": {
|
||||
"dependencies": {"quux": ["foo", "bar"]}
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "neither",
|
||||
"data": {},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "nondependants",
|
||||
"data": {"foo": 1, "bar": 2},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "with dependencies",
|
||||
"data": {"foo": 1, "bar": 2, "quux": 3},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "missing dependency",
|
||||
"data": {"foo": 1, "quux": 2},
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "missing other dependency",
|
||||
"data": {"bar": 1, "quux": 2},
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "missing both dependencies",
|
||||
"data": {"quux": 1},
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "multiple dependencies subschema",
|
||||
"schema": {
|
||||
"dependencies": {
|
||||
"bar": {
|
||||
"properties": {
|
||||
"foo": {"type": "integer"},
|
||||
"bar": {"type": "integer"}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "valid",
|
||||
"data": {"foo": 1, "bar": 2},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "wrong type",
|
||||
"data": {"foo": "quux", "bar": 2},
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "wrong type other",
|
||||
"data": {"foo": 2, "bar": "quux"},
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "wrong type both",
|
||||
"data": {"foo": "quux", "bar": "quux"},
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
@ -1,80 +1,80 @@
|
||||
[
|
||||
{
|
||||
"description": "disallow",
|
||||
"schema": {
|
||||
"disallow": "integer"
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "allowed",
|
||||
"data": "foo",
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "disallowed",
|
||||
"data": 1,
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "multiple disallow",
|
||||
"schema": {
|
||||
"disallow": ["integer", "boolean"]
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "valid",
|
||||
"data": "foo",
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "mismatch",
|
||||
"data": 1,
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "other mismatch",
|
||||
"data": true,
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "multiple disallow subschema",
|
||||
"schema": {
|
||||
"disallow":
|
||||
["string",
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"foo": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}]
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "match",
|
||||
"data": 1,
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "other match",
|
||||
"data": {"foo": 1},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "mismatch",
|
||||
"data": "foo",
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "other mismatch",
|
||||
"data": {"foo": "bar"},
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
[
|
||||
{
|
||||
"description": "disallow",
|
||||
"schema": {
|
||||
"disallow": "integer"
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "allowed",
|
||||
"data": "foo",
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "disallowed",
|
||||
"data": 1,
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "multiple disallow",
|
||||
"schema": {
|
||||
"disallow": ["integer", "boolean"]
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "valid",
|
||||
"data": "foo",
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "mismatch",
|
||||
"data": 1,
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "other mismatch",
|
||||
"data": true,
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "multiple disallow subschema",
|
||||
"schema": {
|
||||
"disallow":
|
||||
["string",
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"foo": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}]
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "match",
|
||||
"data": 1,
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "other match",
|
||||
"data": {"foo": 1},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "mismatch",
|
||||
"data": "foo",
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "other mismatch",
|
||||
"data": {"foo": "bar"},
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
@ -1,60 +1,60 @@
|
||||
[
|
||||
{
|
||||
"description": "by int",
|
||||
"schema": {"divisibleBy": 2},
|
||||
"tests": [
|
||||
{
|
||||
"description": "int by int",
|
||||
"data": 10,
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "int by int fail",
|
||||
"data": 7,
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "ignores non-numbers",
|
||||
"data": "foo",
|
||||
"valid": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "by number",
|
||||
"schema": {"divisibleBy": 1.5},
|
||||
"tests": [
|
||||
{
|
||||
"description": "zero is divisible by anything (except 0)",
|
||||
"data": 0,
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "4.5 is divisible by 1.5",
|
||||
"data": 4.5,
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "35 is not divisible by 1.5",
|
||||
"data": 35,
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "by small number",
|
||||
"schema": {"divisibleBy": 0.0001},
|
||||
"tests": [
|
||||
{
|
||||
"description": "0.0075 is divisible by 0.0001",
|
||||
"data": 0.0075,
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "0.00751 is not divisible by 0.0001",
|
||||
"data": 0.00751,
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
[
|
||||
{
|
||||
"description": "by int",
|
||||
"schema": {"divisibleBy": 2},
|
||||
"tests": [
|
||||
{
|
||||
"description": "int by int",
|
||||
"data": 10,
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "int by int fail",
|
||||
"data": 7,
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "ignores non-numbers",
|
||||
"data": "foo",
|
||||
"valid": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "by number",
|
||||
"schema": {"divisibleBy": 1.5},
|
||||
"tests": [
|
||||
{
|
||||
"description": "zero is divisible by anything (except 0)",
|
||||
"data": 0,
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "4.5 is divisible by 1.5",
|
||||
"data": 4.5,
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "35 is not divisible by 1.5",
|
||||
"data": 35,
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "by small number",
|
||||
"schema": {"divisibleBy": 0.0001},
|
||||
"tests": [
|
||||
{
|
||||
"description": "0.0075 is divisible by 0.0001",
|
||||
"data": 0.0075,
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "0.00751 is not divisible by 0.0001",
|
||||
"data": 0.00751,
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
@ -1,71 +1,71 @@
|
||||
[
|
||||
{
|
||||
"description": "simple enum validation",
|
||||
"schema": {"enum": [1, 2, 3]},
|
||||
"tests": [
|
||||
{
|
||||
"description": "one of the enum is valid",
|
||||
"data": 1,
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "something else is invalid",
|
||||
"data": 4,
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "heterogeneous enum validation",
|
||||
"schema": {"enum": [6, "foo", [], true, {"foo": 12}]},
|
||||
"tests": [
|
||||
{
|
||||
"description": "one of the enum is valid",
|
||||
"data": [],
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "something else is invalid",
|
||||
"data": null,
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "objects are deep compared",
|
||||
"data": {"foo": false},
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "enums in properties",
|
||||
"schema": {
|
||||
"type":"object",
|
||||
"properties": {
|
||||
"foo": {"enum":["foo"]},
|
||||
"bar": {"enum":["bar"], "required":true}
|
||||
}
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "both properties are valid",
|
||||
"data": {"foo":"foo", "bar":"bar"},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "missing optional property is valid",
|
||||
"data": {"bar":"bar"},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "missing required property is invalid",
|
||||
"data": {"foo":"foo"},
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "missing all properties is invalid",
|
||||
"data": {},
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
[
|
||||
{
|
||||
"description": "simple enum validation",
|
||||
"schema": {"enum": [1, 2, 3]},
|
||||
"tests": [
|
||||
{
|
||||
"description": "one of the enum is valid",
|
||||
"data": 1,
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "something else is invalid",
|
||||
"data": 4,
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "heterogeneous enum validation",
|
||||
"schema": {"enum": [6, "foo", [], true, {"foo": 12}]},
|
||||
"tests": [
|
||||
{
|
||||
"description": "one of the enum is valid",
|
||||
"data": [],
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "something else is invalid",
|
||||
"data": null,
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "objects are deep compared",
|
||||
"data": {"foo": false},
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "enums in properties",
|
||||
"schema": {
|
||||
"type":"object",
|
||||
"properties": {
|
||||
"foo": {"enum":["foo"]},
|
||||
"bar": {"enum":["bar"], "required":true}
|
||||
}
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "both properties are valid",
|
||||
"data": {"foo":"foo", "bar":"bar"},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "missing optional property is valid",
|
||||
"data": {"bar":"bar"},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "missing required property is invalid",
|
||||
"data": {"foo":"foo"},
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "missing all properties is invalid",
|
||||
"data": {},
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
@ -1,94 +1,94 @@
|
||||
[
|
||||
{
|
||||
"description": "extends",
|
||||
"schema": {
|
||||
"properties": {"bar": {"type": "integer", "required": true}},
|
||||
"extends": {
|
||||
"properties": {
|
||||
"foo": {"type": "string", "required": true}
|
||||
}
|
||||
}
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "extends",
|
||||
"data": {"foo": "baz", "bar": 2},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "mismatch extends",
|
||||
"data": {"foo": "baz"},
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "mismatch extended",
|
||||
"data": {"bar": 2},
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "wrong type",
|
||||
"data": {"foo": "baz", "bar": "quux"},
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "multiple extends",
|
||||
"schema": {
|
||||
"properties": {"bar": {"type": "integer", "required": true}},
|
||||
"extends" : [
|
||||
{
|
||||
"properties": {
|
||||
"foo": {"type": "string", "required": true}
|
||||
}
|
||||
},
|
||||
{
|
||||
"properties": {
|
||||
"baz": {"type": "null", "required": true}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "valid",
|
||||
"data": {"foo": "quux", "bar": 2, "baz": null},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "mismatch first extends",
|
||||
"data": {"bar": 2, "baz": null},
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "mismatch second extends",
|
||||
"data": {"foo": "quux", "bar": 2},
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "mismatch both",
|
||||
"data": {"bar": 2},
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "extends simple types",
|
||||
"schema": {
|
||||
"minimum": 20,
|
||||
"extends": {"maximum": 30}
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "valid",
|
||||
"data": 25,
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "mismatch extends",
|
||||
"data": 35,
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
[
|
||||
{
|
||||
"description": "extends",
|
||||
"schema": {
|
||||
"properties": {"bar": {"type": "integer", "required": true}},
|
||||
"extends": {
|
||||
"properties": {
|
||||
"foo": {"type": "string", "required": true}
|
||||
}
|
||||
}
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "extends",
|
||||
"data": {"foo": "baz", "bar": 2},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "mismatch extends",
|
||||
"data": {"foo": "baz"},
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "mismatch extended",
|
||||
"data": {"bar": 2},
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "wrong type",
|
||||
"data": {"foo": "baz", "bar": "quux"},
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "multiple extends",
|
||||
"schema": {
|
||||
"properties": {"bar": {"type": "integer", "required": true}},
|
||||
"extends" : [
|
||||
{
|
||||
"properties": {
|
||||
"foo": {"type": "string", "required": true}
|
||||
}
|
||||
},
|
||||
{
|
||||
"properties": {
|
||||
"baz": {"type": "null", "required": true}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "valid",
|
||||
"data": {"foo": "quux", "bar": 2, "baz": null},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "mismatch first extends",
|
||||
"data": {"bar": 2, "baz": null},
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "mismatch second extends",
|
||||
"data": {"foo": "quux", "bar": 2},
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "mismatch both",
|
||||
"data": {"bar": 2},
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "extends simple types",
|
||||
"schema": {
|
||||
"minimum": 20,
|
||||
"extends": {"maximum": 30}
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "valid",
|
||||
"data": 25,
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "mismatch extends",
|
||||
"data": 35,
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
@ -1,46 +1,46 @@
|
||||
[
|
||||
{
|
||||
"description": "a schema given for items",
|
||||
"schema": {
|
||||
"items": {"type": "integer"}
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "valid items",
|
||||
"data": [ 1, 2, 3 ],
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "wrong type of items",
|
||||
"data": [1, "x"],
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "ignores non-arrays",
|
||||
"data": {"foo" : "bar"},
|
||||
"valid": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "an array of schemas for items",
|
||||
"schema": {
|
||||
"items": [
|
||||
{"type": "integer"},
|
||||
{"type": "string"}
|
||||
]
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "correct types",
|
||||
"data": [ 1, "foo" ],
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "wrong types",
|
||||
"data": [ "foo", 1 ],
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
[
|
||||
{
|
||||
"description": "a schema given for items",
|
||||
"schema": {
|
||||
"items": {"type": "integer"}
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "valid items",
|
||||
"data": [ 1, 2, 3 ],
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "wrong type of items",
|
||||
"data": [1, "x"],
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "ignores non-arrays",
|
||||
"data": {"foo" : "bar"},
|
||||
"valid": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "an array of schemas for items",
|
||||
"schema": {
|
||||
"items": [
|
||||
{"type": "integer"},
|
||||
{"type": "string"}
|
||||
]
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "correct types",
|
||||
"data": [ 1, "foo" ],
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "wrong types",
|
||||
"data": [ "foo", 1 ],
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
@ -1,28 +1,28 @@
|
||||
[
|
||||
{
|
||||
"description": "maxItems validation",
|
||||
"schema": {"maxItems": 2},
|
||||
"tests": [
|
||||
{
|
||||
"description": "shorter is valid",
|
||||
"data": [1],
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "exact length is valid",
|
||||
"data": [1, 2],
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "too long is invalid",
|
||||
"data": [1, 2, 3],
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "ignores non-arrays",
|
||||
"data": "foobar",
|
||||
"valid": true
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
[
|
||||
{
|
||||
"description": "maxItems validation",
|
||||
"schema": {"maxItems": 2},
|
||||
"tests": [
|
||||
{
|
||||
"description": "shorter is valid",
|
||||
"data": [1],
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "exact length is valid",
|
||||
"data": [1, 2],
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "too long is invalid",
|
||||
"data": [1, 2, 3],
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "ignores non-arrays",
|
||||
"data": "foobar",
|
||||
"valid": true
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
@ -1,33 +1,33 @@
|
||||
[
|
||||
{
|
||||
"description": "maxLength validation",
|
||||
"schema": {"maxLength": 2},
|
||||
"tests": [
|
||||
{
|
||||
"description": "shorter is valid",
|
||||
"data": "f",
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "exact length is valid",
|
||||
"data": "fo",
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "too long is invalid",
|
||||
"data": "foo",
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "ignores non-strings",
|
||||
"data": 10,
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "two supplementary Unicode code points is long enough",
|
||||
"data": "\uD83D\uDCA9\uD83D\uDCA9",
|
||||
"valid": true
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
[
|
||||
{
|
||||
"description": "maxLength validation",
|
||||
"schema": {"maxLength": 2},
|
||||
"tests": [
|
||||
{
|
||||
"description": "shorter is valid",
|
||||
"data": "f",
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "exact length is valid",
|
||||
"data": "fo",
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "too long is invalid",
|
||||
"data": "foo",
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "ignores non-strings",
|
||||
"data": 10,
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "two supplementary Unicode code points is long enough",
|
||||
"data": "\uD83D\uDCA9\uD83D\uDCA9",
|
||||
"valid": true
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
@ -1,42 +1,42 @@
|
||||
[
|
||||
{
|
||||
"description": "maximum validation",
|
||||
"schema": {"maximum": 3.0},
|
||||
"tests": [
|
||||
{
|
||||
"description": "below the maximum is valid",
|
||||
"data": 2.6,
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "above the maximum is invalid",
|
||||
"data": 3.5,
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "ignores non-numbers",
|
||||
"data": "x",
|
||||
"valid": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "exclusiveMaximum validation",
|
||||
"schema": {
|
||||
"maximum": 3.0,
|
||||
"exclusiveMaximum": true
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "below the maximum is still valid",
|
||||
"data": 2.2,
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "boundary point is invalid",
|
||||
"data": 3.0,
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
[
|
||||
{
|
||||
"description": "maximum validation",
|
||||
"schema": {"maximum": 3.0},
|
||||
"tests": [
|
||||
{
|
||||
"description": "below the maximum is valid",
|
||||
"data": 2.6,
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "above the maximum is invalid",
|
||||
"data": 3.5,
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "ignores non-numbers",
|
||||
"data": "x",
|
||||
"valid": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "exclusiveMaximum validation",
|
||||
"schema": {
|
||||
"maximum": 3.0,
|
||||
"exclusiveMaximum": true
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "below the maximum is still valid",
|
||||
"data": 2.2,
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "boundary point is invalid",
|
||||
"data": 3.0,
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
@ -1,28 +1,28 @@
|
||||
[
|
||||
{
|
||||
"description": "minItems validation",
|
||||
"schema": {"minItems": 1},
|
||||
"tests": [
|
||||
{
|
||||
"description": "longer is valid",
|
||||
"data": [1, 2],
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "exact length is valid",
|
||||
"data": [1],
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "too short is invalid",
|
||||
"data": [],
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "ignores non-arrays",
|
||||
"data": "",
|
||||
"valid": true
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
[
|
||||
{
|
||||
"description": "minItems validation",
|
||||
"schema": {"minItems": 1},
|
||||
"tests": [
|
||||
{
|
||||
"description": "longer is valid",
|
||||
"data": [1, 2],
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "exact length is valid",
|
||||
"data": [1],
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "too short is invalid",
|
||||
"data": [],
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "ignores non-arrays",
|
||||
"data": "",
|
||||
"valid": true
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
@ -1,33 +1,33 @@
|
||||
[
|
||||
{
|
||||
"description": "minLength validation",
|
||||
"schema": {"minLength": 2},
|
||||
"tests": [
|
||||
{
|
||||
"description": "longer is valid",
|
||||
"data": "foo",
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "exact length is valid",
|
||||
"data": "fo",
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "too short is invalid",
|
||||
"data": "f",
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "ignores non-strings",
|
||||
"data": 1,
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "one supplementary Unicode code point is not long enough",
|
||||
"data": "\uD83D\uDCA9",
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
[
|
||||
{
|
||||
"description": "minLength validation",
|
||||
"schema": {"minLength": 2},
|
||||
"tests": [
|
||||
{
|
||||
"description": "longer is valid",
|
||||
"data": "foo",
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "exact length is valid",
|
||||
"data": "fo",
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "too short is invalid",
|
||||
"data": "f",
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "ignores non-strings",
|
||||
"data": 1,
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "one supplementary Unicode code point is not long enough",
|
||||
"data": "\uD83D\uDCA9",
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
@ -1,42 +1,42 @@
|
||||
[
|
||||
{
|
||||
"description": "minimum validation",
|
||||
"schema": {"minimum": 1.1},
|
||||
"tests": [
|
||||
{
|
||||
"description": "above the minimum is valid",
|
||||
"data": 2.6,
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "below the minimum is invalid",
|
||||
"data": 0.6,
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "ignores non-numbers",
|
||||
"data": "x",
|
||||
"valid": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "exclusiveMinimum validation",
|
||||
"schema": {
|
||||
"minimum": 1.1,
|
||||
"exclusiveMinimum": true
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "above the minimum is still valid",
|
||||
"data": 1.2,
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "boundary point is invalid",
|
||||
"data": 1.1,
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
[
|
||||
{
|
||||
"description": "minimum validation",
|
||||
"schema": {"minimum": 1.1},
|
||||
"tests": [
|
||||
{
|
||||
"description": "above the minimum is valid",
|
||||
"data": 2.6,
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "below the minimum is invalid",
|
||||
"data": 0.6,
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "ignores non-numbers",
|
||||
"data": "x",
|
||||
"valid": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "exclusiveMinimum validation",
|
||||
"schema": {
|
||||
"minimum": 1.1,
|
||||
"exclusiveMinimum": true
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "above the minimum is still valid",
|
||||
"data": 1.2,
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "boundary point is invalid",
|
||||
"data": 1.1,
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
@ -1,107 +1,107 @@
|
||||
[
|
||||
{
|
||||
"description": "integer",
|
||||
"schema": {"type": "integer"},
|
||||
"tests": [
|
||||
{
|
||||
"description": "a bignum is an integer",
|
||||
"data": 12345678910111213141516171819202122232425262728293031,
|
||||
"valid": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "number",
|
||||
"schema": {"type": "number"},
|
||||
"tests": [
|
||||
{
|
||||
"description": "a bignum is a number",
|
||||
"data": 98249283749234923498293171823948729348710298301928331,
|
||||
"valid": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "integer",
|
||||
"schema": {"type": "integer"},
|
||||
"tests": [
|
||||
{
|
||||
"description": "a negative bignum is an integer",
|
||||
"data": -12345678910111213141516171819202122232425262728293031,
|
||||
"valid": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "number",
|
||||
"schema": {"type": "number"},
|
||||
"tests": [
|
||||
{
|
||||
"description": "a negative bignum is a number",
|
||||
"data": -98249283749234923498293171823948729348710298301928331,
|
||||
"valid": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "string",
|
||||
"schema": {"type": "string"},
|
||||
"tests": [
|
||||
{
|
||||
"description": "a bignum is not a string",
|
||||
"data": 98249283749234923498293171823948729348710298301928331,
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "integer comparison",
|
||||
"schema": {"maximum": 18446744073709551615},
|
||||
"tests": [
|
||||
{
|
||||
"description": "comparison works for high numbers",
|
||||
"data": 18446744073709551600,
|
||||
"valid": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "float comparison with high precision",
|
||||
"schema": {
|
||||
"maximum": 972783798187987123879878123.18878137,
|
||||
"exclusiveMaximum": true
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "comparison works for high numbers",
|
||||
"data": 972783798187987123879878123.188781371,
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "integer comparison",
|
||||
"schema": {"minimum": -18446744073709551615},
|
||||
"tests": [
|
||||
{
|
||||
"description": "comparison works for very negative numbers",
|
||||
"data": -18446744073709551600,
|
||||
"valid": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "float comparison with high precision on negative numbers",
|
||||
"schema": {
|
||||
"minimum": -972783798187987123879878123.18878137,
|
||||
"exclusiveMinimum": true
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "comparison works for very negative numbers",
|
||||
"data": -972783798187987123879878123.188781371,
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
[
|
||||
{
|
||||
"description": "integer",
|
||||
"schema": {"type": "integer"},
|
||||
"tests": [
|
||||
{
|
||||
"description": "a bignum is an integer",
|
||||
"data": 12345678910111213141516171819202122232425262728293031,
|
||||
"valid": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "number",
|
||||
"schema": {"type": "number"},
|
||||
"tests": [
|
||||
{
|
||||
"description": "a bignum is a number",
|
||||
"data": 98249283749234923498293171823948729348710298301928331,
|
||||
"valid": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "integer",
|
||||
"schema": {"type": "integer"},
|
||||
"tests": [
|
||||
{
|
||||
"description": "a negative bignum is an integer",
|
||||
"data": -12345678910111213141516171819202122232425262728293031,
|
||||
"valid": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "number",
|
||||
"schema": {"type": "number"},
|
||||
"tests": [
|
||||
{
|
||||
"description": "a negative bignum is a number",
|
||||
"data": -98249283749234923498293171823948729348710298301928331,
|
||||
"valid": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "string",
|
||||
"schema": {"type": "string"},
|
||||
"tests": [
|
||||
{
|
||||
"description": "a bignum is not a string",
|
||||
"data": 98249283749234923498293171823948729348710298301928331,
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "integer comparison",
|
||||
"schema": {"maximum": 18446744073709551615},
|
||||
"tests": [
|
||||
{
|
||||
"description": "comparison works for high numbers",
|
||||
"data": 18446744073709551600,
|
||||
"valid": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "float comparison with high precision",
|
||||
"schema": {
|
||||
"maximum": 972783798187987123879878123.18878137,
|
||||
"exclusiveMaximum": true
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "comparison works for high numbers",
|
||||
"data": 972783798187987123879878123.188781371,
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "integer comparison",
|
||||
"schema": {"minimum": -18446744073709551615},
|
||||
"tests": [
|
||||
{
|
||||
"description": "comparison works for very negative numbers",
|
||||
"data": -18446744073709551600,
|
||||
"valid": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "float comparison with high precision on negative numbers",
|
||||
"schema": {
|
||||
"minimum": -972783798187987123879878123.18878137,
|
||||
"exclusiveMinimum": true
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "comparison works for very negative numbers",
|
||||
"data": -972783798187987123879878123.188781371,
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
@ -1,222 +1,222 @@
|
||||
[
|
||||
{
|
||||
"description": "validation of regular expressions",
|
||||
"schema": {"format": "regex"},
|
||||
"tests": [
|
||||
{
|
||||
"description": "a valid regular expression",
|
||||
"data": "([abc])+\\s+$",
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "a regular expression with unclosed parens is invalid",
|
||||
"data": "^(abc]",
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "validation of date-time strings",
|
||||
"schema": {"format": "date-time"},
|
||||
"tests": [
|
||||
{
|
||||
"description": "a valid date-time string",
|
||||
"data": "1963-06-19T08:30:06.283185Z",
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "an invalid date-time string",
|
||||
"data": "06/19/1963 08:30:06 PST",
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "only RFC3339 not all of ISO 8601 are valid",
|
||||
"data": "2013-350T01:01:01",
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "validation of date strings",
|
||||
"schema": {"format": "date"},
|
||||
"tests": [
|
||||
{
|
||||
"description": "a valid date string",
|
||||
"data": "1963-06-19",
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "an invalid date string",
|
||||
"data": "06/19/1963",
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "validation of time strings",
|
||||
"schema": {"format": "time"},
|
||||
"tests": [
|
||||
{
|
||||
"description": "a valid time string",
|
||||
"data": "08:30:06",
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "an invalid time string",
|
||||
"data": "8:30 AM",
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "validation of URIs",
|
||||
"schema": {"format": "uri"},
|
||||
"tests": [
|
||||
{
|
||||
"description": "a valid URI",
|
||||
"data": "http://foo.bar/?baz=qux#quux",
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "a valid protocol-relative URI",
|
||||
"data": "//foo.bar/?baz=qux#quux",
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "an invalid URI",
|
||||
"data": "\\\\WINDOWS\\fileshare",
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "an invalid URI though valid URI reference",
|
||||
"data": "abc",
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "validation of e-mail addresses",
|
||||
"schema": {"format": "email"},
|
||||
"tests": [
|
||||
{
|
||||
"description": "a valid e-mail address",
|
||||
"data": "joe.bloggs@example.com",
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "an invalid e-mail address",
|
||||
"data": "2962",
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "validation of IP addresses",
|
||||
"schema": {"format": "ip-address"},
|
||||
"tests": [
|
||||
{
|
||||
"description": "a valid IP address",
|
||||
"data": "192.168.0.1",
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "an IP address with too many components",
|
||||
"data": "127.0.0.0.1",
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "an IP address with out-of-range values",
|
||||
"data": "256.256.256.256",
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "validation of IPv6 addresses",
|
||||
"schema": {"format": "ipv6"},
|
||||
"tests": [
|
||||
{
|
||||
"description": "a valid IPv6 address",
|
||||
"data": "::1",
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "an IPv6 address with out-of-range values",
|
||||
"data": "12345::",
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "an IPv6 address with too many components",
|
||||
"data": "1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1",
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "an IPv6 address containing illegal characters",
|
||||
"data": "::laptop",
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "validation of host names",
|
||||
"schema": {"format": "host-name"},
|
||||
"tests": [
|
||||
{
|
||||
"description": "a valid host name",
|
||||
"data": "www.example.com",
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "a host name starting with an illegal character",
|
||||
"data": "-a-host-name-that-starts-with--",
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "a host name containing illegal characters",
|
||||
"data": "not_a_valid_host_name",
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "a host name with a component too long",
|
||||
"data": "a-vvvvvvvvvvvvvvvveeeeeeeeeeeeeeeerrrrrrrrrrrrrrrryyyyyyyyyyyyyyyy-long-host-name-component",
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "validation of CSS colors",
|
||||
"schema": {"format": "color"},
|
||||
"tests": [
|
||||
{
|
||||
"description": "a valid CSS color name",
|
||||
"data": "fuchsia",
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "a valid six-digit CSS color code",
|
||||
"data": "#CC8899",
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "a valid three-digit CSS color code",
|
||||
"data": "#C89",
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "an invalid CSS color code",
|
||||
"data": "#00332520",
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "an invalid CSS color name",
|
||||
"data": "puce",
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "a CSS color name containing invalid characters",
|
||||
"data": "light_grayish_red-violet",
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
[
|
||||
{
|
||||
"description": "validation of regular expressions",
|
||||
"schema": {"format": "regex"},
|
||||
"tests": [
|
||||
{
|
||||
"description": "a valid regular expression",
|
||||
"data": "([abc])+\\s+$",
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "a regular expression with unclosed parens is invalid",
|
||||
"data": "^(abc]",
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "validation of date-time strings",
|
||||
"schema": {"format": "date-time"},
|
||||
"tests": [
|
||||
{
|
||||
"description": "a valid date-time string",
|
||||
"data": "1963-06-19T08:30:06.283185Z",
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "an invalid date-time string",
|
||||
"data": "06/19/1963 08:30:06 PST",
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "only RFC3339 not all of ISO 8601 are valid",
|
||||
"data": "2013-350T01:01:01",
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "validation of date strings",
|
||||
"schema": {"format": "date"},
|
||||
"tests": [
|
||||
{
|
||||
"description": "a valid date string",
|
||||
"data": "1963-06-19",
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "an invalid date string",
|
||||
"data": "06/19/1963",
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "validation of time strings",
|
||||
"schema": {"format": "time"},
|
||||
"tests": [
|
||||
{
|
||||
"description": "a valid time string",
|
||||
"data": "08:30:06",
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "an invalid time string",
|
||||
"data": "8:30 AM",
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "validation of URIs",
|
||||
"schema": {"format": "uri"},
|
||||
"tests": [
|
||||
{
|
||||
"description": "a valid URI",
|
||||
"data": "http://foo.bar/?baz=qux#quux",
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "a valid protocol-relative URI",
|
||||
"data": "//foo.bar/?baz=qux#quux",
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "an invalid URI",
|
||||
"data": "\\\\WINDOWS\\fileshare",
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "an invalid URI though valid URI reference",
|
||||
"data": "abc",
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "validation of e-mail addresses",
|
||||
"schema": {"format": "email"},
|
||||
"tests": [
|
||||
{
|
||||
"description": "a valid e-mail address",
|
||||
"data": "joe.bloggs@example.com",
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "an invalid e-mail address",
|
||||
"data": "2962",
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "validation of IP addresses",
|
||||
"schema": {"format": "ip-address"},
|
||||
"tests": [
|
||||
{
|
||||
"description": "a valid IP address",
|
||||
"data": "192.168.0.1",
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "an IP address with too many components",
|
||||
"data": "127.0.0.0.1",
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "an IP address with out-of-range values",
|
||||
"data": "256.256.256.256",
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "validation of IPv6 addresses",
|
||||
"schema": {"format": "ipv6"},
|
||||
"tests": [
|
||||
{
|
||||
"description": "a valid IPv6 address",
|
||||
"data": "::1",
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "an IPv6 address with out-of-range values",
|
||||
"data": "12345::",
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "an IPv6 address with too many components",
|
||||
"data": "1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1",
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "an IPv6 address containing illegal characters",
|
||||
"data": "::laptop",
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "validation of host names",
|
||||
"schema": {"format": "host-name"},
|
||||
"tests": [
|
||||
{
|
||||
"description": "a valid host name",
|
||||
"data": "www.example.com",
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "a host name starting with an illegal character",
|
||||
"data": "-a-host-name-that-starts-with--",
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "a host name containing illegal characters",
|
||||
"data": "not_a_valid_host_name",
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "a host name with a component too long",
|
||||
"data": "a-vvvvvvvvvvvvvvvveeeeeeeeeeeeeeeerrrrrrrrrrrrrrrryyyyyyyyyyyyyyyy-long-host-name-component",
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "validation of CSS colors",
|
||||
"schema": {"format": "color"},
|
||||
"tests": [
|
||||
{
|
||||
"description": "a valid CSS color name",
|
||||
"data": "fuchsia",
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "a valid six-digit CSS color code",
|
||||
"data": "#CC8899",
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "a valid three-digit CSS color code",
|
||||
"data": "#C89",
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "an invalid CSS color code",
|
||||
"data": "#00332520",
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "an invalid CSS color name",
|
||||
"data": "puce",
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "a CSS color name containing invalid characters",
|
||||
"data": "light_grayish_red-violet",
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
@ -1,18 +1,18 @@
|
||||
[
|
||||
{
|
||||
"description": "ECMA 262 regex dialect recognition",
|
||||
"schema": { "format": "regex" },
|
||||
"tests": [
|
||||
{
|
||||
"description": "[^] is a valid regex",
|
||||
"data": "[^]",
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "ECMA 262 has no support for lookbehind",
|
||||
"data": "(?<=foo)bar",
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
[
|
||||
{
|
||||
"description": "ECMA 262 regex dialect recognition",
|
||||
"schema": { "format": "regex" },
|
||||
"tests": [
|
||||
{
|
||||
"description": "[^] is a valid regex",
|
||||
"data": "[^]",
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "ECMA 262 has no support for lookbehind",
|
||||
"data": "(?<=foo)bar",
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
@ -1,15 +1,15 @@
|
||||
[
|
||||
{
|
||||
"description": "some languages do not distinguish between different types of numeric value",
|
||||
"schema": {
|
||||
"type": "integer"
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "a float is not an integer even without fractional part",
|
||||
"data": 1.0,
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
[
|
||||
{
|
||||
"description": "some languages do not distinguish between different types of numeric value",
|
||||
"schema": {
|
||||
"type": "integer"
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "a float is not an integer even without fractional part",
|
||||
"data": 1.0,
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
@ -1,34 +1,34 @@
|
||||
[
|
||||
{
|
||||
"description": "pattern validation",
|
||||
"schema": {"pattern": "^a*$"},
|
||||
"tests": [
|
||||
{
|
||||
"description": "a matching pattern is valid",
|
||||
"data": "aaa",
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "a non-matching pattern is invalid",
|
||||
"data": "abc",
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "ignores non-strings",
|
||||
"data": true,
|
||||
"valid": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "pattern is not anchored",
|
||||
"schema": {"pattern": "a+"},
|
||||
"tests": [
|
||||
{
|
||||
"description": "matches a substring",
|
||||
"data": "xxaayy",
|
||||
"valid": true
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
[
|
||||
{
|
||||
"description": "pattern validation",
|
||||
"schema": {"pattern": "^a*$"},
|
||||
"tests": [
|
||||
{
|
||||
"description": "a matching pattern is valid",
|
||||
"data": "aaa",
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "a non-matching pattern is invalid",
|
||||
"data": "abc",
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "ignores non-strings",
|
||||
"data": true,
|
||||
"valid": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "pattern is not anchored",
|
||||
"schema": {"pattern": "a+"},
|
||||
"tests": [
|
||||
{
|
||||
"description": "matches a substring",
|
||||
"data": "xxaayy",
|
||||
"valid": true
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
@ -1,110 +1,110 @@
|
||||
[
|
||||
{
|
||||
"description":
|
||||
"patternProperties validates properties matching a regex",
|
||||
"schema": {
|
||||
"patternProperties": {
|
||||
"f.*o": {"type": "integer"}
|
||||
}
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "a single valid match is valid",
|
||||
"data": {"foo": 1},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "multiple valid matches is valid",
|
||||
"data": {"foo": 1, "foooooo" : 2},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "a single invalid match is invalid",
|
||||
"data": {"foo": "bar", "fooooo": 2},
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "multiple invalid matches is invalid",
|
||||
"data": {"foo": "bar", "foooooo" : "baz"},
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "ignores non-objects",
|
||||
"data": 12,
|
||||
"valid": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "multiple simultaneous patternProperties are validated",
|
||||
"schema": {
|
||||
"patternProperties": {
|
||||
"a*": {"type": "integer"},
|
||||
"aaa*": {"maximum": 20}
|
||||
}
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "a single valid match is valid",
|
||||
"data": {"a": 21},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "a simultaneous match is valid",
|
||||
"data": {"aaaa": 18},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "multiple matches is valid",
|
||||
"data": {"a": 21, "aaaa": 18},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "an invalid due to one is invalid",
|
||||
"data": {"a": "bar"},
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "an invalid due to the other is invalid",
|
||||
"data": {"aaaa": 31},
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "an invalid due to both is invalid",
|
||||
"data": {"aaa": "foo", "aaaa": 31},
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "regexes are not anchored by default and are case sensitive",
|
||||
"schema": {
|
||||
"patternProperties": {
|
||||
"[0-9]{2,}": { "type": "boolean" },
|
||||
"X_": { "type": "string" }
|
||||
}
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "non recognized members are ignored",
|
||||
"data": { "answer 1": "42" },
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "recognized members are accounted for",
|
||||
"data": { "a31b": null },
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "regexes are case sensitive",
|
||||
"data": { "a_x_3": 3 },
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "regexes are case sensitive, 2",
|
||||
"data": { "a_X_3": 3 },
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
[
|
||||
{
|
||||
"description":
|
||||
"patternProperties validates properties matching a regex",
|
||||
"schema": {
|
||||
"patternProperties": {
|
||||
"f.*o": {"type": "integer"}
|
||||
}
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "a single valid match is valid",
|
||||
"data": {"foo": 1},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "multiple valid matches is valid",
|
||||
"data": {"foo": 1, "foooooo" : 2},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "a single invalid match is invalid",
|
||||
"data": {"foo": "bar", "fooooo": 2},
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "multiple invalid matches is invalid",
|
||||
"data": {"foo": "bar", "foooooo" : "baz"},
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "ignores non-objects",
|
||||
"data": 12,
|
||||
"valid": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "multiple simultaneous patternProperties are validated",
|
||||
"schema": {
|
||||
"patternProperties": {
|
||||
"a*": {"type": "integer"},
|
||||
"aaa*": {"maximum": 20}
|
||||
}
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "a single valid match is valid",
|
||||
"data": {"a": 21},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "a simultaneous match is valid",
|
||||
"data": {"aaaa": 18},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "multiple matches is valid",
|
||||
"data": {"a": 21, "aaaa": 18},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "an invalid due to one is invalid",
|
||||
"data": {"a": "bar"},
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "an invalid due to the other is invalid",
|
||||
"data": {"aaaa": 31},
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "an invalid due to both is invalid",
|
||||
"data": {"aaa": "foo", "aaaa": 31},
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "regexes are not anchored by default and are case sensitive",
|
||||
"schema": {
|
||||
"patternProperties": {
|
||||
"[0-9]{2,}": { "type": "boolean" },
|
||||
"X_": { "type": "string" }
|
||||
}
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "non recognized members are ignored",
|
||||
"data": { "answer 1": "42" },
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "recognized members are accounted for",
|
||||
"data": { "a31b": null },
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "regexes are case sensitive",
|
||||
"data": { "a_x_3": 3 },
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "regexes are case sensitive, 2",
|
||||
"data": { "a_X_3": 3 },
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
@ -1,92 +1,92 @@
|
||||
[
|
||||
{
|
||||
"description": "object properties validation",
|
||||
"schema": {
|
||||
"properties": {
|
||||
"foo": {"type": "integer"},
|
||||
"bar": {"type": "string"}
|
||||
}
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "both properties present and valid is valid",
|
||||
"data": {"foo": 1, "bar": "baz"},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "one property invalid is invalid",
|
||||
"data": {"foo": 1, "bar": {}},
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "both properties invalid is invalid",
|
||||
"data": {"foo": [], "bar": {}},
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "doesn't invalidate other properties",
|
||||
"data": {"quux": []},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "ignores non-objects",
|
||||
"data": [],
|
||||
"valid": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description":
|
||||
"properties, patternProperties, additionalProperties interaction",
|
||||
"schema": {
|
||||
"properties": {
|
||||
"foo": {"type": "array", "maxItems": 3},
|
||||
"bar": {"type": "array"}
|
||||
},
|
||||
"patternProperties": {"f.o": {"minItems": 2}},
|
||||
"additionalProperties": {"type": "integer"}
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "property validates property",
|
||||
"data": {"foo": [1, 2]},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "property invalidates property",
|
||||
"data": {"foo": [1, 2, 3, 4]},
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "patternProperty invalidates property",
|
||||
"data": {"foo": []},
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "patternProperty validates nonproperty",
|
||||
"data": {"fxo": [1, 2]},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "patternProperty invalidates nonproperty",
|
||||
"data": {"fxo": []},
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "additionalProperty ignores property",
|
||||
"data": {"bar": []},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "additionalProperty validates others",
|
||||
"data": {"quux": 3},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "additionalProperty invalidates others",
|
||||
"data": {"quux": "foo"},
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
[
|
||||
{
|
||||
"description": "object properties validation",
|
||||
"schema": {
|
||||
"properties": {
|
||||
"foo": {"type": "integer"},
|
||||
"bar": {"type": "string"}
|
||||
}
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "both properties present and valid is valid",
|
||||
"data": {"foo": 1, "bar": "baz"},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "one property invalid is invalid",
|
||||
"data": {"foo": 1, "bar": {}},
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "both properties invalid is invalid",
|
||||
"data": {"foo": [], "bar": {}},
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "doesn't invalidate other properties",
|
||||
"data": {"quux": []},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "ignores non-objects",
|
||||
"data": [],
|
||||
"valid": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description":
|
||||
"properties, patternProperties, additionalProperties interaction",
|
||||
"schema": {
|
||||
"properties": {
|
||||
"foo": {"type": "array", "maxItems": 3},
|
||||
"bar": {"type": "array"}
|
||||
},
|
||||
"patternProperties": {"f.o": {"minItems": 2}},
|
||||
"additionalProperties": {"type": "integer"}
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "property validates property",
|
||||
"data": {"foo": [1, 2]},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "property invalidates property",
|
||||
"data": {"foo": [1, 2, 3, 4]},
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "patternProperty invalidates property",
|
||||
"data": {"foo": []},
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "patternProperty validates nonproperty",
|
||||
"data": {"fxo": [1, 2]},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "patternProperty invalidates nonproperty",
|
||||
"data": {"fxo": []},
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "additionalProperty ignores property",
|
||||
"data": {"bar": []},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "additionalProperty validates others",
|
||||
"data": {"quux": 3},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "additionalProperty invalidates others",
|
||||
"data": {"quux": "foo"},
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
@ -1,159 +1,159 @@
|
||||
[
|
||||
{
|
||||
"description": "root pointer ref",
|
||||
"schema": {
|
||||
"properties": {
|
||||
"foo": {"$ref": "#"}
|
||||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "match",
|
||||
"data": {"foo": false},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "recursive match",
|
||||
"data": {"foo": {"foo": false}},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "mismatch",
|
||||
"data": {"bar": false},
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "recursive mismatch",
|
||||
"data": {"foo": {"bar": false}},
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "relative pointer ref to object",
|
||||
"schema": {
|
||||
"properties": {
|
||||
"foo": {"type": "integer"},
|
||||
"bar": {"$ref": "#/properties/foo"}
|
||||
}
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "match",
|
||||
"data": {"bar": 3},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "mismatch",
|
||||
"data": {"bar": true},
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "relative pointer ref to array",
|
||||
"schema": {
|
||||
"items": [
|
||||
{"type": "integer"},
|
||||
{"$ref": "#/items/0"}
|
||||
]
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "match array",
|
||||
"data": [1, 2],
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "mismatch array",
|
||||
"data": [1, "foo"],
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "escaped pointer ref",
|
||||
"schema": {
|
||||
"tilda~field": {"type": "integer"},
|
||||
"slash/field": {"type": "integer"},
|
||||
"percent%field": {"type": "integer"},
|
||||
"properties": {
|
||||
"tilda": {"$ref": "#/tilda~0field"},
|
||||
"slash": {"$ref": "#/slash~1field"},
|
||||
"percent": {"$ref": "#/percent%25field"}
|
||||
}
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "slash invalid",
|
||||
"data": {"slash": "aoeu"},
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "tilda invalid",
|
||||
"data": {"tilda": "aoeu"},
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "percent invalid",
|
||||
"data": {"percent": "aoeu"},
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "slash valid",
|
||||
"data": {"slash": 123},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "tilda valid",
|
||||
"data": {"tilda": 123},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "percent valid",
|
||||
"data": {"percent": 123},
|
||||
"valid": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "nested refs",
|
||||
"schema": {
|
||||
"definitions": {
|
||||
"a": {"type": "integer"},
|
||||
"b": {"$ref": "#/definitions/a"},
|
||||
"c": {"$ref": "#/definitions/b"}
|
||||
},
|
||||
"$ref": "#/definitions/c"
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "nested ref valid",
|
||||
"data": 5,
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "nested ref invalid",
|
||||
"data": "a",
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "remote ref, containing refs itself",
|
||||
"schema": {"$ref": "http://json-schema.org/draft-03/schema#"},
|
||||
"tests": [
|
||||
{
|
||||
"description": "remote ref valid",
|
||||
"data": {"items": {"type": "integer"}},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "remote ref invalid",
|
||||
"data": {"items": {"type": 1}},
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
[
|
||||
{
|
||||
"description": "root pointer ref",
|
||||
"schema": {
|
||||
"properties": {
|
||||
"foo": {"$ref": "#"}
|
||||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "match",
|
||||
"data": {"foo": false},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "recursive match",
|
||||
"data": {"foo": {"foo": false}},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "mismatch",
|
||||
"data": {"bar": false},
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "recursive mismatch",
|
||||
"data": {"foo": {"bar": false}},
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "relative pointer ref to object",
|
||||
"schema": {
|
||||
"properties": {
|
||||
"foo": {"type": "integer"},
|
||||
"bar": {"$ref": "#/properties/foo"}
|
||||
}
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "match",
|
||||
"data": {"bar": 3},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "mismatch",
|
||||
"data": {"bar": true},
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "relative pointer ref to array",
|
||||
"schema": {
|
||||
"items": [
|
||||
{"type": "integer"},
|
||||
{"$ref": "#/items/0"}
|
||||
]
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "match array",
|
||||
"data": [1, 2],
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "mismatch array",
|
||||
"data": [1, "foo"],
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "escaped pointer ref",
|
||||
"schema": {
|
||||
"tilda~field": {"type": "integer"},
|
||||
"slash/field": {"type": "integer"},
|
||||
"percent%field": {"type": "integer"},
|
||||
"properties": {
|
||||
"tilda": {"$ref": "#/tilda~0field"},
|
||||
"slash": {"$ref": "#/slash~1field"},
|
||||
"percent": {"$ref": "#/percent%25field"}
|
||||
}
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "slash invalid",
|
||||
"data": {"slash": "aoeu"},
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "tilda invalid",
|
||||
"data": {"tilda": "aoeu"},
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "percent invalid",
|
||||
"data": {"percent": "aoeu"},
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "slash valid",
|
||||
"data": {"slash": 123},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "tilda valid",
|
||||
"data": {"tilda": 123},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "percent valid",
|
||||
"data": {"percent": 123},
|
||||
"valid": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "nested refs",
|
||||
"schema": {
|
||||
"definitions": {
|
||||
"a": {"type": "integer"},
|
||||
"b": {"$ref": "#/definitions/a"},
|
||||
"c": {"$ref": "#/definitions/b"}
|
||||
},
|
||||
"$ref": "#/definitions/c"
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "nested ref valid",
|
||||
"data": 5,
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "nested ref invalid",
|
||||
"data": "a",
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "remote ref, containing refs itself",
|
||||
"schema": {"$ref": "http://json-schema.org/draft-03/schema#"},
|
||||
"tests": [
|
||||
{
|
||||
"description": "remote ref valid",
|
||||
"data": {"items": {"type": "integer"}},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "remote ref invalid",
|
||||
"data": {"items": {"type": 1}},
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
@ -1,74 +1,74 @@
|
||||
[
|
||||
{
|
||||
"description": "remote ref",
|
||||
"schema": {"$ref": "http://localhost:1234/integer.json"},
|
||||
"tests": [
|
||||
{
|
||||
"description": "remote ref valid",
|
||||
"data": 1,
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "remote ref invalid",
|
||||
"data": "a",
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "fragment within remote ref",
|
||||
"schema": {"$ref": "http://localhost:1234/subSchemas.json#/integer"},
|
||||
"tests": [
|
||||
{
|
||||
"description": "remote fragment valid",
|
||||
"data": 1,
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "remote fragment invalid",
|
||||
"data": "a",
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "ref within remote ref",
|
||||
"schema": {
|
||||
"$ref": "http://localhost:1234/subSchemas.json#/refToInteger"
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "ref within ref valid",
|
||||
"data": 1,
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "ref within ref invalid",
|
||||
"data": "a",
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "change resolution scope",
|
||||
"schema": {
|
||||
"id": "http://localhost:1234/",
|
||||
"items": {
|
||||
"id": "folder/",
|
||||
"items": {"$ref": "folderInteger.json"}
|
||||
}
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "changed scope ref valid",
|
||||
"data": [[1]],
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "changed scope ref invalid",
|
||||
"data": [["a"]],
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
[
|
||||
{
|
||||
"description": "remote ref",
|
||||
"schema": {"$ref": "http://localhost:1234/integer.json"},
|
||||
"tests": [
|
||||
{
|
||||
"description": "remote ref valid",
|
||||
"data": 1,
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "remote ref invalid",
|
||||
"data": "a",
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "fragment within remote ref",
|
||||
"schema": {"$ref": "http://localhost:1234/subSchemas.json#/integer"},
|
||||
"tests": [
|
||||
{
|
||||
"description": "remote fragment valid",
|
||||
"data": 1,
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "remote fragment invalid",
|
||||
"data": "a",
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "ref within remote ref",
|
||||
"schema": {
|
||||
"$ref": "http://localhost:1234/subSchemas.json#/refToInteger"
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "ref within ref valid",
|
||||
"data": 1,
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "ref within ref invalid",
|
||||
"data": "a",
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "change resolution scope",
|
||||
"schema": {
|
||||
"id": "http://localhost:1234/",
|
||||
"items": {
|
||||
"id": "folder/",
|
||||
"items": {"$ref": "folderInteger.json"}
|
||||
}
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "changed scope ref valid",
|
||||
"data": [[1]],
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "changed scope ref invalid",
|
||||
"data": [["a"]],
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
@ -1,53 +1,53 @@
|
||||
[
|
||||
{
|
||||
"description": "required validation",
|
||||
"schema": {
|
||||
"properties": {
|
||||
"foo": {"required" : true},
|
||||
"bar": {}
|
||||
}
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "present required property is valid",
|
||||
"data": {"foo": 1},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "non-present required property is invalid",
|
||||
"data": {"bar": 1},
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "required default validation",
|
||||
"schema": {
|
||||
"properties": {
|
||||
"foo": {}
|
||||
}
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "not required by default",
|
||||
"data": {},
|
||||
"valid": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "required explicitly false validation",
|
||||
"schema": {
|
||||
"properties": {
|
||||
"foo": {"required": false}
|
||||
}
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "not required if required is false",
|
||||
"data": {},
|
||||
"valid": true
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
[
|
||||
{
|
||||
"description": "required validation",
|
||||
"schema": {
|
||||
"properties": {
|
||||
"foo": {"required" : true},
|
||||
"bar": {}
|
||||
}
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "present required property is valid",
|
||||
"data": {"foo": 1},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "non-present required property is invalid",
|
||||
"data": {"bar": 1},
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "required default validation",
|
||||
"schema": {
|
||||
"properties": {
|
||||
"foo": {}
|
||||
}
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "not required by default",
|
||||
"data": {},
|
||||
"valid": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "required explicitly false validation",
|
||||
"schema": {
|
||||
"properties": {
|
||||
"foo": {"required": false}
|
||||
}
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "not required if required is false",
|
||||
"data": {},
|
||||
"valid": true
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
@ -1,474 +1,474 @@
|
||||
[
|
||||
{
|
||||
"description": "integer type matches integers",
|
||||
"schema": {"type": "integer"},
|
||||
"tests": [
|
||||
{
|
||||
"description": "an integer is an integer",
|
||||
"data": 1,
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "a float is not an integer",
|
||||
"data": 1.1,
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "a string is not an integer",
|
||||
"data": "foo",
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "an object is not an integer",
|
||||
"data": {},
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "an array is not an integer",
|
||||
"data": [],
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "a boolean is not an integer",
|
||||
"data": true,
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "null is not an integer",
|
||||
"data": null,
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "number type matches numbers",
|
||||
"schema": {"type": "number"},
|
||||
"tests": [
|
||||
{
|
||||
"description": "an integer is a number",
|
||||
"data": 1,
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "a float is a number",
|
||||
"data": 1.1,
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "a string is not a number",
|
||||
"data": "foo",
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "an object is not a number",
|
||||
"data": {},
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "an array is not a number",
|
||||
"data": [],
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "a boolean is not a number",
|
||||
"data": true,
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "null is not a number",
|
||||
"data": null,
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "string type matches strings",
|
||||
"schema": {"type": "string"},
|
||||
"tests": [
|
||||
{
|
||||
"description": "1 is not a string",
|
||||
"data": 1,
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "a float is not a string",
|
||||
"data": 1.1,
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "a string is a string",
|
||||
"data": "foo",
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "an object is not a string",
|
||||
"data": {},
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "an array is not a string",
|
||||
"data": [],
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "a boolean is not a string",
|
||||
"data": true,
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "null is not a string",
|
||||
"data": null,
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "object type matches objects",
|
||||
"schema": {"type": "object"},
|
||||
"tests": [
|
||||
{
|
||||
"description": "an integer is not an object",
|
||||
"data": 1,
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "a float is not an object",
|
||||
"data": 1.1,
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "a string is not an object",
|
||||
"data": "foo",
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "an object is an object",
|
||||
"data": {},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "an array is not an object",
|
||||
"data": [],
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "a boolean is not an object",
|
||||
"data": true,
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "null is not an object",
|
||||
"data": null,
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "array type matches arrays",
|
||||
"schema": {"type": "array"},
|
||||
"tests": [
|
||||
{
|
||||
"description": "an integer is not an array",
|
||||
"data": 1,
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "a float is not an array",
|
||||
"data": 1.1,
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "a string is not an array",
|
||||
"data": "foo",
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "an object is not an array",
|
||||
"data": {},
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "an array is an array",
|
||||
"data": [],
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "a boolean is not an array",
|
||||
"data": true,
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "null is not an array",
|
||||
"data": null,
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "boolean type matches booleans",
|
||||
"schema": {"type": "boolean"},
|
||||
"tests": [
|
||||
{
|
||||
"description": "an integer is not a boolean",
|
||||
"data": 1,
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "a float is not a boolean",
|
||||
"data": 1.1,
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "a string is not a boolean",
|
||||
"data": "foo",
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "an object is not a boolean",
|
||||
"data": {},
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "an array is not a boolean",
|
||||
"data": [],
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "a boolean is a boolean",
|
||||
"data": true,
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "null is not a boolean",
|
||||
"data": null,
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "null type matches only the null object",
|
||||
"schema": {"type": "null"},
|
||||
"tests": [
|
||||
{
|
||||
"description": "an integer is not null",
|
||||
"data": 1,
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "a float is not null",
|
||||
"data": 1.1,
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "a string is not null",
|
||||
"data": "foo",
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "an object is not null",
|
||||
"data": {},
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "an array is not null",
|
||||
"data": [],
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "a boolean is not null",
|
||||
"data": true,
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "null is null",
|
||||
"data": null,
|
||||
"valid": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "any type matches any type",
|
||||
"schema": {"type": "any"},
|
||||
"tests": [
|
||||
{
|
||||
"description": "any type includes integers",
|
||||
"data": 1,
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "any type includes float",
|
||||
"data": 1.1,
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "any type includes string",
|
||||
"data": "foo",
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "any type includes object",
|
||||
"data": {},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "any type includes array",
|
||||
"data": [],
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "any type includes boolean",
|
||||
"data": true,
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "any type includes null",
|
||||
"data": null,
|
||||
"valid": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "multiple types can be specified in an array",
|
||||
"schema": {"type": ["integer", "string"]},
|
||||
"tests": [
|
||||
{
|
||||
"description": "an integer is valid",
|
||||
"data": 1,
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "a string is valid",
|
||||
"data": "foo",
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "a float is invalid",
|
||||
"data": 1.1,
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "an object is invalid",
|
||||
"data": {},
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "an array is invalid",
|
||||
"data": [],
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "a boolean is invalid",
|
||||
"data": true,
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "null is invalid",
|
||||
"data": null,
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "types can include schemas",
|
||||
"schema": {
|
||||
"type": [
|
||||
"array",
|
||||
{"type": "object"}
|
||||
]
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "an integer is invalid",
|
||||
"data": 1,
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "a string is invalid",
|
||||
"data": "foo",
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "a float is invalid",
|
||||
"data": 1.1,
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "an object is valid",
|
||||
"data": {},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "an array is valid",
|
||||
"data": [],
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "a boolean is invalid",
|
||||
"data": true,
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "null is invalid",
|
||||
"data": null,
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description":
|
||||
"when types includes a schema it should fully validate the schema",
|
||||
"schema": {
|
||||
"type": [
|
||||
"integer",
|
||||
{
|
||||
"properties": {
|
||||
"foo": {"type": "null"}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "an integer is valid",
|
||||
"data": 1,
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "an object is valid only if it is fully valid",
|
||||
"data": {"foo": null},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "an object is invalid otherwise",
|
||||
"data": {"foo": "bar"},
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "types from separate schemas are merged",
|
||||
"schema": {
|
||||
"type": [
|
||||
{"type": ["string"]},
|
||||
{"type": ["array", "null"]}
|
||||
]
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "an integer is invalid",
|
||||
"data": 1,
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "a string is valid",
|
||||
"data": "foo",
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "an array is valid",
|
||||
"data": [1, 2, 3],
|
||||
"valid": true
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
[
|
||||
{
|
||||
"description": "integer type matches integers",
|
||||
"schema": {"type": "integer"},
|
||||
"tests": [
|
||||
{
|
||||
"description": "an integer is an integer",
|
||||
"data": 1,
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "a float is not an integer",
|
||||
"data": 1.1,
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "a string is not an integer",
|
||||
"data": "foo",
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "an object is not an integer",
|
||||
"data": {},
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "an array is not an integer",
|
||||
"data": [],
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "a boolean is not an integer",
|
||||
"data": true,
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "null is not an integer",
|
||||
"data": null,
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "number type matches numbers",
|
||||
"schema": {"type": "number"},
|
||||
"tests": [
|
||||
{
|
||||
"description": "an integer is a number",
|
||||
"data": 1,
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "a float is a number",
|
||||
"data": 1.1,
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "a string is not a number",
|
||||
"data": "foo",
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "an object is not a number",
|
||||
"data": {},
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "an array is not a number",
|
||||
"data": [],
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "a boolean is not a number",
|
||||
"data": true,
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "null is not a number",
|
||||
"data": null,
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "string type matches strings",
|
||||
"schema": {"type": "string"},
|
||||
"tests": [
|
||||
{
|
||||
"description": "1 is not a string",
|
||||
"data": 1,
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "a float is not a string",
|
||||
"data": 1.1,
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "a string is a string",
|
||||
"data": "foo",
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "an object is not a string",
|
||||
"data": {},
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "an array is not a string",
|
||||
"data": [],
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "a boolean is not a string",
|
||||
"data": true,
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "null is not a string",
|
||||
"data": null,
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "object type matches objects",
|
||||
"schema": {"type": "object"},
|
||||
"tests": [
|
||||
{
|
||||
"description": "an integer is not an object",
|
||||
"data": 1,
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "a float is not an object",
|
||||
"data": 1.1,
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "a string is not an object",
|
||||
"data": "foo",
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "an object is an object",
|
||||
"data": {},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "an array is not an object",
|
||||
"data": [],
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "a boolean is not an object",
|
||||
"data": true,
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "null is not an object",
|
||||
"data": null,
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "array type matches arrays",
|
||||
"schema": {"type": "array"},
|
||||
"tests": [
|
||||
{
|
||||
"description": "an integer is not an array",
|
||||
"data": 1,
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "a float is not an array",
|
||||
"data": 1.1,
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "a string is not an array",
|
||||
"data": "foo",
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "an object is not an array",
|
||||
"data": {},
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "an array is an array",
|
||||
"data": [],
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "a boolean is not an array",
|
||||
"data": true,
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "null is not an array",
|
||||
"data": null,
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "boolean type matches booleans",
|
||||
"schema": {"type": "boolean"},
|
||||
"tests": [
|
||||
{
|
||||
"description": "an integer is not a boolean",
|
||||
"data": 1,
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "a float is not a boolean",
|
||||
"data": 1.1,
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "a string is not a boolean",
|
||||
"data": "foo",
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "an object is not a boolean",
|
||||
"data": {},
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "an array is not a boolean",
|
||||
"data": [],
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "a boolean is a boolean",
|
||||
"data": true,
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "null is not a boolean",
|
||||
"data": null,
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "null type matches only the null object",
|
||||
"schema": {"type": "null"},
|
||||
"tests": [
|
||||
{
|
||||
"description": "an integer is not null",
|
||||
"data": 1,
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "a float is not null",
|
||||
"data": 1.1,
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "a string is not null",
|
||||
"data": "foo",
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "an object is not null",
|
||||
"data": {},
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "an array is not null",
|
||||
"data": [],
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "a boolean is not null",
|
||||
"data": true,
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "null is null",
|
||||
"data": null,
|
||||
"valid": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "any type matches any type",
|
||||
"schema": {"type": "any"},
|
||||
"tests": [
|
||||
{
|
||||
"description": "any type includes integers",
|
||||
"data": 1,
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "any type includes float",
|
||||
"data": 1.1,
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "any type includes string",
|
||||
"data": "foo",
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "any type includes object",
|
||||
"data": {},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "any type includes array",
|
||||
"data": [],
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "any type includes boolean",
|
||||
"data": true,
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "any type includes null",
|
||||
"data": null,
|
||||
"valid": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "multiple types can be specified in an array",
|
||||
"schema": {"type": ["integer", "string"]},
|
||||
"tests": [
|
||||
{
|
||||
"description": "an integer is valid",
|
||||
"data": 1,
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "a string is valid",
|
||||
"data": "foo",
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "a float is invalid",
|
||||
"data": 1.1,
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "an object is invalid",
|
||||
"data": {},
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "an array is invalid",
|
||||
"data": [],
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "a boolean is invalid",
|
||||
"data": true,
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "null is invalid",
|
||||
"data": null,
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "types can include schemas",
|
||||
"schema": {
|
||||
"type": [
|
||||
"array",
|
||||
{"type": "object"}
|
||||
]
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "an integer is invalid",
|
||||
"data": 1,
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "a string is invalid",
|
||||
"data": "foo",
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "a float is invalid",
|
||||
"data": 1.1,
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "an object is valid",
|
||||
"data": {},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "an array is valid",
|
||||
"data": [],
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "a boolean is invalid",
|
||||
"data": true,
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "null is invalid",
|
||||
"data": null,
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description":
|
||||
"when types includes a schema it should fully validate the schema",
|
||||
"schema": {
|
||||
"type": [
|
||||
"integer",
|
||||
{
|
||||
"properties": {
|
||||
"foo": {"type": "null"}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "an integer is valid",
|
||||
"data": 1,
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "an object is valid only if it is fully valid",
|
||||
"data": {"foo": null},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "an object is invalid otherwise",
|
||||
"data": {"foo": "bar"},
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "types from separate schemas are merged",
|
||||
"schema": {
|
||||
"type": [
|
||||
{"type": ["string"]},
|
||||
{"type": ["array", "null"]}
|
||||
]
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "an integer is invalid",
|
||||
"data": 1,
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "a string is valid",
|
||||
"data": "foo",
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "an array is valid",
|
||||
"data": [1, 2, 3],
|
||||
"valid": true
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
@ -1,79 +1,79 @@
|
||||
[
|
||||
{
|
||||
"description": "uniqueItems validation",
|
||||
"schema": {"uniqueItems": true},
|
||||
"tests": [
|
||||
{
|
||||
"description": "unique array of integers is valid",
|
||||
"data": [1, 2],
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "non-unique array of integers is invalid",
|
||||
"data": [1, 1],
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "numbers are unique if mathematically unequal",
|
||||
"data": [1.0, 1.00, 1],
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "unique array of objects is valid",
|
||||
"data": [{"foo": "bar"}, {"foo": "baz"}],
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "non-unique array of objects is invalid",
|
||||
"data": [{"foo": "bar"}, {"foo": "bar"}],
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "unique array of nested objects is valid",
|
||||
"data": [
|
||||
{"foo": {"bar" : {"baz" : true}}},
|
||||
{"foo": {"bar" : {"baz" : false}}}
|
||||
],
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "non-unique array of nested objects is invalid",
|
||||
"data": [
|
||||
{"foo": {"bar" : {"baz" : true}}},
|
||||
{"foo": {"bar" : {"baz" : true}}}
|
||||
],
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "unique array of arrays is valid",
|
||||
"data": [["foo"], ["bar"]],
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "non-unique array of arrays is invalid",
|
||||
"data": [["foo"], ["foo"]],
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "1 and true are unique",
|
||||
"data": [1, true],
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "0 and false are unique",
|
||||
"data": [0, false],
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "unique heterogeneous types are valid",
|
||||
"data": [{}, [1], true, null, 1],
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "non-unique heterogeneous types are invalid",
|
||||
"data": [{}, [1], true, null, {}, 1],
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
[
|
||||
{
|
||||
"description": "uniqueItems validation",
|
||||
"schema": {"uniqueItems": true},
|
||||
"tests": [
|
||||
{
|
||||
"description": "unique array of integers is valid",
|
||||
"data": [1, 2],
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "non-unique array of integers is invalid",
|
||||
"data": [1, 1],
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "numbers are unique if mathematically unequal",
|
||||
"data": [1.0, 1.00, 1],
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "unique array of objects is valid",
|
||||
"data": [{"foo": "bar"}, {"foo": "baz"}],
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "non-unique array of objects is invalid",
|
||||
"data": [{"foo": "bar"}, {"foo": "bar"}],
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "unique array of nested objects is valid",
|
||||
"data": [
|
||||
{"foo": {"bar" : {"baz" : true}}},
|
||||
{"foo": {"bar" : {"baz" : false}}}
|
||||
],
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "non-unique array of nested objects is invalid",
|
||||
"data": [
|
||||
{"foo": {"bar" : {"baz" : true}}},
|
||||
{"foo": {"bar" : {"baz" : true}}}
|
||||
],
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "unique array of arrays is valid",
|
||||
"data": [["foo"], ["bar"]],
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "non-unique array of arrays is invalid",
|
||||
"data": [["foo"], ["foo"]],
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "1 and true are unique",
|
||||
"data": [1, true],
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "0 and false are unique",
|
||||
"data": [0, false],
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "unique heterogeneous types are valid",
|
||||
"data": [{}, [1], true, null, 1],
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "non-unique heterogeneous types are invalid",
|
||||
"data": [{}, [1], true, null, {}, 1],
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
@ -1,82 +1,82 @@
|
||||
[
|
||||
{
|
||||
"description": "additionalItems as schema",
|
||||
"schema": {
|
||||
"items": [{}],
|
||||
"additionalItems": {"type": "integer"}
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "additional items match schema",
|
||||
"data": [ null, 2, 3, 4 ],
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "additional items do not match schema",
|
||||
"data": [ null, 2, 3, "foo" ],
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "items is schema, no additionalItems",
|
||||
"schema": {
|
||||
"items": {},
|
||||
"additionalItems": false
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "all items match schema",
|
||||
"data": [ 1, 2, 3, 4, 5 ],
|
||||
"valid": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "array of items with no additionalItems",
|
||||
"schema": {
|
||||
"items": [{}, {}, {}],
|
||||
"additionalItems": false
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "no additional items present",
|
||||
"data": [ 1, 2, 3 ],
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "additional items are not permitted",
|
||||
"data": [ 1, 2, 3, 4 ],
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "additionalItems as false without items",
|
||||
"schema": {"additionalItems": false},
|
||||
"tests": [
|
||||
{
|
||||
"description":
|
||||
"items defaults to empty schema so everything is valid",
|
||||
"data": [ 1, 2, 3, 4, 5 ],
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "ignores non-arrays",
|
||||
"data": {"foo" : "bar"},
|
||||
"valid": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "additionalItems are allowed by default",
|
||||
"schema": {"items": [{"type": "integer"}]},
|
||||
"tests": [
|
||||
{
|
||||
"description": "only the first item is validated",
|
||||
"data": [1, "foo", false],
|
||||
"valid": true
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
[
|
||||
{
|
||||
"description": "additionalItems as schema",
|
||||
"schema": {
|
||||
"items": [{}],
|
||||
"additionalItems": {"type": "integer"}
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "additional items match schema",
|
||||
"data": [ null, 2, 3, 4 ],
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "additional items do not match schema",
|
||||
"data": [ null, 2, 3, "foo" ],
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "items is schema, no additionalItems",
|
||||
"schema": {
|
||||
"items": {},
|
||||
"additionalItems": false
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "all items match schema",
|
||||
"data": [ 1, 2, 3, 4, 5 ],
|
||||
"valid": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "array of items with no additionalItems",
|
||||
"schema": {
|
||||
"items": [{}, {}, {}],
|
||||
"additionalItems": false
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "no additional items present",
|
||||
"data": [ 1, 2, 3 ],
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "additional items are not permitted",
|
||||
"data": [ 1, 2, 3, 4 ],
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "additionalItems as false without items",
|
||||
"schema": {"additionalItems": false},
|
||||
"tests": [
|
||||
{
|
||||
"description":
|
||||
"items defaults to empty schema so everything is valid",
|
||||
"data": [ 1, 2, 3, 4, 5 ],
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "ignores non-arrays",
|
||||
"data": {"foo" : "bar"},
|
||||
"valid": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "additionalItems are allowed by default",
|
||||
"schema": {"items": [{"type": "integer"}]},
|
||||
"tests": [
|
||||
{
|
||||
"description": "only the first item is validated",
|
||||
"data": [1, "foo", false],
|
||||
"valid": true
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
@ -1,88 +1,88 @@
|
||||
[
|
||||
{
|
||||
"description":
|
||||
"additionalProperties being false does not allow other properties",
|
||||
"schema": {
|
||||
"properties": {"foo": {}, "bar": {}},
|
||||
"patternProperties": { "^v": {} },
|
||||
"additionalProperties": false
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "no additional properties is valid",
|
||||
"data": {"foo": 1},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "an additional property is invalid",
|
||||
"data": {"foo" : 1, "bar" : 2, "quux" : "boom"},
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "ignores non-objects",
|
||||
"data": [1, 2, 3],
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "patternProperties are not additional properties",
|
||||
"data": {"foo":1, "vroom": 2},
|
||||
"valid": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description":
|
||||
"additionalProperties allows a schema which should validate",
|
||||
"schema": {
|
||||
"properties": {"foo": {}, "bar": {}},
|
||||
"additionalProperties": {"type": "boolean"}
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "no additional properties is valid",
|
||||
"data": {"foo": 1},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "an additional valid property is valid",
|
||||
"data": {"foo" : 1, "bar" : 2, "quux" : true},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "an additional invalid property is invalid",
|
||||
"data": {"foo" : 1, "bar" : 2, "quux" : 12},
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description":
|
||||
"additionalProperties can exist by itself",
|
||||
"schema": {
|
||||
"additionalProperties": {"type": "boolean"}
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "an additional valid property is valid",
|
||||
"data": {"foo" : true},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "an additional invalid property is invalid",
|
||||
"data": {"foo" : 1},
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "additionalProperties are allowed by default",
|
||||
"schema": {"properties": {"foo": {}, "bar": {}}},
|
||||
"tests": [
|
||||
{
|
||||
"description": "additional properties are allowed",
|
||||
"data": {"foo": 1, "bar": 2, "quux": true},
|
||||
"valid": true
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
[
|
||||
{
|
||||
"description":
|
||||
"additionalProperties being false does not allow other properties",
|
||||
"schema": {
|
||||
"properties": {"foo": {}, "bar": {}},
|
||||
"patternProperties": { "^v": {} },
|
||||
"additionalProperties": false
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "no additional properties is valid",
|
||||
"data": {"foo": 1},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "an additional property is invalid",
|
||||
"data": {"foo" : 1, "bar" : 2, "quux" : "boom"},
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "ignores non-objects",
|
||||
"data": [1, 2, 3],
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "patternProperties are not additional properties",
|
||||
"data": {"foo":1, "vroom": 2},
|
||||
"valid": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description":
|
||||
"additionalProperties allows a schema which should validate",
|
||||
"schema": {
|
||||
"properties": {"foo": {}, "bar": {}},
|
||||
"additionalProperties": {"type": "boolean"}
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "no additional properties is valid",
|
||||
"data": {"foo": 1},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "an additional valid property is valid",
|
||||
"data": {"foo" : 1, "bar" : 2, "quux" : true},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "an additional invalid property is invalid",
|
||||
"data": {"foo" : 1, "bar" : 2, "quux" : 12},
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description":
|
||||
"additionalProperties can exist by itself",
|
||||
"schema": {
|
||||
"additionalProperties": {"type": "boolean"}
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "an additional valid property is valid",
|
||||
"data": {"foo" : true},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "an additional invalid property is invalid",
|
||||
"data": {"foo" : 1},
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "additionalProperties are allowed by default",
|
||||
"schema": {"properties": {"foo": {}, "bar": {}}},
|
||||
"tests": [
|
||||
{
|
||||
"description": "additional properties are allowed",
|
||||
"data": {"foo": 1, "bar": 2, "quux": true},
|
||||
"valid": true
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
@ -1,112 +1,112 @@
|
||||
[
|
||||
{
|
||||
"description": "allOf",
|
||||
"schema": {
|
||||
"allOf": [
|
||||
{
|
||||
"properties": {
|
||||
"bar": {"type": "integer"}
|
||||
},
|
||||
"required": ["bar"]
|
||||
},
|
||||
{
|
||||
"properties": {
|
||||
"foo": {"type": "string"}
|
||||
},
|
||||
"required": ["foo"]
|
||||
}
|
||||
]
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "allOf",
|
||||
"data": {"foo": "baz", "bar": 2},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "mismatch second",
|
||||
"data": {"foo": "baz"},
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "mismatch first",
|
||||
"data": {"bar": 2},
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "wrong type",
|
||||
"data": {"foo": "baz", "bar": "quux"},
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "allOf with base schema",
|
||||
"schema": {
|
||||
"properties": {"bar": {"type": "integer"}},
|
||||
"required": ["bar"],
|
||||
"allOf" : [
|
||||
{
|
||||
"properties": {
|
||||
"foo": {"type": "string"}
|
||||
},
|
||||
"required": ["foo"]
|
||||
},
|
||||
{
|
||||
"properties": {
|
||||
"baz": {"type": "null"}
|
||||
},
|
||||
"required": ["baz"]
|
||||
}
|
||||
]
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "valid",
|
||||
"data": {"foo": "quux", "bar": 2, "baz": null},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "mismatch base schema",
|
||||
"data": {"foo": "quux", "baz": null},
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "mismatch first allOf",
|
||||
"data": {"bar": 2, "baz": null},
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "mismatch second allOf",
|
||||
"data": {"foo": "quux", "bar": 2},
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "mismatch both",
|
||||
"data": {"bar": 2},
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "allOf simple types",
|
||||
"schema": {
|
||||
"allOf": [
|
||||
{"maximum": 30},
|
||||
{"minimum": 20}
|
||||
]
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "valid",
|
||||
"data": 25,
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "mismatch one",
|
||||
"data": 35,
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
[
|
||||
{
|
||||
"description": "allOf",
|
||||
"schema": {
|
||||
"allOf": [
|
||||
{
|
||||
"properties": {
|
||||
"bar": {"type": "integer"}
|
||||
},
|
||||
"required": ["bar"]
|
||||
},
|
||||
{
|
||||
"properties": {
|
||||
"foo": {"type": "string"}
|
||||
},
|
||||
"required": ["foo"]
|
||||
}
|
||||
]
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "allOf",
|
||||
"data": {"foo": "baz", "bar": 2},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "mismatch second",
|
||||
"data": {"foo": "baz"},
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "mismatch first",
|
||||
"data": {"bar": 2},
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "wrong type",
|
||||
"data": {"foo": "baz", "bar": "quux"},
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "allOf with base schema",
|
||||
"schema": {
|
||||
"properties": {"bar": {"type": "integer"}},
|
||||
"required": ["bar"],
|
||||
"allOf" : [
|
||||
{
|
||||
"properties": {
|
||||
"foo": {"type": "string"}
|
||||
},
|
||||
"required": ["foo"]
|
||||
},
|
||||
{
|
||||
"properties": {
|
||||
"baz": {"type": "null"}
|
||||
},
|
||||
"required": ["baz"]
|
||||
}
|
||||
]
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "valid",
|
||||
"data": {"foo": "quux", "bar": 2, "baz": null},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "mismatch base schema",
|
||||
"data": {"foo": "quux", "baz": null},
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "mismatch first allOf",
|
||||
"data": {"bar": 2, "baz": null},
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "mismatch second allOf",
|
||||
"data": {"foo": "quux", "bar": 2},
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "mismatch both",
|
||||
"data": {"bar": 2},
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "allOf simple types",
|
||||
"schema": {
|
||||
"allOf": [
|
||||
{"maximum": 30},
|
||||
{"minimum": 20}
|
||||
]
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "valid",
|
||||
"data": 25,
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "mismatch one",
|
||||
"data": 35,
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
@ -1,68 +1,68 @@
|
||||
[
|
||||
{
|
||||
"description": "anyOf",
|
||||
"schema": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "integer"
|
||||
},
|
||||
{
|
||||
"minimum": 2
|
||||
}
|
||||
]
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "first anyOf valid",
|
||||
"data": 1,
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "second anyOf valid",
|
||||
"data": 2.5,
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "both anyOf valid",
|
||||
"data": 3,
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "neither anyOf valid",
|
||||
"data": 1.5,
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "anyOf with base schema",
|
||||
"schema": {
|
||||
"type": "string",
|
||||
"anyOf" : [
|
||||
{
|
||||
"maxLength": 2
|
||||
},
|
||||
{
|
||||
"minLength": 4
|
||||
}
|
||||
]
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "mismatch base schema",
|
||||
"data": 3,
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "one anyOf valid",
|
||||
"data": "foobar",
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "both anyOf invalid",
|
||||
"data": "foo",
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
[
|
||||
{
|
||||
"description": "anyOf",
|
||||
"schema": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "integer"
|
||||
},
|
||||
{
|
||||
"minimum": 2
|
||||
}
|
||||
]
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "first anyOf valid",
|
||||
"data": 1,
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "second anyOf valid",
|
||||
"data": 2.5,
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "both anyOf valid",
|
||||
"data": 3,
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "neither anyOf valid",
|
||||
"data": 1.5,
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "anyOf with base schema",
|
||||
"schema": {
|
||||
"type": "string",
|
||||
"anyOf" : [
|
||||
{
|
||||
"maxLength": 2
|
||||
},
|
||||
{
|
||||
"minLength": 4
|
||||
}
|
||||
]
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "mismatch base schema",
|
||||
"data": 3,
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "one anyOf valid",
|
||||
"data": "foobar",
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "both anyOf invalid",
|
||||
"data": "foo",
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
@ -1,49 +1,49 @@
|
||||
[
|
||||
{
|
||||
"description": "invalid type for default",
|
||||
"schema": {
|
||||
"properties": {
|
||||
"foo": {
|
||||
"type": "integer",
|
||||
"default": []
|
||||
}
|
||||
}
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "valid when property is specified",
|
||||
"data": {"foo": 13},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "still valid when the invalid default is used",
|
||||
"data": {},
|
||||
"valid": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "invalid string value for default",
|
||||
"schema": {
|
||||
"properties": {
|
||||
"bar": {
|
||||
"type": "string",
|
||||
"minLength": 4,
|
||||
"default": "bad"
|
||||
}
|
||||
}
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "valid when property is specified",
|
||||
"data": {"bar": "good"},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "still valid when the invalid default is used",
|
||||
"data": {},
|
||||
"valid": true
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
[
|
||||
{
|
||||
"description": "invalid type for default",
|
||||
"schema": {
|
||||
"properties": {
|
||||
"foo": {
|
||||
"type": "integer",
|
||||
"default": []
|
||||
}
|
||||
}
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "valid when property is specified",
|
||||
"data": {"foo": 13},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "still valid when the invalid default is used",
|
||||
"data": {},
|
||||
"valid": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "invalid string value for default",
|
||||
"schema": {
|
||||
"properties": {
|
||||
"bar": {
|
||||
"type": "string",
|
||||
"minLength": 4,
|
||||
"default": "bad"
|
||||
}
|
||||
}
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "valid when property is specified",
|
||||
"data": {"bar": "good"},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "still valid when the invalid default is used",
|
||||
"data": {},
|
||||
"valid": true
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
@ -1,32 +1,32 @@
|
||||
[
|
||||
{
|
||||
"description": "valid definition",
|
||||
"schema": {"$ref": "http://json-schema.org/draft-04/schema#"},
|
||||
"tests": [
|
||||
{
|
||||
"description": "valid definition schema",
|
||||
"data": {
|
||||
"definitions": {
|
||||
"foo": {"type": "integer"}
|
||||
}
|
||||
},
|
||||
"valid": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "invalid definition",
|
||||
"schema": {"$ref": "http://json-schema.org/draft-04/schema#"},
|
||||
"tests": [
|
||||
{
|
||||
"description": "invalid definition schema",
|
||||
"data": {
|
||||
"definitions": {
|
||||
"foo": {"type": 1}
|
||||
}
|
||||
},
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
[
|
||||
{
|
||||
"description": "valid definition",
|
||||
"schema": {"$ref": "http://json-schema.org/draft-04/schema#"},
|
||||
"tests": [
|
||||
{
|
||||
"description": "valid definition schema",
|
||||
"data": {
|
||||
"definitions": {
|
||||
"foo": {"type": "integer"}
|
||||
}
|
||||
},
|
||||
"valid": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "invalid definition",
|
||||
"schema": {"$ref": "http://json-schema.org/draft-04/schema#"},
|
||||
"tests": [
|
||||
{
|
||||
"description": "invalid definition schema",
|
||||
"data": {
|
||||
"definitions": {
|
||||
"foo": {"type": 1}
|
||||
}
|
||||
},
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
@ -1,113 +1,113 @@
|
||||
[
|
||||
{
|
||||
"description": "dependencies",
|
||||
"schema": {
|
||||
"dependencies": {"bar": ["foo"]}
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "neither",
|
||||
"data": {},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "nondependant",
|
||||
"data": {"foo": 1},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "with dependency",
|
||||
"data": {"foo": 1, "bar": 2},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "missing dependency",
|
||||
"data": {"bar": 2},
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "ignores non-objects",
|
||||
"data": "foo",
|
||||
"valid": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "multiple dependencies",
|
||||
"schema": {
|
||||
"dependencies": {"quux": ["foo", "bar"]}
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "neither",
|
||||
"data": {},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "nondependants",
|
||||
"data": {"foo": 1, "bar": 2},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "with dependencies",
|
||||
"data": {"foo": 1, "bar": 2, "quux": 3},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "missing dependency",
|
||||
"data": {"foo": 1, "quux": 2},
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "missing other dependency",
|
||||
"data": {"bar": 1, "quux": 2},
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "missing both dependencies",
|
||||
"data": {"quux": 1},
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "multiple dependencies subschema",
|
||||
"schema": {
|
||||
"dependencies": {
|
||||
"bar": {
|
||||
"properties": {
|
||||
"foo": {"type": "integer"},
|
||||
"bar": {"type": "integer"}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "valid",
|
||||
"data": {"foo": 1, "bar": 2},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "no dependency",
|
||||
"data": {"foo": "quux"},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "wrong type",
|
||||
"data": {"foo": "quux", "bar": 2},
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "wrong type other",
|
||||
"data": {"foo": 2, "bar": "quux"},
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "wrong type both",
|
||||
"data": {"foo": "quux", "bar": "quux"},
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
[
|
||||
{
|
||||
"description": "dependencies",
|
||||
"schema": {
|
||||
"dependencies": {"bar": ["foo"]}
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "neither",
|
||||
"data": {},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "nondependant",
|
||||
"data": {"foo": 1},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "with dependency",
|
||||
"data": {"foo": 1, "bar": 2},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "missing dependency",
|
||||
"data": {"bar": 2},
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "ignores non-objects",
|
||||
"data": "foo",
|
||||
"valid": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "multiple dependencies",
|
||||
"schema": {
|
||||
"dependencies": {"quux": ["foo", "bar"]}
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "neither",
|
||||
"data": {},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "nondependants",
|
||||
"data": {"foo": 1, "bar": 2},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "with dependencies",
|
||||
"data": {"foo": 1, "bar": 2, "quux": 3},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "missing dependency",
|
||||
"data": {"foo": 1, "quux": 2},
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "missing other dependency",
|
||||
"data": {"bar": 1, "quux": 2},
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "missing both dependencies",
|
||||
"data": {"quux": 1},
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "multiple dependencies subschema",
|
||||
"schema": {
|
||||
"dependencies": {
|
||||
"bar": {
|
||||
"properties": {
|
||||
"foo": {"type": "integer"},
|
||||
"bar": {"type": "integer"}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "valid",
|
||||
"data": {"foo": 1, "bar": 2},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "no dependency",
|
||||
"data": {"foo": "quux"},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "wrong type",
|
||||
"data": {"foo": "quux", "bar": 2},
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "wrong type other",
|
||||
"data": {"foo": 2, "bar": "quux"},
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "wrong type both",
|
||||
"data": {"foo": "quux", "bar": "quux"},
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
@ -1,72 +1,72 @@
|
||||
[
|
||||
{
|
||||
"description": "simple enum validation",
|
||||
"schema": {"enum": [1, 2, 3]},
|
||||
"tests": [
|
||||
{
|
||||
"description": "one of the enum is valid",
|
||||
"data": 1,
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "something else is invalid",
|
||||
"data": 4,
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "heterogeneous enum validation",
|
||||
"schema": {"enum": [6, "foo", [], true, {"foo": 12}]},
|
||||
"tests": [
|
||||
{
|
||||
"description": "one of the enum is valid",
|
||||
"data": [],
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "something else is invalid",
|
||||
"data": null,
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "objects are deep compared",
|
||||
"data": {"foo": false},
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "enums in properties",
|
||||
"schema": {
|
||||
"type":"object",
|
||||
"properties": {
|
||||
"foo": {"enum":["foo"]},
|
||||
"bar": {"enum":["bar"]}
|
||||
},
|
||||
"required": ["bar"]
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "both properties are valid",
|
||||
"data": {"foo":"foo", "bar":"bar"},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "missing optional property is valid",
|
||||
"data": {"bar":"bar"},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "missing required property is invalid",
|
||||
"data": {"foo":"foo"},
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "missing all properties is invalid",
|
||||
"data": {},
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
[
|
||||
{
|
||||
"description": "simple enum validation",
|
||||
"schema": {"enum": [1, 2, 3]},
|
||||
"tests": [
|
||||
{
|
||||
"description": "one of the enum is valid",
|
||||
"data": 1,
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "something else is invalid",
|
||||
"data": 4,
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "heterogeneous enum validation",
|
||||
"schema": {"enum": [6, "foo", [], true, {"foo": 12}]},
|
||||
"tests": [
|
||||
{
|
||||
"description": "one of the enum is valid",
|
||||
"data": [],
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "something else is invalid",
|
||||
"data": null,
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "objects are deep compared",
|
||||
"data": {"foo": false},
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "enums in properties",
|
||||
"schema": {
|
||||
"type":"object",
|
||||
"properties": {
|
||||
"foo": {"enum":["foo"]},
|
||||
"bar": {"enum":["bar"]}
|
||||
},
|
||||
"required": ["bar"]
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "both properties are valid",
|
||||
"data": {"foo":"foo", "bar":"bar"},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "missing optional property is valid",
|
||||
"data": {"bar":"bar"},
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "missing required property is invalid",
|
||||
"data": {"foo":"foo"},
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "missing all properties is invalid",
|
||||
"data": {},
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
@ -1,46 +1,46 @@
|
||||
[
|
||||
{
|
||||
"description": "a schema given for items",
|
||||
"schema": {
|
||||
"items": {"type": "integer"}
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "valid items",
|
||||
"data": [ 1, 2, 3 ],
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "wrong type of items",
|
||||
"data": [1, "x"],
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "ignores non-arrays",
|
||||
"data": {"foo" : "bar"},
|
||||
"valid": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "an array of schemas for items",
|
||||
"schema": {
|
||||
"items": [
|
||||
{"type": "integer"},
|
||||
{"type": "string"}
|
||||
]
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "correct types",
|
||||
"data": [ 1, "foo" ],
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "wrong types",
|
||||
"data": [ "foo", 1 ],
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
[
|
||||
{
|
||||
"description": "a schema given for items",
|
||||
"schema": {
|
||||
"items": {"type": "integer"}
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "valid items",
|
||||
"data": [ 1, 2, 3 ],
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "wrong type of items",
|
||||
"data": [1, "x"],
|
||||
"valid": false
|
||||
},
|
||||
{
|
||||
"description": "ignores non-arrays",
|
||||
"data": {"foo" : "bar"},
|
||||
"valid": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "an array of schemas for items",
|
||||
"schema": {
|
||||
"items": [
|
||||
{"type": "integer"},
|
||||
{"type": "string"}
|
||||
]
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "correct types",
|
||||
"data": [ 1, "foo" ],
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"description": "wrong types",
|
||||
"data": [ "foo", 1 ],
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user