mirror of https://github.com/KLayout/klayout.git
WIP: Fixed documentation, added QtCore.Qt.QT_VERSION(_STR)
This commit is contained in:
parent
3b5e84a5b2
commit
21bf382549
|
|
@ -35,6 +35,7 @@
|
|||
#include <QTextDocument>
|
||||
|
||||
class Qt_Namespace { };
|
||||
class QVariant_Namespace { };
|
||||
|
||||
namespace gsi_qt
|
||||
{
|
||||
|
|
@ -43,8 +44,6 @@ namespace gsi_qt
|
|||
// QVariant::Type implementation
|
||||
// (this type is not created automatically since QVariant is implemented implicitly)
|
||||
|
||||
class QVariant_Namespace { };
|
||||
|
||||
// A dummy namespace "QVariant"
|
||||
gsi::Class<QVariant_Namespace> decl_QVariant_Namespace ("QtCore", "QVariant",
|
||||
gsi::Methods(),
|
||||
|
|
@ -190,4 +189,15 @@ static gsi::ClassExt<Qt_Namespace> inject_Qt_HitTestAccuracy_Enum_in_parent (dec
|
|||
static gsi::ClassExt<Qt_Namespace> decl_Qt_HitTestAccuracy_Enum_as_child (decl_Qt_HitTestAccuracy_Enum, "HitTestAccuracy");
|
||||
static gsi::ClassExt<Qt_Namespace> decl_Qt_HitTestAccuracy_Enums_as_child (decl_Qt_HitTestAccuracy_Enums, "QFlags_HitTestAccuracy");
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Add declarations for Qt constants and propagate into QtCore space
|
||||
|
||||
static int _qt_version () { return QT_VERSION; }
|
||||
static std::string _qt_version_str () { return QT_VERSION_STR; }
|
||||
|
||||
static gsi::ClassExt<Qt_Namespace> decl_QtCore_constants (
|
||||
gsi::constant ("QT_VERSION", _qt_version, "@brief QT_VERSION constant") +
|
||||
gsi::constant ("QT_VERSION_STR", _qt_version_str, "@brief QT_VERSION_STR constant")
|
||||
);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@
|
|||
#include <QTextDocument>
|
||||
|
||||
class Qt_Namespace { };
|
||||
class QVariant_Namespace { };
|
||||
|
||||
namespace gsi_qt
|
||||
{
|
||||
|
|
@ -43,8 +44,6 @@ namespace gsi_qt
|
|||
// QVariant::Type implementation
|
||||
// (this type is not created automatically since QVariant is implemented implicitly)
|
||||
|
||||
class QVariant_Namespace { };
|
||||
|
||||
// A dummy namespace "QVariant"
|
||||
gsi::Class<QVariant_Namespace> decl_QVariant_Namespace ("QtCore", "QVariant",
|
||||
gsi::Methods(),
|
||||
|
|
@ -184,7 +183,8 @@ static gsi::Enum<QtMsgType> decl_QtMsgType ("QtCore", "QtMsgType",
|
|||
gsi::enum_const ("QtCriticalMsg", QtCriticalMsg, "@brief Enum constant QtCriticalMsg of QtMsgType") +
|
||||
gsi::enum_const ("QtFatalMsg", QtFatalMsg, "@brief Enum constant QtFatalMsg of QtMsgType") +
|
||||
gsi::enum_const ("QtInfoMsg", QtInfoMsg, "@brief Enum constant QtInfoMsg of QtMsgType") +
|
||||
gsi::enum_const ("QtSystemMsg", QtSystemMsg, "@brief Enum constant QtSystemMsg of QtMsgType")
|
||||
gsi::enum_const ("QtSystemMsg", QtSystemMsg, "@brief Enum constant QtSystemMsg of QtMsgType"),
|
||||
"@qt\n@brief Binding of QtMsgType"
|
||||
);
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
|
@ -455,9 +455,28 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
static QUrlTwoFlagsClass<QUrl::UrlFormattingOption, QUrl::ComponentFormattingOption> decl_QUrlTwoFlags ("QtCore", "QUrl_FormattingOptions", "@brief Binding of QUrl::FormattingOptions");
|
||||
static QUrlTwoFlagsClass<QUrl::UrlFormattingOption, QUrl::ComponentFormattingOption> decl_QUrlTwoFlags ("QtCore", "QUrl_FormattingOptions", "@qt\n@brief Binding of QUrl::FormattingOptions");
|
||||
|
||||
// inject as QUrl::FormattingOptions
|
||||
static gsi::ClassExt<QUrl> decl_QUrlTwoFlags_as_child (decl_QUrlTwoFlags, "FormattingOptions", "@brief Binding of QUrl::FormattingOptions");
|
||||
static gsi::ClassExt<QUrl> decl_QUrlTwoFlags_as_child (decl_QUrlTwoFlags, "FormattingOptions", "@qt\n@brief Binding of QUrl::FormattingOptions");
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Add declarations for Qt constants and propagate into QtCore space
|
||||
|
||||
static int _qt_version () { return QT_VERSION; }
|
||||
static std::string _qt_version_str () { return QT_VERSION_STR; }
|
||||
|
||||
static gsi::ClassExt<Qt_Namespace> decl_QtCore_constants (
|
||||
gsi::constant ("QT_VERSION", _qt_version,
|
||||
"@brief QT_VERSION constant\n"
|
||||
"This is the Qt version used at build time. "
|
||||
"Note that the script binding may be derived from an older version so effectively the API may be older."
|
||||
) +
|
||||
gsi::constant ("QT_VERSION_STR", _qt_version_str,
|
||||
"@brief QT_VERSION_STR constant\n"
|
||||
"This is the Qt version used at build time. "
|
||||
"Note that the script binding may be derived from an older version so effectively the API may be older."
|
||||
)
|
||||
);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,326 +0,0 @@
|
|||
|
||||
/*
|
||||
|
||||
KLayout Layout Viewer
|
||||
Copyright (C) 2006-2018 Matthias Koefferlein
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
*/
|
||||
|
||||
#include <QtGlobal>
|
||||
|
||||
#if QT_VERSION >= 0x050000
|
||||
|
||||
#include "gsiQt.h"
|
||||
|
||||
#include <QAbstractMessageHandler>
|
||||
#include <QAbstractVideoBuffer>
|
||||
#include <QStringRef>
|
||||
#include <QUrl>
|
||||
|
||||
namespace qt_gsi
|
||||
{
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// QtMsgType implementation
|
||||
// (this type is not created automatically since QtMsgType is not within a namespace)
|
||||
// TODO: automate this within mkqtdecl5.sh
|
||||
|
||||
static gsi::Enum<QtMsgType> decl_QtMsgType ("QtMsgType",
|
||||
gsi::enum_const ("QtDebugMsg", QtDebugMsg, "@brief Enum constant QtDebugMsg of QtMsgType") +
|
||||
gsi::enum_const ("QtWarningMsg", QtWarningMsg, "@brief Enum constant QtWarningMsg of QtMsgType") +
|
||||
gsi::enum_const ("QtCriticalMsg", QtCriticalMsg, "@brief Enum constant QtCriticalMsg of QtMsgType") +
|
||||
gsi::enum_const ("QtFatalMsg", QtFatalMsg, "@brief Enum constant QtFatalMsg of QtMsgType") +
|
||||
gsi::enum_const ("QtInfoMsg", QtInfoMsg, "@brief Enum constant QtInfoMsg of QtMsgType") +
|
||||
gsi::enum_const ("QtSystemMsg", QtSystemMsg, "@brief Enum constant QtSystemMsg of QtMsgType")
|
||||
);
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// QUrlTwoFlags<QUrl::UrlFormattingOption, QUrl::ComponentFormattingOption> bindings
|
||||
|
||||
template <class A, class B>
|
||||
class QUrlTwoFlagsClass;
|
||||
|
||||
/**
|
||||
* @brief An adaptor class for the QUrlTwoFlags<A, B> template derived from QFlagsAdaptor<E> template
|
||||
*/
|
||||
template <class A, class B>
|
||||
class QUrlTwoFlagsAdaptor
|
||||
{
|
||||
public:
|
||||
QUrlTwoFlagsAdaptor () : m_qf () { }
|
||||
QUrlTwoFlagsAdaptor (A e) : m_qf (e) { }
|
||||
QUrlTwoFlagsAdaptor (B e) : m_qf (e) { }
|
||||
QUrlTwoFlagsAdaptor (QFlags<A> e) : m_qf (e) { }
|
||||
QUrlTwoFlagsAdaptor (QFlags<B> e) : m_qf (e) { }
|
||||
QUrlTwoFlagsAdaptor (const QUrlTwoFlags<A, B> &qf) : m_qf (qf) { }
|
||||
QUrlTwoFlagsAdaptor (int i) : m_qf (i) { }
|
||||
|
||||
QUrlTwoFlagsAdaptor (const std::string &s)
|
||||
{
|
||||
const QUrlTwoFlagsClass<A, B> *ecls = dynamic_cast<const QUrlTwoFlagsClass<A, B> *> (gsi::cls_decl<QUrlTwoFlags<A, B> > ());
|
||||
tl_assert (ecls != 0);
|
||||
m_qf = ecls->qflags_from_string (s);
|
||||
}
|
||||
|
||||
QUrlTwoFlags<A, B> &value () { return m_qf; }
|
||||
const QUrlTwoFlags<A, B> &value () const { return m_qf; }
|
||||
|
||||
private:
|
||||
QUrlTwoFlags<A, B> m_qf;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief A binding for QUrlTwoFlags<A, B> derived from QFlags binding
|
||||
*/
|
||||
template <class A, class B>
|
||||
class QUrlTwoFlagsClass
|
||||
: public gsi::Class<QUrlTwoFlagsAdaptor<A, B>, QUrlTwoFlags<A, B> >
|
||||
{
|
||||
public:
|
||||
typedef typename QFlags<A>::Int int_repr;
|
||||
|
||||
QUrlTwoFlagsClass (const std::string &name, const std::string &doc = std::string ())
|
||||
: gsi::Class<QUrlTwoFlagsAdaptor<A, B>, QUrlTwoFlags<A, B> > (name, methods (), doc)
|
||||
{
|
||||
}
|
||||
|
||||
static QUrlTwoFlags<A, B> *new_from_i (int_repr i)
|
||||
{
|
||||
return new QUrlTwoFlags<A, B> (i);
|
||||
}
|
||||
|
||||
static QUrlTwoFlags<A, B> *new_from_e1 (A e)
|
||||
{
|
||||
return new QUrlTwoFlags<A, B> (e);
|
||||
}
|
||||
|
||||
static QUrlTwoFlags<A, B> *new_from_e1f (QFlags<A> e)
|
||||
{
|
||||
return new QUrlTwoFlags<A, B> (e);
|
||||
}
|
||||
|
||||
static QUrlTwoFlags<A, B> *new_from_e2 (B e)
|
||||
{
|
||||
return new QUrlTwoFlags<A, B> (e);
|
||||
}
|
||||
|
||||
static QUrlTwoFlags<A, B> *new_from_e2f (QFlags<B> e)
|
||||
{
|
||||
return new QUrlTwoFlags<A, B> (e);
|
||||
}
|
||||
|
||||
static QUrlTwoFlags<A, B> *new_from_s (const std::string &s)
|
||||
{
|
||||
QUrlTwoFlags<A, B> flags;
|
||||
|
||||
const gsi::Enum<A> *acls = dynamic_cast<const gsi::Enum<A> *> (gsi::cls_decl<A> ());
|
||||
const gsi::Enum<B> *bcls = dynamic_cast<const gsi::Enum<B> *> (gsi::cls_decl<B> ());
|
||||
tl_assert (acls != 0 && bcls != 0);
|
||||
|
||||
tl::Extractor ex (s.c_str ());
|
||||
while (! ex.at_end ()) {
|
||||
|
||||
bool any = false;
|
||||
|
||||
for (typename gsi::EnumSpecs<A>::iterator s = acls->specs ().begin (); s != acls->specs ().end () && !any; ++s) {
|
||||
if (ex.test (s->str.c_str ())) {
|
||||
flags |= A (s->evalue);
|
||||
any = true;
|
||||
}
|
||||
}
|
||||
|
||||
for (typename gsi::EnumSpecs<B>::iterator s = bcls->specs ().begin (); s != bcls->specs ().end () && !any; ++s) {
|
||||
if (ex.test (s->str.c_str ())) {
|
||||
flags |= B (s->evalue);
|
||||
any = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (any) {
|
||||
ex.test ("|");
|
||||
ex.test (",");
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return new QUrlTwoFlags<A, B> (flags);
|
||||
}
|
||||
|
||||
static std::string to_s (const QUrlTwoFlags<A, B> *self)
|
||||
{
|
||||
std::string res;
|
||||
|
||||
const gsi::Enum<A> *acls = dynamic_cast<const gsi::Enum<A> *> (gsi::cls_decl<A> ());
|
||||
const gsi::Enum<B> *bcls = dynamic_cast<const gsi::Enum<B> *> (gsi::cls_decl<B> ());
|
||||
tl_assert (acls != 0 && bcls != 0);
|
||||
|
||||
for (typename gsi::EnumSpecs<A>::iterator s = acls->specs ().begin (); s != acls->specs ().end (); ++s) {
|
||||
if (self->testFlag (s->evalue)) {
|
||||
if (! res.empty ()) {
|
||||
res += "|";
|
||||
}
|
||||
res += s->str;
|
||||
}
|
||||
}
|
||||
|
||||
for (typename gsi::EnumSpecs<B>::iterator s = bcls->specs ().begin (); s != bcls->specs ().end (); ++s) {
|
||||
if (self->testFlag (s->evalue)) {
|
||||
if (! res.empty ()) {
|
||||
res += "|";
|
||||
}
|
||||
res += s->str;
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static int_repr to_i (const QUrlTwoFlags<A, B> *self)
|
||||
{
|
||||
return int_repr (*self);
|
||||
}
|
||||
|
||||
static bool test_flag1 (const QUrlTwoFlags<A, B> *self, A e)
|
||||
{
|
||||
return self->testFlag (e);
|
||||
}
|
||||
|
||||
static bool test_flag2 (const QUrlTwoFlags<A, B> *self, B e)
|
||||
{
|
||||
return self->testFlag (e);
|
||||
}
|
||||
|
||||
static std::string inspect (const QUrlTwoFlags<A, B> *self)
|
||||
{
|
||||
return to_s (self) + tl::sprintf(" (%u)", (unsigned int) (int_repr (*self)));
|
||||
}
|
||||
|
||||
static QUrlTwoFlags<A, B> invert (const QUrlTwoFlags<A, B> *self)
|
||||
{
|
||||
return ~*self;
|
||||
}
|
||||
|
||||
static QUrlTwoFlags<A, B> or_op (const QUrlTwoFlags<A, B> *self, const QUrlTwoFlags<A, B> &other)
|
||||
{
|
||||
return *self | other;
|
||||
}
|
||||
|
||||
static QUrlTwoFlags<A, B> or_op_with_e1 (const QUrlTwoFlags<A, B> *self, A e)
|
||||
{
|
||||
return *self | e;
|
||||
}
|
||||
|
||||
static QUrlTwoFlags<A, B> or_op_with_e2 (const QUrlTwoFlags<A, B> *self, B e)
|
||||
{
|
||||
return *self | e;
|
||||
}
|
||||
|
||||
static QUrlTwoFlags<A, B> and_op (const QUrlTwoFlags<A, B> *self, const QUrlTwoFlags<A, B> &other)
|
||||
{
|
||||
return *self & other;
|
||||
}
|
||||
|
||||
static QUrlTwoFlags<A, B> and_op_with_e1 (const QUrlTwoFlags<A, B> *self, A e)
|
||||
{
|
||||
return *self & e;
|
||||
}
|
||||
|
||||
static QUrlTwoFlags<A, B> and_op_with_e2 (const QUrlTwoFlags<A, B> *self, B e)
|
||||
{
|
||||
return *self & e;
|
||||
}
|
||||
|
||||
static QUrlTwoFlags<A, B> xor_op (const QUrlTwoFlags<A, B> *self, const QUrlTwoFlags<A, B> &other)
|
||||
{
|
||||
return *self ^ other;
|
||||
}
|
||||
|
||||
static QUrlTwoFlags<A, B> xor_op_with_e1 (const QUrlTwoFlags<A, B> *self, A e)
|
||||
{
|
||||
return *self ^ e;
|
||||
}
|
||||
|
||||
static QUrlTwoFlags<A, B> xor_op_with_e2 (const QUrlTwoFlags<A, B> *self, B e)
|
||||
{
|
||||
return *self ^ e;
|
||||
}
|
||||
|
||||
static bool not_equal_with_i (const QUrlTwoFlags<A, B> *self, int_repr i)
|
||||
{
|
||||
return int_repr (*self) != i;
|
||||
}
|
||||
|
||||
static bool not_equal (const QUrlTwoFlags<A, B> *self, const QUrlTwoFlags<A, B> &other)
|
||||
{
|
||||
// See equal() for an explanation why we compare int's.
|
||||
return int_repr (*self) != int_repr (other);
|
||||
}
|
||||
|
||||
static bool equal_with_i (const QUrlTwoFlags<A, B> *self, int_repr i)
|
||||
{
|
||||
return int_repr (*self) == i;
|
||||
}
|
||||
|
||||
static bool equal (const QUrlTwoFlags<A, B> *self, const QUrlTwoFlags<A, B> &other)
|
||||
{
|
||||
// NOTE: in order to avoid ambiguities with non-explicit constructors of objects taking a QFlag as an argument,
|
||||
// we compare int's explicitly. An example for such an ambiguity is QSurfaceFormat in Qt 5.5.1 which takes a QFlags<FormatOption>
|
||||
// object in a non-explicit constructor.
|
||||
return int_repr (*self) == int_repr (other);
|
||||
}
|
||||
|
||||
static gsi::Methods methods ()
|
||||
{
|
||||
return
|
||||
gsi::constructor ("new", &new_from_i, gsi::arg ("i"), "@brief Creates a flag set from an integer value") +
|
||||
gsi::constructor ("new", &new_from_s, gsi::arg ("s"), "@brief Creates a flag set from a string") +
|
||||
gsi::constructor ("new", &new_from_e1, gsi::arg ("e"), "@brief Creates a flag set from an enum") +
|
||||
gsi::constructor ("new", &new_from_e1f, gsi::arg ("e"), "@brief Creates a flag set from a QFlags set") +
|
||||
gsi::constructor ("new", &new_from_e2, gsi::arg ("e"), "@brief Creates a flag set from an enum") +
|
||||
gsi::constructor ("new", &new_from_e2f, gsi::arg ("e"), "@brief Creates a flag set from a QFlags set") +
|
||||
gsi::method_ext ("to_s", &to_s, "@brief Converts the flag set to a string") +
|
||||
gsi::method_ext ("to_i", &to_i, "@brief Converts the flag set to an integer") +
|
||||
gsi::method_ext ("testFlag1", &test_flag1, gsi::arg ("flag"), "@brief Tests whether the flag set contains the given flag") +
|
||||
gsi::method_ext ("testFlag2", &test_flag2, gsi::arg ("flag"), "@brief Tests whether the flag set contains the given flag") +
|
||||
gsi::method_ext ("inspect", &inspect, "@brief Converts the flag set to a visual string") +
|
||||
gsi::method_ext ("|", &or_op, gsi::arg ("other"), "@brief Computes the union of two flag sets") +
|
||||
gsi::method_ext ("|", &or_op_with_e1, gsi::arg ("flag"), "@brief Adds the given flag to the flag set and returns the new flag set") +
|
||||
gsi::method_ext ("|", &or_op_with_e2, gsi::arg ("flag"), "@brief Adds the given flag to the flag set and returns the new flag set") +
|
||||
gsi::method_ext ("&", &and_op, gsi::arg ("other"), "@brief Computes the intersection between the two flag sets") +
|
||||
gsi::method_ext ("&", &and_op_with_e1, gsi::arg ("flag"), "@brief Tests whether the given flag is contained in the flag set and returns a null flag set if not") +
|
||||
gsi::method_ext ("&", &and_op_with_e2, gsi::arg ("flag"), "@brief Tests whether the given flag is contained in the flag set and returns a null flag set if not") +
|
||||
gsi::method_ext ("^", &xor_op, gsi::arg ("other"), "@brief Computes the exclusive-or between the flag set and the other flag set") +
|
||||
gsi::method_ext ("^", &xor_op_with_e1, gsi::arg ("flag"), "@brief Inverts the given flag in the flag set and returns the new flag set") +
|
||||
gsi::method_ext ("^", &xor_op_with_e2, gsi::arg ("flag"), "@brief Inverts the given flag in the flag set and returns the new flag set") +
|
||||
gsi::method_ext ("==", &equal_with_i, gsi::arg ("other"), "@brief Returns true if the flag set equals the given integer value") +
|
||||
gsi::method_ext ("==", &equal, gsi::arg ("i"), "@brief Returns true if the flag set equals the given other flag set") +
|
||||
gsi::method_ext ("!=", ¬_equal_with_i, gsi::arg ("other"), "@brief Returns true if the flag set is not equal to the given integer value") +
|
||||
gsi::method_ext ("!=", ¬_equal, gsi::arg ("i"), "@brief Returns true if the flag set is not equal to the given other flag set") +
|
||||
gsi::method_ext ("~", &invert, "@brief Returns the inverted flag set");
|
||||
}
|
||||
};
|
||||
|
||||
static QUrlTwoFlagsClass<QUrl::UrlFormattingOption, QUrl::ComponentFormattingOption> decl_QUrlTwoFlags ("QUrl_FormattingOptions", "@brief Binding of QUrl::FormattingOptions");
|
||||
|
||||
// inject as QUrl::FormattingOptions
|
||||
static gsi::ClassExt<QUrl> decl_QUrlTwoFlags_as_child (decl_QUrlTwoFlags, "FormattingOptions", "@brief Binding of QUrl::FormattingOptions");
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -44,22 +44,32 @@ namespace lay
|
|||
// --------------------------------------------------------------------------------------
|
||||
// Some utilities
|
||||
|
||||
static std::string module_doc_path (const std::string &m)
|
||||
static std::string to_encoded_class_name (const std::string &s)
|
||||
{
|
||||
return "/code/module_" + m + ".xml";
|
||||
return tl::replaced (s, ":", "+");
|
||||
}
|
||||
|
||||
static std::string class_doc_path (const std::string &c)
|
||||
static std::string from_encoded_class_name (const std::string &s)
|
||||
{
|
||||
return "/code/class_" + c + ".xml";
|
||||
return tl::replaced (s, "+", ":");
|
||||
}
|
||||
|
||||
static std::string class_doc_path (const std::string &c, const std::string &m)
|
||||
static std::string module_doc_url (const std::string &m)
|
||||
{
|
||||
return "/code/module_" + to_encoded_class_name (m) + ".xml";
|
||||
}
|
||||
|
||||
static std::string class_doc_url (const std::string &c)
|
||||
{
|
||||
return "/code/class_" + to_encoded_class_name (c) + ".xml";
|
||||
}
|
||||
|
||||
static std::string class_doc_url (const std::string &c, const std::string &m)
|
||||
{
|
||||
if (c.empty ()) {
|
||||
return "#m_" + m;
|
||||
} else {
|
||||
return "/code/class_" + c + ".xml#m_" + m;
|
||||
return "/code/class_" + to_encoded_class_name (c) + ".xml#m_" + m;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -365,7 +375,7 @@ replace_references (const std::string &t, const gsi::ClassBase *cls_base)
|
|||
|
||||
bool found = false;
|
||||
if (name_map.find (id) != name_map.end ()) {
|
||||
r += "<a href=\"" + escape_xml (class_doc_path (std::string (), id)) + "\">" + escape_xml (id) + "</a>";
|
||||
r += "<a href=\"" + escape_xml (class_doc_url (std::string (), id)) + "\">" + escape_xml (id) + "</a>";
|
||||
found = true;
|
||||
}
|
||||
|
||||
|
|
@ -373,9 +383,9 @@ replace_references (const std::string &t, const gsi::ClassBase *cls_base)
|
|||
if (c->name () == id) {
|
||||
r += "<a href=\"";
|
||||
if (mid.empty ()) {
|
||||
r += escape_xml (class_doc_path (id));
|
||||
r += escape_xml (class_doc_url (id));
|
||||
} else {
|
||||
r += escape_xml (class_doc_path (id, mid));
|
||||
r += escape_xml (class_doc_url (id, mid));
|
||||
}
|
||||
r += "\">";
|
||||
if (mid.empty ()) {
|
||||
|
|
@ -427,7 +437,7 @@ void produce_toc (const gsi::ClassBase *cls, std::vector <std::string> &toc)
|
|||
{
|
||||
DocumentationParser &doc = cls_documentation (cls);
|
||||
if (! doc.hidden) {
|
||||
toc.push_back (class_doc_path (make_qualified_name (cls)));
|
||||
toc.push_back (class_doc_url (make_qualified_name (cls)));
|
||||
}
|
||||
for (tl::weak_collection<gsi::ClassBase>::const_iterator cc = cls->begin_child_classes (); cc != cls->end_child_classes (); ++cc) {
|
||||
produce_toc (cc.operator-> (), toc);
|
||||
|
|
@ -444,7 +454,7 @@ GSIHelpProvider::toc (std::vector<std::string> &t)
|
|||
}
|
||||
|
||||
for (std::set<std::string>::const_iterator m = mod_names.begin (); m != mod_names.end (); ++m) {
|
||||
t.push_back (module_doc_path (*m));
|
||||
t.push_back (module_doc_url (*m));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -460,9 +470,9 @@ GSIHelpProvider::get (const std::string &path) const
|
|||
if (url_path == QString::fromUtf8 ("/code/index.xml")) {
|
||||
text = produce_class_index (0);
|
||||
} else if (module_index_url.indexIn (url_path) == 0) {
|
||||
text = produce_class_index (tl::to_string (module_index_url.cap (1)).c_str ());
|
||||
text = produce_class_index (from_encoded_class_name (tl::to_string (module_index_url.cap (1))).c_str ());
|
||||
} else if (class_doc_url.indexIn (url_path) == 0) {
|
||||
text = produce_class_doc (tl::to_string (class_doc_url.cap (1)));
|
||||
text = produce_class_doc (from_encoded_class_name (tl::to_string (class_doc_url.cap (1))));
|
||||
} else {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Page not found: ")) + path);
|
||||
}
|
||||
|
|
@ -498,7 +508,7 @@ void produce_doc_index (const gsi::ClassBase *cls, std::ostringstream &os)
|
|||
// Only list the name if the class is not hidden, it's a top-level class or the path is an expanded one
|
||||
// (the last criterion avoids generating classes such as A::B_C)
|
||||
if (! doc.hidden) {
|
||||
os << "<topic-ref href=\"" << escape_xml (class_doc_path (qname)) << "\"/>" << std::endl;
|
||||
os << "<topic-ref href=\"" << escape_xml (class_doc_url (qname)) << "\"/>" << std::endl;
|
||||
}
|
||||
|
||||
for (tl::weak_collection<gsi::ClassBase>::const_iterator cc = cls->begin_child_classes (); cc != cls->end_child_classes (); ++cc) {
|
||||
|
|
@ -573,20 +583,20 @@ GSIHelpProvider::produce_class_index (const char *module_name) const
|
|||
}
|
||||
|
||||
for (std::set<std::string>::const_iterator m = mod_names.begin (); m != mod_names.end (); ++m) {
|
||||
os << "<topic-ref href=\"" << escape_xml (module_doc_path (*m)) << "\"/>" << std::endl;
|
||||
os << "<topic-ref href=\"" << escape_xml (module_doc_url (*m)) << "\"/>" << std::endl;
|
||||
}
|
||||
for (std::set<std::string>::const_iterator m = qt_mod_names.begin (); m != qt_mod_names.end (); ++m) {
|
||||
os << "<topic-ref href=\"" << escape_xml (module_doc_path (*m)) << "\"/>" << std::endl;
|
||||
os << "<topic-ref href=\"" << escape_xml (module_doc_url (*m)) << "\"/>" << std::endl;
|
||||
}
|
||||
|
||||
os << "<p>" << tl::to_string (QObject::tr ("Per-Module documentation:")) << "</p>";
|
||||
|
||||
os << "<ul>";
|
||||
for (std::set<std::string>::const_iterator m = mod_names.begin (); m != mod_names.end (); ++m) {
|
||||
os << "<li><a href=\"" << escape_xml (module_doc_path (*m)) << "\">" << tl::to_string (QObject::tr ("Core Module")) << " " << escape_xml (*m) << "</a></li>";
|
||||
os << "<li><a href=\"" << escape_xml (module_doc_url (*m)) << "\">" << tl::to_string (QObject::tr ("Core Module")) << " " << escape_xml (*m) << "</a></li>";
|
||||
}
|
||||
for (std::set<std::string>::const_iterator m = qt_mod_names.begin (); m != qt_mod_names.end (); ++m) {
|
||||
os << "<li><a href=\"" << escape_xml (module_doc_path (*m)) << "\">" << tl::to_string (QObject::tr ("Qt Module")) << " " << escape_xml (*m) << "</a></li>";
|
||||
os << "<li><a href=\"" << escape_xml (module_doc_url (*m)) << "\">" << tl::to_string (QObject::tr ("Qt Module")) << " " << escape_xml (*m) << "</a></li>";
|
||||
}
|
||||
os << "</ul>";
|
||||
|
||||
|
|
@ -605,9 +615,9 @@ GSIHelpProvider::produce_class_index (const char *module_name) const
|
|||
int n = 0;
|
||||
for (class_index_t::const_iterator cc = class_names.begin (); cc != class_names.end (); ++cc, ++n) {
|
||||
os << "<tr class=\"row" << (n % 2) << "\">" << std::endl;
|
||||
os << "<td><a href=\"" << escape_xml (class_doc_path (cc->first)) << "\">" << escape_xml (cc->first) << "</a></td>";
|
||||
os << "<td><a href=\"" << escape_xml (class_doc_url (cc->first)) << "\">" << escape_xml (cc->first) << "</a></td>";
|
||||
if (! module_name) {
|
||||
os << "<td> <nobr><a href=\"" << module_doc_path (cc->second.first) << "\">" << escape_xml (cc->second.first) << "</a></nobr></td>";
|
||||
os << "<td> <nobr><a href=\"" << module_doc_url (cc->second.first) << "\">" << escape_xml (cc->second.first) << "</a></nobr></td>";
|
||||
}
|
||||
os << "<td> <nobr>" << escape_xml (cc->second.second) << "</nobr></td></tr>" << std::endl;
|
||||
}
|
||||
|
|
@ -624,9 +634,9 @@ GSIHelpProvider::produce_class_index (const char *module_name) const
|
|||
int n = 0;
|
||||
for (class_index_t::const_iterator cc = qt_class_names.begin (); cc != qt_class_names.end (); ++cc, ++n) {
|
||||
os << "<tr class=\"row" << (n % 2) << "\">" << std::endl;
|
||||
os << "<td><a href=\"" << escape_xml (class_doc_path (cc->first)) << "\">" << escape_xml (cc->first) << "</a></td>";
|
||||
os << "<td><a href=\"" << escape_xml (class_doc_url (cc->first)) << "\">" << escape_xml (cc->first) << "</a></td>";
|
||||
if (! module_name) {
|
||||
os << "<td> <nobr><a href=\"" << module_doc_path (cc->second.first) << "\">" << escape_xml (cc->second.first) << "</a></nobr></td>";
|
||||
os << "<td> <nobr><a href=\"" << module_doc_url (cc->second.first) << "\">" << escape_xml (cc->second.first) << "</a></nobr></td>";
|
||||
}
|
||||
os << "<td> <nobr>" << escape_xml (cc->second.second) << "</nobr></td></tr>" << std::endl;
|
||||
}
|
||||
|
|
@ -693,7 +703,7 @@ type_to_s (const gsi::ArgType &a, bool linked, bool for_return)
|
|||
s += "new ";
|
||||
}
|
||||
if (linked) {
|
||||
s += "<a href=\"" + escape_xml (class_doc_path (aliased_name (a.cls ()))) + "\">" + escape_xml (aliased_name (a.cls ())) + "</a>";
|
||||
s += "<a href=\"" + escape_xml (class_doc_url (aliased_name (a.cls ()))) + "\">" + escape_xml (aliased_name (a.cls ())) + "</a>";
|
||||
} else {
|
||||
s += aliased_name (a.cls ());
|
||||
}
|
||||
|
|
@ -962,13 +972,13 @@ GSIHelpProvider::produce_class_doc (const std::string &cls) const
|
|||
if (! bdoc.alias.empty ()) {
|
||||
// suppress direct base class alias to our class (x_Native for x)
|
||||
if (bdoc.alias != last_cls->name ()) {
|
||||
os << " » <a href=\"" << escape_xml (class_doc_path (bdoc.alias)) << "\">" << escape_xml (bdoc.alias) << "</a>";
|
||||
os << " » <a href=\"" << escape_xml (class_doc_url (bdoc.alias)) << "\">" << escape_xml (bdoc.alias) << "</a>";
|
||||
all_collected = true;
|
||||
} else if (! all_collected) {
|
||||
classes.push_back (base);
|
||||
}
|
||||
} else if (! bdoc.hidden) {
|
||||
os << " » <a href=\"" << escape_xml (class_doc_path (base->name ())) << "\">" << escape_xml (base->name ()) << "</a>";
|
||||
os << " » <a href=\"" << escape_xml (class_doc_url (base->name ())) << "\">" << escape_xml (base->name ()) << "</a>";
|
||||
all_collected = true;
|
||||
} else if (! all_collected) {
|
||||
// class needs to be mixed into the parent
|
||||
|
|
@ -987,7 +997,7 @@ GSIHelpProvider::produce_class_doc (const std::string &cls) const
|
|||
if (tl_alias) {
|
||||
os << "<p>" << tl::to_string (QObject::tr ("This class is equivalent to the class "));
|
||||
std::string n = make_qualified_name (tl_alias);
|
||||
os << "<a href=\"" << escape_xml (class_doc_path (n)) << "\">" << escape_xml (n) << "</a>";
|
||||
os << "<a href=\"" << escape_xml (class_doc_url (n)) << "\">" << escape_xml (n) << "</a>";
|
||||
os << "</p>" << std::endl;
|
||||
}
|
||||
|
||||
|
|
@ -1006,7 +1016,7 @@ GSIHelpProvider::produce_class_doc (const std::string &cls) const
|
|||
any = true;
|
||||
}
|
||||
|
||||
os << "<a href=\"" << escape_xml (class_doc_path (make_qualified_name (cc.operator-> ()))) << "\">" << escape_xml (cc->name ()) << "</a>";
|
||||
os << "<a href=\"" << escape_xml (class_doc_url (make_qualified_name (cc.operator-> ()))) << "\">" << escape_xml (cc->name ()) << "</a>";
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,6 +29,8 @@ class BasicTest(unittest.TestCase):
|
|||
|
||||
def test_2(self):
|
||||
# Some smoke test
|
||||
v = QtCore.Qt.QT_VERSION
|
||||
self.assertEqual(v > 1, True)
|
||||
b = QtCore.QBuffer()
|
||||
b.setData("all you can eat")
|
||||
b.open(QtCore.QIODevice.ReadOnly)
|
||||
|
|
|
|||
Loading…
Reference in New Issue