]> de.git.xonotic.org Git - xonotic/netradiant.git/blobdiff - include/iscriplib.h
Merge remote-tracking branch 'illwieckz/pakpath'
[xonotic/netradiant.git] / include / iscriplib.h
index 00ba661792a741f272d5a534bba5744a0379953d..8f64503355b4ded1267a926dfd20a2dc4f3f42ab 100644 (file)
@@ -1,86 +1,84 @@
-/*\r
-Copyright (C) 1999-2007 id Software, Inc. and contributors.\r
-For a list of contributors, see the accompanying CONTRIBUTORS file.\r
-\r
-This file is part of GtkRadiant.\r
-\r
-GtkRadiant is free software; you can redistribute it and/or modify\r
-it under the terms of the GNU General Public License as published by\r
-the Free Software Foundation; either version 2 of the License, or\r
-(at your option) any later version.\r
-\r
-GtkRadiant is distributed in the hope that it will be useful,\r
-but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
-GNU General Public License for more details.\r
-\r
-You should have received a copy of the GNU General Public License\r
-along with GtkRadiant; if not, write to the Free Software\r
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\r
-*/\r
-\r
-//-----------------------------------------------------------------------------\r
-//\r
-// DESCRIPTION:\r
-// all purpose scriplib interface for Q3Radiant plugins (cf. parse.h)\r
-//\r
-\r
-#ifndef __ISCRIPLIB_H_\r
-#define __ISCRIPLIB_H_\r
-\r
-/*! \file iscriplib.h\r
- \brief function tables for Radiant core's text parsing functions\r
- two token based parsers cohexist in Radiant\r
- the primary one (GetToken UnGetToken etc.) is used on the .map parsing etc.\r
- COM_Parse is another parser, used on .def parse for instance\r
\r
- NOTE: I hope we can totally get rid of this part when we have XML support\r
-*/\r
-\r
-#define SCRIPLIB_MAJOR "scriptlib"\r
-\r
-typedef qboolean       (* PFN_GETTOKEN)                (qboolean crossline);\r
-typedef void      (* PFN_UNGETTOKEN)   ();\r
-// only used to retrieve &token\r
-typedef char*     (* PFN_TOKEN) ();\r
-typedef void      (* PFN_STARTTOKENPARSING) (char *);\r
-// script line\r
-typedef int       (* PFN_SCRIPTLINE) ();\r
-typedef qboolean  (* PFN_TOKENAVAILABLE) ();\r
-// COM_Parse\r
-typedef char*     (* PFN_COM_PARSE) (char *data);\r
-typedef char*     (* PFN_GET_COM_TOKEN) ();\r
-// Hydra: added support for GetTokenExtra()\r
-typedef qboolean       (* PFN_GETTOKENEXTRA)           (qboolean crossline,char *delimiters,qboolean keepdelimiter);\r
-\r
-struct _QERScripLibTable\r
-{\r
-       float m_fVersion;\r
-       int m_nSize;\r
-       PFN_GETTOKEN    m_pfnGetToken;\r
-       PFN_GETTOKENEXTRA       m_pfnGetTokenExtra; // Hydra: added support for GetTokenExtra()\r
-       PFN_UNGETTOKEN  m_pfnUnGetToken;\r
-       PFN_TOKEN               m_pfnToken;\r
-       PFN_STARTTOKENPARSING  m_pfnStartTokenParsing;\r
-  PFN_SCRIPTLINE m_pfnScriptLine;\r
-  PFN_TOKENAVAILABLE m_pfnTokenAvailable;\r
-  PFN_COM_PARSE m_pfnCOM_Parse;\r
-  PFN_GET_COM_TOKEN m_pfnGet_COM_Token;\r
-};\r
-\r
-#ifdef USE_SCRIPLIBTABLE_DEFINE\r
-#ifndef __SCRIPLIBTABLENAME\r
-#define __SCRIPLIBTABLENAME g_ScripLibTable\r
-#endif\r
-#define GetToken __SCRIPLIBTABLENAME.m_pfnGetToken\r
-#define Token __SCRIPLIBTABLENAME.m_pfnToken\r
-#define UnGetToken __SCRIPLIBTABLENAME.m_pfnUnGetToken\r
-#define StartTokenParsing __SCRIPLIBTABLENAME.m_pfnStartTokenParsing\r
-#define ScriptLine __SCRIPLIBTABLENAME.m_pfnScriptLine\r
-#define TokenAvailable __SCRIPLIBTABLENAME.m_pfnTokenAvailable\r
-#define COM_Parse __SCRIPLIBTABLENAME.m_pfnCOM_Parse\r
-#define Get_COM_Token __SCRIPLIBTABLENAME.m_pfnGet_COM_Token\r
-#define GetTokenExtra __SCRIPLIBTABLENAME.m_pfnGetTokenExtra // Hydra: added support for GetTokenExtra()\r
-#endif\r
-\r
-#endif\r
+/*
+   Copyright (C) 2001-2006, William Joseph.
+   All Rights Reserved.
+
+   This file is part of GtkRadiant.
+
+   GtkRadiant 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.
+
+   GtkRadiant 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 GtkRadiant; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#if !defined( INCLUDED_ISCRIPLIB_H )
+#define INCLUDED_ISCRIPLIB_H
+
+/// \file iscriplib.h
+/// \brief Token input/output stream module.
+
+#include <cstddef>
+#include "generic/constant.h"
+
+#define MAXTOKEN    1024
+
+class Tokeniser
+{
+public:
+virtual void release() = 0;
+virtual void nextLine() = 0;
+virtual const char* getToken() = 0;
+virtual void ungetToken() = 0;
+virtual std::size_t getLine() const = 0;
+virtual std::size_t getColumn() const = 0;
+};
+
+class TextInputStream;
+
+class TokenWriter
+{
+public:
+virtual void release() = 0;
+virtual void nextLine() = 0;
+virtual void writeToken( const char* token ) = 0;
+virtual void writeString( const char* string ) = 0;
+virtual void writeInteger( int i ) = 0;
+virtual void writeUnsigned( std::size_t i ) = 0;
+virtual void writeFloat( double f ) = 0;
+};
+
+class TextOutputStream;
+
+struct _QERScripLibTable
+{
+       INTEGER_CONSTANT( Version, 1 );
+       STRING_CONSTANT( Name, "scriptlib" );
+
+       Tokeniser& ( *m_pfnNewScriptTokeniser )( TextInputStream & istream );
+       Tokeniser& ( *m_pfnNewSimpleTokeniser )( TextInputStream & istream );
+       TokenWriter& ( *m_pfnNewSimpleTokenWriter )( TextOutputStream & ostream );
+};
+
+#include "modulesystem.h"
+
+template<typename Type>
+class GlobalModule;
+typedef GlobalModule<_QERScripLibTable> GlobalScripLibModule;
+
+template<typename Type>
+class GlobalModuleRef;
+typedef GlobalModuleRef<_QERScripLibTable> GlobalScripLibModuleRef;
+
+inline _QERScripLibTable& GlobalScriptLibrary(){
+       return GlobalScripLibModule::getTable();
+}
+
+#endif