Spinning Topp Logo BlackTopp Studios
inc
scripting.h
1 // © Copyright 2010 - 2016 BlackTopp Studios Inc.
2 /* This file is part of The Mezzanine Engine.
3 
4  The Mezzanine Engine is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  The Mezzanine Engine is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with The Mezzanine Engine. If not, see <http://www.gnu.org/licenses/>.
16 */
17 /* The original authors have included a copy of the license specified above in the
18  'Docs' folder. See 'gpl.txt'
19 */
20 /* We welcome the use of the Mezzanine engine to anyone, including companies who wish to
21  Build professional software and charge for their product.
22 
23  However there are some practical restrictions, so if your project involves
24  any of the following you should contact us and we will try to work something
25  out:
26  - DRM or Copy Protection of any kind(except Copyrights)
27  - Software Patents You Do Not Wish to Freely License
28  - Any Kind of Linking to Non-GPL licensed Works
29  - Are Currently In Violation of Another Copyright Holder's GPL License
30  - If You want to change our code and not add a few hundred MB of stuff to
31  your distribution
32 
33  These and other limitations could cause serious legal problems if you ignore
34  them, so it is best to simply contact us or the Free Software Foundation, if
35  you have any questions.
36 
37  Joseph Toppi - toppij@gmail.com
38  John Blackwood - makoenergy02@gmail.com
39 */
40 #ifndef _scripting_h
41 #define _scripting_h
42 
43 #ifdef MEZZLUA51
44  #define LINKLUAMANUAL /// - @ref LuaManual
45 #else
46  #define LINKLUAMANUAL /// - Lua Not Compiled in this build - @ref LuaManual
47 #endif
48 
49 namespace Mezzanine
50 {
51  /// @namespace Mezzanine::Scripting
52  /// @brief This namespace is for all the classes belonging to the Scripting Subsystem.
53  /// @details The system for integrating scripting languages into the engine.
54  /// @n @n
55  /// In general each languages Interpretter/Engine/Compiler/VM is locating in its own
56  /// subnamespace in the associated manager. Here is a list of Languages compiled in
57  /// this build.
58  /// @n @n
59  /// - @ref ScriptingManual
60  ///
61  LINKLUAMANUAL
62 
63 
64 
65  namespace Scripting
66  {}
67 }
68 
69 /// @page ScriptingManual
70 /// Many scripting languages suitable for being embedded in games have a number of
71 /// similar traits. All have some kind of runtime that must be initialized, this
72 /// runtime accepts strings of script source and performs the steps the source
73 /// desribe. Some keep internal track of the source, others expect the the caller to
74 /// do so. Most allow passing arguments into scripts and accepting return values.
75 /// Some allow the script to be compiled to a bytecode and others do not. A scripting
76 /// manager is a generic interface to this functionality and is expected to be the primary
77 /// interface for game developers who want to use a given scripting language.
78 /// @n @n
79 /// Almost every language makes a point of interoperating with C. Some provide a
80 /// special Application Prorammer Interface (API - intended for mostly programmers
81 /// use) for C to call on like Ruby, Lua and AngelScript. Some take advantage of
82 /// the reliable and unchanging C Application Binary Interface (ABI - primarily
83 /// for direct executable to executable integration), such as Java, C#,
84 /// Ruby when using FFI.
85 /// @n @n
86 /// In addition to these kinds of complexities, there are different reasons to use
87 /// a scripting language. The uses cases fall on a spectrum of "Writing a game in
88 /// a Scripting language with just performance sensitive pieces in C/C++" to the
89 /// other extreme of "The bulk of the code in C/C++ with the ability to run
90 /// scripts for flexibilty". The are reasons for both of these use cases and
91 /// they do not meaningfully conflict. Presumably any extra code written in the
92 /// more performant C and C++ will benefit all, with the primary reason to not do
93 /// so being time and technical skill required to do it. If something is already
94 /// written this way, then why not take advantage of it.
95 /// @n @n
96 /// The Interface of the scripting system was an attempt to
97 /// allow enough flexibility to accomodate most scripting and managed languages,
98 /// for the purpose of this discussion I mean any language with its own bytecode.
99 /// @n @n
100 ///
101 /// The scripting system is included the Mezzanine::Scripting namespace. It is primarily
102 /// composed of four interface classes, four abstract classes. An implementation of a
103 /// scripting system should implement these four classes in a sub-namespace:
104 /// - Mezzanine::Scripting::iScript
105 /// - Mezzanine::Scripting::iScriptArgument
106 /// - Mezzanine::Scripting::iScriptingManager
107 /// - Mezzanine::Scripting::iScriptWorkUnit
108 ///
109 /// @n @n
110 /// SWIG ( http://swig.org ) is a tool that generates code in either C or the
111 /// target language. It gets the information required to do this byreading the
112 /// Mezzanine source code directly. It support a variety of languages but is
113 /// currently
114 ///
115 /// Whether or not the is updated each build
116 /// can be controlled by the Mezz_SWIG CMake Flag. When this flag
117 /// is enabled a SWIG_Mezzanine build target is added to the project. To satisfy
118 /// build systems this target/project compiles src/blank.cpp as the only files.
119 /// During the build steps in that target it attempt to Swig from the command line.
120 /// @n @n
121 /// This can be run manually by invoking that target specifically. For example:
122 /// @code
123 /// $ make SWIG_Mezzanine
124 /// $ ninja SWIG_Mezzanine
125 /// @endcode
126 /// @section CppApiToLua How the C++ API converts to Lua
127 /// The Documentation for the C++ API is also the canonical documentation for the
128 /// Lua scripting system. The are some differences those that are not and these
129 /// detailed on the functions that are different are generalized here.
130 /// @subsection CApiLuaNamepacesBecomeModules Lua Modules are Related to Namespaces
131 /// Major namespaces become modules in Lua. You can check on the Lua51ScriptingEngine
132 /// if there is a function for loading a specific namespace. For example if you want
133 /// a script to use classes and functions in the Mezzanine::Threading namespace
134 /// then you will need to load either the safe or the unlimited threading libraries
135 /// in Lua. This can be done either by passing the right flags to the constructor of
136 /// the Lua51ScriptingEngine or by calling Lua51ScriptingEngine::OpenMezzanineThreadingLibrary()
137 /// or Lua51ScriptingEngine::OpenMezzanineThreadingSafeLibrary() . Each Module
138 /// in Lua stores all of its members in a table of the module's name, and a
139 /// reference to the table is stored in the Mezzanine table. This is preferred way
140 /// to call Lua functionality from modules, and calling the table directly may be
141 /// removed in the future. Here is an example of using a class in the Threading
142 /// and another in the root namespace:
143 /// @code
144 /// bar = MezzanineSafe.Threading.Barrier(4)
145 /// vec = MezzanineSafe.Vector3(1,1,1)
146 /// @endcode
147 /// @n @n
148 /// @subsection CApiLuaNamespacesFlattened Other Namespaces Are Flattened
149 /// Namespaces are flattened into the Lua module they are included n:
150 /// C++ code:
151 /// @code
152 /// Mezzanine::Vector3 Vec = Mezzanine::StringTools::ConvertToVector3("3 4 6")
153 /// @endcode
154 /// @n @n
155 /// Lua Code:
156 /// @code
157 /// Vec=MezzanineSafe.ConvertToVector3("3 4 6")
158 /// @endcode
159 /// @n @n
160 /// @subsection CApiLuaEnumsFlattened Enums Are Flattened
161 /// In C++ enumerations might hold values useful in the scope of class. For example
162 /// the Mezzanine::Exception holds ExceptionCodes that are useful categorizing types
163 /// of errors. Because each C++ class is represented in Lua as a function that
164 /// returns a class instance, the syntax "MezzanineSafe.Exception.IO_EXCEPTION" could
165 /// not work. Enums that are part of a class are instead defined in the same table
166 /// as the class function and have the class name concatenated to theirs.
167 /// @n
168 /// This is different than enums
169 /// A few example can explain better:
170 /// C++ code:
171 /// @code
172 /// int x = Mezzanine::Exception::IO_EXCEPTION // An enum value on a class
173 /// int y = Mezzanine::Threading::NotStarted // An enum value in the Threading namespace
174 /// @endcode
175 /// @n @n
176 /// Lua Code:
177 /// @code
178 /// x = MezzanineSafe.Exception_IO_EXCEPTION -- flattened to the MezzanineSafe Table/Module
179 /// y = MezzanineSafe.Threading.NotStarted -- In the Threading table/Module
180 /// @endcode
181 /// @n @n
182 ///
183 ///
184 /// Need to say something about modules in lua
185 /// datatypes, singleton, vector3, quaternion, and the proxies are likely to be duplicate in multiple places
186 ///
187 
188 #include "script.h"
189 #include "scriptargument.h"
190 #include "scriptingmanager.h"
191 #include "scriptworkunit.h"
192 
193 
194 // Each one of these sections should have a complete implementation of a scripting and
195 // appropriate bindings for the mezzanine engine.
196 #ifdef MEZZLUA51
197  #include "Lua51/lua51script.h"
198  #include "Lua51/lua51scriptargument.h"
200  #include "Lua51/lua51workunit.h"
201 #endif
202 
203 
204 #endif // \_scripting_h
This file has the interfaces for Scripts and tag derived classes.
This file has the interfaces for ScriptsWorkUnit.
This file has the declaration for a workunit that can execute lua script every frame.
This file has the interface for the Lua scripts.
This file has the definition of the Script Arguments for Lua 51.
This file has the interfaces for Script Arguments and the associated dependency chain.
The bulk of the engine components go in this namspace.
Definition: actor.cpp:56
This file has the interface for the Lua based implementation of the Scripting system.
This file has the interfaces for Scripting managers and the associated dependency chain...