From 6853f8374ec283c422fb402245826ac502bb44cf Mon Sep 17 00:00:00 2001 From: "bill@localhost" Date: Sun, 1 Nov 2009 22:09:23 -0600 Subject: [PATCH] made building from source on OS X a hell of a lot easier - no more .dylibs, and all the header files are contained in the frameworks (as they should be!) --- .../macosx/love.xcodeproj/project.pbxproj | 34 +- src/common/runtime.h | 616 +++++++++--------- src/modules/filesystem/physfs/File.h | 4 + src/modules/filesystem/physfs/Filesystem.cpp | 2 +- src/modules/font/freetype/Font.h | 40 +- .../font/freetype/TrueTypeRasterizer.h | 40 +- src/modules/graphics/opengl/TrueTypeFont.h | 40 +- src/modules/sound/lullaby/Mpg123Decoder.h | 6 +- src/modules/sound/lullaby/Sound.cpp | 2 +- 9 files changed, 400 insertions(+), 384 deletions(-) diff --git a/platform/macosx/love.xcodeproj/project.pbxproj b/platform/macosx/love.xcodeproj/project.pbxproj index 1a5c3b36b..95c119b56 100644 --- a/platform/macosx/love.xcodeproj/project.pbxproj +++ b/platform/macosx/love.xcodeproj/project.pbxproj @@ -8,8 +8,6 @@ /* Begin PBXBuildFile section */ 8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */; }; - A904A5FD1043A2BE005228C3 /* libmpg123.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = A904A5FC1043A2BE005228C3 /* libmpg123.dylib */; }; - A904A6221043A72A005228C3 /* libmpg123.dylib in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = A904A5FC1043A2BE005228C3 /* libmpg123.dylib */; }; A9255DD11043183600BA1496 /* FreeType.framework in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = A93E6E4810420B4A007D418B /* FreeType.framework */; }; A9255DD21043183600BA1496 /* SDL.framework in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = A93E6E5210420B57007D418B /* SDL.framework */; }; A9255DD31043183600BA1496 /* Lua.framework in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = A93E6E5310420B57007D418B /* Lua.framework */; }; @@ -192,16 +190,17 @@ A968F0D91083A9FC00A895AA /* Mouse.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A968F0D81083A9FC00A895AA /* Mouse.cpp */; }; A968F0DD1083AA6600A895AA /* Shape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A968F0DB1083AA6600A895AA /* Shape.cpp */; }; A968F0DE1083AA6600A895AA /* Joint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A968F0DC1083AA6600A895AA /* Joint.cpp */; }; - A968F1271083AC1A00A895AA /* libltdl.3.dylib in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = A9255F8110432C3E00BA1496 /* libltdl.3.dylib */; }; A98D914410507C97008E03F2 /* EncodedImageData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A98D914310507C97008E03F2 /* EncodedImageData.cpp */; }; A9B4BA9C1045937F001DBC80 /* ParticleSystem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A9B4BA9A1045937F001DBC80 /* ParticleSystem.cpp */; }; A9B4BA9D1045937F001DBC80 /* wrap_ParticleSystem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A9B4BA9B1045937F001DBC80 /* wrap_ParticleSystem.cpp */; }; A9D307EA106635C3004FEDF8 /* physfs.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A9D307E9106635C3004FEDF8 /* physfs.framework */; }; A9D307F2106635D3004FEDF8 /* physfs.framework in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = A9D307E9106635C3004FEDF8 /* physfs.framework */; }; - A9D8FC0F1043EBEC0063561F /* libmodplug.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = A9DE839E1043D81A00567BA4 /* libmodplug.dylib */; }; - A9DE839F1043D81A00567BA4 /* libmodplug.dylib in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = A9DE839E1043D81A00567BA4 /* libmodplug.dylib */; }; A9DEC1C11046EFA70049C70C /* Love.icns in Resources */ = {isa = PBXBuildFile; fileRef = A9DEC1BF1046EFA60049C70C /* Love.icns */; }; A9DEC1C21046EFA70049C70C /* LoveDocument.icns in Resources */ = {isa = PBXBuildFile; fileRef = A9DEC1C01046EFA70049C70C /* LoveDocument.icns */; }; + A9F16927109E7BAD00FC83D1 /* libmodplug.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A9F16926109E7BAD00FC83D1 /* libmodplug.framework */; }; + A9F169A7109E824900FC83D1 /* mpg123.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A9F169A6109E824900FC83D1 /* mpg123.framework */; }; + A9F169AC109E825000FC83D1 /* mpg123.framework in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = A9F169A6109E824900FC83D1 /* mpg123.framework */; }; + A9F169AD109E825000FC83D1 /* libmodplug.framework in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = A9F16926109E7BAD00FC83D1 /* libmodplug.framework */; }; /* End PBXBuildFile section */ /* Begin PBXCopyFilesBuildPhase section */ @@ -211,10 +210,9 @@ dstPath = ""; dstSubfolderSpec = 10; files = ( - A968F1271083AC1A00A895AA /* libltdl.3.dylib in Copy Frameworks */, + A9F169AC109E825000FC83D1 /* mpg123.framework in Copy Frameworks */, + A9F169AD109E825000FC83D1 /* libmodplug.framework in Copy Frameworks */, A9D307F2106635D3004FEDF8 /* physfs.framework in Copy Frameworks */, - A9DE839F1043D81A00567BA4 /* libmodplug.dylib in Copy Frameworks */, - A904A6221043A72A005228C3 /* libmpg123.dylib in Copy Frameworks */, A9255F58104324E100BA1496 /* Ogg.framework in Copy Frameworks */, A9255F431043240F00BA1496 /* IL.framework in Copy Frameworks */, A9255E031043195A00BA1496 /* Vorbis.framework in Copy Frameworks */, @@ -231,13 +229,11 @@ 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = ""; }; 8D1107310486CEB800E47090 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 8D1107320486CEB800E47090 /* love.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = love.app; sourceTree = BUILT_PRODUCTS_DIR; }; - A904A5FC1043A2BE005228C3 /* libmpg123.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libmpg123.dylib; sourceTree = ""; }; A9255DEA1043188D00BA1496 /* SDLMain.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDLMain.m; sourceTree = ""; }; A9255DEB1043188D00BA1496 /* SDLMain.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDLMain.h; sourceTree = ""; }; A9255E021043195A00BA1496 /* Vorbis.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Vorbis.framework; path = /Library/Frameworks/Vorbis.framework; sourceTree = ""; }; A9255F421043240F00BA1496 /* IL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = IL.framework; path = /Library/Frameworks/IL.framework; sourceTree = ""; }; A9255F51104324D700BA1496 /* Ogg.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Ogg.framework; path = /Library/Frameworks/Ogg.framework; sourceTree = ""; }; - A9255F8110432C3E00BA1496 /* libltdl.3.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libltdl.3.dylib; path = /usr/lib/libltdl.3.dylib; sourceTree = ""; }; A93E69DE10420ABF007D418B /* config.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = config.h; sourceTree = ""; }; A93E69DF10420ABF007D418B /* Data.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Data.h; sourceTree = ""; }; A93E69E010420ABF007D418B /* Exception.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Exception.cpp; sourceTree = ""; }; @@ -625,9 +621,10 @@ A9B4BA9A1045937F001DBC80 /* ParticleSystem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ParticleSystem.cpp; sourceTree = ""; }; A9B4BA9B1045937F001DBC80 /* wrap_ParticleSystem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = wrap_ParticleSystem.cpp; sourceTree = ""; }; A9D307E9106635C3004FEDF8 /* physfs.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = physfs.framework; path = /Library/Frameworks/physfs.framework; sourceTree = ""; }; - A9DE839E1043D81A00567BA4 /* libmodplug.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libmodplug.dylib; sourceTree = ""; }; A9DEC1BF1046EFA60049C70C /* Love.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; name = Love.icns; path = icons/Love.icns; sourceTree = ""; }; A9DEC1C01046EFA70049C70C /* LoveDocument.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; name = LoveDocument.icns; path = icons/LoveDocument.icns; sourceTree = ""; }; + A9F16926109E7BAD00FC83D1 /* libmodplug.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = libmodplug.framework; path = /Library/Frameworks/libmodplug.framework; sourceTree = ""; }; + A9F169A6109E824900FC83D1 /* mpg123.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = mpg123.framework; path = /Library/Frameworks/mpg123.framework; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -644,9 +641,9 @@ A93E6E5410420B57007D418B /* SDL.framework in Frameworks */, A93E6E5510420B57007D418B /* Lua.framework in Frameworks */, A9255F52104324D700BA1496 /* Ogg.framework in Frameworks */, - A904A5FD1043A2BE005228C3 /* libmpg123.dylib in Frameworks */, - A9D8FC0F1043EBEC0063561F /* libmodplug.dylib in Frameworks */, A9D307EA106635C3004FEDF8 /* physfs.framework in Frameworks */, + A9F16927109E7BAD00FC83D1 /* libmodplug.framework in Frameworks */, + A9F169A7109E824900FC83D1 /* mpg123.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -656,10 +653,10 @@ 1058C7A0FEA54F0111CA2CBB /* Linked Frameworks */ = { isa = PBXGroup; children = ( + A9F169A6109E824900FC83D1 /* mpg123.framework */, + A9F16926109E7BAD00FC83D1 /* libmodplug.framework */, A9D307E9106635C3004FEDF8 /* physfs.framework */, A9255F51104324D700BA1496 /* Ogg.framework */, - A9DE839E1043D81A00567BA4 /* libmodplug.dylib */, - A904A5FC1043A2BE005228C3 /* libmpg123.dylib */, A9255F421043240F00BA1496 /* IL.framework */, A9255E021043195A00BA1496 /* Vorbis.framework */, A93E6E4610420B4A007D418B /* OpenAL.framework */, @@ -675,7 +672,6 @@ 1058C7A2FEA54F0111CA2CBB /* Other Frameworks */ = { isa = PBXGroup; children = ( - A9255F8110432C3E00BA1496 /* libltdl.3.dylib */, ); name = "Other Frameworks"; sourceTree = ""; @@ -1519,7 +1515,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "#! /bin/sh\n#Use install_name_tool, make love to search libs in its own framework folder instead\n#*very* hackish.\n\n# IL\ninstall_name_tool -change /Library/Frameworks/IL.framework/Versions/A/IL @executable_path/../Frameworks/IL.framework/Versions/A/IL build/Release/love.app/Contents/MacOS/love\n\n# FreeType\ninstall_name_tool -change /Library/Frameworks/FreeType.framework/Versions/2.3/FreeType @executable_path/../Frameworks/FreeType.framework/Versions/2.3/FreeType build/Release/love.app/Contents/MacOS/love\n\n# SDL\ninstall_name_tool -change /Library/Frameworks/SDL.framework/Versions/A/SDL @executable_path/../Frameworks/SDL.framework/Versions/A/SDL build/Release/love.app/Contents/MacOS/love\n\n# Lua\ninstall_name_tool -change /Library/Frameworks/Lua.framework/Versions/A/Lua @executable_path/../Frameworks/Lua.framework/Versions/A/Lua build/Release/love.app/Contents/MacOS/love\n\n# Ogg\ninstall_name_tool -change /Library/Frameworks/Ogg.framework/Versions/A/Ogg @executable_path/../Frameworks/Ogg.framework/Versions/A/Ogg build/Release/love.app/Contents/MacOS/love\n\ninstall_name_tool -change /Library/Frameworks/Ogg.framework/Versions/A/Ogg @executable_path/../Frameworks/Ogg.framework/Versions/A/Ogg build/Release/love.app/Contents/Frameworks/Vorbis.framework/Versions/A/Vorbis\n\n# Vorbis\ninstall_name_tool -change /Library/Frameworks/Vorbis.framework/Versions/A/Vorbis @executable_path/../Frameworks/Vorbis.framework/Versions/A/Vorbis build/Release/love.app/Contents/MacOS/love\n\n# libmpg123\ninstall_name_tool -change /usr/local/lib/libmpg123.0.dylib @executable_path/../Frameworks/libmpg123.dylib build/Release/love.app/Contents/MacOS/love\n\ninstall_name_tool -change /Users/bill/libs/lib/libmpg123.0.dylib @executable_path/../Frameworks/libmpg123.dylib build/Release/love.app/Contents/MacOS/love\n\n# libphysfs\ninstall_name_tool -change /Users/bill/downloads/physfs-2.0.0/build/Release/libphysfs.dylib @executable_path/../Frameworks/libphysfs.dylib build/Release/love.app/Contents/MacOS/love\n\ninstall_name_tool -change /Users/bill/downloads/physfs-2.0.0/build/Release/libphysfs.dylib @executable_path/../Frameworks/libphysfs.dylib build/Release/love.app/Contents/Frameworks/libphysfs.dylib\n\n# libmodplug\ninstall_name_tool -change /Users/bill/libs/lib/libmodplug.0.dylib @executable_path/../Frameworks/libmodplug.dylib build/Release/love.app/Contents/MacOS/love\n\ninstall_name_tool -change /Users/bill/libs-ppc/lib/libmodplug.0.dylib @executable_path/../Frameworks/libmodplug.dylib build/Release/love.app/Contents/MacOS/love\n\n# libltdl\ninstall_name_tool -change /usr/lib/libltdl.3.dylib @executable_path/../Frameworks/libltdl.3.dylib build/Release/love.app/Contents/Frameworks/libmpg123.dylib\n\nexit 0"; + shellScript = "#! /bin/sh\n#Use install_name_tool, make love to search libs in its own framework folder instead\n#*very* hackish.\n\n# IL\ninstall_name_tool -change /Library/Frameworks/IL.framework/Versions/A/IL @executable_path/../Frameworks/IL.framework/Versions/A/IL build/Release/love.app/Contents/MacOS/love\n\n# FreeType\ninstall_name_tool -change /Library/Frameworks/FreeType.framework/Versions/2.3/FreeType @executable_path/../Frameworks/FreeType.framework/Versions/2.3/FreeType build/Release/love.app/Contents/MacOS/love\n\n# SDL\ninstall_name_tool -change /Library/Frameworks/SDL.framework/Versions/A/SDL @executable_path/../Frameworks/SDL.framework/Versions/A/SDL build/Release/love.app/Contents/MacOS/love\n\n# Lua\ninstall_name_tool -change /Library/Frameworks/Lua.framework/Versions/A/Lua @executable_path/../Frameworks/Lua.framework/Versions/A/Lua build/Release/love.app/Contents/MacOS/love\n\n# Ogg\ninstall_name_tool -change /Library/Frameworks/Ogg.framework/Versions/A/Ogg @executable_path/../Frameworks/Ogg.framework/Versions/A/Ogg build/Release/love.app/Contents/MacOS/love\n\ninstall_name_tool -change /Library/Frameworks/Ogg.framework/Versions/A/Ogg @executable_path/../Frameworks/Ogg.framework/Versions/A/Ogg build/Release/love.app/Contents/Frameworks/Vorbis.framework/Versions/A/Vorbis\n\n# Vorbis\ninstall_name_tool -change /Library/Frameworks/Vorbis.framework/Versions/A/Vorbis @executable_path/../Frameworks/Vorbis.framework/Versions/A/Vorbis build/Release/love.app/Contents/MacOS/love\n\n# mpg123\ninstall_name_tool -change /Library/Frameworks/mpg123.framework @executable_path/../Frameworks/mpg123.framework build/Release/love.app/Contents/MacOS/love\n\n# physfs\ninstall_name_tool -change /Library/Frameworks/physfs.framework @executable_path/../Frameworks/physfs.framework build/Release/love.app/Contents/MacOS/love\n\n# libmodplug\ninstall_name_tool -change /Library/Framework/libmodplug.framework @executable_path/../Frameworks/libmodplug.framework build/Release/love.app/Contents/MacOS/love\n\nexit 0"; }; A9DEC1F51046F3F30049C70C /* Create DMG */ = { isa = PBXShellScriptBuildPhase; @@ -1846,9 +1842,8 @@ GCC_WARN_TYPECHECK_CALLS_TO_PRINTF = NO; GCC_WARN_UNUSED_VARIABLE = YES; HEADER_SEARCH_PATHS = ( + /Library/Frameworks/Lua.framework/Headers, /Library/Frameworks/SDL.framework/Headers, - /usr/local/include, - /opt/local/include, ../../src, ../../src/modules, ); @@ -1857,6 +1852,7 @@ OTHER_LDFLAGS = ""; PREBINDING = NO; PRODUCT_NAME = love; + SCAN_ALL_SOURCE_FILES_FOR_INCLUDES = YES; SDKROOT = macosx10.5; USER_HEADER_SEARCH_PATHS = ""; VALID_ARCHS = "i386 ppc"; diff --git a/src/common/runtime.h b/src/common/runtime.h index 1449ad57f..54fce90a6 100644 --- a/src/common/runtime.h +++ b/src/common/runtime.h @@ -1,313 +1,313 @@ -/** -* Copyright (c) 2006-2009 LOVE Development Team -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -**/ - -#ifndef LOVE_RUNTIME_H -#define LOVE_RUNTIME_H - -// LOVE -#include "types.h" - +/** +* Copyright (c) 2006-2009 LOVE Development Team +* +* This software is provided 'as-is', without any express or implied +* warranty. In no event will the authors be held liable for any damages +* arising from the use of this software. +* +* Permission is granted to anyone to use this software for any purpose, +* including commercial applications, and to alter it and redistribute it +* freely, subject to the following restrictions: +* +* 1. The origin of this software must not be misrepresented; you must not +* claim that you wrote the original software. If you use this software +* in a product, an acknowledgment in the product documentation would be +* appreciated but is not required. +* 2. Altered source versions must be plainly marked as such, and must not be +* misrepresented as being the original software. +* 3. This notice may not be removed or altered from any source distribution. +**/ + +#ifndef LOVE_RUNTIME_H +#define LOVE_RUNTIME_H + +// LOVE +#include "types.h" + // Lua extern "C" { #include #include #include -} - -namespace love -{ - // Forward declarations. - class Module; - class Reference; - - /** - * Registries represent special tables which can be accessed with - * luax_getregistry. - **/ - enum Registry - { - REGISTRY_GC = 1, - REGISTRY_MODULES, - }; - - /** - * This structure wraps all Lua-exposed objects. It exists in the - * Lua state as a full userdata (so we can catch __gc "events"), - * though the Object it refers to is light userdata in the sense - * that it is not allocated by the Lua VM. - **/ - struct Proxy - { - // Holds type information (see types.h). - bits flags; - - // The light userdata. - void * data; - - // True if Lua should delete on GC. - bool own; - }; - - /** - * A Module with Lua wrapper functions and other data. - **/ - struct WrappedModule - { - // The module containing the functions. - Module * module; - - // The name for the table to put the functions in, without the 'love'-prefix. - const char * name; - - // The type flags of this module. - love::bits flags; - - // The functions of the module (last element {0,0}). - const luaL_Reg * functions; - - // A list of functions which expose the types of the modules (last element 0). - const lua_CFunction * types; - - }; - - /** - * Returns a reference to the top stack element (-1) if the value - * is of the specified type. If the value is incorrect, zero is returned. - * - * In any case, the top stack element is popped, regardless of its type. - **/ - Reference * luax_refif(lua_State * L, int type); - - /** - * Prints the current contents of the stack. Only useful for debugging. - * @param L The Lua state. - **/ - void luax_printstack(lua_State * L); - - /** - * Converts the value at idx to a bool. It follow the same rules - * as lua_toboolean, but returns a bool instead of an int. - * @param L The Lua state. - * @param idx The index on the Lua state. - * @return True if the value evaluates to true, false otherwise. - **/ - bool luax_toboolean(lua_State * L, int idx); - - /** - * Pushes a bool onto the stack. It's the same as lua_pushboolean, - * but with bool instead of int. - * @param L The Lua state. - * @paarm b The bool to push. - **/ - void luax_pushboolean(lua_State * L, bool b); - - /** - * Converts the value at idx to a bool, or if not present, b is returned. - * @param L The Lua state. - * @param idx The index of the Lua state. - * @param b The value to return if no value exist at the specified index. - * @return True if the value evaluates to true, false otherwise. - **/ - bool luax_optboolean(lua_State * L, int idx, bool b); - - /** - * Require at least 'min' number of items on the stack. - * @param L The Lua state. - * @param min The minimum number of items on the stack. - * @return Zero if conditions are met, otherwise a Lua error (longjmp). - **/ - int luax_assert_argc(lua_State * L, int min); - - /** - * Require at least 'min', but more than 'max' items on the stack. - * @param L The Lua state. - * @param min The minimum number of items on the stack. - * @param max The maximum number of items on the stack. - * @return Zero if conditions are met, otherwise a Lua error (longjmp). - **/ - int luax_assert_argc(lua_State * L, int min, int max); - - /** - * Require that the value at idx is a function. - * @param L The Lua state. - *@param idx The index on the stack. - **/ - int luax_assert_function(lua_State * L, int idx); - - /** - * Register a module in the love table. The love table will be created if it does not exist. - * @param L The Lua state. - **/ - int luax_register_module(lua_State * L, const WrappedModule & m); - - /** - * Inserts a module with 'name' into the package.preloaded table. - * @param f The function to be called when the module is opened. - * @param name The name of the module, with 'love'-prefix, for instance 'love.graphics'. - **/ - int luax_preload(lua_State * L, lua_CFunction f, const char * name); - - /** - * Register a new type. - * @param tname The name of the type. This must not conflict with other type names, - * even from other modules. - * @param f The list of member functions for the type. - **/ - int luax_register_type(lua_State * L, const char * tname, const luaL_Reg * f = 0); - - /** - * Register a new searcher function for package.loaders. This can for instance enable - * loading of files through love.filesystem using standard require. - * @param L The Lua state. - * @param f The searcher function. - **/ - int luax_register_searcher(lua_State * L, lua_CFunction f); - - /** - * Creates a new Lua-accessible object of the given type, and put it on the stack. - * @param L The Lua state. - * @param name The name of the type. This must match the used earlier with luax_register_type. - * @param flags The type information. - * @param data The pointer to the actual object. - * @own Set this to true (default) if the object should be released upon garbage collection. - **/ - void luax_newtype(lua_State * L, const char * name, bits flags, void * data, bool own = true); - - /** - * Checks whether the value at idx is a certain type. - * @param L The Lua state. - * @param idx The index on the stack. - * @param type The type to check for. - * @return True if the value is Proxy of the specified type, false otherwise. - **/ - bool luax_istype(lua_State * L, int idx, love::bits type); - - /** - * Gets the function love.module.function and puts it on top of the stack (alone). If the - * love table, the module, or the function does not exist, an error is returned. - * @return An error if nonexistent, or 1 if successful. - **/ - int luax_getfunction(lua_State * L, const char * module, const char * function); - - /** - * Converts an object into another object by the specified function love.module.function. - * The conversion function must accept a single object of the relevant type as a parameter, - * and returnone value. If the function does not exist (see luax_getfunction), an error is returned. - * - * Note that the initial object at idx is replaced by the new object. - * - * @param L The Lua state. - * @param idx The index on the stack. - * @param module The module in the love table. - * @param function The function in the module. - **/ - int luax_convobj(lua_State * L, int idx, const char * module, const char * function); - - /** - * 'Insist' that a table 'k' exists in the table at idx. Insistence involves that the - * table (k) is created if it does not exist in the table at idx. The table at idx must - * pre-exist, however. Also note that if the a non-table value exists at the specified - * location, it will be overwritten with a new table. The insisted table, and only the - * insisted table, will be placed on top of the stack. - * - * @param idx The index on the stack containing a table. - * @param k The name of the table we are insisting exist. - **/ - int luax_insist(lua_State * L, int idx, const char * k); - - /** - * Insist that a global table 'k' exists. See luax_insist. - * @param k The name of the table we are insisting exist. - **/ - int luax_insistglobal(lua_State * L, const char * k); - - /** - * Insists that a table 'k' exists inside the 'love' table. See luax_insist. - * @param k The name of the table we are insisting exist. - **/ - int luax_insistlove(lua_State * L, const char * k); - - /** - * Gets (creates if needed) the specified Registry, and puts it on top - * of the stack. - * @param L The Lua state. - * @param r The Registry to get. - **/ - int luax_getregistry(lua_State * L, Registry r); - - /** - * Converts the value at idx to the specified type without checking that - * this conversion is valid. If the type has been previously verified with - * luax_istype, then this can be safely used. Otherwise, use luax_checktype. - * @param L The Lua state. - * @param idx The index on the stack. - * @param name The name of the type. - * @param type The type bit. - **/ - template - T * luax_totype(lua_State * L, int idx, const char * name, love::bits type) - { - return (T*)(((Proxy *)lua_touserdata(L, idx))->data); - } - - /** - * Like luax_totype, but causes an error if the value at idx is not Proxy, - * or is not the specified type. - * @param L The Lua state. - * @param idx The index on the stack. - * @param name The name of the type. - * @param type The type bit. - **/ - template - T * luax_checktype(lua_State * L, int idx, const char * name, love::bits type) - { - if(lua_isuserdata(L, idx) == 0) - luaL_error(L, "Incorrect parameter type: expected userdata."); - - Proxy * u = (Proxy *)lua_touserdata(L, idx); - - if((u->flags & type) != type) - luaL_error(L, "Incorrect parameter type: expected %s", name); - - return (T *)u->data; - } - - template - T * luax_getmodule(lua_State * L, const char * k, love::bits type) - { - luax_getregistry(L, REGISTRY_MODULES); - lua_getfield(L, -1, k); - - if(!lua_isuserdata(L, -1)) - luaL_error(L, "Tried to get nonexisting module %s.", k); - - Proxy * u = (Proxy *)lua_touserdata(L, -1); - - if((u->flags & type) != type) - luaL_error(L, "Incorrect module %s", k); - - lua_pop(L, 2); - - return (T*)u->data; - } - -} // love - -#endif // LOVE_RUNTIME_H +} + +namespace love +{ + // Forward declarations. + class Module; + class Reference; + + /** + * Registries represent special tables which can be accessed with + * luax_getregistry. + **/ + enum Registry + { + REGISTRY_GC = 1, + REGISTRY_MODULES, + }; + + /** + * This structure wraps all Lua-exposed objects. It exists in the + * Lua state as a full userdata (so we can catch __gc "events"), + * though the Object it refers to is light userdata in the sense + * that it is not allocated by the Lua VM. + **/ + struct Proxy + { + // Holds type information (see types.h). + bits flags; + + // The light userdata. + void * data; + + // True if Lua should delete on GC. + bool own; + }; + + /** + * A Module with Lua wrapper functions and other data. + **/ + struct WrappedModule + { + // The module containing the functions. + Module * module; + + // The name for the table to put the functions in, without the 'love'-prefix. + const char * name; + + // The type flags of this module. + love::bits flags; + + // The functions of the module (last element {0,0}). + const luaL_Reg * functions; + + // A list of functions which expose the types of the modules (last element 0). + const lua_CFunction * types; + + }; + + /** + * Returns a reference to the top stack element (-1) if the value + * is of the specified type. If the value is incorrect, zero is returned. + * + * In any case, the top stack element is popped, regardless of its type. + **/ + Reference * luax_refif(lua_State * L, int type); + + /** + * Prints the current contents of the stack. Only useful for debugging. + * @param L The Lua state. + **/ + void luax_printstack(lua_State * L); + + /** + * Converts the value at idx to a bool. It follow the same rules + * as lua_toboolean, but returns a bool instead of an int. + * @param L The Lua state. + * @param idx The index on the Lua state. + * @return True if the value evaluates to true, false otherwise. + **/ + bool luax_toboolean(lua_State * L, int idx); + + /** + * Pushes a bool onto the stack. It's the same as lua_pushboolean, + * but with bool instead of int. + * @param L The Lua state. + * @paarm b The bool to push. + **/ + void luax_pushboolean(lua_State * L, bool b); + + /** + * Converts the value at idx to a bool, or if not present, b is returned. + * @param L The Lua state. + * @param idx The index of the Lua state. + * @param b The value to return if no value exist at the specified index. + * @return True if the value evaluates to true, false otherwise. + **/ + bool luax_optboolean(lua_State * L, int idx, bool b); + + /** + * Require at least 'min' number of items on the stack. + * @param L The Lua state. + * @param min The minimum number of items on the stack. + * @return Zero if conditions are met, otherwise a Lua error (longjmp). + **/ + int luax_assert_argc(lua_State * L, int min); + + /** + * Require at least 'min', but more than 'max' items on the stack. + * @param L The Lua state. + * @param min The minimum number of items on the stack. + * @param max The maximum number of items on the stack. + * @return Zero if conditions are met, otherwise a Lua error (longjmp). + **/ + int luax_assert_argc(lua_State * L, int min, int max); + + /** + * Require that the value at idx is a function. + * @param L The Lua state. + *@param idx The index on the stack. + **/ + int luax_assert_function(lua_State * L, int idx); + + /** + * Register a module in the love table. The love table will be created if it does not exist. + * @param L The Lua state. + **/ + int luax_register_module(lua_State * L, const WrappedModule & m); + + /** + * Inserts a module with 'name' into the package.preloaded table. + * @param f The function to be called when the module is opened. + * @param name The name of the module, with 'love'-prefix, for instance 'love.graphics'. + **/ + int luax_preload(lua_State * L, lua_CFunction f, const char * name); + + /** + * Register a new type. + * @param tname The name of the type. This must not conflict with other type names, + * even from other modules. + * @param f The list of member functions for the type. + **/ + int luax_register_type(lua_State * L, const char * tname, const luaL_Reg * f = 0); + + /** + * Register a new searcher function for package.loaders. This can for instance enable + * loading of files through love.filesystem using standard require. + * @param L The Lua state. + * @param f The searcher function. + **/ + int luax_register_searcher(lua_State * L, lua_CFunction f); + + /** + * Creates a new Lua-accessible object of the given type, and put it on the stack. + * @param L The Lua state. + * @param name The name of the type. This must match the used earlier with luax_register_type. + * @param flags The type information. + * @param data The pointer to the actual object. + * @own Set this to true (default) if the object should be released upon garbage collection. + **/ + void luax_newtype(lua_State * L, const char * name, bits flags, void * data, bool own = true); + + /** + * Checks whether the value at idx is a certain type. + * @param L The Lua state. + * @param idx The index on the stack. + * @param type The type to check for. + * @return True if the value is Proxy of the specified type, false otherwise. + **/ + bool luax_istype(lua_State * L, int idx, love::bits type); + + /** + * Gets the function love.module.function and puts it on top of the stack (alone). If the + * love table, the module, or the function does not exist, an error is returned. + * @return An error if nonexistent, or 1 if successful. + **/ + int luax_getfunction(lua_State * L, const char * module, const char * function); + + /** + * Converts an object into another object by the specified function love.module.function. + * The conversion function must accept a single object of the relevant type as a parameter, + * and returnone value. If the function does not exist (see luax_getfunction), an error is returned. + * + * Note that the initial object at idx is replaced by the new object. + * + * @param L The Lua state. + * @param idx The index on the stack. + * @param module The module in the love table. + * @param function The function in the module. + **/ + int luax_convobj(lua_State * L, int idx, const char * module, const char * function); + + /** + * 'Insist' that a table 'k' exists in the table at idx. Insistence involves that the + * table (k) is created if it does not exist in the table at idx. The table at idx must + * pre-exist, however. Also note that if the a non-table value exists at the specified + * location, it will be overwritten with a new table. The insisted table, and only the + * insisted table, will be placed on top of the stack. + * + * @param idx The index on the stack containing a table. + * @param k The name of the table we are insisting exist. + **/ + int luax_insist(lua_State * L, int idx, const char * k); + + /** + * Insist that a global table 'k' exists. See luax_insist. + * @param k The name of the table we are insisting exist. + **/ + int luax_insistglobal(lua_State * L, const char * k); + + /** + * Insists that a table 'k' exists inside the 'love' table. See luax_insist. + * @param k The name of the table we are insisting exist. + **/ + int luax_insistlove(lua_State * L, const char * k); + + /** + * Gets (creates if needed) the specified Registry, and puts it on top + * of the stack. + * @param L The Lua state. + * @param r The Registry to get. + **/ + int luax_getregistry(lua_State * L, Registry r); + + /** + * Converts the value at idx to the specified type without checking that + * this conversion is valid. If the type has been previously verified with + * luax_istype, then this can be safely used. Otherwise, use luax_checktype. + * @param L The Lua state. + * @param idx The index on the stack. + * @param name The name of the type. + * @param type The type bit. + **/ + template + T * luax_totype(lua_State * L, int idx, const char * name, love::bits type) + { + return (T*)(((Proxy *)lua_touserdata(L, idx))->data); + } + + /** + * Like luax_totype, but causes an error if the value at idx is not Proxy, + * or is not the specified type. + * @param L The Lua state. + * @param idx The index on the stack. + * @param name The name of the type. + * @param type The type bit. + **/ + template + T * luax_checktype(lua_State * L, int idx, const char * name, love::bits type) + { + if(lua_isuserdata(L, idx) == 0) + luaL_error(L, "Incorrect parameter type: expected userdata."); + + Proxy * u = (Proxy *)lua_touserdata(L, idx); + + if((u->flags & type) != type) + luaL_error(L, "Incorrect parameter type: expected %s", name); + + return (T *)u->data; + } + + template + T * luax_getmodule(lua_State * L, const char * k, love::bits type) + { + luax_getregistry(L, REGISTRY_MODULES); + lua_getfield(L, -1, k); + + if(!lua_isuserdata(L, -1)) + luaL_error(L, "Tried to get nonexisting module %s.", k); + + Proxy * u = (Proxy *)lua_touserdata(L, -1); + + if((u->flags & type) != type) + luaL_error(L, "Incorrect module %s", k); + + lua_pop(L, 2); + + return (T*)u->data; + } + +} // love + +#endif // LOVE_RUNTIME_H diff --git a/src/modules/filesystem/physfs/File.h b/src/modules/filesystem/physfs/File.h index ff1aba344..064fcfdff 100644 --- a/src/modules/filesystem/physfs/File.h +++ b/src/modules/filesystem/physfs/File.h @@ -25,7 +25,11 @@ #include // PhysFS +#ifdef LOVE_MACOSX // wacky Mac behavior means different #include syntax! +#include +#else #include +#endif // STD #include diff --git a/src/modules/filesystem/physfs/Filesystem.cpp b/src/modules/filesystem/physfs/Filesystem.cpp index 5513ee955..306c6d3ec 100644 --- a/src/modules/filesystem/physfs/Filesystem.cpp +++ b/src/modules/filesystem/physfs/Filesystem.cpp @@ -21,7 +21,7 @@ #include "Filesystem.h" // Physfs -#include +//#include // this gets included by virtue of Filesystem.h including File.h namespace love { diff --git a/src/modules/font/freetype/Font.h b/src/modules/font/freetype/Font.h index ed8721cc8..3afe95683 100644 --- a/src/modules/font/freetype/Font.h +++ b/src/modules/font/freetype/Font.h @@ -1,21 +1,21 @@ -/** -* Copyright (c) 2006-2009 LOVE Development Team -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. +/** +* Copyright (c) 2006-2009 LOVE Development Team +* +* This software is provided 'as-is', without any express or implied +* warranty. In no event will the authors be held liable for any damages +* arising from the use of this software. +* +* Permission is granted to anyone to use this software for any purpose, +* including commercial applications, and to alter it and redistribute it +* freely, subject to the following restrictions: +* +* 1. The origin of this software must not be misrepresented; you must not +* claim that you wrote the original software. If you use this software +* in a product, an acknowledgment in the product documentation would be +* appreciated but is not required. +* 2. Altered source versions must be plainly marked as such, and must not be +* misrepresented as being the original software. +* 3. This notice may not be removed or altered from any source distribution. **/ #ifndef LOVE_FONT_FREETYPE_FONT_H @@ -28,7 +28,11 @@ #include // FreeType2 +#ifdef LOVE_MACOSX +#include +#else #include +#endif #include #include #include diff --git a/src/modules/font/freetype/TrueTypeRasterizer.h b/src/modules/font/freetype/TrueTypeRasterizer.h index 6e541ccf5..fd7126a35 100644 --- a/src/modules/font/freetype/TrueTypeRasterizer.h +++ b/src/modules/font/freetype/TrueTypeRasterizer.h @@ -1,21 +1,21 @@ -/** -* Copyright (c) 2006-2009 LOVE Development Team -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. +/** +* Copyright (c) 2006-2009 LOVE Development Team +* +* This software is provided 'as-is', without any express or implied +* warranty. In no event will the authors be held liable for any damages +* arising from the use of this software. +* +* Permission is granted to anyone to use this software for any purpose, +* including commercial applications, and to alter it and redistribute it +* freely, subject to the following restrictions: +* +* 1. The origin of this software must not be misrepresented; you must not +* claim that you wrote the original software. If you use this software +* in a product, an acknowledgment in the product documentation would be +* appreciated but is not required. +* 2. Altered source versions must be plainly marked as such, and must not be +* misrepresented as being the original software. +* 3. This notice may not be removed or altered from any source distribution. **/ #ifndef LOVE_FONT_FREETYPE_TRUE_TYPE_RASTERIZER_H @@ -26,7 +26,11 @@ #include // TrueType2 +#ifdef LOVE_MACOSX +#include +#else #include +#endif #include #include #include diff --git a/src/modules/graphics/opengl/TrueTypeFont.h b/src/modules/graphics/opengl/TrueTypeFont.h index 68bcd8a53..459e612c8 100644 --- a/src/modules/graphics/opengl/TrueTypeFont.h +++ b/src/modules/graphics/opengl/TrueTypeFont.h @@ -1,21 +1,21 @@ -/** -* Copyright (c) 2006-2009 LOVE Development Team -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. +/** +* Copyright (c) 2006-2009 LOVE Development Team +* +* This software is provided 'as-is', without any express or implied +* warranty. In no event will the authors be held liable for any damages +* arising from the use of this software. +* +* Permission is granted to anyone to use this software for any purpose, +* including commercial applications, and to alter it and redistribute it +* freely, subject to the following restrictions: +* +* 1. The origin of this software must not be misrepresented; you must not +* claim that you wrote the original software. If you use this software +* in a product, an acknowledgment in the product documentation would be +* appreciated but is not required. +* 2. Altered source versions must be plainly marked as such, and must not be +* misrepresented as being the original software. +* 3. This notice may not be removed or altered from any source distribution. **/ #ifndef LOVE_GRAPHICS_OPENGL_TRUETYPE_FONT_H @@ -25,7 +25,11 @@ #include "Font.h" // FreeType2 +#ifdef LOVE_MACOSX +#include +#else #include +#endif #include #include #include diff --git a/src/modules/sound/lullaby/Mpg123Decoder.h b/src/modules/sound/lullaby/Mpg123Decoder.h index 4b7198bd2..d0f4f5acb 100644 --- a/src/modules/sound/lullaby/Mpg123Decoder.h +++ b/src/modules/sound/lullaby/Mpg123Decoder.h @@ -26,7 +26,11 @@ #include "Decoder.h" // libmpg123 +#ifdef LOVE_MACOSX +#include +#else #include +#endif namespace love { @@ -55,7 +59,7 @@ namespace lullaby bool seek(float s); bool rewind(); bool isSeekable(); - int getChannels() const; + int getChannels() const; int getBits() const; }; // Decoder diff --git a/src/modules/sound/lullaby/Sound.cpp b/src/modules/sound/lullaby/Sound.cpp index 8820efaab..d37698014 100644 --- a/src/modules/sound/lullaby/Sound.cpp +++ b/src/modules/sound/lullaby/Sound.cpp @@ -23,7 +23,7 @@ #include "ModPlugDecoder.h" #include "Mpg123Decoder.h" #include "VorbisDecoder.h" -#include "FLACDecoder.h" +//#include "FLACDecoder.h" namespace love {