Commit 621d44a7 authored by Atsuhito Kohda's avatar Atsuhito Kohda

Imported Debian patch 0.3~svn671-1

parents 83908e50 eae65317
License
License
=======
TeXworks is copyright (c) 2007-09 by Jonathan Kew.
Distributed under the terms of the GNU General Public License, version 2 or (at your option) any later version.
See the file COPYING for details.
The SyncTeX code is copyright (c) 2008, 2009 by JŽr™me Laurens; see synctex_parser.c for license details.
The SyncTeX code is copyright (c) 2008, 2009 by Jérôme Laurens; see synctex_parser.c for license details.
Building TeXworks
......
......@@ -29,24 +29,30 @@ OBJECTS_DIR = ./obj
UI_DIR = ./ui
RCC_DIR = ./rcc
# packagers should override this to identify the source of the particular TeXworks build;
# avoid spaces or other chars that would need quoting on the command line
QMAKE_CXXFLAGS += -DTW_BUILD_ID=personal
# comment this out if poppler's xpdf headers are not available on the build system
QMAKE_CXXFLAGS += -DHAVE_POPPLER_XPDF_HEADERS
# put all symbols in the dynamic symbol table to plugins can access them; if not
# given, plugin loading may fail with a debug warning for some plugins
# Note: only works for gnu compilers; need to check what flags to pass to other compilers
QMAKE_LFLAGS += -Wl,--export-dynamic
!macx {
QMAKE_LFLAGS += -Wl,--export-dynamic
}
unix:!macx {
TARGET = texworks
} else {
TARGET = TeXworks
QMAKE_CXXFLAGS = -fexceptions
QMAKE_LFLAGS = -fexceptions
QMAKE_CXXFLAGS += -fexceptions
QMAKE_LFLAGS += -fexceptions
}
QT += xml script scripttools
CONFIG += rtti
CONFIG += rtti uitools
unix {
system(./getDefaultBinPaths.sh):warning("Unable to determine TeX path, guessing defaults")
......@@ -64,12 +70,14 @@ macx {
INCLUDEPATH += /usr/local/include/poppler/qt4
INCLUDEPATH += /usr/local/include/hunspell
LIBS += /usr/lib/libQtUiTools.a
LIBS += -L/usr/local/lib
LIBS += -lpoppler
LIBS += -lpoppler-qt4
LIBS += -lhunspell-1.2
LIBS += -lgcc_eh
LIBS += -lz
LIBS += -framework CoreServices
QMAKE_INFO_PLIST = TeXworks.plist
......@@ -96,6 +104,8 @@ linux-g++ {
# Qt/dbus config on Debian is broken, hence the lines below
LIBS += -lQtDBus
INCLUDEPATH += /usr/include/qt4/QtDBus
# needed to link successfully on Fedora, apparently
LIBS += -lz
}
openbsd-g++ {
......@@ -138,6 +148,7 @@ HEADERS += src/TWApp.h \
src/TWScript.h \
src/TWScriptAPI.h \
src/TeXDocument.h \
src/CommandlineParser.h \
src/CompletingEdit.h \
src/TeXHighlighter.h \
src/TeXDocks.h \
......@@ -172,7 +183,9 @@ SOURCES += src/main.cpp \
src/TWUtils.cpp \
src/TWScriptable.cpp \
src/TWScript.cpp \
src/TWScriptAPI.cpp \
src/TeXDocument.cpp \
src/CommandlineParser.cpp \
src/CompletingEdit.cpp \
src/TeXHighlighter.cpp \
src/TeXDocks.cpp \
......@@ -209,3 +222,23 @@ TRANSLATIONS += trans/TeXworks_af.ts \
trans/TeXworks_tr.ts \
trans/TeXworks_zh_CN.ts
unix:!macx { # installation on Unix-ish platforms
isEmpty(INSTALL_PREFIX):INSTALL_PREFIX = /usr/local
isEmpty(BIN_DIR):BIN_DIR = $$INSTALL_PREFIX/bin
isEmpty(DATA_DIR):DATA_DIR = $$INSTALL_PREFIX/share
isEmpty(DOCS_DIR):DOCS_DIR = $$DATA_DIR/doc/texworks
isEmpty(ICON_DIR):ICON_DIR = $$DATA_DIR/pixmaps
isEmpty(MAN_DIR):MAN_DIR = $$DATA_DIR/man/man1
isEmpty(DESKTOP_DIR):DESKTOP_DIR = $$DATA_DIR/applications
target.path = $$BIN_DIR
documentation.files = COPYING README
documentation.path = $$DOCS_DIR
icon.files = res/images/TeXworks.png
icon.path = $$ICON_DIR
man.files = man/texworks.1
man.path = $$MAN_DIR
desktop.files = texworks.desktop
desktop.path = $$DESKTOP_DIR
INSTALLS = target documentation icon man desktop
}
texworks (0.3~svn671-1) experimental; urgency=low
* New Upstream Release. (Rev.671)
* Updated patches.
-- Atsuhito KOHDA <kohda@debian.org> Tue, 03 Aug 2010 15:31:17 +0900
texworks (0.3~svn606-1) experimental; urgency=low
* New Upstream Release. (Rev.606)
......
--- texworks-0.3/src/TWApp.cpp.orig 2010-02-22 13:19:33.000000000 +0900
+++ texworks-0.3/src/TWApp.cpp 2010-02-22 13:20:27.000000000 +0900
@@ -599,6 +599,8 @@
@@ -816,6 +816,8 @@
<< Engine("pdfLaTeX", "pdflatex" EXE, QStringList("$synctexoption") << "$fullname", true)
<< Engine("XeTeX", "xetex" EXE, QStringList("$synctexoption") << "$fullname", true)
<< Engine("XeLaTeX", "xelatex" EXE, QStringList("$synctexoption") << "$fullname", true)
......
--- texworks-0.3~svn569.orig/TeXworks.pro
+++ texworks-0.3~svn569/TeXworks.pro
@@ -87,8 +87,8 @@
@@ -95,8 +95,8 @@
# Enclose the path in \\\" (which later gets expanded to \", which in turn
# gets expanded to " in the c++ code)
......@@ -11,32 +11,3 @@
QMAKE_CXXFLAGS += -DTW_DICPATH=\\\"/usr/share/myspell/dicts\\\"
}
--- texworks-0.3~svn569/plugins-src/TWPythonPlugin/TWPythonPlugin.cpp 2010-02-16 12:38:52.000000000 +0900
+++ texworks-scripting-python-0.3.0~svn558~karmic1/plugins-src/TWPythonPlugin/TWPythonPlugin.cpp 2010-01-31 18:00:06.000000000 +0900
@@ -44,17 +44,6 @@
typedef int Py_ssize_t;
#endif
-/* macros that may not be available in older python headers */
-#ifndef Py_RETURN_NONE
-#define Py_RETURN_NONE return Py_INCREF(Py_None), Py_None
-#endif
-#ifndef Py_RETURN_TRUE
-#define Py_RETURN_TRUE return Py_INCREF(Py_True), Py_True
-#endif
-#ifndef Py_RETURN_FALSE
-#define Py_RETURN_FALSE return Py_INCREF(Py_False), Py_False
-#endif
-
/** \brief Structure to hold data for the pyQObject wrapper */
typedef struct {
PyObject_HEAD
@@ -458,7 +447,7 @@
QVariantList list;
QVariantMap map;
PyObject * key, * value;
- int i = 0;
+ Py_ssize_t i = 0;
QString str;
// in Python 3.x, the PyInt_* were removed in favor of PyLong_*
--- texworks-0.0.1~svn337.orig/src/TeXDocument.h
+++ texworks-0.0.1~svn337/src/TeXDocument.h
@@ -127,6 +127,7 @@
@@ -133,6 +133,7 @@
public slots:
void typeset();
void interrupt();
......@@ -22,7 +22,7 @@
#include <math.h>
@@ -1131,6 +1136,7 @@
@@ -1136,6 +1141,7 @@
connect(actionNew, SIGNAL(triggered()), qApp, SLOT(newFile()));
connect(actionNew_from_Template, SIGNAL(triggered()), qApp, SLOT(newFromTemplate()));
connect(actionOpen, SIGNAL(triggered()), qApp, SLOT(open()));
......@@ -30,7 +30,7 @@
connect(actionQuit_TeXworks, SIGNAL(triggered()), TWApp::instance(), SLOT(maybeQuit()));
@@ -1711,3 +1717,203 @@
@@ -1716,3 +1722,203 @@
}
}
......@@ -274,16 +274,16 @@
<customwidget>
--- texworks-0.0.1~svn337.orig/src/TeXDocument.cpp
+++ texworks-0.0.1~svn337/src/TeXDocument.cpp
@@ -58,6 +58,8 @@
#include <QPushButton>
@@ -56,6 +56,8 @@
#include <QFileSystemWatcher>
#include <QTextBrowser>
#include <QDebug>
+#include <QPrinter>
+#include <QPrintDialog>
#ifdef Q_WS_WIN
#include <windows.h>
@@ -169,6 +171,7 @@
@@ -171,6 +173,7 @@
connect(actionSave_All, SIGNAL(triggered()), this, SLOT(saveAll()));
connect(actionRevert_to_Saved, SIGNAL(triggered()), this, SLOT(revert()));
connect(actionClose, SIGNAL(triggered()), this, SLOT(close()));
......@@ -291,7 +291,7 @@
connect(actionRemove_Aux_Files, SIGNAL(triggered()), this, SLOT(removeAuxFiles()));
@@ -2866,3 +2869,26 @@
@@ -2844,3 +2847,26 @@
pdfDoc = NULL;
}
}
......
......@@ -69,8 +69,8 @@ clean:
patch -NRp1 < ./debian/patch-plugin || true
rm -f document-print.png res/tango/document-print.png
rm -f $(PLIDIR)/libTWLuaPlugin.so
rm -f $(PLIPYT)/libTWPythonPlugin.so
rm -f $(PLIDIR)/libTWLuaPlugin.so $(PLIDIR)/Makefile
rm -f $(PLIPYT)/libTWPythonPlugin.so $(PLIPYT)/Makefile
dh_clean
......
.TH TEXWORKS 1
.SH NAME
.B texworks
\- a simple TeX front-end program
.SH SYNOPSIS
.B texworks
[OPTIONS] [FILES]
.SH DESCRIPTION
.B TeXworks
is an environment for authoring TeX (LaTeX, ConTeXt, etc) documents, with a Unicode-based, TeX-aware editor, integrated PDF viewer, and a clean, simple interface accessible to casual and non-technical users.
It is inspired by Dick Koch's award-winning TeXShop program for Mac OS X, which has made quality typesetting through TeX accessible to a wider community of users, without a technical or intimidating face. The goal of
.B TeXworks
is to deliver a similarly integrated, easy-to-use environment for users on other platforms, especially GNU/Linux and Windows.
.SH OPTIONS
.TP
.B --help, -?
Display a short overview over all command line options
.TP
.B --position=, -p
Open the next specified file at the given position (line or page)
.TP
.B --version, -v
Display version information
.SH ENVIRONMENT
.TP
TW_INIPATH
Overrides the location of the preferences file.
.TP
TW_LIBPATH
Overrides the location of the additional configuration and library files.
.TP
TW_DICPATH
Overrides the location of dictionary files.
.TP
TW_HELPPATH
Overrides the location of help files.
.TP
TW_PLUGINPATH
Overrides the location of plugins.
.SH FILES
.TP
.I ~/.config/TUG/TeXworks.conf
Text file to store the preferences.
.TP
.I ~/.TeXworks/*
Additional configuration and library files (e.g. for auto completion, templates, etc.).
.TP
.I /usr/local/bin/texworks-setup.ini
Setup file to override the location of the files mentioned above (e.g. for enabling portable operation).
.SH SEE ALSO
.B TeXworks
homepage: \%http://tug.org/texworks/
.B TeXworks
development: \%http://code.google.com/p/texworks/
.SH BUGS
If you find a bug, please report it at \%http://code.google.com/p/texworks/issues/list
.SH AUTHORS
Jonathan Kew, Stefan Löffler, and others
#############################################################################
# Makefile for building: libTWLuaPlugin.so
# Generated by qmake (2.01a) (Qt 4.5.3) on: ? 4? 15 09:21:30 2010
# Project: TWLuaPlugin.pro
# Template: lib
# Command: /usr/bin/qmake-qt4 -unix -after target.path\ =\ /usr/lib/texworks -o Makefile TWLuaPlugin.pro
#############################################################################
####### Compiler, tools and options
CC = gcc
CXX = g++
DEFINES = -DQT_NO_DEBUG -DQT_PLUGIN -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED
CFLAGS = -pipe -O2 -I/usr/include/lua5.1 -Wall -W -D_REENTRANT -fPIC $(DEFINES)
CXXFLAGS = -pipe -O2 -I/usr/include/lua5.1 -Wall -W -D_REENTRANT -fPIC $(DEFINES)
INCPATH = -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I../../src -Imoc
LINK = g++
LFLAGS = -Wl,-O1 -shared
LIBS = $(SUBLIBS) -L/usr/lib -llua5.1 -lQtGui -lQtCore -lpthread
AR = ar cqs
RANLIB =
QMAKE = /usr/bin/qmake-qt4
TAR = tar -cf
COMPRESS = gzip -9f
COPY = cp -f
SED = sed
COPY_FILE = $(COPY)
COPY_DIR = $(COPY) -r
INSTALL_FILE = install -m 644 -p
INSTALL_DIR = $(COPY_DIR)
INSTALL_PROGRAM = install -m 755 -p
DEL_FILE = rm -f
SYMLINK = ln -sf
DEL_DIR = rmdir
MOVE = mv -f
CHK_DIR_EXISTS= test -d
MKDIR = mkdir -p
####### Output directory
OBJECTS_DIR = obj/
####### Files
SOURCES = TWLuaPlugin.cpp \
../../src/TWScript.cpp moc/moc_TWLuaPlugin.cpp \
moc/moc_TWScript.cpp \
moc/moc_TWScriptAPI.cpp
OBJECTS = obj/TWLuaPlugin.o \
obj/TWScript.o \
obj/moc_TWLuaPlugin.o \
obj/moc_TWScript.o \
obj/moc_TWScriptAPI.o
DIST = /usr/share/qt4/mkspecs/common/g++.conf \
/usr/share/qt4/mkspecs/common/unix.conf \
/usr/share/qt4/mkspecs/common/linux.conf \
/usr/share/qt4/mkspecs/qconfig.pri \
/usr/share/qt4/mkspecs/features/qt_functions.prf \
/usr/share/qt4/mkspecs/features/qt_config.prf \
/usr/share/qt4/mkspecs/features/exclusive_builds.prf \
/usr/share/qt4/mkspecs/features/default_pre.prf \
/usr/share/qt4/mkspecs/features/release.prf \
/usr/share/qt4/mkspecs/features/default_post.prf \
/usr/share/qt4/mkspecs/features/link_pkgconfig.prf \
/usr/share/qt4/mkspecs/features/warn_on.prf \
/usr/share/qt4/mkspecs/features/qt.prf \
/usr/share/qt4/mkspecs/features/unix/thread.prf \
/usr/share/qt4/mkspecs/features/moc.prf \
/usr/share/qt4/mkspecs/features/resources.prf \
/usr/share/qt4/mkspecs/features/uic.prf \
/usr/share/qt4/mkspecs/features/yacc.prf \
/usr/share/qt4/mkspecs/features/lex.prf \
/usr/share/qt4/mkspecs/features/include_source_dir.prf \
TWLuaPlugin.pro
QMAKE_TARGET = TWLuaPlugin
DESTDIR =
TARGET = libTWLuaPlugin.so
TARGETD = libTWLuaPlugin.so
first: all
####### Implicit rules
.SUFFIXES: .o .c .cpp .cc .cxx .C
.cpp.o:
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
.cc.o:
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
.cxx.o:
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
.C.o:
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
.c.o:
$(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<"
####### Build rules
all: Makefile $(TARGET)
$(TARGET): $(OBJECTS) $(SUBLIBS) $(OBJCOMP)
-$(DEL_FILE) $(TARGET)
$(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(LIBS) $(OBJCOMP)
Makefile: TWLuaPlugin.pro /usr/share/qt4/mkspecs/linux-g++/qmake.conf /usr/share/qt4/mkspecs/common/g++.conf \
/usr/share/qt4/mkspecs/common/unix.conf \
/usr/share/qt4/mkspecs/common/linux.conf \
/usr/share/qt4/mkspecs/qconfig.pri \
/usr/share/qt4/mkspecs/features/qt_functions.prf \
/usr/share/qt4/mkspecs/features/qt_config.prf \
/usr/share/qt4/mkspecs/features/exclusive_builds.prf \
/usr/share/qt4/mkspecs/features/default_pre.prf \
/usr/share/qt4/mkspecs/features/release.prf \
/usr/share/qt4/mkspecs/features/default_post.prf \
/usr/share/qt4/mkspecs/features/link_pkgconfig.prf \
/usr/share/qt4/mkspecs/features/warn_on.prf \
/usr/share/qt4/mkspecs/features/qt.prf \
/usr/share/qt4/mkspecs/features/unix/thread.prf \
/usr/share/qt4/mkspecs/features/moc.prf \
/usr/share/qt4/mkspecs/features/resources.prf \
/usr/share/qt4/mkspecs/features/uic.prf \
/usr/share/qt4/mkspecs/features/yacc.prf \
/usr/share/qt4/mkspecs/features/lex.prf \
/usr/share/qt4/mkspecs/features/include_source_dir.prf \
/usr/lib/libQtGui.prl \
/usr/lib/libQtCore.prl
$(QMAKE) -unix -after target.path\ =\ /usr/lib/texworks -o Makefile TWLuaPlugin.pro
/usr/share/qt4/mkspecs/common/g++.conf:
/usr/share/qt4/mkspecs/common/unix.conf:
/usr/share/qt4/mkspecs/common/linux.conf:
/usr/share/qt4/mkspecs/qconfig.pri:
/usr/share/qt4/mkspecs/features/qt_functions.prf:
/usr/share/qt4/mkspecs/features/qt_config.prf:
/usr/share/qt4/mkspecs/features/exclusive_builds.prf:
/usr/share/qt4/mkspecs/features/default_pre.prf:
/usr/share/qt4/mkspecs/features/release.prf:
/usr/share/qt4/mkspecs/features/default_post.prf:
/usr/share/qt4/mkspecs/features/link_pkgconfig.prf:
/usr/share/qt4/mkspecs/features/warn_on.prf:
/usr/share/qt4/mkspecs/features/qt.prf:
/usr/share/qt4/mkspecs/features/unix/thread.prf:
/usr/share/qt4/mkspecs/features/moc.prf:
/usr/share/qt4/mkspecs/features/resources.prf:
/usr/share/qt4/mkspecs/features/uic.prf:
/usr/share/qt4/mkspecs/features/yacc.prf:
/usr/share/qt4/mkspecs/features/lex.prf:
/usr/share/qt4/mkspecs/features/include_source_dir.prf:
/usr/lib/libQtGui.prl:
/usr/lib/libQtCore.prl:
qmake: FORCE
@$(QMAKE) -unix -after target.path\ =\ /usr/lib/texworks -o Makefile TWLuaPlugin.pro
dist:
@$(CHK_DIR_EXISTS) obj/TWLuaPlugin1.0.0 || $(MKDIR) obj/TWLuaPlugin1.0.0
$(COPY_FILE) --parents $(SOURCES) $(DIST) obj/TWLuaPlugin1.0.0/ && $(COPY_FILE) --parents TWLuaPlugin.h ../../src/TWScript.h ../../src/TWScriptAPI.h obj/TWLuaPlugin1.0.0/ && $(COPY_FILE) --parents TWLuaPlugin.cpp ../../src/TWScript.cpp obj/TWLuaPlugin1.0.0/ && (cd `dirname obj/TWLuaPlugin1.0.0` && $(TAR) TWLuaPlugin1.0.0.tar TWLuaPlugin1.0.0 && $(COMPRESS) TWLuaPlugin1.0.0.tar) && $(MOVE) `dirname obj/TWLuaPlugin1.0.0`/TWLuaPlugin1.0.0.tar.gz . && $(DEL_FILE) -r obj/TWLuaPlugin1.0.0
clean:compiler_clean
-$(DEL_FILE) $(OBJECTS)
-$(DEL_FILE) *~ core *.core
####### Sub-libraries
distclean: clean
-$(DEL_FILE) $(TARGET)
-$(DEL_FILE) Makefile
mocclean: compiler_moc_header_clean compiler_moc_source_clean
mocables: compiler_moc_header_make_all compiler_moc_source_make_all
compiler_moc_header_make_all: moc/moc_TWLuaPlugin.cpp moc/moc_TWScript.cpp moc/moc_TWScriptAPI.cpp
compiler_moc_header_clean:
-$(DEL_FILE) moc/moc_TWLuaPlugin.cpp moc/moc_TWScript.cpp moc/moc_TWScriptAPI.cpp
moc/moc_TWLuaPlugin.cpp: TWLuaPlugin.h
/usr/bin/moc-qt4 $(DEFINES) $(INCPATH) TWLuaPlugin.h -o moc/moc_TWLuaPlugin.cpp
moc/moc_TWScript.cpp: ../../src/TWScript.h
/usr/bin/moc-qt4 $(DEFINES) $(INCPATH) ../../src/TWScript.h -o moc/moc_TWScript.cpp
moc/moc_TWScriptAPI.cpp: ../../src/TWScript.h \
../../src/TWScriptAPI.h
/usr/bin/moc-qt4 $(DEFINES) $(INCPATH) ../../src/TWScriptAPI.h -o moc/moc_TWScriptAPI.cpp
compiler_rcc_make_all:
compiler_rcc_clean:
compiler_image_collection_make_all: qmake_image_collection.cpp
compiler_image_collection_clean:
-$(DEL_FILE) qmake_image_collection.cpp
compiler_moc_source_make_all:
compiler_moc_source_clean:
compiler_uic_make_all:
compiler_uic_clean:
compiler_yacc_decl_make_all:
compiler_yacc_decl_clean:
compiler_yacc_impl_make_all:
compiler_yacc_impl_clean:
compiler_lex_make_all:
compiler_lex_clean:
compiler_clean: compiler_moc_header_clean
####### Compile
obj/TWLuaPlugin.o: TWLuaPlugin.cpp TWLuaPlugin.h
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/TWLuaPlugin.o TWLuaPlugin.cpp
obj/TWScript.o: ../../src/TWScript.cpp ../../src/TWScript.h \
../../src/TWScriptAPI.h
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/TWScript.o ../../src/TWScript.cpp
obj/moc_TWLuaPlugin.o: moc/moc_TWLuaPlugin.cpp
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/moc_TWLuaPlugin.o moc/moc_TWLuaPlugin.cpp
obj/moc_TWScript.o: moc/moc_TWScript.cpp
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/moc_TWScript.o moc/moc_TWScript.cpp
obj/moc_TWScriptAPI.o: moc/moc_TWScriptAPI.cpp
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/moc_TWScriptAPI.o moc/moc_TWScriptAPI.cpp
####### Install
install_target: first FORCE
@$(CHK_DIR_EXISTS) $(INSTALL_ROOT)/usr/lib/texworks/ || $(MKDIR) $(INSTALL_ROOT)/usr/lib/texworks/
-$(INSTALL_PROGRAM) "$(TARGET)" "$(INSTALL_ROOT)/usr/lib/texworks/$(TARGET)"
-strip --strip-unneeded "$(INSTALL_ROOT)/usr/lib/texworks/$(TARGET)"
uninstall_target: FORCE
-$(DEL_FILE) "$(INSTALL_ROOT)/usr/lib/texworks/$(TARGET)"
-$(DEL_DIR) $(INSTALL_ROOT)/usr/lib/texworks/
install: install_target FORCE
uninstall: uninstall_target FORCE
FORCE:
......@@ -30,9 +30,6 @@
TWLuaPlugin::TWLuaPlugin()
{
// Base class constructor
QObject::QObject();
// Initialize lua state
luaState = luaL_newstate();
if (luaState) {
......@@ -42,7 +39,8 @@ TWLuaPlugin::TWLuaPlugin()
TWLuaPlugin::~TWLuaPlugin()
{
if (luaState) lua_close(luaState);
if (luaState)
lua_close(luaState);
}
TWScript* TWLuaPlugin::newScript(const QString& fileName)
......@@ -58,7 +56,8 @@ bool LuaScript::execute(TWScriptAPI *tw) const
int status;
lua_State * L = m_LuaPlugin->getLuaState();
if (!L) return false;
if (!L)
return false;
// register the TW interface for use in lua
if (!LuaScript::pushQObject(L, tw, false)) {
......@@ -91,7 +90,10 @@ bool LuaScript::execute(TWScriptAPI *tw) const
/*static*/
int LuaScript::pushQObject(lua_State * L, QObject * obj, const bool throwError /*= true*/)
{
if (!L || !obj) return 0;
Q_UNUSED(throwError)
if (!L || !obj)
return 0;
lua_newtable(L);
......@@ -99,6 +101,9 @@ int LuaScript::pushQObject(lua_State * L, QObject * obj, const bool throwError /
// all call operations on object methods
if (lua_getmetatable(L, -1) == 0)
lua_newtable(L);
lua_pushlightuserdata(L, obj);
lua_setfield(L, -2, "__qobject");
lua_pushlightuserdata(L, obj);
lua_pushcclosure(L, LuaScript::setProperty, 1);
......@@ -129,7 +134,8 @@ int LuaScript::pushVariant(lua_State * L, const QVariant & v, const bool throwEr
QVariantMap::const_iterator iMap;
QVariantMap map;
if (!L) return 0;
if (!L)
return 0;
if (v.isNull()) {
lua_pushnil(L);
return 1;
......@@ -156,8 +162,9 @@ int LuaScript::pushVariant(lua_State * L, const QVariant & v, const bool throwEr
lua_newtable(L);
for (i = 1, iList = list.begin(); iList != list.end(); ++iList, ++i) {
lua_pushnumber(L, i);
LuaScript::pushVariant(L, *iList);
lua_setfield(L, -2, qPrintable(QString("%1").arg(i)));
lua_settable(L, -3);
}
return 1;
#if QT_VERSION >= 0x040500
......@@ -181,8 +188,9 @@ int LuaScript::pushVariant(lua_State * L, const QVariant & v, const bool throwEr
}
return 1;
case QMetaType::QObjectStar:
case QMetaType::QWidgetStar:
return LuaScript::pushQObject(L, v.value<QObject*>(), throwError);
case QMetaType::QWidgetStar:
return LuaScript::pushQObject(L, qobject_cast<QObject*>(v.value<QWidget*>()), throwError);
default:
// Don't throw errors if we are not in protected mode in lua, i.e.
// if the call to this function originated from C code, not in response
......@@ -311,7 +319,7 @@ int LuaScript::setProperty(lua_State * L)
/*static*/
QVariant LuaScript::getLuaStackValue(lua_State * L, int idx, const bool throwError /*= true*/)
{
bool isArray = true, isMap = true;
bool isArray = true, isMap = true, isQObject = false;
QVariantList vl;
QVariantMap vm;
int i, n, iMax;
......@@ -328,40 +336,72 @@ QVariant LuaScript::getLuaStackValue(lua_State * L, int idx, const bool throwErr
case LUA_TSTRING:
return QVariant(QString::fromUtf8(lua_tostring(L, idx)));
case LUA_TTABLE:
// Special treatment for tables
// If all keys are in the form 1..n, we can convert it to a QList
// convert index to an absolute value since we'll be messing with
// the stack
if (idx < 0) idx += lua_gettop(L) + 1;
// Check if we're dealing with a QObject* wrapper
if (lua_getmetatable(L, idx)) {
i = lua_gettop(L);
lua_pushnil(L);
// see if the metatable contains the key "__qobject"; if it
// doesn't, trying to get it later could result in an error
while (lua_next(L, i)) {
lua_pop(L, 1); // pop the value (we don't need it)
if (!lua_isstring(L, -1))
continue;
lua_pushvalue(L, -1); // duplicate the key so we don't disturb lua_next
if (QString(lua_tostring(L, -1)) == "__qobject")
isQObject = true;
lua_pop(L, 1); // pop the duplicate key
}
if (isQObject) {
lua_getfield(L, -1, "__qobject");
if (lua_islightuserdata(L, -1)) {
QObject * obj = (QObject*)lua_touserdata(L, -1);
lua_pop(L, 2);
return QVariant::fromValue(obj);
}
lua_pop(L, 1);
}
lua_pop(L, 1); // pop the metatable
}
// Special treatment for tables
// If all keys are in the form 1..n, we can convert it to a QList
// taken from the lua reference of lua_next()
lua_pushnil(L);
n = 0;
iMax = 0;
while (lua_next(L, idx)) {
if (isArray) {
if (!lua_isnumber(L, -2)) isArray = false;
if (!lua_isnumber(L, -2))
isArray = false;
else {
++n;
if (lua_tonumber(L, -2) > iMax) iMax = lua_tonumber(L, -2);
if (lua_tonumber(L, -2) > iMax)
iMax = lua_tonumber(L, -2);
}
}
if (isMap) {
// keys must be convertable to string
if (!lua_isstring(L, -2)) isMap = false;
if (!lua_isstring(L, -2))
isMap = false;
// some value types are not supported by QVariant
if (
lua_isfunction(L, -1) ||
if (lua_isfunction(L, -1) ||
lua_islightuserdata(L, -1) ||
lua_isthread(L, -1) ||
lua_isuserdata(L, -1)
) isMap = false;
lua_isuserdata(L, -1) )
isMap = false;
}
lua_pop(L, 1);
++i;
}
if (n != iMax) isArray = false;
if (n != iMax)
isArray = false;
// Lua is picky about the correct type of index for accessing table
// members. Hence we can't simply retrieve the table items by index
......@@ -370,8 +410,9 @@ QVariant LuaScript::getLuaStackValue(lua_State * L, int idx, const bool throwErr
// they keys need not be ordered when calling lua_next, we have to
// allocate the complete list first and overwrite the items as we
// get them.
if(isArray) {
for(i = 0; i < n; ++i) vl.append(QVariant());
if (isArray) {
for (i = 0; i < n; ++i)
vl.append(QVariant());
lua_pushnil(L);
while (lua_next(L, idx)) {
......@@ -406,7 +447,8 @@ QVariant LuaScript::getLuaStackValue(lua_State * L, int idx, const bool throwErr
// if the call to this function originated from C code, not in response