Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package surgescript for openSUSE:Factory checked in at 2022-09-18 17:32:28 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/surgescript (Old) and /work/SRC/openSUSE:Factory/.surgescript.new.2083 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "surgescript" Sun Sep 18 17:32:28 2022 rev:2 rq:1004478 version:0.5.6 Changes: -------- --- /work/SRC/openSUSE:Factory/surgescript/surgescript.changes 2021-05-01 00:47:19.775283379 +0200 +++ /work/SRC/openSUSE:Factory/.surgescript.new.2083/surgescript.changes 2022-09-18 17:32:28.585815349 +0200 @@ -1,0 +2,13 @@ +Sat Sep 17 12:11:21 UTC 2022 - Martin Hauke <[email protected]> + +- Update to version 0.5.6 + * Improved the SurgeScript CLI with a time limit option, the + ability to run scripts from stdin and optional multithreading + support + * Added Emscripten support + * Updated docs + * General improvements +- Drop patch: + * surgescript-fix_nonvoid.patch + +------------------------------------------------------------------- Old: ---- surgescript-0.5.5.tar.gz surgescript-fix_nonvoid.patch New: ---- surgescript-0.5.6.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ surgescript.spec ++++++ --- /var/tmp/diff_new_pack.oWxjZX/_old 2022-09-18 17:32:29.369817637 +0200 +++ /var/tmp/diff_new_pack.oWxjZX/_new 2022-09-18 17:32:29.377817660 +0200 @@ -1,7 +1,7 @@ # # spec file for package surgescript # -# Copyright (c) 2021 SUSE LLC +# Copyright (c) 2022 SUSE LLC # Copyright (c) 2020 Artur Iwicki <[email protected]> # # All modifications and additions to the file contributed by third parties @@ -17,16 +17,14 @@ # -%define _sover 0_5_5 +%define _sover 0_5_6 Name: surgescript -Version: 0.5.5 +Version: 0.5.6 Release: 0 Summary: A scripting language for games License: Apache-2.0 URL: https://opensurge2d.org Source0: https://github.com/alemart/surgescript/archive/v%{version}/%{name}-%{version}.tar.gz -# PATCH-FIX-OPENSUSE surgescript-fix_nonvoid.patch -- https://github.com/alemart/surgescript/issues/5 -Patch0: surgescript-fix_nonvoid.patch BuildRequires: cmake BuildRequires: gcc-c++ BuildRequires: pkgconfig @@ -70,7 +68,7 @@ developing applications using %{name}. %prep -%autosetup -p1 +%setup -q %build %cmake \ ++++++ surgescript-0.5.5.tar.gz -> surgescript-0.5.6.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/surgescript-0.5.5/.github/FUNDING.yml new/surgescript-0.5.6/.github/FUNDING.yml --- old/surgescript-0.5.5/.github/FUNDING.yml 2021-01-22 19:42:07.000000000 +0100 +++ new/surgescript-0.5.6/.github/FUNDING.yml 2022-09-01 01:55:59.000000000 +0200 @@ -1,6 +1,6 @@ # These are supported funding model platforms -github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] +github: alemart # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] patreon: # Replace with a single Patreon username open_collective: # Replace with a single Open Collective username ko_fi: # Replace with a single Ko-fi username @@ -9,4 +9,4 @@ liberapay: # Replace with a single Liberapay username issuehunt: # Replace with a single IssueHunt username otechie: # Replace with a single Otechie username -custom: 'https://opensurge2d.org/contribute' # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] +custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/surgescript-0.5.5/.gitignore new/surgescript-0.5.6/.gitignore --- old/surgescript-0.5.5/.gitignore 2021-01-22 19:42:07.000000000 +0100 +++ new/surgescript-0.5.6/.gitignore 2022-09-01 01:55:59.000000000 +0200 @@ -9,6 +9,11 @@ !.vscode/launch.json !.vscode/extensions.json +# msvc +.vs/ +out/ +CMakeSettings.json + # vim # swap [._]*.s[a-v][a-z] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/surgescript-0.5.5/CHANGES.md new/surgescript-0.5.6/CHANGES.md --- old/surgescript-0.5.5/CHANGES.md 2021-01-22 19:42:07.000000000 +0100 +++ new/surgescript-0.5.6/CHANGES.md 2022-09-01 01:55:59.000000000 +0200 @@ -1,6 +1,14 @@ # Release Notes -## 0.5.5 - January 22nd, 2020 +## 0.5.6 - September 1st, 2022 + +* Improved the SurgeScript CLI with a time limit option, the ability to run scripts from stdin and optional multithreading support +* Added Visual Studio support (Cody Licorish) +* Added Emscripten support +* Updated docs +* General improvements + +## 0.5.5 - January 22nd, 2021 * Added the ability to pause the SurgeScript VM * Added utility macros for checking the SurgeScript version at compile time diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/surgescript-0.5.5/CMakeLists.txt new/surgescript-0.5.6/CMakeLists.txt --- old/surgescript-0.5.5/CMakeLists.txt 2021-01-22 19:42:07.000000000 +0100 +++ new/surgescript-0.5.6/CMakeLists.txt 2022-09-01 01:55:59.000000000 +0200 @@ -1,42 +1,40 @@ # ------------------------------------------------------------------------------ # SurgeScript # A scripting language for games -# Copyright 2016-2021 Alexandre Martins <alemartf(at)gmail(dot)com> +# Copyright 2016-2022 Alexandre Martins <alemartf(at)gmail(dot)com> # ------------------------------------------------------------------------------ # Project info cmake_minimum_required(VERSION 3.2) project( surgescript - VERSION 0.5.5 + VERSION 0.5.6 LANGUAGES C ) -set(PROJECT_YEARS "2016-2021") +include(GNUInstallDirs) +include(CheckLibraryExists) +set(PROJECT_YEARS "2016-2022") # Default config -set(CMAKE_C_STANDARD 99) +set(CMAKE_C_STANDARD 11) if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build: Debug | Release | MinSizeRel | RelWithDebInfo" FORCE) set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo") endif() -if(UNIX AND CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) - set(CMAKE_INSTALL_PREFIX "/usr" CACHE PATH "Install path prefix (prepended onto install directories)" FORCE) -endif() # User options option(WANT_SHARED "Build SurgeScript as a shared library" ON) option(WANT_STATIC "Build SurgeScript as a static library" ON) -option(WANT_EXECUTABLE "Build the surgescript executable" ON) -set(LIB_SUFFIX "" CACHE STRING "Suffix to append to 'lib' directories, e.g., '64'") # libs must be installed to "lib64" in some systems -set(PKGCONFIG_PATH "lib${LIB_SUFFIX}/pkgconfig" CACHE PATH "Destination folder of the pkg-config (.pc) file") +option(WANT_EXECUTABLE "Build the SurgeScript CLI" ON) +option(WANT_EXECUTABLE_MULTITHREAD "Enable multithreading on the SurgeScript CLI" ON) +set(PKGCONFIG_PATH "pkgconfig" CACHE PATH "Destination folder of the pkg-config (.pc) file") if(UNIX) - set(METAINFO_PATH "share/metainfo" CACHE PATH "Destination folder of the metainfo file") - set(ICON_PATH "share/pixmaps" CACHE PATH "Destination folder of the icon file") + set(METAINFO_PATH "metainfo" CACHE PATH "Destination folder of the metainfo file") + set(ICON_PATH "pixmaps" CACHE PATH "Destination folder of the icon file") endif() -# Output folder -set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}) -set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}) +# Library search +CHECK_LIBRARY_EXISTS(m sqrt "${CMAKE_SYSTEM_LIBRARY_PATH}" SURGESCRIPT_libm_EXISTS) # Sources set( @@ -113,6 +111,9 @@ src/surgescript.h ) +# Output folder +set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}) + # Generate files from templates function(generate_file TEMPLATE) configure_file(src/surgescript/${TEMPLATE}.in "${CMAKE_BINARY_DIR}/src/surgescript/${TEMPLATE}" @ONLY) @@ -124,7 +125,7 @@ set(LIB_LINKAGE "-static") endif() configure_file(src/surgescript/misc/surgescript.pc.in "${LIBRARY_OUTPUT_PATH}/surgescript${LIB_LINKAGE}.pc" @ONLY) - install(FILES "${LIBRARY_OUTPUT_PATH}/surgescript${LIB_LINKAGE}.pc" DESTINATION "${CMAKE_INSTALL_PREFIX}/${PKGCONFIG_PATH}") + install(FILES "${LIBRARY_OUTPUT_PATH}/surgescript${LIB_LINKAGE}.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR}/${PKGCONFIG_PATH}") endfunction() generate_file("misc/info.c") @@ -140,40 +141,62 @@ message(STATUS "Will build libsurgescript") generate_pc_file("shared") add_library(surgescript SHARED ${SURGESCRIPT_SOURCES} ${SURGESCRIPT_HEADERS}) - target_link_libraries(surgescript m) + if (SURGESCRIPT_libm_EXISTS) + target_link_libraries(surgescript m) + endif() set_target_properties(surgescript PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION ${LIB_SOVERSION}) - install(TARGETS surgescript DESTINATION "lib${LIB_SUFFIX}") + install(TARGETS surgescript DESTINATION "${CMAKE_INSTALL_LIBDIR}") endif() if(WANT_STATIC) message(STATUS "Will build libsurgescript-static") generate_pc_file("static") add_library(surgescript-static STATIC ${SURGESCRIPT_SOURCES} ${SURGESCRIPT_HEADERS}) - target_link_libraries(surgescript-static m) + if (SURGESCRIPT_libm_EXISTS) + target_link_libraries(surgescript-static m) + endif () set_target_properties(surgescript-static PROPERTIES VERSION ${PROJECT_VERSION}) - install(TARGETS surgescript-static DESTINATION "lib${LIB_SUFFIX}") + install(TARGETS surgescript-static DESTINATION "${CMAKE_INSTALL_LIBDIR}") endif() # Install headers -install(DIRECTORY src/ DESTINATION include FILES_MATCHING PATTERN "*.h") -install(DIRECTORY "${CMAKE_BINARY_DIR}/src/" DESTINATION include FILES_MATCHING PATTERN "*.h") +install(DIRECTORY src/ DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" FILES_MATCHING PATTERN "*.h") +install(DIRECTORY "${CMAKE_BINARY_DIR}/src/" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" FILES_MATCHING PATTERN "*.h") -# Build the executable +# Build the SurgeScript CLI if(WANT_EXECUTABLE) + message(STATUS "Will build the SurgeScript CLI") + # Set the appropriate lib set(LIBSURGESCRIPT "surgescript") if(WANT_STATIC AND (NOT WANT_SHARED OR WIN32)) set(LIBSURGESCRIPT "surgescript-static") endif() + # Use multithreading? + set(LIBTHREAD "") + set(ENABLE_THREADS 0) + if(WANT_EXECUTABLE_MULTITHREAD) + message(STATUS "Will use multithreading on the SurgeScript CLI") + + # hmmmm... + set(LIBTHREAD "pthread") + set(ENABLE_THREADS 1) + endif() + # Create the executable - message(STATUS "Will build surgescript") add_executable(surgescript.bin src/main.c) include_directories("${CMAKE_BINARY_DIR}/src") - target_link_libraries(surgescript.bin ${LIBSURGESCRIPT}) + target_compile_definitions(surgescript.bin PUBLIC ENABLE_THREADS=${ENABLE_THREADS}) + target_link_libraries(surgescript.bin ${LIBSURGESCRIPT} ${LIBTHREAD}) target_include_directories(surgescript.bin PRIVATE src) set_target_properties(surgescript.bin PROPERTIES OUTPUT_NAME surgescript) + # WebAssembly + if(EMSCRIPTEN) + target_link_options(surgescript.bin PRIVATE -Os --closure 1 -sMODULARIZE=1 -sMALLOC="emmalloc" -sEXPORTED_FUNCTIONS=["_main"]) # Reduce output size + endif() + # Windows icon if(WIN32 AND MINGW) if(NOT CMAKE_RC_COMPILER) @@ -185,12 +208,12 @@ # *nix metadata & icon if(UNIX) - file(TO_CMAKE_PATH "${CMAKE_INSTALL_PREFIX}/${ICON_PATH}/surgescript.png" ICON_FILEPATH) + file(TO_CMAKE_PATH "${CMAKE_INSTALL_DATADIR}/${ICON_PATH}/surgescript.png" ICON_FILEPATH) generate_file("misc/surgescript.appdata.xml") - install(FILES "${CMAKE_BINARY_DIR}/src/surgescript/misc/surgescript.appdata.xml" DESTINATION "${CMAKE_INSTALL_PREFIX}/${METAINFO_PATH}") - install(FILES src/surgescript/misc/surgescript.png DESTINATION "${CMAKE_INSTALL_PREFIX}/${ICON_PATH}") + install(FILES "${CMAKE_BINARY_DIR}/src/surgescript/misc/surgescript.appdata.xml" DESTINATION "${CMAKE_INSTALL_DATADIR}/${METAINFO_PATH}") + install(FILES src/surgescript/misc/surgescript.png DESTINATION "${CMAKE_INSTALL_DATADIR}/${ICON_PATH}") endif() # Installing the executable - install(TARGETS surgescript.bin DESTINATION bin) + install(TARGETS surgescript.bin DESTINATION "${CMAKE_INSTALL_BINDIR}") endif() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/surgescript-0.5.5/docs/engine/actor.md new/surgescript-0.5.6/docs/engine/actor.md --- old/surgescript-0.5.5/docs/engine/actor.md 2021-01-22 19:42:07.000000000 +0100 +++ new/surgescript-0.5.6/docs/engine/actor.md 2022-09-01 01:55:59.000000000 +0200 @@ -52,24 +52,12 @@ Reference to the Animation object of the Actor. -#### alpha - -`alpha`: number. - -Opacity value, ranging from zero (0% opaque) to one (100% opaque). Defaults to 1.0. - #### entity `entity`: object, read-only. The entity associated with this component. -#### offset - -`offset`: [Vector2](/engine/vector2) object. - -A *(x,y)* offset relative to the parent object. Defaults to zero. - #### hflip `hflip`: boolean. @@ -88,6 +76,50 @@ Should the actor be rendered? Defaults to `true`. +#### alpha + +`alpha`: number. + +Opacity value, ranging from zero (0% opaque) to one (100% opaque). Defaults to 1.0. + +#### offset + +`offset`: [Vector2](/engine/vector2) object. + +A *(x,y)* offset relative to the parent object. Defaults to zero. + +#### anchor + +`anchor`: [Vector2](/engine/vector2) object. + +A shortcut to `animation.anchor`. See also: [anchor](/engine/animation#anchor). + +*Available since:* Open Surge 0.6.0 + +#### hotSpot + +`hotSpot`: [Vector2](/engine/vector2) object. + +A shortcut to `animation.hotSpot`. See also: [hot spot](/engine/animation#hotspot). + +*Available since:* Open Surge 0.6.0. In versions prior to 0.6.0, you may get the hot spot using the [Animation](/engine/animation#hotspot) object. + +#### actionSpot + +`actionSpot`: [Vector2](/engine/vector2) object. + +A shortcut to `animation.actionSpot`. See also: [action spot](/engine/animation#actionspot). + +*Available since:* Open Surge 0.6.0 + +#### actionOffset + +`actionOffset`: [Vector2](/engine/vector2) object, read-only. + +A shortcut to `animation.actionOffset`. See also: [action offset](/engine/animation#actionoffset). + +*Available since:* Open Surge 0.6.0 + #### width `width`: number, read-only. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/surgescript-0.5.5/docs/engine/animation.md new/surgescript-0.5.6/docs/engine/animation.md --- old/surgescript-0.5.5/docs/engine/animation.md 2021-01-22 19:42:07.000000000 +0100 +++ new/surgescript-0.5.6/docs/engine/animation.md 2022-09-01 01:55:59.000000000 +0200 @@ -27,7 +27,7 @@ `id`: number. -The number of the current animation, defined in a .spr file. +The number of the animation, defined in a .spr file. #### sprite @@ -39,7 +39,7 @@ `exists`: boolean, read-only. -Will be `true` if the current animation exists, i.e., if its sprite and its animation number have been defined in a .spr file. +Will be `true` if the animation exists, i.e., if its sprite and its animation number have been defined in a .spr file. *Available since:* Open Surge 0.5.1 @@ -47,31 +47,57 @@ `finished`: boolean, read-only. -Will be `true` if the current animation has finished playing. +Will be `true` if the animation has finished playing. -#### hotspot +#### anchor -`hotspot`: [Vector2](/engine/vector2) object, read-only. +`anchor`: [Vector2](/engine/vector2) object, read-only. -The position of the hot spot of the current animation. +The hot spot of the animation normalized to [0,1] x [0,1]. + +*Available since:* Open Surge 0.6.0 + +#### hotSpot + +`hotSpot`: [Vector2](/engine/vector2) object, read-only. + +The hot spot of the animation. Coordinates are given in pixels. + +*Note:* prior to Open Surge 0.6.0, this property was called `hotspot`. + +#### actionSpot + +`actionSpot`: [Vector2](/engine/vector2) object, read-only. + +The action spot of the animation. Coordinates are given in pixels. If the sprite is flipped, the action spot is automatically flipped relative to the [hot spot](#hotspot) of the animation. + +*Available since:* Open Surge 0.6.0 + +#### actionOffset + +`actionOffset`: [Vector2](/engine/vector2) object, read-only. + +When this vector is added to the position of the sprite, you'll get the position of the [action spot](#actionspot). This is suitable to be used with [transform.localPosition](/engine/transform#localposition). + +*Available since:* Open Surge 0.6.0 #### fps `fps`: number, read-only. -Frames per second of the current animation. +Frames per second of the animation. #### repeats `repeats`: boolean, read-only. -Does the current animation repeat itself? +Does the animation repeat itself? #### frameCount `frameCount`: number, read-only. -The number of frames of the current animation. +The number of frames of the animation. #### frame @@ -89,4 +115,4 @@ `sync`: boolean. -Is the current animation is synchronized? A synchronized animation is a repeating animation that displays the same frame across multiple sprites. Defaults to `false`. \ No newline at end of file +Is the animation is synchronized? A synchronized animation is a repeating animation that displays the same frame across multiple sprites. Defaults to `false`. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/surgescript-0.5.5/docs/engine/collider.md new/surgescript-0.5.6/docs/engine/collider.md --- old/surgescript-0.5.5/docs/engine/collider.md 2021-01-22 19:42:07.000000000 +0100 +++ new/surgescript-0.5.6/docs/engine/collider.md 2022-09-01 01:55:59.000000000 +0200 @@ -74,6 +74,14 @@ Is the collider visible? This is useful for debugging. The default value is `false`. +#### anchor + +`anchor`: [Vector2](/engine/vector2) object. + +The anchor of the collider. See also: [setAnchor](#setanchor). + +*Available since:* Open Surge 0.6.0 + Functions --------- @@ -109,7 +117,7 @@ `setAnchor(x, y)` -Defines the anchor of the collider to be (`x`, `y`), where these values are (usually) numbers between 0.0 and 1.0. Imagine a bounding box of the collider. Point (0.5, 0.5) is the default, representing its center. Point (0.0, 0.0) is the top-left and (1,0, 1.0), the bottom-right. The anchor of the collider will be aligned to the hot spot of the sprite of the entity. +Defines the anchor of the collider to be (`x`, `y`), where these values are (usually) numbers between 0.0 and 1.0. Imagine a bounding box of the collider. Point (0.5, 0.5) is the default, representing its center. Point (0.0, 0.0) is the top-left and (1,0, 1.0), the bottom-right. The anchor of the collider will be aligned to the hot spot of the sprite of the entity. See also: [anchor](#anchor). *Arguments* diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/surgescript-0.5.5/docs/engine/level.md new/surgescript-0.5.6/docs/engine/level.md --- old/surgescript-0.5.5/docs/engine/level.md 2021-01-22 19:42:07.000000000 +0100 +++ new/surgescript-0.5.6/docs/engine/level.md 2022-09-01 01:55:59.000000000 +0200 @@ -142,14 +142,16 @@ `gravity`: number, read-only. -A default value for the level gravity, in pixels per second squared. +The acceleration of gravity, measured in pixels per second squared. #### time -`time`: number, read-only. +`time`: number. Elapsed time in the level, given in seconds. +*Note:* this property is writable since Open Surge 0.6.0. + #### next `next`: number. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/surgescript-0.5.5/docs/engine/platformer.md new/surgescript-0.5.6/docs/engine/platformer.md --- old/surgescript-0.5.5/docs/engine/platformer.md 2021-01-22 19:42:07.000000000 +0100 +++ new/surgescript-0.5.6/docs/engine/platformer.md 2022-09-01 01:55:59.000000000 +0200 @@ -58,6 +58,14 @@ Jump speed, in pixels per second. The higher the value, the more intense the jump. +#### gravityMultiplier + +`gravityMultiplier`: number. + +A multiplier used to modify how the Platformer is affected by gravity. When set to 1.0, the Platformer will subject to the [default acceleration of gravity](/engine/level#gravity). When set to 2.0 (0.5), the Platformer will be subject to twice (half) the default gravity, and so on. Zero means no gravity. Defaults to 1.0. + +*Available since:* Open Surge 0.6.0 + #### direction `direction`: number, read-only. @@ -205,10 +213,14 @@ #### forceJump -`forceJump()` +`forceJump(speed)` Makes the platformer jump, regardless if it's touching the ground or not. +*Arguments* + +* `speed`: number. Jump speed in pixels per second. + *Returns* Returns the platformer itself. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/surgescript-0.5.5/docs/engine/player.md new/surgescript-0.5.6/docs/engine/player.md --- old/surgescript-0.5.5/docs/engine/player.md 2021-01-22 19:42:07.000000000 +0100 +++ new/surgescript-0.5.6/docs/engine/player.md 2022-09-01 01:55:59.000000000 +0200 @@ -177,17 +177,49 @@ } ``` +#### animation + +`animation`: [Animation](/engine/animation) object, read-only. + +Reference to the Animation object of the Player. + #### anim `anim`: number. -A shortcut to `animation.id`: an integer corresponding to the animation number. +A shortcut to `animation.id`: an integer corresponding to the animation number. See also: [Animation](/engine/animation), [id](/engine/animation#id). -#### animation +#### anchor -`animation`: [Animation](/engine/animation) object, read-only. +`anchor`: [Vector2](/engine/vector2) object. -Reference to the Animation object of the Player. +A shortcut to `animation.anchor`. See also: [anchor](/engine/animation#anchor). + +*Available since:* Open Surge 0.6.0 + +#### hotSpot + +`hotSpot`: [Vector2](/engine/vector2) object. + +A shortcut to `animation.hotSpot`. See also: [hot spot](/engine/animation#hotspot). + +*Available since:* Open Surge 0.6.0. In versions prior to 0.6.0, you may get the hot spot using the [Animation](/engine/animation#hotspot) object. + +#### actionSpot + +`actionSpot`: [Vector2](/engine/vector2) object. + +A shortcut to `animation.actionSpot`. See also: [action spot](/engine/animation#actionspot). + +*Available since:* Open Surge 0.6.0 + +#### actionOffset + +`actionOffset`: [Vector2](/engine/vector2) object, read-only. + +A shortcut to `animation.actionOffset`. See also: [action offset](/engine/animation#actionoffset). + +*Available since:* Open Surge 0.6.0 #### attacking diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/surgescript-0.5.5/docs/engine/prefs.md new/surgescript-0.5.6/docs/engine/prefs.md --- old/surgescript-0.5.5/docs/engine/prefs.md 2021-01-22 19:42:07.000000000 +0100 +++ new/surgescript-0.5.6/docs/engine/prefs.md 2022-09-01 01:55:59.000000000 +0200 @@ -15,6 +15,12 @@ { Prefs["counter"] += 1; Console.print("counter: " + Prefs["counter"]); + + state = "idle"; + } + + state "idle" + { } fun constructor() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/surgescript-0.5.5/docs/engine/text.md new/surgescript-0.5.6/docs/engine/text.md --- old/surgescript-0.5.5/docs/engine/text.md 2021-01-22 19:42:07.000000000 +0100 +++ new/surgescript-0.5.6/docs/engine/text.md 2022-09-01 01:55:59.000000000 +0200 @@ -64,7 +64,7 @@ #### size -`size`: [Vector2](/engine/vector2) object. +`size`: [Vector2](/engine/vector2) object, read-only. The size, in pixels, of the rendered text. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/surgescript-0.5.5/mkdocs.yml new/surgescript-0.5.6/mkdocs.yml --- old/surgescript-0.5.5/mkdocs.yml 2021-01-22 19:42:07.000000000 +0100 +++ new/surgescript-0.5.6/mkdocs.yml 2022-09-01 01:55:59.000000000 +0200 @@ -6,7 +6,7 @@ copyright: 'SurgeScript is a scripting language for games. Copyright ?? 2016-2021 Alexandre Martins.' google_analytics: ['UA-120511928-1', 'opensurge2d.org'] repo_url: 'https://github.com/alemart/surgescript' -strict: true +strict: false theme: name: 'material' nav: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/surgescript-0.5.5/src/main.c new/surgescript-0.5.6/src/main.c --- old/surgescript-0.5.5/src/main.c 2021-01-22 19:42:07.000000000 +0100 +++ new/surgescript-0.5.6/src/main.c 2022-09-01 01:55:59.000000000 +0200 @@ -1,7 +1,7 @@ /* * SurgeScript * A scripting language for games - * Copyright 2016-2020 Alexandre Martins <alemartf(at)gmail(dot)com> + * Copyright 2016-2022 Alexandre Martins <alemartf(at)gmail(dot)com> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,18 +16,34 @@ * limitations under the License. * * runtime/main.c - * SurgeScript Runtime Engine entry point + * SurgeScript CLI */ #include <surgescript.h> #include <string.h> #include <stdio.h> -static surgescript_vm_t* make_vm(int argc, char** argv); +/* multithread support */ +#if ENABLE_THREADS +# if __STDC_VERSION__ >= 201112L && !defined(__STDC_NO_THREADS__) +# include <threads.h> +# else +# error "Can't compile the SurgeScript CLI: threads.h is not found on this environment. Please change the environment or disable multithreading." +# endif +#endif + +static surgescript_vm_t* make_vm(int argc, char** argv, uint64_t* time_limit); +static void run_vm(surgescript_vm_t* vm, uint64_t time_limit); +static void destroy_vm(surgescript_vm_t* vm); static void print_to_stdout(const char* message); static void print_to_stderr(const char* message); static void discard_message(const char* message); static void show_help(const char* executable); +static char* read_from_stdin(); +static int main_loop(void* arg); + +/* default time limit, given in milliseconds */ +#define DEFAULT_TIME_LIMIT 30000 /* * main() @@ -35,26 +51,103 @@ */ int main(int argc, char* argv[]) { - if(argc > 1) { - /* create the VM and compile the input file(s) */ - surgescript_vm_t* vm = make_vm(argc, argv); - if(vm != NULL) { - /* run the VM */ - while(surgescript_vm_update(vm)) { - ; + uint64_t time_limit = DEFAULT_TIME_LIMIT; + + /* Create the VM and compile the input file(s) */ + surgescript_vm_t* vm = make_vm(argc, argv, &time_limit); + + /* got a VM? */ + if(vm != NULL) { + /* run the VM */ + run_vm(vm, time_limit); + + /* destroy the VM */ + destroy_vm(vm); + } + + /* done! */ + return 0; +} + +/** + * run_vm() + * Run the VM with a time limit + */ +void run_vm(surgescript_vm_t* vm, uint64_t time_limit) +{ + uint64_t start_time = surgescript_util_gettickcount(); + #define show_time_limit_error() \ + fprintf(stderr, "Time limit of %.1lf seconds exceeded.\n", (double)time_limit * 0.001) + +#if !ENABLE_THREADS + + /* main loop */ + while(surgescript_vm_update(vm)) { + + /* time limit */ + if(time_limit > 0 && surgescript_util_gettickcount() > start_time + time_limit) { + show_time_limit_error(); + break; + } + + } + +#else + + /* run the SurgeScript VM on a separate thread */ + thrd_t thread; + thrd_create(&thread, main_loop, vm); + + /* handle the time limit, if it's been set */ + if(time_limit > 0) { + while(surgescript_vm_is_active(vm)) { + if(surgescript_util_gettickcount() > start_time + time_limit) { + show_time_limit_error(); + exit(1); /* TODO we should kill the other thread instead */ } - /* destroy the VM */ - surgescript_vm_destroy(vm); + thrd_yield(); } } - else { - /* print usage */ - show_help(surgescript_util_basename(argv[0])); + + /* wait for the other thread to complete */ + thrd_join(thread, NULL); + +#endif + +} + +/** + * destroy_vm() + * Destroy a SurgeScript VM + */ +void destroy_vm(surgescript_vm_t* vm) +{ + surgescript_vm_destroy(vm); +} + +/** + * main_loop() + * Game loop for multithreaded execution + */ +int main_loop(void* arg) +{ +#if !ENABLE_THREADS + + (void)arg; + return 0; + +#else + + surgescript_vm_t* vm = (surgescript_vm_t*)arg; + + while(surgescript_vm_update(vm)) { + thrd_yield(); } - /* done! */ return 0; + +#endif } /* @@ -62,7 +155,7 @@ * Parses the command line arguments and creates a VM * with the compiled scripts */ -surgescript_vm_t* make_vm(int argc, char** argv) +surgescript_vm_t* make_vm(int argc, char** argv, uint64_t* time_limit) { surgescript_vm_t* vm = NULL; int i; @@ -87,8 +180,20 @@ show_help(surgescript_util_basename(argv[0])); return NULL; } + else if(strcmp(arg, "--timelimit") == 0 || strcmp(arg, "-t") == 0) { + /* set time limit (maximum execution time) */ + if(++i < argc && time_limit != NULL) { + double seconds = atof(argv[i]); + *time_limit = (seconds > 0.0) ? (uint64_t)(seconds * 1000.0) : 0; + } + } + else if(strcmp(arg, "--") == 0) { + /* user-specific command line arguments */ + break; + } else { - printf("Unrecognized option: '%s'.\nType '%s --help' for more information.\n", arg, surgescript_util_basename(argv[0])); + /* unrecognized option */ + fprintf(stderr, "Unrecognized option: '%s'.\nType '%s --help' for more information.\n", arg, surgescript_util_basename(argv[0])); return NULL; } } @@ -97,13 +202,32 @@ vm = surgescript_vm_create(); /* compile the scripts */ - for(; i < argc && strcmp(argv[i], "--") != 0; i++) { - const char* file = argv[i]; - surgescript_vm_compile(vm, file); + if(i < argc && strcmp(argv[i], "--") != 0) { + /* read files */ + for(; i < argc && strcmp(argv[i], "--") != 0; i++) { + const char* file = argv[i]; + surgescript_vm_compile(vm, file); + } + } + else { + fprintf(stderr, "Reading from stdin... Run '%s -h' for help.\n", surgescript_util_basename(argv[0])); + + /* read from stdin */ + char* code = read_from_stdin(); + surgescript_vm_compile_code_in_memory(vm, code); + ssfree(code); } /* launch the VM */ - surgescript_vm_launch_ex(vm, argc, argv); + if(i < argc && strcmp(argv[i], "--") == 0) { + /* launch with user-specific command line arguments */ + ++i; + surgescript_vm_launch_ex(vm, argc - i, (char**)(argv + i)); + } + else { + /* launch without user-specific command line arguments */ + surgescript_vm_launch(vm); + } /* done! */ return vm; @@ -126,6 +250,7 @@ "Options:\n" " -v, --version shows the version of SurgeScript\n" " -D, --debug prints debugging information\n" + " -t, --timelimit sets a maximum execution time, in seconds (0 = no limit)\n" " -h, --help shows this message\n" "\n" "Examples:\n" @@ -133,6 +258,7 @@ " %s file1.ss file2.ss compiles and executes file1.ss and file2.ss\n" " %s --debug test.ss compiles and runs test.ss with debugging information\n" " %s file.ss -- -x -y passes custom arguments -x and -y to file.ss\n" + " %s -t 5 runs a script read from stdin, with a time limit of 5 seconds\n" "\n" "Full documentation available at: <%s>\n", surgescript_util_version(), @@ -144,6 +270,7 @@ executable, executable, executable, + executable, surgescript_util_website() ); } @@ -173,4 +300,26 @@ void discard_message(const char* message) { ; -} \ No newline at end of file +} + +/** + * read_from_stdin() + * Read data from stdin and store it in a string + */ +char* read_from_stdin() +{ + const size_t BUFSIZE = 1024; + char* data = NULL; + size_t read_chars = 0, data_size = 0; + + /* read to data[] */ + do { + data_size += BUFSIZE; + data = ssrealloc(data, data_size + 1); + read_chars += fread(data + read_chars, sizeof(char), BUFSIZE, stdin); + data[read_chars] = '\0'; + } while(read_chars == data_size); + + /* done! */ + return data; +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/surgescript-0.5.5/src/surgescript/compiler/parser.c new/surgescript-0.5.6/src/surgescript/compiler/parser.c --- old/surgescript-0.5.5/src/surgescript/compiler/parser.c 2021-01-22 19:42:07.000000000 +0100 +++ new/surgescript-0.5.6/src/surgescript/compiler/parser.c 2022-09-01 01:55:59.000000000 +0200 @@ -191,7 +191,7 @@ { FILE* fp = surgescript_util_fopen_utf8(absolute_path, "rb"); /* use binary mode, so offsets don't get messed up */ if(fp) { - static size_t BUFSIZE = 1024; + const size_t BUFSIZE = 1024; char* data = NULL; size_t read_chars = 0, data_size = 0; @@ -1105,7 +1105,7 @@ if(!is_state_context(context)) ssfatal("Compile Error: timeout can only be used inside a state (see %s:%d).", context.source_file, surgescript_token_linenumber(parser->previous)); match(parser, SSTOK_LPAREN); - expr(parser, context); + assignexpr(parser, context); emit_timeout(context); match(parser, SSTOK_RPAREN); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/surgescript-0.5.5/src/surgescript/compiler/parser.h new/surgescript-0.5.6/src/surgescript/compiler/parser.h --- old/surgescript-0.5.5/src/surgescript/compiler/parser.h 2021-01-22 19:42:07.000000000 +0100 +++ new/surgescript-0.5.6/src/surgescript/compiler/parser.h 2022-09-01 01:55:59.000000000 +0200 @@ -77,7 +77,7 @@ * | ! <unaryexpr> * | typeof <unaryexpr> | typeof ( <expr> ) * | ++ identifier | -- identifier - * | timeout ( <expr> ) + * | timeout ( <assignexpr> ) * | <postfixexpr> * <postfixexpr> := identifier ++ | identifier -- * | <funcallexpr> <postfixexpr1> @@ -155,4 +155,4 @@ void surgescript_parser_set_flags(surgescript_parser_t* parser, surgescript_parser_flags_t flags); /* set parser options (flags) */ surgescript_parser_flags_t surgescript_parser_get_flags(surgescript_parser_t* parser); /* get parser flags */ -#endif \ No newline at end of file +#endif Binary files old/surgescript-0.5.5/src/surgescript/misc/icon.png and new/surgescript-0.5.6/src/surgescript/misc/icon.png differ Binary files old/surgescript-0.5.5/src/surgescript/misc/surgescript.ico and new/surgescript-0.5.6/src/surgescript/misc/surgescript.ico differ Binary files old/surgescript-0.5.5/src/surgescript/misc/surgescript.png and new/surgescript-0.5.6/src/surgescript/misc/surgescript.png differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/surgescript-0.5.5/src/surgescript/runtime/program.c new/surgescript-0.5.6/src/surgescript/runtime/program.c --- old/surgescript-0.5.5/src/surgescript/runtime/program.c 2021-01-22 19:42:07.000000000 +0100 +++ new/surgescript-0.5.6/src/surgescript/runtime/program.c 2022-09-01 01:55:59.000000000 +0200 @@ -1,7 +1,7 @@ /* * SurgeScript * A scripting language for games - * Copyright 2016-2019 Alexandre Martins <alemartf(at)gmail(dot)com> + * Copyright 2016-2021 Alexandre Martins <alemartf(at)gmail(dot)com> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -518,12 +518,8 @@ break; case SSOP_DIV: - if(fast_notzero(surgescript_var_get_number(t(b)))) - surgescript_var_set_number(t(a), surgescript_var_get_number(t(a)) / surgescript_var_get_number(t(b))); - else if(fast_sign(surgescript_var_get_number(t(a))) >= 0) - surgescript_var_set_number(t(a), INFINITY * fast_sign1(surgescript_var_get_number(t(b)))); - else - surgescript_var_set_number(t(a), -INFINITY * fast_sign1(surgescript_var_get_number(t(b)))); + /* division by zero should follow the IEEE-754 */ + surgescript_var_set_number(t(a), surgescript_var_get_number(t(a)) / surgescript_var_get_number(t(b))); break; case SSOP_MOD: @@ -590,48 +586,42 @@ *ip = a.u; return; } - else - break; + break; case SSOP_JNE: if(surgescript_var_get_rawbits(_t[2])) { *ip = a.u; return; } - else - break; + break; case SSOP_JL: if(surgescript_var_get_rawbits(_t[2]) < 0) { *ip = a.u; return; } - else - break; + break; case SSOP_JG: if(surgescript_var_get_rawbits(_t[2]) > 0) { *ip = a.u; return; } - else - break; + break; case SSOP_JLE: if(surgescript_var_get_rawbits(_t[2]) <= 0) { *ip = a.u; return; } - else - break; + break; case SSOP_JGE: if(surgescript_var_get_rawbits(_t[2]) >= 0) { *ip = a.u; return; } - else - break; + break; /* function calls */ case SSOP_CALL: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/surgescript-0.5.5/src/surgescript/runtime/variable.c new/surgescript-0.5.6/src/surgescript/runtime/variable.c --- old/surgescript-0.5.5/src/surgescript/runtime/variable.c 2021-01-22 19:42:07.000000000 +0100 +++ new/surgescript-0.5.6/src/surgescript/runtime/variable.c 2022-09-01 01:55:59.000000000 +0200 @@ -1,7 +1,7 @@ /* * SurgeScript * A scripting language for games - * Copyright 2016-2019 Alexandre Martins <alemartf(at)gmail(dot)com> + * Copyright 2016-2019, 2021 Alexandre Martins <alemartf(at)gmail(dot)com> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -299,15 +299,19 @@ switch(var->type) { case SSVAR_NULL: return ssstrdup("null"); + case SSVAR_BOOL: return ssstrdup(var->boolean ? "true" : "false"); + case SSVAR_STRING: return ssstrdup(var->string); + case SSVAR_NUMBER: { char buf[32]; surgescript_var_to_string(var, buf, sizeof(buf)); return ssstrdup(buf); } + case SSVAR_OBJECTHANDLE: { if(manager != NULL) { surgescript_object_t* obj = surgescript_objectmanager_get(manager, var->handle); @@ -320,8 +324,12 @@ else return ssstrdup("[object]"); } + case SSVAR_RAW: return ssstrdup("<raw>"); + + default: + return ssstrdup("<unknown>"); } } @@ -335,15 +343,17 @@ switch(var->type) { case SSVAR_OBJECTHANDLE: return var->handle; + case SSVAR_NUMBER: return surgescript_objectmanager_system_object(NULL, "Number"); + case SSVAR_STRING: return surgescript_objectmanager_system_object(NULL, "String"); + case SSVAR_BOOL: return surgescript_objectmanager_system_object(NULL, "Boolean"); - case SSVAR_NULL: - return surgescript_objectmanager_null(NULL); - case SSVAR_RAW: + + default: return surgescript_objectmanager_null(NULL); } } @@ -521,7 +531,7 @@ case SSVAR_NUMBER: { /* encourage users to use approximatelyEqual() */ /* epsilon comparisons may cause underlying problems, e.g., with infinity */ - return (a->number > b->number) - (a->number < b->number); + return isgreater(a->number, b->number) - isless(a->number, b->number); } case SSVAR_RAW: return (a->raw > b->raw) - (a->raw < b->raw); @@ -560,9 +570,10 @@ unsigned long y = surgescript_var_get_objecthandle(b); return (x > y) - (x < y); } - else - return 0; /* this shouldn't happen */ } + + /* this shouldn't happen */ + return 0; } /* @@ -748,6 +759,10 @@ /* Deallocates a bucket (must be fast) */ void free_bucket(surgescript_varbucket_t* bucket) { + /* can't free if not in use */ + ssassert(bucket->in_use); + + /* put the bucket back in the pool */ bucket->in_use = false; bucket->next = varpool_currbucket; varpool_currbucket = bucket; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/surgescript-0.5.5/src/surgescript/util/ssarray.h new/surgescript-0.5.6/src/surgescript/util/ssarray.h --- old/surgescript-0.5.5/src/surgescript/util/ssarray.h 2021-01-22 19:42:07.000000000 +0100 +++ new/surgescript-0.5.6/src/surgescript/util/ssarray.h 2022-09-01 01:55:59.000000000 +0200 @@ -28,7 +28,7 @@ * SSARRAY() * declares an array of a certain type */ -#define SSARRAY(type, arr) type* arr; size_t arr##_len, arr##_cap; +#define SSARRAY(type, arr) type* arr; size_t arr##_len, arr##_cap /* * ssarray_init()
