Merged default into minor.
--HG-- branch : minor
@@ -9,3 +9,4 @@ e0f98d53debb62347c6433ca0534a0f77f15f76f 0.8.0
|
|||||||
8b113c345e97e7bb7e963e5d67451abdfb05cfde 0.9.1
|
8b113c345e97e7bb7e963e5d67451abdfb05cfde 0.9.1
|
||||||
a5e405cdf14d030b71d09a105086797942ae91a9 0.9.2
|
a5e405cdf14d030b71d09a105086797942ae91a9 0.9.2
|
||||||
14717f0fb5d96d380c10fe6f41b74b7652c7d836 0.10.0
|
14717f0fb5d96d380c10fe6f41b74b7652c7d836 0.10.0
|
||||||
|
3cb3559eebb89803c0b7fa83d51d8e48a2b20b7a 0.10.1
|
||||||
|
|||||||
@@ -1,5 +1,39 @@
|
|||||||
|
LOVE 0.10.1 [Super Toast]
|
||||||
|
-------------------------
|
||||||
|
|
||||||
|
Released: 2016-02-14
|
||||||
|
|
||||||
|
* Added a new love.conf flag t.externalstorage, which determines whether files are saved in internal or external storage on Android devices.
|
||||||
|
* Added a new variant of love.graphics.arc which can draw different types of arcs ("pie", "open", or "closed").
|
||||||
|
* Added "lighten" and "darken" BlendModes. They can only be used with the "premultiplied" BlendAlphaMode.
|
||||||
|
* Added the "lighten" GraphicsFeature constant.
|
||||||
|
* Added the ability to avoid clearing specific Canvases when calling love.graphics.clear, if multiple Canvases are active at once via love.graphics.setCanvas.
|
||||||
|
* Added Text:getDimensions.
|
||||||
|
* Added optional "collideconnected" argument to love.physics.newMotorJoint.
|
||||||
|
|
||||||
|
* Fixed a Lua error in the no-game screen if the window's height is too small.
|
||||||
|
* Fixed the default error handler to reset the mouse Cursor.
|
||||||
|
* Fixed love.filesystem functions crashing when called if liblove is used directly without calling love.filesystem.init.
|
||||||
|
* Fixed audio on Android to pause when the app is inactive, and resume when the app becomes active again.
|
||||||
|
* Fixed the Video decoding thread hanging after Video:seek or when a Video finishes.
|
||||||
|
* Fixed Video:isPlaying to always return false after it finishes playing.
|
||||||
|
* Fixed RandomGenerator:random crashing if a nil 'self' is used.
|
||||||
|
* Fixed loading BMFont files which have characters with 0 width or height (a space character, for example).
|
||||||
|
* Fixed love.graphics.newFont causing crashes if FileData is passed in.
|
||||||
|
* Fixed love.graphics.clear(colortable) causing crashes on OpenGL ES 2 systems when a Canvas is active.
|
||||||
|
* Fixed a driver bug on some Android devices which caused all objects to show up as black.
|
||||||
|
* Fixed a driver bug on Windows with AMD graphics cards where love.graphics.clear would not always work.
|
||||||
|
* Fixed Shader:sendColor incorrectly converting alpha values from sRGB to linear RGB when gamma-correct rendering is enabled.
|
||||||
|
* Fixed love.graphics.newMesh(vertices) double-converting colors from sRGB to linear RGB when gamma-correct rendering is enabled.
|
||||||
|
* Fixed love.graphics.new* crashing when there is no graphics context/window.
|
||||||
|
|
||||||
|
* Updated the Windows executable to prefer the high-powered AMD graphics card on systems which have switchable Intel+AMD GPUs.
|
||||||
|
* Updated love.touch.getTouches to return the list of IDs in the relative order that the touches initially happened, instead of being in a random order.
|
||||||
|
* Updated the error messages caused by invalid or bad arguments to ImageData and SoundData methods to be more descriptive.
|
||||||
|
|
||||||
|
|
||||||
LOVE 0.10.0 [Super Toast]
|
LOVE 0.10.0 [Super Toast]
|
||||||
--------------
|
-------------------------
|
||||||
|
|
||||||
Released: 2015-12-22
|
Released: 2015-12-22
|
||||||
|
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 361 KiB |
|
Before Width: | Height: | Size: 151 KiB After Width: | Height: | Size: 151 KiB |
|
Before Width: | Height: | Size: 35 KiB After Width: | Height: | Size: 361 KiB |
|
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 25 KiB |
|
Before Width: | Height: | Size: 35 KiB After Width: | Height: | Size: 361 KiB |
|
Before Width: | Height: | Size: 98 KiB After Width: | Height: | Size: 59 KiB |
|
Before Width: | Height: | Size: 99 KiB After Width: | Height: | Size: 72 KiB |
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"info" : {
|
||||||
|
"version" : 1,
|
||||||
|
"author" : "xcode"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 8.2 KiB |
|
After Width: | Height: | Size: 19 KiB |
|
After Width: | Height: | Size: 713 B |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 19 KiB |
|
After Width: | Height: | Size: 46 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 3.5 KiB |
|
After Width: | Height: | Size: 46 KiB |
|
After Width: | Height: | Size: 109 KiB |
|
After Width: | Height: | Size: 132 KiB |
|
After Width: | Height: | Size: 10 KiB |
|
After Width: | Height: | Size: 723 B |
|
After Width: | Height: | Size: 24 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 56 KiB |
|
After Width: | Height: | Size: 4.4 KiB |
@@ -0,0 +1,68 @@
|
|||||||
|
{
|
||||||
|
"images" : [
|
||||||
|
{
|
||||||
|
"size" : "16x16",
|
||||||
|
"idiom" : "mac",
|
||||||
|
"filename" : "16.png",
|
||||||
|
"scale" : "1x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "16x16",
|
||||||
|
"idiom" : "mac",
|
||||||
|
"filename" : "32.png",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "32x32",
|
||||||
|
"idiom" : "mac",
|
||||||
|
"filename" : "32.png",
|
||||||
|
"scale" : "1x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "32x32",
|
||||||
|
"idiom" : "mac",
|
||||||
|
"filename" : "64.png",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "128x128",
|
||||||
|
"idiom" : "mac",
|
||||||
|
"filename" : "128.png",
|
||||||
|
"scale" : "1x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "128x128",
|
||||||
|
"idiom" : "mac",
|
||||||
|
"filename" : "256.png",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "256x256",
|
||||||
|
"idiom" : "mac",
|
||||||
|
"filename" : "256.png",
|
||||||
|
"scale" : "1x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "256x256",
|
||||||
|
"idiom" : "mac",
|
||||||
|
"filename" : "512.png",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "512x512",
|
||||||
|
"idiom" : "mac",
|
||||||
|
"filename" : "512.png",
|
||||||
|
"scale" : "1x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "512x512",
|
||||||
|
"idiom" : "mac",
|
||||||
|
"filename" : "1024.png",
|
||||||
|
"scale" : "2x"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"info" : {
|
||||||
|
"version" : 1,
|
||||||
|
"author" : "xcode"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,121 +3,121 @@
|
|||||||
{
|
{
|
||||||
"size" : "29x29",
|
"size" : "29x29",
|
||||||
"idiom" : "iphone",
|
"idiom" : "iphone",
|
||||||
"filename" : "pig-29pt@1x.png",
|
"filename" : "icon-29pt@1x.png",
|
||||||
"scale" : "1x"
|
"scale" : "1x"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"size" : "29x29",
|
"size" : "29x29",
|
||||||
"idiom" : "iphone",
|
"idiom" : "iphone",
|
||||||
"filename" : "pig-29pt@2x.png",
|
"filename" : "icon-29pt@2x.png",
|
||||||
"scale" : "2x"
|
"scale" : "2x"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"size" : "29x29",
|
"size" : "29x29",
|
||||||
"idiom" : "iphone",
|
"idiom" : "iphone",
|
||||||
"filename" : "pig-29pt@3x.png",
|
"filename" : "icon-29pt@3x.png",
|
||||||
"scale" : "3x"
|
"scale" : "3x"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"size" : "40x40",
|
"size" : "40x40",
|
||||||
"idiom" : "iphone",
|
"idiom" : "iphone",
|
||||||
"filename" : "pig-40pt@2x.png",
|
"filename" : "icon-40pt@2x.png",
|
||||||
"scale" : "2x"
|
"scale" : "2x"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"size" : "40x40",
|
"size" : "40x40",
|
||||||
"idiom" : "iphone",
|
"idiom" : "iphone",
|
||||||
"filename" : "pig-40pt@3x.png",
|
"filename" : "icon-40pt@3x.png",
|
||||||
"scale" : "3x"
|
"scale" : "3x"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"size" : "57x57",
|
"size" : "57x57",
|
||||||
"idiom" : "iphone",
|
"idiom" : "iphone",
|
||||||
"filename" : "pig-57pt@1x.png",
|
"filename" : "icon-57pt@1x.png",
|
||||||
"scale" : "1x"
|
"scale" : "1x"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"size" : "57x57",
|
"size" : "57x57",
|
||||||
"idiom" : "iphone",
|
"idiom" : "iphone",
|
||||||
"filename" : "pig-57pt@2x.png",
|
"filename" : "icon-57pt@2x.png",
|
||||||
"scale" : "2x"
|
"scale" : "2x"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"size" : "60x60",
|
"size" : "60x60",
|
||||||
"idiom" : "iphone",
|
"idiom" : "iphone",
|
||||||
"filename" : "pig-60pt@2x.png",
|
"filename" : "icon-60pt@2x.png",
|
||||||
"scale" : "2x"
|
"scale" : "2x"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"size" : "60x60",
|
"size" : "60x60",
|
||||||
"idiom" : "iphone",
|
"idiom" : "iphone",
|
||||||
"filename" : "pig-60pt@3x.png",
|
"filename" : "icon-60pt@3x.png",
|
||||||
"scale" : "3x"
|
"scale" : "3x"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"size" : "29x29",
|
"size" : "29x29",
|
||||||
"idiom" : "ipad",
|
"idiom" : "ipad",
|
||||||
"filename" : "pig-29pt@1x.png",
|
"filename" : "icon-29pt@1x.png",
|
||||||
"scale" : "1x"
|
"scale" : "1x"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"size" : "29x29",
|
"size" : "29x29",
|
||||||
"idiom" : "ipad",
|
"idiom" : "ipad",
|
||||||
"filename" : "pig-29pt@2x.png",
|
"filename" : "icon-29pt@2x.png",
|
||||||
"scale" : "2x"
|
"scale" : "2x"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"size" : "40x40",
|
"size" : "40x40",
|
||||||
"idiom" : "ipad",
|
"idiom" : "ipad",
|
||||||
"filename" : "pig-40pt@1x.png",
|
"filename" : "icon-40pt@1x.png",
|
||||||
"scale" : "1x"
|
"scale" : "1x"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"size" : "40x40",
|
"size" : "40x40",
|
||||||
"idiom" : "ipad",
|
"idiom" : "ipad",
|
||||||
"filename" : "pig-40pt@2x.png",
|
"filename" : "icon-40pt@2x.png",
|
||||||
"scale" : "2x"
|
"scale" : "2x"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"size" : "50x50",
|
"size" : "50x50",
|
||||||
"idiom" : "ipad",
|
"idiom" : "ipad",
|
||||||
"filename" : "pig-50pt@1x.png",
|
"filename" : "icon-50pt@1x.png",
|
||||||
"scale" : "1x"
|
"scale" : "1x"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"size" : "50x50",
|
"size" : "50x50",
|
||||||
"idiom" : "ipad",
|
"idiom" : "ipad",
|
||||||
"filename" : "pig-50pt@2x.png",
|
"filename" : "icon-50pt@2x.png",
|
||||||
"scale" : "2x"
|
"scale" : "2x"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"size" : "72x72",
|
"size" : "72x72",
|
||||||
"idiom" : "ipad",
|
"idiom" : "ipad",
|
||||||
"filename" : "pig-72pt@1x.png",
|
"filename" : "icon-72pt@1x.png",
|
||||||
"scale" : "1x"
|
"scale" : "1x"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"size" : "72x72",
|
"size" : "72x72",
|
||||||
"idiom" : "ipad",
|
"idiom" : "ipad",
|
||||||
"filename" : "pig-72pt@2x.png",
|
"filename" : "icon-72pt@2x.png",
|
||||||
"scale" : "2x"
|
"scale" : "2x"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"size" : "76x76",
|
"size" : "76x76",
|
||||||
"idiom" : "ipad",
|
"idiom" : "ipad",
|
||||||
"filename" : "pig-76pt@1x.png",
|
"filename" : "icon-76pt@1x.png",
|
||||||
"scale" : "1x"
|
"scale" : "1x"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"size" : "76x76",
|
"size" : "76x76",
|
||||||
"idiom" : "ipad",
|
"idiom" : "ipad",
|
||||||
"filename" : "pig-76pt@2x.png",
|
"filename" : "icon-76pt@2x.png",
|
||||||
"scale" : "2x"
|
"scale" : "2x"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"size" : "83.5x83.5",
|
"size" : "83.5x83.5",
|
||||||
"idiom" : "ipad",
|
"idiom" : "ipad",
|
||||||
"filename" : "pig-83.5pt@2x.png",
|
"filename" : "icon-83.5pt@2x.png",
|
||||||
"scale" : "2x"
|
"scale" : "2x"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@@ -125,4 +125,4 @@
|
|||||||
"version" : 1,
|
"version" : 1,
|
||||||
"author" : "xcode"
|
"author" : "xcode"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
After Width: | Height: | Size: 2.0 KiB |
|
After Width: | Height: | Size: 4.7 KiB |
|
After Width: | Height: | Size: 8.5 KiB |
|
After Width: | Height: | Size: 3.0 KiB |
|
After Width: | Height: | Size: 7.5 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 3.9 KiB |
|
After Width: | Height: | Size: 10 KiB |
|
After Width: | Height: | Size: 4.7 KiB |
|
After Width: | Height: | Size: 13 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 25 KiB |
|
After Width: | Height: | Size: 6.4 KiB |
|
After Width: | Height: | Size: 18 KiB |
|
After Width: | Height: | Size: 6.9 KiB |
|
After Width: | Height: | Size: 20 KiB |
|
After Width: | Height: | Size: 22 KiB |
|
Before Width: | Height: | Size: 5.1 KiB |
|
Before Width: | Height: | Size: 8.0 KiB |
|
Before Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 6.0 KiB |
|
Before Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 7.1 KiB |
|
Before Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 8.0 KiB |
|
Before Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 9.1 KiB |
|
Before Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 9.5 KiB |
|
Before Width: | Height: | Size: 17 KiB |
|
Before Width: | Height: | Size: 17 KiB |
@@ -1,8 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="7531" systemVersion="14D131" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES">
|
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="9531" systemVersion="15C50" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES">
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<deployment identifier="iOS"/>
|
<deployment identifier="iOS"/>
|
||||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7520"/>
|
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9529"/>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<objects>
|
<objects>
|
||||||
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
|
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
|
||||||
|
|||||||
@@ -20,10 +20,9 @@
|
|||||||
FA0797991BF480A200034B7C /* GameController.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA0797981BF480A200034B7C /* GameController.framework */; };
|
FA0797991BF480A200034B7C /* GameController.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA0797981BF480A200034B7C /* GameController.framework */; };
|
||||||
FA08F69616C766E000F007B5 /* love.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA08F69116C765A200F007B5 /* love.framework */; };
|
FA08F69616C766E000F007B5 /* love.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA08F69116C765A200F007B5 /* love.framework */; };
|
||||||
FA08F69716C766E700F007B5 /* love.framework in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = FA08F69116C765A200F007B5 /* love.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
|
FA08F69716C766E700F007B5 /* love.framework in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = FA08F69116C765A200F007B5 /* love.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
|
||||||
FA0B78D21A95814A000E1D17 /* love.icns in Resources */ = {isa = PBXBuildFile; fileRef = FA0B78D01A95814A000E1D17 /* love.icns */; };
|
|
||||||
FA0B78D31A95814A000E1D17 /* lovedocument.icns in Resources */ = {isa = PBXBuildFile; fileRef = FA0B78D11A95814A000E1D17 /* lovedocument.icns */; };
|
|
||||||
FA0B7F301A95AC7D000E1D17 /* love.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A93E6A3410420AC0007D418B /* love.cpp */; };
|
FA0B7F301A95AC7D000E1D17 /* love.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A93E6A3410420AC0007D418B /* love.cpp */; };
|
||||||
FA27B3CB1B498696008A9DCE /* Theora.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA27B3CA1B498696008A9DCE /* Theora.framework */; };
|
FA27B3CB1B498696008A9DCE /* Theora.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA27B3CA1B498696008A9DCE /* Theora.framework */; };
|
||||||
|
FA5933751C6D625B000EC779 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = FA5D249A1A96CF4300C6FC8F /* Images.xcassets */; };
|
||||||
FA5D24821A96CA1800C6FC8F /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA5D24811A96CA1800C6FC8F /* OpenAL.framework */; };
|
FA5D24821A96CA1800C6FC8F /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA5D24811A96CA1800C6FC8F /* OpenAL.framework */; };
|
||||||
FA5D24841A96CA2700C6FC8F /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA5D24831A96CA2700C6FC8F /* OpenGLES.framework */; };
|
FA5D24841A96CA2700C6FC8F /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA5D24831A96CA2700C6FC8F /* OpenGLES.framework */; };
|
||||||
FA5D24881A96CA8A00C6FC8F /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA5D24871A96CA8A00C6FC8F /* UIKit.framework */; };
|
FA5D24881A96CA8A00C6FC8F /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA5D24871A96CA8A00C6FC8F /* UIKit.framework */; };
|
||||||
@@ -113,8 +112,6 @@
|
|||||||
A9F169A6109E824900FC83D1 /* mpg123.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = mpg123.framework; path = /Library/Frameworks/mpg123.framework; sourceTree = "<absolute>"; };
|
A9F169A6109E824900FC83D1 /* mpg123.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = mpg123.framework; path = /Library/Frameworks/mpg123.framework; sourceTree = "<absolute>"; };
|
||||||
FA0797981BF480A200034B7C /* GameController.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GameController.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.1.sdk/System/Library/Frameworks/GameController.framework; sourceTree = DEVELOPER_DIR; };
|
FA0797981BF480A200034B7C /* GameController.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GameController.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.1.sdk/System/Library/Frameworks/GameController.framework; sourceTree = DEVELOPER_DIR; };
|
||||||
FA08F69116C765A200F007B5 /* love.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = love.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
FA08F69116C765A200F007B5 /* love.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = love.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
FA0B78D01A95814A000E1D17 /* love.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; name = love.icns; path = macosx/love.icns; sourceTree = "<group>"; };
|
|
||||||
FA0B78D11A95814A000E1D17 /* lovedocument.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; name = lovedocument.icns; path = macosx/lovedocument.icns; sourceTree = "<group>"; };
|
|
||||||
FA0B7F061A95AAF3000E1D17 /* love.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = love.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
FA0B7F061A95AAF3000E1D17 /* love.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = love.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
FA27B3CA1B498696008A9DCE /* Theora.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Theora.framework; path = /Library/Frameworks/Theora.framework; sourceTree = "<absolute>"; };
|
FA27B3CA1B498696008A9DCE /* Theora.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Theora.framework; path = /Library/Frameworks/Theora.framework; sourceTree = "<absolute>"; };
|
||||||
FA577A9316C7217800860150 /* liblove.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; path = liblove.xcodeproj; sourceTree = "<group>"; };
|
FA577A9316C7217800860150 /* liblove.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; path = liblove.xcodeproj; sourceTree = "<group>"; };
|
||||||
@@ -127,7 +124,7 @@
|
|||||||
FA5D24931A96CABA00C6FC8F /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.1.sdk/usr/lib/libz.dylib; sourceTree = DEVELOPER_DIR; };
|
FA5D24931A96CABA00C6FC8F /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.1.sdk/usr/lib/libz.dylib; sourceTree = DEVELOPER_DIR; };
|
||||||
FA5D24951A96CAC200C6FC8F /* CoreMotion.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreMotion.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.1.sdk/System/Library/Frameworks/CoreMotion.framework; sourceTree = DEVELOPER_DIR; };
|
FA5D24951A96CAC200C6FC8F /* CoreMotion.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreMotion.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.1.sdk/System/Library/Frameworks/CoreMotion.framework; sourceTree = DEVELOPER_DIR; };
|
||||||
FA5D24971A96CE1E00C6FC8F /* love-ios.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = "love-ios.plist"; path = "ios/love-ios.plist"; sourceTree = "<group>"; };
|
FA5D24971A96CE1E00C6FC8F /* love-ios.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = "love-ios.plist"; path = "ios/love-ios.plist"; sourceTree = "<group>"; };
|
||||||
FA5D249A1A96CF4300C6FC8F /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = ios/Images.xcassets; sourceTree = "<group>"; };
|
FA5D249A1A96CF4300C6FC8F /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; };
|
||||||
FA5D24C11A96D78000C6FC8F /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.1.sdk/System/Library/Frameworks/Foundation.framework; sourceTree = DEVELOPER_DIR; };
|
FA5D24C11A96D78000C6FC8F /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.1.sdk/System/Library/Frameworks/Foundation.framework; sourceTree = DEVELOPER_DIR; };
|
||||||
FA7C63691A9C49570000FD29 /* Launch Screen.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = "Launch Screen.xib"; path = "ios/Launch Screen.xib"; sourceTree = "<group>"; };
|
FA7C63691A9C49570000FD29 /* Launch Screen.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = "Launch Screen.xib"; path = "ios/Launch Screen.xib"; sourceTree = "<group>"; };
|
||||||
FA9B4A0916E1579F00074F42 /* SDL2.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SDL2.framework; path = /Library/Frameworks/SDL2.framework; sourceTree = "<absolute>"; };
|
FA9B4A0916E1579F00074F42 /* SDL2.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SDL2.framework; path = /Library/Frameworks/SDL2.framework; sourceTree = "<absolute>"; };
|
||||||
@@ -206,8 +203,6 @@
|
|||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
FAC1A448196F5DC600125284 /* license.txt */,
|
FAC1A448196F5DC600125284 /* license.txt */,
|
||||||
FA0B78D01A95814A000E1D17 /* love.icns */,
|
|
||||||
FA0B78D11A95814A000E1D17 /* lovedocument.icns */,
|
|
||||||
);
|
);
|
||||||
name = Resources;
|
name = Resources;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@@ -379,9 +374,8 @@
|
|||||||
isa = PBXResourcesBuildPhase;
|
isa = PBXResourcesBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
|
FA5933751C6D625B000EC779 /* Images.xcassets in Resources */,
|
||||||
FAC1A449196F5DC600125284 /* license.txt in Resources */,
|
FAC1A449196F5DC600125284 /* license.txt in Resources */,
|
||||||
FA0B78D31A95814A000E1D17 /* lovedocument.icns in Resources */,
|
|
||||||
FA0B78D21A95814A000E1D17 /* love.icns in Resources */,
|
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
@@ -432,6 +426,7 @@
|
|||||||
C01FCF4B08A954540054247B /* Debug */ = {
|
C01FCF4B08A954540054247B /* Debug */ = {
|
||||||
isa = XCBuildConfiguration;
|
isa = XCBuildConfiguration;
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
|
ASSETCATALOG_COMPILER_APPICON_NAME = "OS X AppIcon";
|
||||||
COMBINE_HIDPI_IMAGES = YES;
|
COMBINE_HIDPI_IMAGES = YES;
|
||||||
FRAMEWORK_SEARCH_PATHS = (
|
FRAMEWORK_SEARCH_PATHS = (
|
||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
@@ -458,6 +453,7 @@
|
|||||||
C01FCF4C08A954540054247B /* Release */ = {
|
C01FCF4C08A954540054247B /* Release */ = {
|
||||||
isa = XCBuildConfiguration;
|
isa = XCBuildConfiguration;
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
|
ASSETCATALOG_COMPILER_APPICON_NAME = "OS X AppIcon";
|
||||||
COMBINE_HIDPI_IMAGES = YES;
|
COMBINE_HIDPI_IMAGES = YES;
|
||||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||||
FRAMEWORK_SEARCH_PATHS = (
|
FRAMEWORK_SEARCH_PATHS = (
|
||||||
@@ -597,8 +593,8 @@
|
|||||||
FA0B7F261A95AAF4000E1D17 /* Debug */ = {
|
FA0B7F261A95AAF4000E1D17 /* Debug */ = {
|
||||||
isa = XCBuildConfiguration;
|
isa = XCBuildConfiguration;
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
ASSETCATALOG_COMPILER_APPICON_NAME = "iOS AppIcon";
|
||||||
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
|
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = "iOS LaunchImage";
|
||||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||||
@@ -643,8 +639,8 @@
|
|||||||
FA0B7F271A95AAF4000E1D17 /* Release */ = {
|
FA0B7F271A95AAF4000E1D17 /* Release */ = {
|
||||||
isa = XCBuildConfiguration;
|
isa = XCBuildConfiguration;
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
ASSETCATALOG_COMPILER_APPICON_NAME = "iOS AppIcon";
|
||||||
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
|
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = "iOS LaunchImage";
|
||||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||||
@@ -685,8 +681,8 @@
|
|||||||
FA0B7F281A95AAF4000E1D17 /* Distribution */ = {
|
FA0B7F281A95AAF4000E1D17 /* Distribution */ = {
|
||||||
isa = XCBuildConfiguration;
|
isa = XCBuildConfiguration;
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
ASSETCATALOG_COMPILER_APPICON_NAME = "iOS AppIcon";
|
||||||
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
|
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = "iOS LaunchImage";
|
||||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||||
@@ -786,6 +782,7 @@
|
|||||||
FA5326C718971A0900F7BBF4 /* Distribution */ = {
|
FA5326C718971A0900F7BBF4 /* Distribution */ = {
|
||||||
isa = XCBuildConfiguration;
|
isa = XCBuildConfiguration;
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
|
ASSETCATALOG_COMPILER_APPICON_NAME = "OS X AppIcon";
|
||||||
COMBINE_HIDPI_IMAGES = YES;
|
COMBINE_HIDPI_IMAGES = YES;
|
||||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||||
FRAMEWORK_SEARCH_PATHS = (
|
FRAMEWORK_SEARCH_PATHS = (
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
<array>
|
<array>
|
||||||
<dict>
|
<dict>
|
||||||
<key>CFBundleTypeIconFile</key>
|
<key>CFBundleTypeIconFile</key>
|
||||||
<string>lovedocument</string>
|
<string>GameIcon</string>
|
||||||
<key>CFBundleTypeName</key>
|
<key>CFBundleTypeName</key>
|
||||||
<string>LÖVE Project</string>
|
<string>LÖVE Project</string>
|
||||||
<key>CFBundleTypeRole</key>
|
<key>CFBundleTypeRole</key>
|
||||||
@@ -47,8 +47,6 @@
|
|||||||
</array>
|
</array>
|
||||||
<key>CFBundleExecutable</key>
|
<key>CFBundleExecutable</key>
|
||||||
<string>love</string>
|
<string>love</string>
|
||||||
<key>CFBundleIconFile</key>
|
|
||||||
<string>love.icns</string>
|
|
||||||
<key>CFBundleIdentifier</key>
|
<key>CFBundleIdentifier</key>
|
||||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||||
<key>CFBundleInfoDictionaryVersion</key>
|
<key>CFBundleInfoDictionaryVersion</key>
|
||||||
@@ -79,7 +77,7 @@
|
|||||||
<key>UTTypeDescription</key>
|
<key>UTTypeDescription</key>
|
||||||
<string>LÖVE Project</string>
|
<string>LÖVE Project</string>
|
||||||
<key>UTTypeIconFile</key>
|
<key>UTTypeIconFile</key>
|
||||||
<string>lovedocument</string>
|
<string>GameIcon</string>
|
||||||
<key>UTTypeIdentifier</key>
|
<key>UTTypeIdentifier</key>
|
||||||
<string>org.love2d.love-game</string>
|
<string>org.love2d.love-game</string>
|
||||||
<key>UTTypeReferenceURL</key>
|
<key>UTTypeReferenceURL</key>
|
||||||
|
|||||||
@@ -26,35 +26,21 @@ namespace love
|
|||||||
|
|
||||||
static love::Type extractudatatype(lua_State *L, int idx)
|
static love::Type extractudatatype(lua_State *L, int idx)
|
||||||
{
|
{
|
||||||
Type t = INVALID_ID;
|
Proxy *u = (Proxy *)lua_touserdata(L, idx);
|
||||||
if (!lua_isuserdata(L, idx))
|
|
||||||
return t;
|
|
||||||
if (luaL_getmetafield(L, idx, "type") == 0)
|
|
||||||
return t;
|
|
||||||
lua_pushvalue(L, idx);
|
|
||||||
int result = lua_pcall(L, 1, 1, 0);
|
|
||||||
if (result == 0)
|
|
||||||
getTypeName(lua_tostring(L, -1), t);
|
|
||||||
if (result == 0 || result == LUA_ERRRUN)
|
|
||||||
lua_pop(L, 1);
|
|
||||||
return t;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void delete_table(std::vector<std::pair<Variant*, Variant*> > *table)
|
if (u == nullptr || u->type <= INVALID_ID || u->type >= TYPE_MAX_ENUM)
|
||||||
{
|
return INVALID_ID;
|
||||||
while (!table->empty())
|
|
||||||
{
|
// We could get rid of the dynamic_cast for more performance, but it would
|
||||||
std::pair<Variant*, Variant*> &kv = table->back();
|
// be less safe...
|
||||||
kv.first->release();
|
if (dynamic_cast<Object *>(u->object) != nullptr)
|
||||||
kv.second->release();
|
return u->type;
|
||||||
table->pop_back();
|
|
||||||
}
|
return INVALID_ID;
|
||||||
delete table;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::Variant()
|
Variant::Variant()
|
||||||
: type(NIL)
|
: type(NIL)
|
||||||
, data()
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,19 +57,18 @@ Variant::Variant(double number)
|
|||||||
}
|
}
|
||||||
|
|
||||||
Variant::Variant(const char *string, size_t len)
|
Variant::Variant(const char *string, size_t len)
|
||||||
: type(STRING)
|
|
||||||
{
|
{
|
||||||
char *buf = new char[len+1];
|
if (len <= MAX_SMALL_STRING_LENGTH)
|
||||||
memset(buf, 0, len+1);
|
{
|
||||||
memcpy(buf, string, len);
|
type = SMALLSTRING;
|
||||||
data.string.str = buf;
|
memcpy(data.smallstring.str, string, len);
|
||||||
data.string.len = len;
|
data.smallstring.len = (uint8) len;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
Variant::Variant(char c)
|
{
|
||||||
: type(CHARACTER)
|
type = STRING;
|
||||||
{
|
data.string = new SharedString(string, len);
|
||||||
data.character = c;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::Variant(void *userdata)
|
Variant::Variant(void *userdata)
|
||||||
@@ -107,10 +92,23 @@ Variant::Variant(love::Type udatatype, void *userdata)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Variant gets ownership of the vector.
|
// Variant gets ownership of the vector.
|
||||||
Variant::Variant(std::vector<std::pair<Variant*, Variant*> > *table)
|
Variant::Variant(std::vector<std::pair<Variant, Variant>> *table)
|
||||||
: type(TABLE)
|
: type(TABLE)
|
||||||
{
|
{
|
||||||
data.table = table;
|
data.table = new SharedTable(table);
|
||||||
|
}
|
||||||
|
|
||||||
|
Variant::Variant(const Variant &v)
|
||||||
|
: type(v.type)
|
||||||
|
, udatatype(v.udatatype)
|
||||||
|
, data(v.data)
|
||||||
|
{
|
||||||
|
if (type == STRING)
|
||||||
|
data.string->retain();
|
||||||
|
else if (type == FUSERDATA)
|
||||||
|
((love::Object *) data.userdata)->retain();
|
||||||
|
else if (type == TABLE)
|
||||||
|
data.table->retain();
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::~Variant()
|
Variant::~Variant()
|
||||||
@@ -118,102 +116,126 @@ Variant::~Variant()
|
|||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case STRING:
|
case STRING:
|
||||||
delete[] data.string.str;
|
data.string->release();
|
||||||
break;
|
break;
|
||||||
case FUSERDATA:
|
case FUSERDATA:
|
||||||
((love::Object *) data.userdata)->release();
|
((love::Object *) data.userdata)->release();
|
||||||
break;
|
break;
|
||||||
case TABLE:
|
case TABLE:
|
||||||
delete_table(data.table);
|
data.table->release();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant *Variant::fromLua(lua_State *L, int n, bool allowTables)
|
Variant &Variant::operator = (const Variant &v)
|
||||||
|
{
|
||||||
|
if (v.type == STRING)
|
||||||
|
v.data.string->retain();
|
||||||
|
else if (v.type == FUSERDATA)
|
||||||
|
((love::Object *) v.data.userdata)->retain();
|
||||||
|
else if (v.type == TABLE)
|
||||||
|
v.data.table->retain();
|
||||||
|
|
||||||
|
if (type == STRING)
|
||||||
|
data.string->release();
|
||||||
|
else if (type == FUSERDATA)
|
||||||
|
((love::Object *) v.data.userdata)->release();
|
||||||
|
else if (type == TABLE)
|
||||||
|
data.table->release();
|
||||||
|
|
||||||
|
type = v.type;
|
||||||
|
data = v.data;
|
||||||
|
udatatype = v.udatatype;
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Variant::fromLua(lua_State *L, int n, Variant *v, bool allowTables)
|
||||||
{
|
{
|
||||||
Variant *v = nullptr;
|
|
||||||
size_t len;
|
size_t len;
|
||||||
const char *str;
|
const char *str;
|
||||||
|
|
||||||
if (n < 0) // Fix the stack position, we might modify it later
|
if (n < 0) // Fix the stack position, we might modify it later
|
||||||
n += lua_gettop(L) + 1;
|
n += lua_gettop(L) + 1;
|
||||||
|
|
||||||
switch (lua_type(L, n))
|
switch (lua_type(L, n))
|
||||||
{
|
{
|
||||||
case LUA_TBOOLEAN:
|
case LUA_TBOOLEAN:
|
||||||
v = new Variant(luax_toboolean(L, n));
|
*v = Variant(luax_toboolean(L, n));
|
||||||
break;
|
return true;
|
||||||
case LUA_TNUMBER:
|
case LUA_TNUMBER:
|
||||||
v = new Variant(lua_tonumber(L, n));
|
*v = Variant(lua_tonumber(L, n));
|
||||||
break;
|
return true;
|
||||||
case LUA_TSTRING:
|
case LUA_TSTRING:
|
||||||
str = lua_tolstring(L, n, &len);
|
str = lua_tolstring(L, n, &len);
|
||||||
v = new Variant(str, len);
|
*v = Variant(str, len);
|
||||||
break;
|
return true;
|
||||||
case LUA_TLIGHTUSERDATA:
|
case LUA_TLIGHTUSERDATA:
|
||||||
v = new Variant(lua_touserdata(L, n));
|
*v = Variant(lua_touserdata(L, n));
|
||||||
break;
|
return true;
|
||||||
case LUA_TUSERDATA:
|
case LUA_TUSERDATA:
|
||||||
v = new Variant(extractudatatype(L, n), lua_touserdata(L, n));
|
*v = Variant(extractudatatype(L, n), lua_touserdata(L, n));
|
||||||
break;
|
return true;
|
||||||
case LUA_TNIL:
|
case LUA_TNIL:
|
||||||
v = new Variant();
|
*v = Variant();
|
||||||
break;
|
return true;
|
||||||
case LUA_TTABLE:
|
case LUA_TTABLE:
|
||||||
if (allowTables)
|
if (allowTables)
|
||||||
{
|
{
|
||||||
bool success = true;
|
bool success = true;
|
||||||
std::vector<std::pair<Variant*, Variant*>> *table = new std::vector<std::pair<Variant*, Variant*>>();
|
std::vector<std::pair<Variant, Variant>> *table = new std::vector<std::pair<Variant, Variant>>();
|
||||||
|
std::pair<Variant, Variant> pair;
|
||||||
|
|
||||||
|
size_t len = luax_objlen(L, -1);
|
||||||
|
if (len > 0)
|
||||||
|
table->reserve(len);
|
||||||
|
|
||||||
lua_pushnil(L);
|
lua_pushnil(L);
|
||||||
|
|
||||||
while (lua_next(L, n))
|
while (lua_next(L, n))
|
||||||
{
|
{
|
||||||
Variant *key = fromLua(L, -2, false);
|
if (!fromLua(L, -2, &pair.first, false) || !fromLua(L, -1, &pair.second, false))
|
||||||
if (!key)
|
|
||||||
{
|
{
|
||||||
success = false;
|
success = false;
|
||||||
lua_pop(L, 2);
|
lua_pop(L, 2);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant *value = fromLua(L, -1, false);
|
table->push_back(pair);
|
||||||
if (!value)
|
|
||||||
{
|
|
||||||
delete key;
|
|
||||||
success = false;
|
|
||||||
lua_pop(L, 2);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
table->push_back(std::make_pair(key, value));
|
|
||||||
|
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (success)
|
if (success)
|
||||||
v = new Variant(table);
|
{
|
||||||
|
*v = Variant(table);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
delete_table(table);
|
delete table;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return v;
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Variant::toLua(lua_State *L)
|
void Variant::toLua(lua_State *L) const
|
||||||
{
|
{
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case BOOLEAN:
|
case BOOLEAN:
|
||||||
lua_pushboolean(L, data.boolean);
|
lua_pushboolean(L, data.boolean);
|
||||||
break;
|
break;
|
||||||
case CHARACTER:
|
|
||||||
lua_pushlstring(L, &data.character, 1);
|
|
||||||
break;
|
|
||||||
case NUMBER:
|
case NUMBER:
|
||||||
lua_pushnumber(L, data.number);
|
lua_pushnumber(L, data.number);
|
||||||
break;
|
break;
|
||||||
case STRING:
|
case STRING:
|
||||||
lua_pushlstring(L, data.string.str, data.string.len);
|
lua_pushlstring(L, data.string->str, data.string->len);
|
||||||
|
break;
|
||||||
|
case SMALLSTRING:
|
||||||
|
lua_pushlstring(L, data.smallstring.str, data.smallstring.len);
|
||||||
break;
|
break;
|
||||||
case LUSERDATA:
|
case LUSERDATA:
|
||||||
lua_pushlightuserdata(L, data.userdata);
|
lua_pushlightuserdata(L, data.userdata);
|
||||||
@@ -228,15 +250,20 @@ void Variant::toLua(lua_State *L)
|
|||||||
// I can do (at the moment).
|
// I can do (at the moment).
|
||||||
break;
|
break;
|
||||||
case TABLE:
|
case TABLE:
|
||||||
lua_createtable(L, 0, (int) data.table->size());
|
{
|
||||||
for (size_t i = 0; i < data.table->size(); ++i)
|
std::vector<std::pair<Variant, Variant>> *table = data.table->table;
|
||||||
|
lua_createtable(L, 0, (int) table->size());
|
||||||
|
|
||||||
|
for (size_t i = 0; i < table->size(); ++i)
|
||||||
{
|
{
|
||||||
std::pair<Variant*, Variant*> &kv = data.table->at(i);
|
std::pair<Variant, Variant> &kv = table->at(i);
|
||||||
kv.first->toLua(L);
|
kv.first.toLua(L);
|
||||||
kv.second->toLua(L);
|
kv.second.toLua(L);
|
||||||
lua_settable(L, -3);
|
lua_settable(L, -3);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case NIL:
|
case NIL:
|
||||||
default:
|
default:
|
||||||
lua_pushnil(L);
|
lua_pushnil(L);
|
||||||
|
|||||||
@@ -23,15 +23,15 @@
|
|||||||
|
|
||||||
#include "common/runtime.h"
|
#include "common/runtime.h"
|
||||||
#include "common/Object.h"
|
#include "common/Object.h"
|
||||||
|
#include "common/int.h"
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <utility>
|
|
||||||
|
|
||||||
namespace love
|
namespace love
|
||||||
{
|
{
|
||||||
|
|
||||||
class Variant : public love::Object
|
class Variant
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@@ -39,44 +39,81 @@ public:
|
|||||||
Variant(bool boolean);
|
Variant(bool boolean);
|
||||||
Variant(double number);
|
Variant(double number);
|
||||||
Variant(const char *string, size_t len);
|
Variant(const char *string, size_t len);
|
||||||
Variant(char c);
|
|
||||||
Variant(void *userdata);
|
Variant(void *userdata);
|
||||||
Variant(love::Type udatatype, void *userdata);
|
Variant(love::Type udatatype, void *userdata);
|
||||||
Variant(std::vector<std::pair<Variant*, Variant*> > *table);
|
Variant(std::vector<std::pair<Variant, Variant>> *table);
|
||||||
virtual ~Variant();
|
Variant(const Variant &v);
|
||||||
|
~Variant();
|
||||||
|
|
||||||
static Variant *fromLua(lua_State *L, int n, bool allowTables = true);
|
Variant &operator = (const Variant &v);
|
||||||
void toLua(lua_State *L);
|
|
||||||
|
static bool fromLua(lua_State *L, int n, Variant *v, bool allowTables = true);
|
||||||
|
void toLua(lua_State *L) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
class SharedString : public love::Object
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
SharedString(const char *string, size_t len)
|
||||||
|
: len(len)
|
||||||
|
{
|
||||||
|
str = new char[len+1];
|
||||||
|
memcpy(str, string, len);
|
||||||
|
}
|
||||||
|
virtual ~SharedString() { delete[] str; }
|
||||||
|
|
||||||
|
char *str;
|
||||||
|
size_t len;
|
||||||
|
};
|
||||||
|
|
||||||
|
class SharedTable : public love::Object
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
SharedTable(std::vector<std::pair<Variant, Variant>> *table)
|
||||||
|
: table(table)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ~SharedTable() { delete table; }
|
||||||
|
|
||||||
|
std::vector<std::pair<Variant, Variant>> *table;
|
||||||
|
};
|
||||||
|
|
||||||
enum Type
|
enum Type
|
||||||
{
|
{
|
||||||
UNKNOWN = 0,
|
UNKNOWN = 0,
|
||||||
BOOLEAN,
|
BOOLEAN,
|
||||||
NUMBER,
|
NUMBER,
|
||||||
CHARACTER,
|
|
||||||
STRING,
|
STRING,
|
||||||
|
SMALLSTRING,
|
||||||
LUSERDATA,
|
LUSERDATA,
|
||||||
FUSERDATA,
|
FUSERDATA,
|
||||||
NIL,
|
NIL,
|
||||||
TABLE
|
TABLE
|
||||||
} type;
|
};
|
||||||
union
|
|
||||||
|
static const int MAX_SMALL_STRING_LENGTH = 15;
|
||||||
|
|
||||||
|
Type type;
|
||||||
|
love::Type udatatype;
|
||||||
|
|
||||||
|
union Data
|
||||||
{
|
{
|
||||||
bool boolean;
|
bool boolean;
|
||||||
char character;
|
|
||||||
double number;
|
double number;
|
||||||
|
SharedString *string;
|
||||||
|
void *userdata;
|
||||||
|
SharedTable *table;
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
const char *str;
|
char str[MAX_SMALL_STRING_LENGTH];
|
||||||
size_t len;
|
uint8 len;
|
||||||
} string;
|
} smallstring;
|
||||||
void *userdata;
|
|
||||||
std::vector<std::pair<Variant*, Variant*>> *table;
|
|
||||||
} data;
|
} data;
|
||||||
|
|
||||||
private:
|
|
||||||
love::Type udatatype;
|
|
||||||
|
|
||||||
}; // Variant
|
}; // Variant
|
||||||
} // love
|
} // love
|
||||||
|
|
||||||
|
|||||||
@@ -445,7 +445,7 @@ T *luax_checktype(lua_State *L, int idx, love::Type type)
|
|||||||
|
|
||||||
Proxy *u = (Proxy *)lua_touserdata(L, idx);
|
Proxy *u = (Proxy *)lua_touserdata(L, idx);
|
||||||
|
|
||||||
if (!typeFlags[u->type][type])
|
if (u->type <= INVALID_ID || u->type >= TYPE_MAX_ENUM || !typeFlags[u->type][type])
|
||||||
{
|
{
|
||||||
const char *name = "Invalid";
|
const char *name = "Invalid";
|
||||||
getTypeName(type, name);
|
getTypeName(type, name);
|
||||||
@@ -469,7 +469,7 @@ T *luax_getmodule(lua_State *L, love::Type type)
|
|||||||
|
|
||||||
Proxy *u = (Proxy *)lua_touserdata(L, -1);
|
Proxy *u = (Proxy *)lua_touserdata(L, -1);
|
||||||
|
|
||||||
if (!typeFlags[u->type][type])
|
if (u->type <= INVALID_ID || u->type >= TYPE_MAX_ENUM || !typeFlags[u->type][type])
|
||||||
luaL_error(L, "Incorrect module %s", name);
|
luaL_error(L, "Incorrect module %s", name);
|
||||||
|
|
||||||
lua_pop(L, 2);
|
lua_pop(L, 2);
|
||||||
|
|||||||
@@ -574,7 +574,7 @@ void Source::setRelative(bool enable)
|
|||||||
throw SpatialSupportException();
|
throw SpatialSupportException();
|
||||||
|
|
||||||
if (valid)
|
if (valid)
|
||||||
alSourcei(source, AL_SOURCE_RELATIVE, relative ? AL_TRUE : AL_FALSE);
|
alSourcei(source, AL_SOURCE_RELATIVE, enable ? AL_TRUE : AL_FALSE);
|
||||||
|
|
||||||
relative = enable;
|
relative = enable;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ namespace love
|
|||||||
namespace event
|
namespace event
|
||||||
{
|
{
|
||||||
|
|
||||||
Message::Message(const std::string &name, const std::vector<StrongRef<Variant>> &vargs)
|
Message::Message(const std::string &name, const std::vector<Variant> &vargs)
|
||||||
: name(name)
|
: name(name)
|
||||||
, args(vargs)
|
, args(vargs)
|
||||||
{
|
{
|
||||||
@@ -42,13 +42,8 @@ int Message::toLua(lua_State *L)
|
|||||||
{
|
{
|
||||||
luax_pushstring(L, name);
|
luax_pushstring(L, name);
|
||||||
|
|
||||||
for (const StrongRef<Variant> &v : args)
|
for (const Variant &v : args)
|
||||||
{
|
v.toLua(L);
|
||||||
if (v.get() != nullptr)
|
|
||||||
v->toLua(L);
|
|
||||||
else
|
|
||||||
lua_pushnil(L);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (int) args.size() + 1;
|
return (int) args.size() + 1;
|
||||||
}
|
}
|
||||||
@@ -56,26 +51,26 @@ int Message::toLua(lua_State *L)
|
|||||||
Message *Message::fromLua(lua_State *L, int n)
|
Message *Message::fromLua(lua_State *L, int n)
|
||||||
{
|
{
|
||||||
std::string name = luax_checkstring(L, n);
|
std::string name = luax_checkstring(L, n);
|
||||||
std::vector<StrongRef<Variant>> vargs;
|
std::vector<Variant> vargs;
|
||||||
|
|
||||||
int count = lua_gettop(L) - n;
|
int count = lua_gettop(L) - n;
|
||||||
n++;
|
n++;
|
||||||
|
|
||||||
|
Variant varg;
|
||||||
|
|
||||||
for (int i = 0; i < count; i++)
|
for (int i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
if (lua_isnoneornil(L, n+i))
|
if (lua_isnoneornil(L, n+i))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
vargs.push_back(Variant::fromLua(L, n+i));
|
if (!Variant::fromLua(L, n+i, &varg))
|
||||||
|
|
||||||
if (!vargs.back().get())
|
|
||||||
{
|
{
|
||||||
vargs.clear();
|
vargs.clear();
|
||||||
luaL_error(L, "Argument %d can't be stored safely\nExpected boolean, number, string or userdata.", n+i);
|
luaL_error(L, "Argument %d can't be stored safely\nExpected boolean, number, string or userdata.", n+i);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
vargs.back()->release(); // fromLua gave a +1 ref.
|
vargs.push_back(varg);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Message(name, vargs);
|
return new Message(name, vargs);
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ class Message : public Object
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Message(const std::string &name, const std::vector<StrongRef<Variant>> &vargs = {});
|
Message(const std::string &name, const std::vector<Variant> &vargs = {});
|
||||||
~Message();
|
~Message();
|
||||||
|
|
||||||
int toLua(lua_State *L);
|
int toLua(lua_State *L);
|
||||||
@@ -52,7 +52,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
|
|
||||||
std::string name;
|
std::string name;
|
||||||
std::vector<StrongRef<Variant>> args;
|
std::vector<Variant> args;
|
||||||
|
|
||||||
}; // Message
|
}; // Message
|
||||||
|
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ Message *Event::convert(const SDL_Event &e) const
|
|||||||
{
|
{
|
||||||
Message *msg = nullptr;
|
Message *msg = nullptr;
|
||||||
|
|
||||||
std::vector<StrongRef<Variant>> vargs;
|
std::vector<Variant> vargs;
|
||||||
vargs.reserve(4);
|
vargs.reserve(4);
|
||||||
|
|
||||||
love::filesystem::Filesystem *filesystem = nullptr;
|
love::filesystem::Filesystem *filesystem = nullptr;
|
||||||
@@ -192,9 +192,9 @@ Message *Event::convert(const SDL_Event &e) const
|
|||||||
if (!love::keyboard::Keyboard::getConstant(scancode, txt2))
|
if (!love::keyboard::Keyboard::getConstant(scancode, txt2))
|
||||||
txt2 = "unknown";
|
txt2 = "unknown";
|
||||||
|
|
||||||
vargs.push_back(new Variant(txt, strlen(txt)));
|
vargs.emplace_back(txt, strlen(txt));
|
||||||
vargs.push_back(new Variant(txt2, strlen(txt2)));
|
vargs.emplace_back(txt2, strlen(txt2));
|
||||||
vargs.push_back(new Variant(e.key.repeat != 0));
|
vargs.emplace_back(e.key.repeat != 0);
|
||||||
msg = new Message("keypressed", vargs);
|
msg = new Message("keypressed", vargs);
|
||||||
break;
|
break;
|
||||||
case SDL_KEYUP:
|
case SDL_KEYUP:
|
||||||
@@ -209,20 +209,20 @@ Message *Event::convert(const SDL_Event &e) const
|
|||||||
if (!love::keyboard::Keyboard::getConstant(scancode, txt2))
|
if (!love::keyboard::Keyboard::getConstant(scancode, txt2))
|
||||||
txt2 = "unknown";
|
txt2 = "unknown";
|
||||||
|
|
||||||
vargs.push_back(new Variant(txt, strlen(txt)));
|
vargs.emplace_back(txt, strlen(txt));
|
||||||
vargs.push_back(new Variant(txt2, strlen(txt2)));
|
vargs.emplace_back(txt2, strlen(txt2));
|
||||||
msg = new Message("keyreleased", vargs);
|
msg = new Message("keyreleased", vargs);
|
||||||
break;
|
break;
|
||||||
case SDL_TEXTINPUT:
|
case SDL_TEXTINPUT:
|
||||||
txt = e.text.text;
|
txt = e.text.text;
|
||||||
vargs.push_back(new Variant(txt, strlen(txt)));
|
vargs.emplace_back(txt, strlen(txt));
|
||||||
msg = new Message("textinput", vargs);
|
msg = new Message("textinput", vargs);
|
||||||
break;
|
break;
|
||||||
case SDL_TEXTEDITING:
|
case SDL_TEXTEDITING:
|
||||||
txt = e.edit.text;
|
txt = e.edit.text;
|
||||||
vargs.push_back(new Variant(txt, strlen(txt)));
|
vargs.emplace_back(txt, strlen(txt));
|
||||||
vargs.push_back(new Variant((double) e.edit.start));
|
vargs.emplace_back((double) e.edit.start);
|
||||||
vargs.push_back(new Variant((double) e.edit.length));
|
vargs.emplace_back((double) e.edit.length);
|
||||||
msg = new Message("textedited", vargs);
|
msg = new Message("textedited", vargs);
|
||||||
break;
|
break;
|
||||||
case SDL_MOUSEMOTION:
|
case SDL_MOUSEMOTION:
|
||||||
@@ -233,11 +233,11 @@ Message *Event::convert(const SDL_Event &e) const
|
|||||||
double yrel = (double) e.motion.yrel;
|
double yrel = (double) e.motion.yrel;
|
||||||
windowToPixelCoords(&x, &y);
|
windowToPixelCoords(&x, &y);
|
||||||
windowToPixelCoords(&xrel, &yrel);
|
windowToPixelCoords(&xrel, &yrel);
|
||||||
vargs.push_back(new Variant(x));
|
vargs.emplace_back(x);
|
||||||
vargs.push_back(new Variant(y));
|
vargs.emplace_back(y);
|
||||||
vargs.push_back(new Variant(xrel));
|
vargs.emplace_back(xrel);
|
||||||
vargs.push_back(new Variant(yrel));
|
vargs.emplace_back(yrel);
|
||||||
vargs.push_back(new Variant(e.motion.which == SDL_TOUCH_MOUSEID));
|
vargs.emplace_back(e.motion.which == SDL_TOUCH_MOUSEID);
|
||||||
msg = new Message("mousemoved", vargs);
|
msg = new Message("mousemoved", vargs);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -260,18 +260,18 @@ Message *Event::convert(const SDL_Event &e) const
|
|||||||
double x = (double) e.button.x;
|
double x = (double) e.button.x;
|
||||||
double y = (double) e.button.y;
|
double y = (double) e.button.y;
|
||||||
windowToPixelCoords(&x, &y);
|
windowToPixelCoords(&x, &y);
|
||||||
vargs.push_back(new Variant(x));
|
vargs.emplace_back(x);
|
||||||
vargs.push_back(new Variant(y));
|
vargs.emplace_back(y);
|
||||||
vargs.push_back(new Variant((double) button));
|
vargs.emplace_back((double) button);
|
||||||
vargs.push_back(new Variant(e.button.which == SDL_TOUCH_MOUSEID));
|
vargs.emplace_back(e.button.which == SDL_TOUCH_MOUSEID);
|
||||||
msg = new Message((e.type == SDL_MOUSEBUTTONDOWN) ?
|
msg = new Message((e.type == SDL_MOUSEBUTTONDOWN) ?
|
||||||
"mousepressed" : "mousereleased",
|
"mousepressed" : "mousereleased",
|
||||||
vargs);
|
vargs);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SDL_MOUSEWHEEL:
|
case SDL_MOUSEWHEEL:
|
||||||
vargs.push_back(new Variant((double) e.wheel.x));
|
vargs.emplace_back((double) e.wheel.x);
|
||||||
vargs.push_back(new Variant((double) e.wheel.y));
|
vargs.emplace_back((double) e.wheel.y);
|
||||||
msg = new Message("wheelmoved", vargs);
|
msg = new Message("wheelmoved", vargs);
|
||||||
break;
|
break;
|
||||||
case SDL_FINGERDOWN:
|
case SDL_FINGERDOWN:
|
||||||
@@ -316,12 +316,12 @@ Message *Event::convert(const SDL_Event &e) const
|
|||||||
// bits as can fit in a pointer (for now.)
|
// bits as can fit in a pointer (for now.)
|
||||||
// We use lightuserdata instead of a lua_Number (double) because doubles
|
// We use lightuserdata instead of a lua_Number (double) because doubles
|
||||||
// can't represent all possible id values on 64-bit systems.
|
// can't represent all possible id values on 64-bit systems.
|
||||||
vargs.push_back(new Variant((void *) (intptr_t) touchinfo.id));
|
vargs.emplace_back((void *) (intptr_t) touchinfo.id);
|
||||||
vargs.push_back(new Variant(touchinfo.x));
|
vargs.emplace_back(touchinfo.x);
|
||||||
vargs.push_back(new Variant(touchinfo.y));
|
vargs.emplace_back(touchinfo.y);
|
||||||
vargs.push_back(new Variant(touchinfo.dx));
|
vargs.emplace_back(touchinfo.dx);
|
||||||
vargs.push_back(new Variant(touchinfo.dy));
|
vargs.emplace_back(touchinfo.dy);
|
||||||
vargs.push_back(new Variant(touchinfo.pressure));
|
vargs.emplace_back(touchinfo.pressure);
|
||||||
|
|
||||||
if (e.type == SDL_FINGERDOWN)
|
if (e.type == SDL_FINGERDOWN)
|
||||||
txt = "touchpressed";
|
txt = "touchpressed";
|
||||||
@@ -356,7 +356,7 @@ Message *Event::convert(const SDL_Event &e) const
|
|||||||
|
|
||||||
if (filesystem->isRealDirectory(e.drop.file))
|
if (filesystem->isRealDirectory(e.drop.file))
|
||||||
{
|
{
|
||||||
vargs.push_back(new Variant(e.drop.file, strlen(e.drop.file)));
|
vargs.emplace_back(e.drop.file, strlen(e.drop.file));
|
||||||
msg = new Message("directorydropped", vargs);
|
msg = new Message("directorydropped", vargs);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -364,7 +364,7 @@ Message *Event::convert(const SDL_Event &e) const
|
|||||||
Proxy proxy;
|
Proxy proxy;
|
||||||
proxy.object = new love::filesystem::DroppedFile(e.drop.file);
|
proxy.object = new love::filesystem::DroppedFile(e.drop.file);
|
||||||
proxy.type = FILESYSTEM_DROPPED_FILE_ID;
|
proxy.type = FILESYSTEM_DROPPED_FILE_ID;
|
||||||
vargs.push_back(new Variant(proxy.type, &proxy));
|
vargs.emplace_back(proxy.type, &proxy);
|
||||||
msg = new Message("filedropped", vargs);
|
msg = new Message("filedropped", vargs);
|
||||||
proxy.object->release();
|
proxy.object->release();
|
||||||
}
|
}
|
||||||
@@ -382,13 +382,6 @@ Message *Event::convert(const SDL_Event &e) const
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// We gave +1 refs to the StrongRef list, so we should release them.
|
|
||||||
for (const StrongRef<Variant> &v : vargs)
|
|
||||||
{
|
|
||||||
if (v.get() != nullptr)
|
|
||||||
v->release();
|
|
||||||
}
|
|
||||||
|
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -400,7 +393,7 @@ Message *Event::convertJoystickEvent(const SDL_Event &e) const
|
|||||||
|
|
||||||
Message *msg = nullptr;
|
Message *msg = nullptr;
|
||||||
|
|
||||||
std::vector<StrongRef<Variant>> vargs;
|
std::vector<Variant> vargs;
|
||||||
vargs.reserve(4);
|
vargs.reserve(4);
|
||||||
|
|
||||||
Proxy proxy;
|
Proxy proxy;
|
||||||
@@ -418,8 +411,8 @@ Message *Event::convertJoystickEvent(const SDL_Event &e) const
|
|||||||
if (!proxy.object)
|
if (!proxy.object)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
vargs.push_back(new Variant(proxy.type, (void *) &proxy));
|
vargs.emplace_back(proxy.type, (void *) &proxy);
|
||||||
vargs.push_back(new Variant((double)(e.jbutton.button+1)));
|
vargs.emplace_back((double)(e.jbutton.button+1));
|
||||||
msg = new Message((e.type == SDL_JOYBUTTONDOWN) ?
|
msg = new Message((e.type == SDL_JOYBUTTONDOWN) ?
|
||||||
"joystickpressed" : "joystickreleased",
|
"joystickpressed" : "joystickreleased",
|
||||||
vargs);
|
vargs);
|
||||||
@@ -431,10 +424,10 @@ Message *Event::convertJoystickEvent(const SDL_Event &e) const
|
|||||||
if (!proxy.object)
|
if (!proxy.object)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
vargs.push_back(new Variant(proxy.type, (void *) &proxy));
|
vargs.emplace_back(proxy.type, (void *) &proxy);
|
||||||
vargs.push_back(new Variant((double)(e.jaxis.axis+1)));
|
vargs.emplace_back((double)(e.jaxis.axis+1));
|
||||||
float value = joystick::Joystick::clampval(e.jaxis.value / 32768.0f);
|
float value = joystick::Joystick::clampval(e.jaxis.value / 32768.0f);
|
||||||
vargs.push_back(new Variant((double) value));
|
vargs.emplace_back((double) value);
|
||||||
msg = new Message("joystickaxis", vargs);
|
msg = new Message("joystickaxis", vargs);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -447,9 +440,9 @@ Message *Event::convertJoystickEvent(const SDL_Event &e) const
|
|||||||
if (!proxy.object)
|
if (!proxy.object)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
vargs.push_back(new Variant(proxy.type, (void *) &proxy));
|
vargs.emplace_back(proxy.type, (void *) &proxy);
|
||||||
vargs.push_back(new Variant((double)(e.jhat.hat+1)));
|
vargs.emplace_back((double)(e.jhat.hat+1));
|
||||||
vargs.push_back(new Variant(txt, strlen(txt)));
|
vargs.emplace_back(txt, strlen(txt));
|
||||||
msg = new Message("joystickhat", vargs);
|
msg = new Message("joystickhat", vargs);
|
||||||
break;
|
break;
|
||||||
case SDL_CONTROLLERBUTTONDOWN:
|
case SDL_CONTROLLERBUTTONDOWN:
|
||||||
@@ -465,8 +458,8 @@ Message *Event::convertJoystickEvent(const SDL_Event &e) const
|
|||||||
if (!proxy.object)
|
if (!proxy.object)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
vargs.push_back(new Variant(proxy.type, (void *) &proxy));
|
vargs.emplace_back(proxy.type, (void *) &proxy);
|
||||||
vargs.push_back(new Variant(txt, strlen(txt)));
|
vargs.emplace_back(txt, strlen(txt));
|
||||||
msg = new Message(e.type == SDL_CONTROLLERBUTTONDOWN ?
|
msg = new Message(e.type == SDL_CONTROLLERBUTTONDOWN ?
|
||||||
"gamepadpressed" : "gamepadreleased", vargs);
|
"gamepadpressed" : "gamepadreleased", vargs);
|
||||||
break;
|
break;
|
||||||
@@ -481,11 +474,11 @@ Message *Event::convertJoystickEvent(const SDL_Event &e) const
|
|||||||
if (!proxy.object)
|
if (!proxy.object)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
vargs.push_back(new Variant(proxy.type, (void *) &proxy));
|
vargs.emplace_back(proxy.type, (void *) &proxy);
|
||||||
|
|
||||||
vargs.push_back(new Variant(txt, strlen(txt)));
|
vargs.emplace_back(txt, strlen(txt));
|
||||||
float value = joystick::Joystick::clampval(e.caxis.value / 32768.0f);
|
float value = joystick::Joystick::clampval(e.caxis.value / 32768.0f);
|
||||||
vargs.push_back(new Variant((double) value));
|
vargs.emplace_back((double) value);
|
||||||
msg = new Message("gamepadaxis", vargs);
|
msg = new Message("gamepadaxis", vargs);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -495,7 +488,7 @@ Message *Event::convertJoystickEvent(const SDL_Event &e) const
|
|||||||
proxy.type = JOYSTICK_JOYSTICK_ID;
|
proxy.type = JOYSTICK_JOYSTICK_ID;
|
||||||
if (proxy.object)
|
if (proxy.object)
|
||||||
{
|
{
|
||||||
vargs.push_back(new Variant(proxy.type, (void *) &proxy));
|
vargs.emplace_back(proxy.type, (void *) &proxy);
|
||||||
msg = new Message("joystickadded", vargs);
|
msg = new Message("joystickadded", vargs);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -506,37 +499,14 @@ Message *Event::convertJoystickEvent(const SDL_Event &e) const
|
|||||||
if (proxy.object)
|
if (proxy.object)
|
||||||
{
|
{
|
||||||
joymodule->removeJoystick((joystick::Joystick *) proxy.object);
|
joymodule->removeJoystick((joystick::Joystick *) proxy.object);
|
||||||
vargs.push_back(new Variant(proxy.type, (void *) &proxy));
|
vargs.emplace_back(proxy.type, (void *) &proxy);
|
||||||
msg = new Message("joystickremoved", vargs);
|
msg = new Message("joystickremoved", vargs);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#ifdef LOVE_ANDROID
|
|
||||||
case SDL_WINDOWEVENT_MINIMIZED:
|
|
||||||
{
|
|
||||||
auto audio = Module::getInstance<audio::Audio>(Module::M_AUDIO);
|
|
||||||
if (audio)
|
|
||||||
audio->pause();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case SDL_WINDOWEVENT_RESTORED:
|
|
||||||
{
|
|
||||||
auto audio = Module::getInstance<audio::Audio>(Module::M_AUDIO);
|
|
||||||
if (audio)
|
|
||||||
audio->resume();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// We gave +1 refs to the StrongRef list, so we should release them.
|
|
||||||
for (const StrongRef<Variant> &v : vargs)
|
|
||||||
{
|
|
||||||
if (v.get() != nullptr)
|
|
||||||
v->release();
|
|
||||||
}
|
|
||||||
|
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -544,7 +514,7 @@ Message *Event::convertWindowEvent(const SDL_Event &e) const
|
|||||||
{
|
{
|
||||||
Message *msg = nullptr;
|
Message *msg = nullptr;
|
||||||
|
|
||||||
std::vector<StrongRef<Variant>> vargs;
|
std::vector<Variant> vargs;
|
||||||
vargs.reserve(4);
|
vargs.reserve(4);
|
||||||
|
|
||||||
window::Window *win = nullptr;
|
window::Window *win = nullptr;
|
||||||
@@ -556,17 +526,17 @@ Message *Event::convertWindowEvent(const SDL_Event &e) const
|
|||||||
{
|
{
|
||||||
case SDL_WINDOWEVENT_FOCUS_GAINED:
|
case SDL_WINDOWEVENT_FOCUS_GAINED:
|
||||||
case SDL_WINDOWEVENT_FOCUS_LOST:
|
case SDL_WINDOWEVENT_FOCUS_LOST:
|
||||||
vargs.push_back(new Variant(e.window.event == SDL_WINDOWEVENT_FOCUS_GAINED));
|
vargs.emplace_back(e.window.event == SDL_WINDOWEVENT_FOCUS_GAINED);
|
||||||
msg = new Message("focus", vargs);
|
msg = new Message("focus", vargs);
|
||||||
break;
|
break;
|
||||||
case SDL_WINDOWEVENT_ENTER:
|
case SDL_WINDOWEVENT_ENTER:
|
||||||
case SDL_WINDOWEVENT_LEAVE:
|
case SDL_WINDOWEVENT_LEAVE:
|
||||||
vargs.push_back(new Variant(e.window.event == SDL_WINDOWEVENT_ENTER));
|
vargs.emplace_back(e.window.event == SDL_WINDOWEVENT_ENTER);
|
||||||
msg = new Message("mousefocus", vargs);
|
msg = new Message("mousefocus", vargs);
|
||||||
break;
|
break;
|
||||||
case SDL_WINDOWEVENT_SHOWN:
|
case SDL_WINDOWEVENT_SHOWN:
|
||||||
case SDL_WINDOWEVENT_HIDDEN:
|
case SDL_WINDOWEVENT_HIDDEN:
|
||||||
vargs.push_back(new Variant(e.window.event == SDL_WINDOWEVENT_SHOWN));
|
vargs.emplace_back(e.window.event == SDL_WINDOWEVENT_SHOWN);
|
||||||
msg = new Message("visible", vargs);
|
msg = new Message("visible", vargs);
|
||||||
break;
|
break;
|
||||||
case SDL_WINDOWEVENT_RESIZED:
|
case SDL_WINDOWEVENT_RESIZED:
|
||||||
@@ -578,10 +548,10 @@ Message *Event::convertWindowEvent(const SDL_Event &e) const
|
|||||||
if (sdlwin)
|
if (sdlwin)
|
||||||
SDL_GL_GetDrawableSize(sdlwin, &px_w, &px_h);
|
SDL_GL_GetDrawableSize(sdlwin, &px_w, &px_h);
|
||||||
|
|
||||||
vargs.push_back(new Variant((double) px_w));
|
vargs.emplace_back((double) px_w);
|
||||||
vargs.push_back(new Variant((double) px_h));
|
vargs.emplace_back((double) px_h);
|
||||||
vargs.push_back(new Variant((double) e.window.data1));
|
vargs.emplace_back((double) e.window.data1);
|
||||||
vargs.push_back(new Variant((double) e.window.data2));
|
vargs.emplace_back((double) e.window.data2);
|
||||||
msg = new Message("resize", vargs);
|
msg = new Message("resize", vargs);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -590,13 +560,21 @@ Message *Event::convertWindowEvent(const SDL_Event &e) const
|
|||||||
if (win)
|
if (win)
|
||||||
win->onSizeChanged(e.window.data1, e.window.data2);
|
win->onSizeChanged(e.window.data1, e.window.data2);
|
||||||
break;
|
break;
|
||||||
}
|
case SDL_WINDOWEVENT_MINIMIZED:
|
||||||
|
case SDL_WINDOWEVENT_RESTORED:
|
||||||
// We gave +1 refs to the StrongRef list, so we should release them.
|
#ifdef LOVE_ANDROID
|
||||||
for (const StrongRef<Variant> &v : vargs)
|
|
||||||
{
|
{
|
||||||
if (v.get() != nullptr)
|
auto audio = Module::getInstance<audio::Audio>(Module::M_AUDIO);
|
||||||
v->release();
|
if (audio)
|
||||||
|
{
|
||||||
|
if (e.window.event == SDL_WINDOWEVENT_MINIMIZED)
|
||||||
|
audio->pause();
|
||||||
|
else if (e.window.event == SDL_WINDOWEVENT_RESTORED)
|
||||||
|
audio->resume();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return msg;
|
return msg;
|
||||||
|
|||||||
@@ -95,14 +95,11 @@ int w_clear(lua_State *)
|
|||||||
|
|
||||||
int w_quit(lua_State *L)
|
int w_quit(lua_State *L)
|
||||||
{
|
{
|
||||||
std::vector<StrongRef<Variant>> args;
|
std::vector<Variant> args;
|
||||||
|
|
||||||
Variant *v = Variant::fromLua(L, 1);
|
Variant v;
|
||||||
if (v)
|
if (Variant::fromLua(L, 1, &v))
|
||||||
{
|
|
||||||
args.push_back(v);
|
args.push_back(v);
|
||||||
v->release();
|
|
||||||
}
|
|
||||||
|
|
||||||
Message *m = new Message("quit", args);
|
Message *m = new Message("quit", args);
|
||||||
instance()->push(m);
|
instance()->push(m);
|
||||||
|
|||||||
@@ -117,6 +117,7 @@ public:
|
|||||||
return actual_samples;
|
return actual_samples;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Format getSizedFormat(Format format);
|
||||||
static bool isSupported();
|
static bool isSupported();
|
||||||
static bool isMultiFormatMultiCanvasSupported();
|
static bool isMultiFormatMultiCanvasSupported();
|
||||||
static bool isFormatSupported(Format format);
|
static bool isFormatSupported(Format format);
|
||||||
@@ -143,7 +144,6 @@ private:
|
|||||||
|
|
||||||
void drawv(const Matrix4 &t, const Vertex *v);
|
void drawv(const Matrix4 &t, const Vertex *v);
|
||||||
|
|
||||||
static Format getSizedFormat(Format format);
|
|
||||||
static void convertFormat(Format format, GLenum &internalformat, GLenum &externalformat, GLenum &type);
|
static void convertFormat(Format format, GLenum &internalformat, GLenum &externalformat, GLenum &type);
|
||||||
static size_t getFormatBitsPerPixel(Format format);
|
static size_t getFormatBitsPerPixel(Format format);
|
||||||
|
|
||||||
|
|||||||
@@ -459,17 +459,23 @@ void Graphics::clear(const std::vector<OptionalColorf> &colors)
|
|||||||
if (colors.size() == 0)
|
if (colors.size() == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (states.back().canvases.size() == 0)
|
size_t numcanvases = states.back().canvases.size();
|
||||||
|
|
||||||
|
if (numcanvases > 0 && colors.size() != numcanvases)
|
||||||
|
throw love::Exception("Number of clear colors must match the number of active canvases (%ld)", states.back().canvases.size());
|
||||||
|
|
||||||
|
// We want to take the single-color codepath if there's no active Canvas, or
|
||||||
|
// if there's only one active Canvas. The multi-color codepath (in the loop
|
||||||
|
// below) assumes MRT functions are available, and also may call more
|
||||||
|
// expensive GL functions which are unnecessary if only one Canvas is active.
|
||||||
|
if (numcanvases <= 1)
|
||||||
{
|
{
|
||||||
if (colors[0].enabled)
|
if (colors[0].enabled)
|
||||||
clear({colors[0].r, colors[0].g, colors[0].b, colors[0].a});
|
clear(colors[0].toColor());
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (colors.size() != states.back().canvases.size())
|
|
||||||
throw love::Exception("Number of clear colors must match the number of active canvases (%ld)", states.back().canvases.size());
|
|
||||||
|
|
||||||
bool drawbuffermodified = false;
|
bool drawbuffermodified = false;
|
||||||
|
|
||||||
for (int i = 0; i < (int) colors.size(); i++)
|
for (int i = 0; i < (int) colors.size(); i++)
|
||||||
@@ -840,11 +846,14 @@ ParticleSystem *Graphics::newParticleSystem(Texture *texture, int size)
|
|||||||
|
|
||||||
Canvas *Graphics::newCanvas(int width, int height, Canvas::Format format, int msaa)
|
Canvas *Graphics::newCanvas(int width, int height, Canvas::Format format, int msaa)
|
||||||
{
|
{
|
||||||
|
if (!Canvas::isSupported())
|
||||||
|
throw love::Exception("Canvases are not supported by your OpenGL drivers!");
|
||||||
|
|
||||||
if (!Canvas::isFormatSupported(format))
|
if (!Canvas::isFormatSupported(format))
|
||||||
{
|
{
|
||||||
const char *fstr = "rgba8";
|
const char *fstr = "rgba8";
|
||||||
Canvas::getConstant(format, fstr);
|
Canvas::getConstant(Canvas::getSizedFormat(format), fstr);
|
||||||
throw love::Exception("The %s canvas format is not supported by your OpenGL implementation.", fstr);
|
throw love::Exception("The %s canvas format is not supported by your OpenGL drivers.", fstr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (width > gl.getMaxTextureSize())
|
if (width > gl.getMaxTextureSize())
|
||||||
@@ -868,7 +877,7 @@ Canvas *Graphics::newCanvas(int width, int height, Canvas::Format format, int ms
|
|||||||
switch (err)
|
switch (err)
|
||||||
{
|
{
|
||||||
case GL_FRAMEBUFFER_UNSUPPORTED:
|
case GL_FRAMEBUFFER_UNSUPPORTED:
|
||||||
error_string << "Not supported by your OpenGL implementation.";
|
error_string << "Not supported by your OpenGL drivers.";
|
||||||
break;
|
break;
|
||||||
case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT:
|
case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT:
|
||||||
error_string << "Texture format cannot be rendered to on this system.";
|
error_string << "Texture format cannot be rendered to on this system.";
|
||||||
@@ -879,14 +888,14 @@ Canvas *Graphics::newCanvas(int width, int height, Canvas::Format format, int ms
|
|||||||
case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER:
|
case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER:
|
||||||
case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER:
|
case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER:
|
||||||
case GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE:
|
case GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE:
|
||||||
error_string << "Error in implementation.";
|
error_string << "Error in graphics driver.";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// my intel hda card wrongly returns 0 to glCheckFramebufferStatus() but sets
|
// my intel hda card wrongly returns 0 to glCheckFramebufferStatus() but sets
|
||||||
// no error flag. I think it meant to return GL_FRAMEBUFFER_UNSUPPORTED, but who
|
// no error flag. I think it meant to return GL_FRAMEBUFFER_UNSUPPORTED, but who
|
||||||
// knows.
|
// knows.
|
||||||
if (glGetError() == GL_NO_ERROR)
|
if (glGetError() == GL_NO_ERROR)
|
||||||
error_string << "May not be supported by your OpenGL implementation.";
|
error_string << "May not be supported by your OpenGL drivers.";
|
||||||
// the remaining error is an indication of a serious fuckup since it should
|
// the remaining error is an indication of a serious fuckup since it should
|
||||||
// only be returned if glCheckFramebufferStatus() was called with the wrong
|
// only be returned if glCheckFramebufferStatus() was called with the wrong
|
||||||
// arguments.
|
// arguments.
|
||||||
|
|||||||
@@ -66,6 +66,8 @@ public:
|
|||||||
{
|
{
|
||||||
float r, g, b, a;
|
float r, g, b, a;
|
||||||
bool enabled;
|
bool enabled;
|
||||||
|
|
||||||
|
Colorf toColor() const { return Colorf(r, g, b, a); }
|
||||||
};
|
};
|
||||||
|
|
||||||
Graphics();
|
Graphics();
|
||||||
|
|||||||
@@ -47,6 +47,13 @@ namespace opengl
|
|||||||
|
|
||||||
#define instance() (Module::getInstance<Graphics>(Module::M_GRAPHICS))
|
#define instance() (Module::getInstance<Graphics>(Module::M_GRAPHICS))
|
||||||
|
|
||||||
|
static int luax_checkgraphicscreated(lua_State *L)
|
||||||
|
{
|
||||||
|
if (!instance()->isCreated())
|
||||||
|
return luaL_error(L, "love.graphics cannot function without a window!");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int w_reset(lua_State *)
|
int w_reset(lua_State *)
|
||||||
{
|
{
|
||||||
instance()->reset();
|
instance()->reset();
|
||||||
@@ -290,6 +297,8 @@ static const char *imageFlagName(Image::FlagType flagtype)
|
|||||||
|
|
||||||
int w_newImage(lua_State *L)
|
int w_newImage(lua_State *L)
|
||||||
{
|
{
|
||||||
|
luax_checkgraphicscreated(L);
|
||||||
|
|
||||||
std::vector<love::image::ImageData *> data;
|
std::vector<love::image::ImageData *> data;
|
||||||
std::vector<love::image::CompressedImageData *> cdata;
|
std::vector<love::image::CompressedImageData *> cdata;
|
||||||
|
|
||||||
@@ -400,6 +409,8 @@ int w_newImage(lua_State *L)
|
|||||||
|
|
||||||
int w_newQuad(lua_State *L)
|
int w_newQuad(lua_State *L)
|
||||||
{
|
{
|
||||||
|
luax_checkgraphicscreated(L);
|
||||||
|
|
||||||
Quad::Viewport v;
|
Quad::Viewport v;
|
||||||
v.x = luaL_checknumber(L, 1);
|
v.x = luaL_checknumber(L, 1);
|
||||||
v.y = luaL_checknumber(L, 2);
|
v.y = luaL_checknumber(L, 2);
|
||||||
@@ -417,6 +428,8 @@ int w_newQuad(lua_State *L)
|
|||||||
|
|
||||||
int w_newFont(lua_State *L)
|
int w_newFont(lua_State *L)
|
||||||
{
|
{
|
||||||
|
luax_checkgraphicscreated(L);
|
||||||
|
|
||||||
Font *font = nullptr;
|
Font *font = nullptr;
|
||||||
|
|
||||||
// Convert to Rasterizer, if necessary.
|
// Convert to Rasterizer, if necessary.
|
||||||
@@ -443,6 +456,8 @@ int w_newFont(lua_State *L)
|
|||||||
|
|
||||||
int w_newImageFont(lua_State *L)
|
int w_newImageFont(lua_State *L)
|
||||||
{
|
{
|
||||||
|
luax_checkgraphicscreated(L);
|
||||||
|
|
||||||
// filter for glyphs
|
// filter for glyphs
|
||||||
Texture::Filter filter = instance()->getDefaultFilter();
|
Texture::Filter filter = instance()->getDefaultFilter();
|
||||||
|
|
||||||
@@ -483,6 +498,8 @@ int w_newImageFont(lua_State *L)
|
|||||||
|
|
||||||
int w_newSpriteBatch(lua_State *L)
|
int w_newSpriteBatch(lua_State *L)
|
||||||
{
|
{
|
||||||
|
luax_checkgraphicscreated(L);
|
||||||
|
|
||||||
Texture *texture = luax_checktexture(L, 1);
|
Texture *texture = luax_checktexture(L, 1);
|
||||||
int size = (int) luaL_optnumber(L, 2, 1000);
|
int size = (int) luaL_optnumber(L, 2, 1000);
|
||||||
Mesh::Usage usage = Mesh::USAGE_DYNAMIC;
|
Mesh::Usage usage = Mesh::USAGE_DYNAMIC;
|
||||||
@@ -505,6 +522,8 @@ int w_newSpriteBatch(lua_State *L)
|
|||||||
|
|
||||||
int w_newParticleSystem(lua_State *L)
|
int w_newParticleSystem(lua_State *L)
|
||||||
{
|
{
|
||||||
|
luax_checkgraphicscreated(L);
|
||||||
|
|
||||||
Texture *texture = luax_checktexture(L, 1);
|
Texture *texture = luax_checktexture(L, 1);
|
||||||
lua_Number size = luaL_optnumber(L, 2, 1000);
|
lua_Number size = luaL_optnumber(L, 2, 1000);
|
||||||
ParticleSystem *t = 0;
|
ParticleSystem *t = 0;
|
||||||
@@ -522,6 +541,8 @@ int w_newParticleSystem(lua_State *L)
|
|||||||
|
|
||||||
int w_newCanvas(lua_State *L)
|
int w_newCanvas(lua_State *L)
|
||||||
{
|
{
|
||||||
|
luax_checkgraphicscreated(L);
|
||||||
|
|
||||||
// check if width and height are given. else default to screen dimensions.
|
// check if width and height are given. else default to screen dimensions.
|
||||||
int width = (int) luaL_optnumber(L, 1, instance()->getWidth());
|
int width = (int) luaL_optnumber(L, 1, instance()->getWidth());
|
||||||
int height = (int) luaL_optnumber(L, 2, instance()->getHeight());
|
int height = (int) luaL_optnumber(L, 2, instance()->getHeight());
|
||||||
@@ -547,6 +568,8 @@ int w_newCanvas(lua_State *L)
|
|||||||
|
|
||||||
int w_newShader(lua_State *L)
|
int w_newShader(lua_State *L)
|
||||||
{
|
{
|
||||||
|
luax_checkgraphicscreated(L);
|
||||||
|
|
||||||
// clamp stack to 2 elements
|
// clamp stack to 2 elements
|
||||||
lua_settop(L, 2);
|
lua_settop(L, 2);
|
||||||
|
|
||||||
@@ -848,6 +871,8 @@ static Mesh *newCustomMesh(lua_State *L)
|
|||||||
|
|
||||||
int w_newMesh(lua_State *L)
|
int w_newMesh(lua_State *L)
|
||||||
{
|
{
|
||||||
|
luax_checkgraphicscreated(L);
|
||||||
|
|
||||||
// Check first argument: table or number of vertices.
|
// Check first argument: table or number of vertices.
|
||||||
int arg1type = lua_type(L, 1);
|
int arg1type = lua_type(L, 1);
|
||||||
if (arg1type != LUA_TTABLE && arg1type != LUA_TNUMBER)
|
if (arg1type != LUA_TTABLE && arg1type != LUA_TNUMBER)
|
||||||
@@ -868,6 +893,8 @@ int w_newMesh(lua_State *L)
|
|||||||
|
|
||||||
int w_newText(lua_State *L)
|
int w_newText(lua_State *L)
|
||||||
{
|
{
|
||||||
|
luax_checkgraphicscreated(L);
|
||||||
|
|
||||||
Font *font = luax_checkfont(L, 1);
|
Font *font = luax_checkfont(L, 1);
|
||||||
Text *t = nullptr;
|
Text *t = nullptr;
|
||||||
|
|
||||||
@@ -888,6 +915,8 @@ int w_newText(lua_State *L)
|
|||||||
|
|
||||||
int w_newVideo(lua_State *L)
|
int w_newVideo(lua_State *L)
|
||||||
{
|
{
|
||||||
|
luax_checkgraphicscreated(L);
|
||||||
|
|
||||||
if (!luax_istype(L, 1, VIDEO_VIDEO_STREAM_ID))
|
if (!luax_istype(L, 1, VIDEO_VIDEO_STREAM_ID))
|
||||||
luax_convobj(L, 1, "video", "newVideoStream");
|
luax_convobj(L, 1, "video", "newVideoStream");
|
||||||
|
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ bool Keyboard::isDown(const std::vector<Key> &keylist) const
|
|||||||
for (Key key : keylist)
|
for (Key key : keylist)
|
||||||
{
|
{
|
||||||
SDL_Scancode scancode = SDL_GetScancodeFromKey(keymap[key]);
|
SDL_Scancode scancode = SDL_GetScancodeFromKey(keymap[key]);
|
||||||
|
|
||||||
if (state[scancode])
|
if (state[scancode])
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -68,11 +69,9 @@ bool Keyboard::isScancodeDown(const std::vector<Scancode> &scancodelist) const
|
|||||||
|
|
||||||
for (Scancode scancode : scancodelist)
|
for (Scancode scancode : scancodelist)
|
||||||
{
|
{
|
||||||
SDL_Scancode sdlscancode = SDL_SCANCODE_UNKNOWN;
|
SDL_Scancode sdlcode = SDL_SCANCODE_UNKNOWN;
|
||||||
if (!scancodes.find(scancode, sdlscancode))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (state[sdlscancode])
|
if (scancodes.find(scancode, sdlcode) && state[sdlcode])
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ MotorJoint::MotorJoint(Body *body1, Body *body2)
|
|||||||
joint = (b2MotorJoint *) createJoint(&def);
|
joint = (b2MotorJoint *) createJoint(&def);
|
||||||
}
|
}
|
||||||
|
|
||||||
MotorJoint::MotorJoint(Body *body1, Body *body2, float correctionFactor)
|
MotorJoint::MotorJoint(Body *body1, Body *body2, float correctionFactor, bool collideConnected)
|
||||||
: Joint(body1, body2)
|
: Joint(body1, body2)
|
||||||
, joint(NULL)
|
, joint(NULL)
|
||||||
{
|
{
|
||||||
@@ -50,6 +50,7 @@ MotorJoint::MotorJoint(Body *body1, Body *body2, float correctionFactor)
|
|||||||
|
|
||||||
def.Initialize(body1->body, body2->body);
|
def.Initialize(body1->body, body2->body);
|
||||||
def.correctionFactor = correctionFactor;
|
def.correctionFactor = correctionFactor;
|
||||||
|
def.collideConnected = collideConnected;
|
||||||
|
|
||||||
joint = (b2MotorJoint *) createJoint(&def);
|
joint = (b2MotorJoint *) createJoint(&def);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ class MotorJoint : public Joint
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
MotorJoint(Body *body1, Body* body2);
|
MotorJoint(Body *body1, Body* body2);
|
||||||
MotorJoint(Body *body1, Body* body2, float correctionFactor);
|
MotorJoint(Body *body1, Body* body2, float correctionFactor, bool collideConnected);
|
||||||
virtual ~MotorJoint();
|
virtual ~MotorJoint();
|
||||||
|
|
||||||
/// Set/get the target linear offset, in frame A, in meters.
|
/// Set/get the target linear offset, in frame A, in meters.
|
||||||
|
|||||||
@@ -268,9 +268,9 @@ MotorJoint *Physics::newMotorJoint(Body *body1, Body *body2)
|
|||||||
return new MotorJoint(body1, body2);
|
return new MotorJoint(body1, body2);
|
||||||
}
|
}
|
||||||
|
|
||||||
MotorJoint *Physics::newMotorJoint(Body *body1, Body *body2, float correctionFactor)
|
MotorJoint *Physics::newMotorJoint(Body *body1, Body *body2, float correctionFactor, bool collideConnected)
|
||||||
{
|
{
|
||||||
return new MotorJoint(body1, body2, correctionFactor);
|
return new MotorJoint(body1, body2, correctionFactor, collideConnected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -257,7 +257,7 @@ public:
|
|||||||
* and body2.
|
* and body2.
|
||||||
**/
|
**/
|
||||||
MotorJoint *newMotorJoint(Body *body1, Body *body2);
|
MotorJoint *newMotorJoint(Body *body1, Body *body2);
|
||||||
MotorJoint *newMotorJoint(Body *body1, Body *body2, float correctionFactor);
|
MotorJoint *newMotorJoint(Body *body1, Body *body2, float correctionFactor, bool collideConnected);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new Fixture attaching shape to body.
|
* Creates a new Fixture attaching shape to body.
|
||||||
|
|||||||
@@ -419,8 +419,9 @@ int w_newMotorJoint(lua_State *L)
|
|||||||
if (!lua_isnoneornil(L, 3))
|
if (!lua_isnoneornil(L, 3))
|
||||||
{
|
{
|
||||||
float correctionFactor = (float)luaL_checknumber(L, 3);
|
float correctionFactor = (float)luaL_checknumber(L, 3);
|
||||||
|
bool collideConnected = luax_optboolean(L, 4, false);
|
||||||
luax_catchexcept(L, [&]() {
|
luax_catchexcept(L, [&]() {
|
||||||
j = instance()->newMotorJoint(body1, body2, correctionFactor);
|
j = instance()->newMotorJoint(body1, body2, correctionFactor, collideConnected);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -88,12 +88,6 @@ Channel::Channel(const std::string &name)
|
|||||||
|
|
||||||
Channel::~Channel()
|
Channel::~Channel()
|
||||||
{
|
{
|
||||||
while (!queue.empty())
|
|
||||||
{
|
|
||||||
queue.front()->release();
|
|
||||||
queue.pop();
|
|
||||||
}
|
|
||||||
|
|
||||||
delete mutex;
|
delete mutex;
|
||||||
delete cond;
|
delete cond;
|
||||||
|
|
||||||
@@ -101,13 +95,9 @@ Channel::~Channel()
|
|||||||
namedChannels.erase(name);
|
namedChannels.erase(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long Channel::push(Variant *var)
|
unsigned long Channel::push(const Variant &var)
|
||||||
{
|
{
|
||||||
if (!var)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
Lock l(mutex);
|
Lock l(mutex);
|
||||||
var->retain();
|
|
||||||
|
|
||||||
// Keep a reference to ourselves
|
// Keep a reference to ourselves
|
||||||
// if we're non-empty and named.
|
// if we're non-empty and named.
|
||||||
@@ -120,11 +110,8 @@ unsigned long Channel::push(Variant *var)
|
|||||||
return ++sent;
|
return ++sent;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Channel::supply(Variant *var)
|
void Channel::supply(const Variant &var)
|
||||||
{
|
{
|
||||||
if (!var)
|
|
||||||
return;
|
|
||||||
|
|
||||||
Lock l(mutex);
|
Lock l(mutex);
|
||||||
unsigned long id = push(var);
|
unsigned long id = push(var);
|
||||||
|
|
||||||
@@ -132,13 +119,14 @@ void Channel::supply(Variant *var)
|
|||||||
cond->wait(mutex);
|
cond->wait(mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant *Channel::pop()
|
bool Channel::pop(Variant *var)
|
||||||
{
|
{
|
||||||
Lock l(mutex);
|
Lock l(mutex);
|
||||||
if (queue.empty())
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
Variant *var = queue.front();
|
if (queue.empty())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
*var = queue.front();
|
||||||
queue.pop();
|
queue.pop();
|
||||||
|
|
||||||
received++;
|
received++;
|
||||||
@@ -149,28 +137,26 @@ Variant *Channel::pop()
|
|||||||
if (named && queue.empty())
|
if (named && queue.empty())
|
||||||
release();
|
release();
|
||||||
|
|
||||||
return var;
|
return true;
|
||||||
} // NOTE: Returns a retained Variant
|
|
||||||
|
|
||||||
Variant *Channel::demand()
|
|
||||||
{
|
|
||||||
Variant *var;
|
|
||||||
Lock l(mutex);
|
|
||||||
while (!(var = pop()))
|
|
||||||
cond->wait(mutex);
|
|
||||||
|
|
||||||
return var;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant *Channel::peek()
|
void Channel::demand(Variant *var)
|
||||||
{
|
{
|
||||||
Lock l(mutex);
|
Lock l(mutex);
|
||||||
if (queue.empty())
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
Variant *var = queue.front();
|
while (!pop(var))
|
||||||
var->retain();
|
cond->wait(mutex);
|
||||||
return var;
|
}
|
||||||
|
|
||||||
|
bool Channel::peek(Variant *var)
|
||||||
|
{
|
||||||
|
Lock l(mutex);
|
||||||
|
|
||||||
|
if (queue.empty())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
*var = queue.front();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Channel::getCount()
|
int Channel::getCount()
|
||||||
@@ -188,10 +174,7 @@ void Channel::clear()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
while (!queue.empty())
|
while (!queue.empty())
|
||||||
{
|
|
||||||
queue.front()->release();
|
|
||||||
queue.pop();
|
queue.pop();
|
||||||
}
|
|
||||||
|
|
||||||
// Finish all the supply waits
|
// Finish all the supply waits
|
||||||
received = sent;
|
received = sent;
|
||||||
|
|||||||
@@ -37,8 +37,6 @@ namespace thread
|
|||||||
class Channel : public love::Object
|
class Channel : public love::Object
|
||||||
{
|
{
|
||||||
// FOR WRAPPER USE ONLY
|
// FOR WRAPPER USE ONLY
|
||||||
friend void retainVariant(Channel *, Variant *);
|
|
||||||
friend void releaseVariant(Channel *, Variant *);
|
|
||||||
friend int w_Channel_performAtomic(lua_State *);
|
friend int w_Channel_performAtomic(lua_State *);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -48,11 +46,11 @@ public:
|
|||||||
|
|
||||||
static Channel *getChannel(const std::string &name);
|
static Channel *getChannel(const std::string &name);
|
||||||
|
|
||||||
unsigned long push(Variant *var);
|
unsigned long push(const Variant &var);
|
||||||
void supply(Variant *var); // blocking push
|
void supply(const Variant &var); // blocking push
|
||||||
Variant *pop();
|
bool pop(Variant *var);
|
||||||
Variant *demand(); // blocking pop
|
void demand(Variant *var); // blocking pop
|
||||||
Variant *peek();
|
bool peek(Variant *var);
|
||||||
int getCount();
|
int getCount();
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
@@ -67,7 +65,7 @@ private:
|
|||||||
|
|
||||||
Mutex *mutex;
|
Mutex *mutex;
|
||||||
Conditional *cond;
|
Conditional *cond;
|
||||||
std::queue<Variant *> queue;
|
std::queue<Variant> queue;
|
||||||
bool named;
|
bool named;
|
||||||
std::string name;
|
std::string name;
|
||||||
|
|
||||||
|
|||||||
@@ -33,18 +33,12 @@ namespace thread
|
|||||||
LuaThread::LuaThread(const std::string &name, love::Data *code)
|
LuaThread::LuaThread(const std::string &name, love::Data *code)
|
||||||
: code(code)
|
: code(code)
|
||||||
, name(name)
|
, name(name)
|
||||||
, args(nullptr)
|
|
||||||
, nargs(0)
|
|
||||||
{
|
{
|
||||||
threadName = name;
|
threadName = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
LuaThread::~LuaThread()
|
LuaThread::~LuaThread()
|
||||||
{
|
{
|
||||||
// No args should still exist at this point,
|
|
||||||
// but you never know.
|
|
||||||
for (int i = 0; i < nargs; ++i)
|
|
||||||
args[i]->release();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LuaThread::threadFunction()
|
void LuaThread::threadFunction()
|
||||||
@@ -74,16 +68,12 @@ void LuaThread::threadFunction()
|
|||||||
error = luax_tostring(L, -1);
|
error = luax_tostring(L, -1);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int pushedargs = nargs;
|
int pushedargs = (int) args.size();
|
||||||
for (int i = 0; i < nargs; ++i)
|
|
||||||
{
|
for (int i = 0; i < pushedargs; i++)
|
||||||
args[i]->toLua(L);
|
args[i].toLua(L);
|
||||||
args[i]->release();
|
|
||||||
}
|
args.clear();
|
||||||
// Set both args and nargs to nil, prevents the deconstructor from
|
|
||||||
// accessing it again.
|
|
||||||
nargs = 0;
|
|
||||||
args = nullptr;
|
|
||||||
|
|
||||||
if (lua_pcall(L, pushedargs, 0, 0) != 0)
|
if (lua_pcall(L, pushedargs, 0, 0) != 0)
|
||||||
error = luax_tostring(L, -1);
|
error = luax_tostring(L, -1);
|
||||||
@@ -97,14 +87,9 @@ void LuaThread::threadFunction()
|
|||||||
this->release();
|
this->release();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LuaThread::start(Variant **args, int nargs)
|
bool LuaThread::start(const std::vector<Variant> &args)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < this->nargs; ++i)
|
|
||||||
this->args[i]->release();
|
|
||||||
|
|
||||||
this->args = args;
|
this->args = args;
|
||||||
this->nargs = nargs;
|
|
||||||
|
|
||||||
return Threadable::start();
|
return Threadable::start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,16 +111,12 @@ void LuaThread::onError()
|
|||||||
p.type = THREAD_THREAD_ID;
|
p.type = THREAD_THREAD_ID;
|
||||||
p.object = this;
|
p.object = this;
|
||||||
|
|
||||||
std::vector<StrongRef<Variant>> vargs = {
|
std::vector<Variant> vargs = {
|
||||||
new Variant(THREAD_THREAD_ID, &p),
|
Variant(p.type, &p),
|
||||||
new Variant(error.c_str(), error.length())
|
Variant(error.c_str(), error.length())
|
||||||
};
|
};
|
||||||
|
|
||||||
event::Message *msg = new event::Message("threaderror", vargs);
|
event::Message *msg = new event::Message("threaderror", vargs);
|
||||||
|
|
||||||
for (const StrongRef<Variant> &v : vargs)
|
|
||||||
v->release();
|
|
||||||
|
|
||||||
eventmodule->push(msg);
|
eventmodule->push(msg);
|
||||||
msg->release();
|
msg->release();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
// STL
|
// STL
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
// LOVE
|
// LOVE
|
||||||
#include "common/Data.h"
|
#include "common/Data.h"
|
||||||
@@ -44,7 +45,7 @@ public:
|
|||||||
void threadFunction();
|
void threadFunction();
|
||||||
const std::string &getError() const;
|
const std::string &getError() const;
|
||||||
|
|
||||||
bool start(Variant **args, int nargs);
|
bool start(const std::vector<Variant> &args);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
@@ -54,8 +55,7 @@ private:
|
|||||||
std::string name;
|
std::string name;
|
||||||
std::string error;
|
std::string error;
|
||||||
|
|
||||||
Variant **args;
|
std::vector<Variant> args;
|
||||||
int nargs;
|
|
||||||
|
|
||||||
}; // LuaThread
|
}; // LuaThread
|
||||||
|
|
||||||
|
|||||||
@@ -25,20 +25,6 @@ namespace love
|
|||||||
namespace thread
|
namespace thread
|
||||||
{
|
{
|
||||||
|
|
||||||
void retainVariant(Channel *c, Variant *v)
|
|
||||||
{
|
|
||||||
c->lockMutex();
|
|
||||||
v->retain();
|
|
||||||
c->unlockMutex();
|
|
||||||
}
|
|
||||||
|
|
||||||
void releaseVariant(Channel *c, Variant *v)
|
|
||||||
{
|
|
||||||
c->lockMutex();
|
|
||||||
v->release();
|
|
||||||
c->unlockMutex();
|
|
||||||
}
|
|
||||||
|
|
||||||
Channel *luax_checkchannel(lua_State *L, int idx)
|
Channel *luax_checkchannel(lua_State *L, int idx)
|
||||||
{
|
{
|
||||||
return luax_checktype<Channel>(L, idx, THREAD_CHANNEL_ID);
|
return luax_checktype<Channel>(L, idx, THREAD_CHANNEL_ID);
|
||||||
@@ -47,34 +33,29 @@ Channel *luax_checkchannel(lua_State *L, int idx)
|
|||||||
int w_Channel_push(lua_State *L)
|
int w_Channel_push(lua_State *L)
|
||||||
{
|
{
|
||||||
Channel *c = luax_checkchannel(L, 1);
|
Channel *c = luax_checkchannel(L, 1);
|
||||||
Variant *var = lua_isnoneornil(L, 2) ? 0 : Variant::fromLua(L, 2);
|
Variant var;
|
||||||
if (!var)
|
if (!Variant::fromLua(L, 2, &var))
|
||||||
return luaL_argerror(L, 2, "boolean, number, string, love type, or flat table expected");
|
return luaL_argerror(L, 2, "boolean, number, string, love type, or flat table expected");
|
||||||
c->push(var);
|
c->push(var);
|
||||||
releaseVariant(c, var);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int w_Channel_supply(lua_State *L)
|
int w_Channel_supply(lua_State *L)
|
||||||
{
|
{
|
||||||
Channel *c = luax_checkchannel(L, 1);
|
Channel *c = luax_checkchannel(L, 1);
|
||||||
Variant *var = lua_isnoneornil(L, 2) ? 0 : Variant::fromLua(L, 2);
|
Variant var;
|
||||||
if (!var)
|
if (!Variant::fromLua(L, 2, &var))
|
||||||
return luaL_argerror(L, 2, "boolean, number, string, love type, or flat table expected");
|
return luaL_argerror(L, 2, "boolean, number, string, love type, or flat table expected");
|
||||||
c->supply(var);
|
c->supply(var);
|
||||||
releaseVariant(c, var);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int w_Channel_pop(lua_State *L)
|
int w_Channel_pop(lua_State *L)
|
||||||
{
|
{
|
||||||
Channel *c = luax_checkchannel(L, 1);
|
Channel *c = luax_checkchannel(L, 1);
|
||||||
Variant *var = c->pop();
|
Variant var;
|
||||||
if (var)
|
if (c->pop(&var))
|
||||||
{
|
var.toLua(L);
|
||||||
var->toLua(L);
|
|
||||||
releaseVariant(c, var);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
lua_pushnil(L);
|
lua_pushnil(L);
|
||||||
return 1;
|
return 1;
|
||||||
@@ -83,21 +64,18 @@ int w_Channel_pop(lua_State *L)
|
|||||||
int w_Channel_demand(lua_State *L)
|
int w_Channel_demand(lua_State *L)
|
||||||
{
|
{
|
||||||
Channel *c = luax_checkchannel(L, 1);
|
Channel *c = luax_checkchannel(L, 1);
|
||||||
Variant *var = c->demand();
|
Variant var;
|
||||||
var->toLua(L);
|
c->demand(&var);
|
||||||
releaseVariant(c, var);
|
var.toLua(L);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int w_Channel_peek(lua_State *L)
|
int w_Channel_peek(lua_State *L)
|
||||||
{
|
{
|
||||||
Channel *c = luax_checkchannel(L, 1);
|
Channel *c = luax_checkchannel(L, 1);
|
||||||
Variant *var = c->peek();
|
Variant var;
|
||||||
if (var)
|
if (c->peek(&var))
|
||||||
{
|
var.toLua(L);
|
||||||
var->toLua(L);
|
|
||||||
releaseVariant(c, var);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
lua_pushnil(L);
|
lua_pushnil(L);
|
||||||
return 1;
|
return 1;
|
||||||
|
|||||||
@@ -33,26 +33,22 @@ LuaThread *luax_checkthread(lua_State *L, int idx)
|
|||||||
int w_Thread_start(lua_State *L)
|
int w_Thread_start(lua_State *L)
|
||||||
{
|
{
|
||||||
LuaThread *t = luax_checkthread(L, 1);
|
LuaThread *t = luax_checkthread(L, 1);
|
||||||
|
std::vector<Variant> args;
|
||||||
int nargs = lua_gettop(L) - 1;
|
int nargs = lua_gettop(L) - 1;
|
||||||
Variant **args = 0;
|
|
||||||
|
|
||||||
if (nargs > 0)
|
Variant v;
|
||||||
|
for (int i = 0; i < nargs; ++i)
|
||||||
{
|
{
|
||||||
args = new Variant*[nargs];
|
if (!Variant::fromLua(L, i+2, &v))
|
||||||
for (int i = 0; i < nargs; ++i)
|
|
||||||
{
|
{
|
||||||
args[i] = Variant::fromLua(L, i+2);
|
args.clear();
|
||||||
if (!args[i])
|
return luaL_argerror(L, i+2, "boolean, number, string, love type, or flat table expected");
|
||||||
{
|
|
||||||
for (int j = i; j >= 0; j--)
|
|
||||||
delete args[j];
|
|
||||||
delete[] args;
|
|
||||||
return luaL_argerror(L, i+2, "boolean, number, string, love type, or flat table expected");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
args.push_back(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
luax_pushboolean(L, t->start(args, nargs));
|
luax_pushboolean(L, t->start(args));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||