new convenient script methods
authorCharles McGarvey <chazmcgarvey@brokenzipper.com>
Tue, 9 Mar 2010 16:56:56 +0000 (09:56 -0700)
committerCharles McGarvey <chazmcgarvey@brokenzipper.com>
Tue, 9 Mar 2010 16:56:56 +0000 (09:56 -0700)
13 files changed:
Makefile.am
configure.ac
data/scenes/Classic.lua
data/yoinkrc
src/Moof/Script.hh
src/Scene.cc
src/yoink.rc
win32/makedeps.sh
win32/makepackage.sh
win32/setup.ico [moved from src/setup.ico with 100% similarity]
win32/uninstall.ico [moved from src/uninstall.ico with 100% similarity]
win32/yoink.ico [moved from src/yoink.ico with 100% similarity]
win32/yoink.nsi

index f3c3773fa70b7f40aa70e45d32fa50c1e4aeaf1b..7f62c7d7dad4f09e8e70be2a5c2d4bd3e6ab35ed 100644 (file)
@@ -9,10 +9,10 @@ EXTRA_DIST = autogen.sh extra win32
 .PHONY: run debug docs portable installer
 
 run: all
-       @$(CD) src && $(MAKE) run
+       @cd src && $(MAKE) run
 
 debug: all
-       @$(CD) src && $(MAKE) debug
+       @cd src && $(MAKE) debug
 
 docs:
        $(DOXYGEN)
@@ -20,11 +20,11 @@ docs:
 if WIN32
 
 portable: all
-       $(SH) win32/makepackage.sh -p $(prefix) -d "$(DATA_FILES)" \
+       $(SH) win32/makepackage.sh -p $(prefix) -d "@DATA_FILES@" \
                -s $(STRIP) -V $(VERSION)
 
 installer: all
-       $(SH) win32/makepackage.sh -p $(prefix) -d "$(DATA_FILES)" \
+       $(SH) win32/makepackage.sh -p $(prefix) -d "@DATA_FILES@" \
                -s $(STRIP) -V $(VERSION) -i $(MAKENSIS)
 
 endif
index 93319640e08f43f3ff1cdf99e5b1d3d54d7618bc..d3d55aedbf694a237b489e60647be74a316a568b 100644 (file)
@@ -318,7 +318,7 @@ fi
 
 if test x$missing == xyes
 then
-       AC_MSG_WARN([It looks like you're missing some dependencies--building may fail!])
+       AC_MSG_ERROR([Please resolve the missing dependencies, and try again.])
 fi
 
 
index fb4765fc1e30fbca4136a04c91a8dd7bc61b0e4b..75ea02a54c99777b02e3e60585403f30ca4da6d4 100644 (file)
@@ -5,6 +5,11 @@ LogInfo("-----",
                "Converted to Lua by Charles McGarvey",
                "-----")
 
+--for key,value in pairs(_G) do print(key, value) end
+meh = Blah:new()
+meh:sayHello()
+print(meh:myStr(3.1415))
+
 -- Scene API:
 --
 -- Functions:
index bf5bc83b0f621f22647bc81f10a494e74ac06764..f6f362cbeedb0d88403317c000cd0293d70ef0bd 100644 (file)
@@ -81,5 +81,5 @@ swapcontrol           = true
 -- 2 include warnings
 -- 3 print everything, including debug messages
 
-loglevel = 2
+loglevel               = 2
 
index 9af54402ae74846e88418531d8b679e71595c02d..620db5bc6906c82bd58446be23a2075367c20208 100644 (file)
@@ -15,8 +15,9 @@
 /**
  * @file Script.hh
  * A thin wrapper over Lua.  This is not meant as a complicated binding
- * package between C++ and Lua.  It does not try to make the boundary
- * invisible.  It does not hide the concept of the Lua stack, but rather
+ * package between C++ and Lua.  It is not meant to obscure the division
+ * between C++ and Lua but rather to clarify it and make it more
+ * manageable.  It does not hide the concept of the Lua stack, but rather
  * provides that mechanism with a certain level of abstraction while also
  * providing a cleaner, more consistent API.
  */
@@ -32,8 +33,6 @@
 #include <boost/shared_ptr.hpp>
 #include <lua.hpp>
 
-#include <Moof/Log.hh>
-
 
 namespace Mf {
 
@@ -412,6 +411,19 @@ public:
                        return true;
                }
 
+               /**
+                * Get the value of a field from the table.
+                */
+
+               template <typename T, typename V>
+               bool get(T& value, V field) const
+               {
+                       pushField(field);
+                       bool ret = Slot(mState, -1).get(value);
+                       lua_pop(mState, 1);
+                       return ret;
+               }
+
 
                /**
                 * Copy the value and push the copy to the stack.
@@ -447,7 +459,7 @@ public:
                }
 
                
-               void pushMetatable() const
+               void pushMetaTable() const
                {
                        lua_getmetatable(mState, index);
                }
@@ -569,7 +581,6 @@ public:
                lua_setglobal(mState, name.c_str());
        }
 
-
        Result doString(const std::string& commands)
        {
                return (Result)luaL_dostring(mState, commands.c_str());
index afbfa440f9f915f949feda5e459b7c4fa1d80c2e..918ff5250b843c8c8b0020b3935ab848e07cf4ae 100644 (file)
@@ -140,7 +140,7 @@ struct Scene::Impl : public Mf::Manager<Impl>
 
        //Mf::Octree<Quad>::Ptr mOctree;
        std::list< boost::shared_ptr<Impl::Quad> >      mObjects;
-       std::list< Mf::Line<2> >                                        mLines;
+       std::list<Mf::Line2>                                            mLines;
 
        Mf::Aabb<3>                             mBounds;
 
@@ -261,24 +261,26 @@ struct Scene::Impl : public Mf::Manager<Impl>
 
        int scale(Mf::Script& script)
        {
-               if (script.getSize() == 3)
+               int size = script.getSize();
+
+               if (size == 1)
                {
-                       Mf::Vector3 vec;
-                       script[1].requireNumber().get(vec[0]);
-                       script[2].requireNumber().get(vec[1]);
-                       script[3].requireNumber().get(vec[2]);
+                       Mf::Scalar value = 1.0;
+                       script[1].requireNumber().get(value);
 
                        Mf::Matrix4 scaling;
-                       cml::matrix_scale(scaling, vec);
+                       cml::matrix_uniform_scale(scaling, value);
                        mTransform = scaling * mTransform;
                }
-               else if (script.getSize() == 1)
+               else if (size == 3)
                {
-                       Mf::Scalar value = 1.0;
-                       script[1].requireNumber().get(value);
+                       Mf::Vector3 vec;
+                       script[1].requireNumber().get(vec[0]);
+                       script[2].requireNumber().get(vec[1]);
+                       script[3].requireNumber().get(vec[2]);
 
                        Mf::Matrix4 scaling;
-                       cml::matrix_uniform_scale(scaling, value);
+                       cml::matrix_scale(scaling, vec);
                        mTransform = scaling * mTransform;
                }
                else
@@ -311,16 +313,13 @@ struct Scene::Impl : public Mf::Manager<Impl>
 
        int drawTilemap(Mf::Script& script)
        {
-               Mf::Script::Slot table = script[1].requireTable();
-               Mf::Script::Slot top = script[-1];
+               Mf::Script::Slot        table = script[1].requireTable();
 
-               int                             width = 1;
-               int                             height = 1;
-               int                             nTiles = 0;
+               int width  = 1;
+               int height = 1;
+               int nTiles = 0;
 
-               table.pushField("width");
-               top.get(width);
-               script.pop();
+               table.get(width, "width");
 
                nTiles = table.getLength();
                if (nTiles % width != 0)
@@ -358,12 +357,8 @@ struct Scene::Impl : public Mf::Manager<Impl>
                                int wPlus1 = w + 1;
                                int hPlus1 = h + 1;
 
-                               table.pushField(i);
-
                                Mf::Texture::TileIndex index;
-                               top.get(index);
-
-                               script.pop();
+                               table.get(index, i);
 
                                vertices[h][wPlus1] = Mf::demote(mTransform *
                                                Mf::Vector4(wPlus1, h, 0.0, 1.0));
@@ -386,10 +381,7 @@ struct Scene::Impl : public Mf::Manager<Impl>
                }
 
                Quad::Surface   surface = Quad::NONE;
-
-               table.pushField("surface");
-               top.get(surface);
-               script.pop();
+               table.get(surface, "surface");
 
                if (surface != Quad::NONE)
                {
@@ -402,7 +394,6 @@ struct Scene::Impl : public Mf::Manager<Impl>
                        Mf::Vector2 tr = Mf::demote(vertices[height][width]);
 
                        mLines.push_back(Mf::Line<2>(bl, tr));
-                       Mf::logInfo("new line");
                }
 
                return 0;
@@ -420,18 +411,10 @@ struct Scene::Impl : public Mf::Manager<Impl>
 
                if (param.isTable())
                {
-                       script.push(1);
-                       param.pushField();
-                       top.get(index);
-
-                       param.pushField("u_scale");
-                       top.get(width);
-
-                       param.pushField("blend");
-                       top.get(blending);
-
-                       param.pushField("fog");
-                       top.get(fog);
+                       param.get(index, 1);
+                       param.get(width, "u_scale");
+                       param.get(blending, "blend");
+                       param.get(fog, "fog");
                }
                else if (param.isNumber())
                {
@@ -441,7 +424,7 @@ struct Scene::Impl : public Mf::Manager<Impl>
                Mf::Vector3 vertices[2][width+1];
 
                Mf::Scalar xf;
-               Mf::Scalar increment = 1.0 / Mf::Scalar(width);
+               Mf::Scalar increment = SCALAR(1.0) / Mf::Scalar(width);
 
                for (int h = 0; h <= 1; ++h)
                {
index 8d626fc7b75496e9f0e7a62e1ddefc0b85deadc8..18c10e8bcb716a5a4ba894df3e71e912f783338c 100644 (file)
@@ -39,5 +39,5 @@ BEGIN
        END
 END
 
-1000 ICON "yoink.ico"
+1000 ICON "../win32/yoink.ico"
 
index 026d9116b6522c76211f9be17554b4718680ef36..e004aec4548944056de8f41ad00cc6cfb648e163 100755 (executable)
 # libvorbis 1.2.3
 # lua 5.1.4
 # openal-soft 1.11.753
-# zlib 1.2.3
 #
 # This script requires a working mingw32 toolchain and other basic tools.
-# Have fun!
+# You also need zlib which may not have been included with your mingw32
+# installation; you're on your own for that one.  Have fun!
 #
 # Example usage:
 #   ./makedeps.sh -H i486-mingw32 -p /usr/i486-mingw32 -m "-j8"
@@ -84,8 +84,9 @@ function die()
 }
 
 DESTDIR="`pwd`/deps"
-mkdir -p $DESTDIR
-rm -f $DESTDIR/README
+mkdir -p "$DESTDIR"
+rm -f "$DESTDIR/README"
+rm -rf "$DESTDIR/$PREFIX"
 
 
 PACKAGE="boost_1_42_0"
@@ -181,23 +182,24 @@ EOL
 ) || die "installing $PACKAGE"
 
 
-PACKAGE="zlib123-dll"
-cd $DESTDIR
-test ! -f $PACKAGE.zip && (wget "http://www.zlib.net/$PACKAGE.zip" || die "downloading $PACKAGE")
-(md5sum -c <<"EOL"
-cc7fa97f9c19386bb701acc79d0abbca  zlib123-dll.zip
-EOL
-) || die "verifying $PACKAGE"
-rm -rf $PACKAGE
-unzip -d $PACKAGE $PACKAGE.zip || die "unpackaging $PACKAGE"
-cd $PACKAGE
-($HOST-dlltool -k -d lib/zlib.def -D zlib1.dll -l libzdll.a && \
-mkdir -p $DESTDIR/$PREFIX/{lib,include} && \
-install -p -m 0644 include/* $DESTDIR/$PREFIX/include/ && \
-install -p -m 0755 zlib1.dll $DESTDIR/$PREFIX/bin/ && \
-install -p -m 0755 libzdll.a $DESTDIR/$PREFIX/lib/ && \
-cd $DESTDIR/$PREFIX/lib && \
-ln -fs libzdll.a libz.dll.a) || die "installing $PACKAGE"
+#PACKAGE="zlib123-dll"
+#cd $DESTDIR
+#test ! -f $PACKAGE.zip && (wget "http://www.zlib.net/$PACKAGE.zip" || die "downloading $PACKAGE")
+#(md5sum -c <<"EOL"
+#cc7fa97f9c19386bb701acc79d0abbca  zlib123-dll.zip
+#EOL
+#) || die "verifying $PACKAGE"
+#rm -rf $PACKAGE
+#unzip -d $PACKAGE $PACKAGE.zip || die "unpackaging $PACKAGE"
+#cd $PACKAGE
+#($HOST-dlltool -k -d lib/zlib.def -D zlib1.dll -l libzdll.a && \
+#$HOST-ranlib libzdll.a && \
+#mkdir -p $DESTDIR/$PREFIX/{lib,include} && \
+#install -p -m 0644 include/* $DESTDIR/$PREFIX/include/ && \
+#install -p -m 0755 zlib1.dll $DESTDIR/$PREFIX/bin/ && \
+#install -p -m 0755 libzdll.a $DESTDIR/$PREFIX/lib/ && \
+#cd $DESTDIR/$PREFIX/lib && \
+#ln -fs libzdll.a libz.dll.a) || die "installing $PACKAGE"
 
 
 PACKAGE="libpng-1.4.1"
@@ -210,11 +212,11 @@ EOL
 rm -rf $PACKAGE
 tar xzf $PACKAGE.tar.gz || die "unpackaging $PACKAGE"
 cd $PACKAGE
-./configure --host=$HOST --prefix=$PREFIX \
-CPPFLAGS="-I$DESTDIR/$PREFIX/include" \
-LDFLAGS="-L$DESTDIR/$PREFIX/lib" || die "configuring $PACKAGE"
-make $MAKEOPTS || die "making $PACKAGE"
-make DESTDIR=$DESTDIR install || die "installing $PACKAGE"
+cp scripts/makefile.mingw Makefile && \
+make $MAKEOPTS prefix="$PREFIX" CC="$HOST-gcc" AR="$HOST-ar" RANLIB="$HOST-ranlib" \
+ZLIBINC="-I$DESTDIR/$PREFIX/include" \
+ZLIBLIB="-L$DESTDIR/$PREFIX/lib" libpng.a libpng14.dll || die "making $PACKAGE"
+make DESTDIR=$DESTDIR install prefix="$PREFIX" || die "installing $PACKAGE"
 
 
 PACKAGE="lua-5.1.4"
index 6cb1afa66c6b8eaeddc58a804b13c831a2411d1f..0cb48857b6e0e3964319ea335dcf96cb5ba580e8 100755 (executable)
@@ -2,7 +2,7 @@
 
 #
 # Yoink
-# Run this script to create a portable win32 package.
+# Run this script to create a win32 package.
 #
 
 function showhelp()
@@ -62,15 +62,14 @@ function die()
 }
 
 ROOT="$PWD"
-BUILD="$PWD/tmp-$$"
-NAME="yoink-$VERSION"
-ARCHIVE="$BUILD/$NAME"
-INSTALLER_SCRIPT="$ROOT/win32/yoink.nsi"
+BUILD="$ROOT/tmp-$$"
+DIRECTORY="yoink-$VERSION"
+ARCHIVE="$BUILD/$DIRECTORY"
 
 MAN2HTML="$ROOT/doc/man2html.sh"
 UNIX2DOS="$ROOT/win32/unix2dos.sh"
 
-DLLS="libogg-0 libpng14-14 libvorbis-0 libvorbisfile-3 lua51 OpenAL32 SDL zlib1"
+DLLS="libogg-0 libpng14 libvorbis-0 libvorbisfile-3 lua51 OpenAL32 SDL zlib1"
 
 
 if test ! -f "src/version.c"
@@ -121,21 +120,26 @@ cd "$ROOT"
 
 if test "x$MAKENSIS" = x
 then
-# build the portable archive
+# build portable archive
+       echo "No valid makensis executable passed;"
+       echo "making portable package instead..."
+       NAME="$DIRECTORY.zip"
        cd "$BUILD"
-       zip -r $NAME.zip $NAME || die "zipping portable archive"
+       zip -r "$NAME" "$DIRECTORY" || die "zipping portable archive"
        cd "$ROOT"
-       mv "$BUILD/$NAME.zip" .
-       echo "Done! Package saved to $NAME.zip."
+       mv "$BUILD/$NAME" .
+       echo "Done! Package saved to $NAME."
 else
 # build an installer
-       cd "$BULID"
-       "$MAKENSIS" "$INSTALLER_SCRIPT" \
-               -DINSTALLFILES="$NAME" -DVERSION="$VERSION" \
+       NAME="yoinksetup-$VERSION.exe"
+       cd "$BUILD"
+       cp "$ROOT/win32/yoink.nsi" .
+       "$MAKENSIS" -DROOTPATH="$ROOT" -DINSTALLFILES="$ARCHIVE" \
+               -DVERSION="$VERSION" -DOUTFILE="$NAME" yoink.nsi \
                || die "running '$MAKENSIS'"
        cd "$ROOT"
-       mv "$BUILD/$NAME.exe" .
-       echo "Done! Installer saved to $NAME.exe."
+       mv "$BUILD/$NAME" .
+       echo "Done! Installer saved to $NAME."
 fi
 
 
similarity index 100%
rename from src/setup.ico
rename to win32/setup.ico
similarity index 100%
rename from src/uninstall.ico
rename to win32/uninstall.ico
similarity index 100%
rename from src/yoink.ico
rename to win32/yoink.ico
index 7f1b635094714bf2bc3f56bf4e88d3acf8f8c28f..2638a655caa0932e13971a6de5a23f9a739c9871 100644 (file)
@@ -12,7 +12,7 @@
 
   ;Name and file
   Name "Yoink"
-  OutFile "yoinksetup-$VERSION.exe"
+  OutFile "${OUTFILE}"
   SetCompressor /SOLID lzma
 
   ;Default installation folder
@@ -27,8 +27,8 @@
 ;--------------------------------
 ;Interface Settings
 
-  !define MUI_ICON "../src/setup.ico"
-  !define MUI_UNICON "../src/uninstall.ico"
+  !define MUI_ICON "${ROOTPATH}/win32/setup.ico"
+  !define MUI_UNICON "${ROOTPATH}/win32/uninstall.ico"
 
   !define MUI_COMPONENTSPAGE_SMALLDESC
 
@@ -64,7 +64,7 @@ Section "Install Yoink!" SecInstallYoink
   SetOutPath "$INSTDIR"
   
   ;ADD YOUR OWN FILES HERE...
-  File /r "$INSTALLFILES/*"
+  File /r "${INSTALLFILES}/*"
   
   ;Store installation folder
   WriteRegStr HKCU "Software\Yoink" "" $INSTDIR
@@ -78,9 +78,9 @@ Section "Install Yoink!" SecInstallYoink
   CreateShortCut "$SMPROGRAMS\Yoink\Uninstall.lnk" "$INSTDIR\uninstall.exe"
 
   WriteRegStr HKCU "Software\Games\Yoink" "" "$INSTDIR"
-  WriteRegStr HKCU "Software\Games\Yoink" "Version" "$VERSION"
+  WriteRegStr HKCU "Software\Games\Yoink" "Version" "${VERSION}"
   WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\Yoink" "DisplayName" "Yoink"
-  WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\Yoink" "DisplayVersion" "$VERSION"
+  WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\Yoink" "DisplayVersion" "${VERSION}"
   WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\Yoink" "UninstallString" "$INSTDIR\uninstall.exe"
 
 SectionEnd
This page took 0.039177 seconds and 4 git commands to generate.