/src/ogre/OgreMain/include/OgreScriptCompiler.h
Line | Count | Source |
1 | | /* |
2 | | ----------------------------------------------------------------------------- |
3 | | This source file is part of OGRE |
4 | | (Object-oriented Graphics Rendering Engine) |
5 | | For the latest info, see http://www.ogre3d.org/ |
6 | | |
7 | | Copyright (c) 2000-2014 Torus Knot Software Ltd |
8 | | |
9 | | Permission is hereby granted, free of charge, to any person obtaining a copy |
10 | | of this software and associated documentation files (the "Software"), to deal |
11 | | in the Software without restriction, including without limitation the rights |
12 | | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
13 | | copies of the Software, and to permit persons to whom the Software is |
14 | | furnished to do so, subject to the following conditions: |
15 | | |
16 | | The above copyright notice and this permission notice shall be included in |
17 | | all copies or substantial portions of the Software. |
18 | | |
19 | | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
20 | | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
21 | | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
22 | | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
23 | | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
24 | | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
25 | | THE SOFTWARE. |
26 | | ----------------------------------------------------------------------------- |
27 | | */ |
28 | | |
29 | | #ifndef __SCRIPTCOMPILER_H_ |
30 | | #define __SCRIPTCOMPILER_H_ |
31 | | |
32 | | #include "OgreSharedPtr.h" |
33 | | #include "OgreSingleton.h" |
34 | | #include "OgreScriptLoader.h" |
35 | | #include "OgreGpuProgram.h" |
36 | | #include "OgreAny.h" |
37 | | #include "Threading/OgreThreadHeaders.h" |
38 | | #include "OgreHeaderPrefix.h" |
39 | | |
40 | | namespace Ogre |
41 | | { |
42 | | /** \addtogroup Core |
43 | | * @{ |
44 | | */ |
45 | | /** \addtogroup Script |
46 | | * @{ |
47 | | */ |
48 | | /** These enums hold the types of the concrete parsed nodes */ |
49 | | enum ConcreteNodeType |
50 | | { |
51 | | CNT_VARIABLE, |
52 | | CNT_VARIABLE_ASSIGN, |
53 | | CNT_WORD, |
54 | | CNT_IMPORT, |
55 | | CNT_QUOTE, |
56 | | CNT_LBRACE, |
57 | | CNT_RBRACE, |
58 | | CNT_COLON |
59 | | }; |
60 | | |
61 | | /** The ConcreteNode is the struct that holds an un-conditioned sub-tree of parsed input */ |
62 | | struct ConcreteNode; |
63 | | typedef SharedPtr<ConcreteNode> ConcreteNodePtr; |
64 | | typedef std::list<ConcreteNodePtr> ConcreteNodeList; |
65 | | typedef SharedPtr<ConcreteNodeList> ConcreteNodeListPtr; |
66 | | struct ConcreteNode : public ScriptCompilerAlloc |
67 | | { |
68 | | String token, file; |
69 | | unsigned int line; |
70 | | ConcreteNodeType type; |
71 | | ConcreteNodeList children; |
72 | | ConcreteNode *parent; |
73 | | }; |
74 | | |
75 | | /** This enum holds the types of the possible abstract nodes */ |
76 | | enum AbstractNodeType |
77 | | { |
78 | | ANT_UNKNOWN, |
79 | | ANT_ATOM, |
80 | | ANT_OBJECT, |
81 | | ANT_PROPERTY, |
82 | | ANT_IMPORT, |
83 | | ANT_VARIABLE_SET, |
84 | | ANT_VARIABLE_ACCESS |
85 | | }; |
86 | | class AbstractNode; |
87 | | typedef SharedPtr<AbstractNode> AbstractNodePtr; |
88 | | typedef std::list<AbstractNodePtr> AbstractNodeList; |
89 | | typedef SharedPtr<AbstractNodeList> AbstractNodeListPtr; |
90 | | |
91 | | struct _OgreExport ScriptProperty |
92 | | { |
93 | | String name; |
94 | | StringVector values; |
95 | | }; |
96 | | |
97 | | class _OgreExport AbstractNode : public AbstractNodeAlloc |
98 | | { |
99 | | public: |
100 | | String file; |
101 | | unsigned int line; |
102 | | AbstractNodeType type; |
103 | | AbstractNode *parent; |
104 | | Any context; // A holder for translation context data |
105 | | public: |
106 | | AbstractNode(AbstractNode *ptr); |
107 | 0 | virtual ~AbstractNode(){} |
108 | | /// Returns a new AbstractNode which is a replica of this one. |
109 | | virtual AbstractNode *clone() const = 0; |
110 | | /// Returns a string value depending on the type of the AbstractNode. |
111 | | virtual const String& getValue() const = 0; |
112 | | /// Returns the string content of the node for ANT_ATOM. Empty string otherwise. |
113 | | const String& getString() const; |
114 | | /// Returns the property name and values of the node for ANT_PROPERTY. Empty string otherwise. |
115 | | ScriptProperty getProperty() const; |
116 | | }; |
117 | | |
118 | | /** This is an abstract node which cannot be broken down further */ |
119 | | class _OgreExport AtomAbstractNode : public AbstractNode |
120 | | { |
121 | | public: |
122 | | String value; |
123 | | uint32 id; |
124 | | public: |
125 | | AtomAbstractNode(AbstractNode *ptr); |
126 | | AbstractNode *clone() const override; |
127 | 0 | const String& getValue() const override { return value; } |
128 | | }; |
129 | | |
130 | | inline const String& AbstractNode::getString() const |
131 | 0 | { |
132 | 0 | return type == ANT_ATOM ? static_cast<const AtomAbstractNode*>(this)->value : BLANKSTRING; |
133 | 0 | } |
134 | | |
135 | | /** This specific abstract node represents a script object */ |
136 | | class _OgreExport ObjectAbstractNode : public AbstractNode |
137 | | { |
138 | | private: |
139 | | std::map<String,String> mEnv; |
140 | | public: |
141 | | String name, cls; |
142 | | std::vector<String> bases; |
143 | | uint32 id; |
144 | | bool abstract; |
145 | | AbstractNodeList children; |
146 | | AbstractNodeList values; |
147 | | AbstractNodeList overrides; // For use when processing object inheritance and overriding |
148 | | public: |
149 | | ObjectAbstractNode(AbstractNode *ptr); |
150 | | AbstractNode *clone() const override; |
151 | 0 | const String& getValue() const override { return cls; } |
152 | | |
153 | | void addVariable(const String &name); |
154 | | void setVariable(const String &name, const String &value); |
155 | | std::pair<bool,String> getVariable(const String &name) const; |
156 | | const std::map<String,String> &getVariables() const; |
157 | | }; |
158 | | |
159 | | /** This abstract node represents a script property */ |
160 | | class _OgreExport PropertyAbstractNode : public AbstractNode |
161 | | { |
162 | | public: |
163 | | String name; |
164 | | uint32 id; |
165 | | AbstractNodeList values; |
166 | | public: |
167 | | PropertyAbstractNode(AbstractNode *ptr); |
168 | | AbstractNode *clone() const override; |
169 | 0 | const String& getValue() const override { return name; } |
170 | | }; |
171 | | |
172 | | inline ScriptProperty AbstractNode::getProperty() const |
173 | 0 | { |
174 | 0 | if (type != ANT_PROPERTY) |
175 | 0 | return ScriptProperty(); |
176 | 0 |
|
177 | 0 | const PropertyAbstractNode *prop = static_cast<const PropertyAbstractNode*>(this); |
178 | 0 | StringVector values; |
179 | 0 | for (const auto& value : prop->values) |
180 | 0 | values.push_back(value->getString()); |
181 | 0 | return {prop->name, values}; |
182 | 0 | } |
183 | | |
184 | | /** This abstract node represents an import statement */ |
185 | | class _OgreExport ImportAbstractNode : public AbstractNode |
186 | | { |
187 | | public: |
188 | | String target, source; |
189 | | public: |
190 | | ImportAbstractNode(); |
191 | | AbstractNode *clone() const override; |
192 | 0 | const String& getValue() const override { return target; } |
193 | | }; |
194 | | |
195 | | /** This abstract node represents a variable assignment */ |
196 | | class _OgreExport VariableAccessAbstractNode : public AbstractNode |
197 | | { |
198 | | public: |
199 | | String name; |
200 | | public: |
201 | | VariableAccessAbstractNode(AbstractNode *ptr); |
202 | | AbstractNode *clone() const override; |
203 | 0 | const String& getValue() const override { return name; } |
204 | | }; |
205 | | |
206 | | class ScriptCompilerEvent; |
207 | | class ScriptCompilerListener; |
208 | | |
209 | | /** This is the main class for the compiler. It calls the parser |
210 | | and processes the CST into an AST and then uses translators |
211 | | to translate the AST into the final resources. |
212 | | */ |
213 | | class _OgreExport ScriptCompiler : public ScriptCompilerAlloc |
214 | | { |
215 | | public: // Externally accessible types |
216 | | //typedef std::map<String,uint32> IdMap; |
217 | | typedef std::unordered_map<String,uint32> IdMap; |
218 | | |
219 | | // These are the built-in error codes |
220 | | enum{ |
221 | | CE_STRINGEXPECTED, |
222 | | CE_NUMBEREXPECTED, |
223 | | CE_FEWERPARAMETERSEXPECTED, |
224 | | CE_VARIABLEEXPECTED, |
225 | | CE_UNDEFINEDVARIABLE, |
226 | | CE_OBJECTNAMEEXPECTED, |
227 | | CE_OBJECTALLOCATIONERROR, |
228 | | CE_INVALIDPARAMETERS, |
229 | | CE_DUPLICATEOVERRIDE, |
230 | | CE_UNEXPECTEDTOKEN, |
231 | | CE_OBJECTBASENOTFOUND, |
232 | | CE_REFERENCETOANONEXISTINGOBJECT, |
233 | | CE_DEPRECATEDSYMBOL |
234 | | }; |
235 | | static String formatErrorCode(uint32 code); |
236 | | public: |
237 | | ScriptCompiler(); |
238 | 0 | virtual ~ScriptCompiler() {} |
239 | | |
240 | | /// Takes in a string of script code and compiles it into resources |
241 | | /** |
242 | | * @param str The script code |
243 | | * @param source The source of the script code (e.g. a script file) |
244 | | * @param group The resource group to place the compiled resources into |
245 | | */ |
246 | | bool compile(const String &str, const String &source, const String &group); |
247 | | /// Compiles resources from the given concrete node list |
248 | | bool compile(const ConcreteNodeListPtr &nodes, const String &group); |
249 | | /// Adds the given error to the compiler's list of errors |
250 | | void addError(uint32 code, const String &file, int line, const String &msg = ""); |
251 | | /// @overload |
252 | | void addError(const AbstractNode& node, const String &msg = "", uint32 code = CE_INVALIDPARAMETERS); |
253 | | /// Sets the listener used by the compiler |
254 | | void setListener(ScriptCompilerListener *listener); |
255 | | /// Returns the currently set listener |
256 | | ScriptCompilerListener *getListener(); |
257 | | /// Returns the resource group currently set for this compiler |
258 | | const String &getResourceGroup() const; |
259 | | /// Returns the current source file name |
260 | 0 | const String& getFileName() const { return mSourceFile; } |
261 | | /// Internal method for firing the handleEvent method |
262 | | bool _fireEvent(ScriptCompilerEvent *evt, void *retval); |
263 | | |
264 | | /// Adds a custom word id which can be used for custom script translators |
265 | | /** |
266 | | @param |
267 | | word The word to be registered. |
268 | | |
269 | | @return |
270 | | The word id for the registered word. |
271 | | |
272 | | @note |
273 | | If the word is already registered, the already registered id is returned. |
274 | | */ |
275 | | uint32 registerCustomWordId(const String &word); |
276 | | |
277 | | private: // Tree processing |
278 | | AbstractNodeListPtr convertToAST(const ConcreteNodeList &nodes); |
279 | | /// This built-in function processes import nodes |
280 | | void processImports(AbstractNodeList &nodes); |
281 | | /// Loads the requested script and converts it to an AST |
282 | | AbstractNodeListPtr loadImportPath(const String &name); |
283 | | /// Returns the abstract nodes from the given tree which represent the target |
284 | | AbstractNodeList locateTarget(const AbstractNodeList& nodes, const String &target); |
285 | | /// Handles object inheritance and variable expansion |
286 | | void processObjects(AbstractNodeList& nodes, const AbstractNodeList &top); |
287 | | /// Handles processing the variables |
288 | | void processVariables(AbstractNodeList& nodes); |
289 | | /// This function overlays the given object on the destination object following inheritance rules |
290 | | void overlayObject(const ObjectAbstractNode &source, ObjectAbstractNode& dest); |
291 | | /// Returns true if the given class is name excluded |
292 | | bool isNameExcluded(const ObjectAbstractNode& node, AbstractNode *parent); |
293 | | /// This function sets up the initial values in word id map |
294 | | void initWordMap(); |
295 | | private: |
296 | | friend String getPropertyName(const ScriptCompiler *compiler, uint32 id); |
297 | | String mSourceFile; |
298 | | // Resource group |
299 | | String mGroup; |
300 | | // The word -> id conversion table |
301 | | IdMap mIds; |
302 | | |
303 | | // The largest registered id |
304 | | uint32 mLargestRegisteredWordId; |
305 | | |
306 | | // This is an environment map |
307 | | typedef std::map<String,String> Environment; |
308 | | Environment mEnv; |
309 | | |
310 | | typedef std::map<String,AbstractNodeListPtr> ImportCacheMap; |
311 | | ImportCacheMap mImports; // The set of imported scripts to avoid circular dependencies |
312 | | typedef std::multimap<String,String> ImportRequestMap; |
313 | | ImportRequestMap mImportRequests; // This holds the target objects for each script to be imported |
314 | | |
315 | | // This stores the imports of the scripts, so they are separated and can be treated specially |
316 | | AbstractNodeList mImportTable; |
317 | | |
318 | | // Error list |
319 | | // The container for errors |
320 | | struct Error |
321 | | { |
322 | | String file, message; |
323 | | int line; |
324 | | uint32 code; |
325 | | }; |
326 | | typedef std::list<Error> ErrorList; |
327 | | ErrorList mErrors; |
328 | | |
329 | | // The listener |
330 | | ScriptCompilerListener *mListener; |
331 | | private: // Internal helper classes and processors |
332 | | class AbstractTreeBuilder |
333 | | { |
334 | | private: |
335 | | AbstractNodeListPtr mNodes; |
336 | | AbstractNode *mCurrent; |
337 | | ScriptCompiler *mCompiler; |
338 | | public: |
339 | | AbstractTreeBuilder(ScriptCompiler *compiler); |
340 | | const AbstractNodeListPtr &getResult() const; |
341 | | void visit(ConcreteNode *node); |
342 | | static void visit(AbstractTreeBuilder *visitor, const ConcreteNodeList &nodes); |
343 | | }; |
344 | | friend class AbstractTreeBuilder; |
345 | | public: // Public translator definitions |
346 | | // This enum are built-in word id values |
347 | | enum |
348 | | { |
349 | | ID_ON = 1, |
350 | | ID_OFF = 2, |
351 | | ID_TRUE = 1, |
352 | | ID_FALSE = 2, |
353 | | ID_YES = 1, |
354 | | ID_NO = 2 |
355 | | }; |
356 | | }; |
357 | | |
358 | | /** |
359 | | * This struct is a base class for events which can be thrown by the compilers and caught by |
360 | | * subscribers. There are a set number of standard events which are used by Ogre's core. |
361 | | * New event types may be derived for more custom compiler processing. |
362 | | */ |
363 | | class ScriptCompilerEvent |
364 | | { |
365 | | public: |
366 | | String mType; |
367 | | |
368 | 0 | ScriptCompilerEvent(const String &type):mType(type){} |
369 | 0 | virtual ~ScriptCompilerEvent(){} |
370 | | private: // Non-copyable |
371 | | ScriptCompilerEvent(const ScriptCompilerEvent&); |
372 | | ScriptCompilerEvent &operator = (const ScriptCompilerEvent&); |
373 | | }; |
374 | | |
375 | | /** This is a listener for the compiler. The compiler can be customized with |
376 | | this listener. It lets you listen in on events occurring during compilation, |
377 | | hook them, and change the behavior. |
378 | | */ |
379 | | class _OgreExport ScriptCompilerListener |
380 | | { |
381 | | public: |
382 | | ScriptCompilerListener(); |
383 | 0 | virtual ~ScriptCompilerListener() {} |
384 | | |
385 | | /// Returns the concrete node list from the given file |
386 | | virtual ConcreteNodeListPtr importFile(ScriptCompiler *compiler, const String &name); |
387 | | /// Allows for responding to and overriding behavior before a CST is translated into an AST |
388 | | virtual void preConversion(ScriptCompiler *compiler, ConcreteNodeListPtr nodes); |
389 | | /// Allows vetoing of continued compilation after the entire AST conversion process finishes |
390 | | /** |
391 | | @remarks Once the script is turned completely into an AST, including import |
392 | | and override handling, this function allows a listener to exit |
393 | | the compilation process. |
394 | | @return True continues compilation, false aborts |
395 | | */ |
396 | | virtual bool postConversion(ScriptCompiler *compiler, const AbstractNodeListPtr&); |
397 | | /// Called when an error occurred |
398 | | virtual void handleError(ScriptCompiler *compiler, uint32 code, const String &file, int line, const String &msg); |
399 | | /// Called when an event occurs during translation, return true if handled |
400 | | /** |
401 | | @remarks This function is called from the translators when an event occurs that |
402 | | that can be responded to. Often this is overriding names, or it can be a request for |
403 | | custom resource creation. |
404 | | @arg compiler A reference to the compiler |
405 | | @arg evt The event object holding information about the event to be processed |
406 | | @arg retval A possible return value from handlers |
407 | | @return True if the handler processed the event |
408 | | */ |
409 | | virtual bool handleEvent(ScriptCompiler *compiler, ScriptCompilerEvent *evt, void *retval); |
410 | | }; |
411 | | |
412 | | class ScriptTranslator; |
413 | | class ScriptTranslatorManager; |
414 | | |
415 | | /** Manages threaded compilation of scripts. This script loader forwards |
416 | | scripts compilations to a specific compiler instance. |
417 | | */ |
418 | | class _OgreExport ScriptCompilerManager : public Singleton<ScriptCompilerManager>, public ScriptLoader, public ScriptCompilerAlloc |
419 | | { |
420 | | private: |
421 | | OGRE_AUTO_MUTEX; |
422 | | |
423 | | // A list of patterns loaded by this compiler manager |
424 | | StringVector mScriptPatterns; |
425 | | |
426 | | // Stores a map from object types to the translators that handle them |
427 | | std::vector<ScriptTranslatorManager*> mManagers; |
428 | | |
429 | | // A pointer to the built-in ScriptTranslatorManager |
430 | | ScriptTranslatorManager *mBuiltinTranslatorManager; |
431 | | |
432 | | // the specific compiler instance used |
433 | | ScriptCompiler mScriptCompiler; |
434 | | public: |
435 | | ScriptCompilerManager(); |
436 | | virtual ~ScriptCompilerManager(); |
437 | | |
438 | | /// Sets the listener used for compiler instances |
439 | | void setListener(ScriptCompilerListener *listener); |
440 | | /// Returns the currently set listener used for compiler instances |
441 | | ScriptCompilerListener *getListener(); |
442 | | |
443 | | /// Adds the given translator manager to the list of managers |
444 | | void addTranslatorManager(ScriptTranslatorManager *man); |
445 | | /// Removes the given translator manager from the list of managers |
446 | | void removeTranslatorManager(ScriptTranslatorManager *man); |
447 | | /// Clears all translator managers |
448 | | void clearTranslatorManagers(); |
449 | | /// Retrieves a ScriptTranslator from the supported managers |
450 | | ScriptTranslator *getTranslator(const AbstractNodePtr &node); |
451 | | |
452 | | /// Adds a custom word id which can be used for custom script translators |
453 | | /** |
454 | | @param |
455 | | word The word to be registered. |
456 | | |
457 | | @return |
458 | | The word id for the registered word. |
459 | | |
460 | | @note |
461 | | If the word is already registered, the already registered id is returned. |
462 | | */ |
463 | | uint32 registerCustomWordId(const String &word); |
464 | | |
465 | | /// Adds a script extension that can be handled (e.g. *.material, *.pu, etc.) |
466 | | void addScriptPattern(const String &pattern); |
467 | | /// @copydoc ScriptLoader::getScriptPatterns |
468 | | const StringVector& getScriptPatterns(void) const override; |
469 | | /// @copydoc ScriptLoader::parseScript |
470 | | void parseScript(DataStreamPtr& stream, const String& groupName) override; |
471 | | /// @copydoc ScriptLoader::getLoadingOrder |
472 | | Real getLoadingOrder(void) const override; |
473 | | |
474 | | /// @copydoc Singleton::getSingleton() |
475 | | static ScriptCompilerManager& getSingleton(void); |
476 | | /// @copydoc Singleton::getSingleton() |
477 | | static ScriptCompilerManager* getSingletonPtr(void); |
478 | | }; |
479 | | |
480 | | class _OgreExport ProcessResourceNameScriptCompilerEvent : public ScriptCompilerEvent |
481 | | { |
482 | | public: |
483 | | enum ResourceType |
484 | | { |
485 | | TEXTURE, |
486 | | MATERIAL, |
487 | | GPU_PROGRAM, |
488 | | COMPOSITOR |
489 | | }; |
490 | | ResourceType mResourceType; |
491 | | String mName; |
492 | | static String eventType; |
493 | | |
494 | | ProcessResourceNameScriptCompilerEvent(ResourceType resourceType, const String &name) |
495 | 0 | :ScriptCompilerEvent(eventType), mResourceType(resourceType), mName(name){} |
496 | | }; |
497 | | |
498 | | class _OgreExport ProcessNameExclusionScriptCompilerEvent : public ScriptCompilerEvent |
499 | | { |
500 | | public: |
501 | | String mClass; |
502 | | AbstractNode *mParent; |
503 | | static String eventType; |
504 | | |
505 | | ProcessNameExclusionScriptCompilerEvent(const String &cls, AbstractNode *parent) |
506 | 0 | :ScriptCompilerEvent(eventType), mClass(cls), mParent(parent){} |
507 | | }; |
508 | | |
509 | | class _OgreExport CreateMaterialScriptCompilerEvent : public ScriptCompilerEvent |
510 | | { |
511 | | public: |
512 | | String mFile, mName, mResourceGroup; |
513 | | static String eventType; |
514 | | |
515 | | CreateMaterialScriptCompilerEvent(const String &file, const String &name, const String &resourceGroup) |
516 | 0 | :ScriptCompilerEvent(eventType), mFile(file), mName(name), mResourceGroup(resourceGroup){} |
517 | | }; |
518 | | |
519 | | class _OgreExport CreateGpuProgramScriptCompilerEvent : public ScriptCompilerEvent |
520 | | { |
521 | | public: |
522 | | String mFile, mName, mResourceGroup, mSource, mSyntax; |
523 | | GpuProgramType mProgramType; |
524 | | static String eventType; |
525 | | |
526 | | CreateGpuProgramScriptCompilerEvent(const String &file, const String &name, const String &resourceGroup, const String &source, |
527 | | const String &syntax, GpuProgramType programType) |
528 | | :ScriptCompilerEvent(eventType), mFile(file), mName(name), mResourceGroup(resourceGroup), mSource(source), |
529 | | mSyntax(syntax), mProgramType(programType) |
530 | 0 | {} |
531 | | }; |
532 | | |
533 | | /// @deprecated use CreateGpuProgramScriptCompilerEvent |
534 | | typedef OGRE_DEPRECATED CreateGpuProgramScriptCompilerEvent CreateHighLevelGpuProgramScriptCompilerEvent; |
535 | | |
536 | | class _OgreExport CreateGpuSharedParametersScriptCompilerEvent : public ScriptCompilerEvent |
537 | | { |
538 | | public: |
539 | | String mFile, mName, mResourceGroup; |
540 | | static String eventType; |
541 | | |
542 | | CreateGpuSharedParametersScriptCompilerEvent(const String &file, const String &name, const String &resourceGroup) |
543 | 0 | :ScriptCompilerEvent(eventType), mFile(file), mName(name), mResourceGroup(resourceGroup){} |
544 | | }; |
545 | | |
546 | | class _OgreExport CreateParticleSystemScriptCompilerEvent : public ScriptCompilerEvent |
547 | | { |
548 | | public: |
549 | | String mFile, mName, mResourceGroup; |
550 | | static String eventType; |
551 | | |
552 | | CreateParticleSystemScriptCompilerEvent(const String &file, const String &name, const String &resourceGroup) |
553 | 0 | :ScriptCompilerEvent(eventType), mFile(file), mName(name), mResourceGroup(resourceGroup){} |
554 | | }; |
555 | | |
556 | | class _OgreExport CreateCompositorScriptCompilerEvent : public ScriptCompilerEvent |
557 | | { |
558 | | public: |
559 | | String mFile, mName, mResourceGroup; |
560 | | static String eventType; |
561 | | |
562 | | CreateCompositorScriptCompilerEvent(const String &file, const String &name, const String &resourceGroup) |
563 | 0 | :ScriptCompilerEvent(eventType), mFile(file), mName(name), mResourceGroup(resourceGroup){} |
564 | | }; |
565 | | |
566 | | /// This enum defines the integer ids for keywords this compiler handles |
567 | | enum |
568 | | { |
569 | | ID_MATERIAL = 3, |
570 | | ID_VERTEX_PROGRAM, |
571 | | ID_GEOMETRY_PROGRAM, |
572 | | ID_FRAGMENT_PROGRAM, |
573 | | ID_TECHNIQUE, |
574 | | ID_PASS, |
575 | | ID_TEXTURE_UNIT, |
576 | | ID_VERTEX_PROGRAM_REF, |
577 | | ID_GEOMETRY_PROGRAM_REF, |
578 | | ID_FRAGMENT_PROGRAM_REF, |
579 | | ID_SHADOW_CASTER_VERTEX_PROGRAM_REF, |
580 | | ID_SHADOW_CASTER_FRAGMENT_PROGRAM_REF, |
581 | | ID_SHADOW_RECEIVER_VERTEX_PROGRAM_REF, |
582 | | ID_SHADOW_RECEIVER_FRAGMENT_PROGRAM_REF, |
583 | | ID_SHADOW_CASTER_MATERIAL, |
584 | | ID_SHADOW_RECEIVER_MATERIAL, |
585 | | |
586 | | ID_LOD_VALUES, |
587 | | ID_LOD_STRATEGY, |
588 | | ID_LOD_DISTANCES, |
589 | | ID_RECEIVE_SHADOWS, |
590 | | ID_TRANSPARENCY_CASTS_SHADOWS, |
591 | | ID_SET_TEXTURE_ALIAS, |
592 | | |
593 | | ID_SOURCE, |
594 | | ID_SYNTAX, |
595 | | ID_DEFAULT_PARAMS, |
596 | | ID_PARAM_INDEXED, |
597 | | ID_PARAM_NAMED, |
598 | | ID_PARAM_INDEXED_AUTO, |
599 | | ID_PARAM_NAMED_AUTO, |
600 | | |
601 | | ID_SCHEME, |
602 | | ID_LOD_INDEX, |
603 | | ID_GPU_VENDOR_RULE, |
604 | | ID_GPU_DEVICE_RULE, |
605 | | ID_INCLUDE, |
606 | | ID_EXCLUDE, |
607 | | |
608 | | ID_AMBIENT, |
609 | | ID_DIFFUSE, |
610 | | ID_SPECULAR, |
611 | | ID_EMISSIVE, |
612 | | ID_VERTEXCOLOUR, |
613 | | ID_SCENE_BLEND, |
614 | | ID_COLOUR_BLEND, |
615 | | ID_ONE, |
616 | | ID_ZERO, |
617 | | ID_DEST_COLOUR, |
618 | | ID_SRC_COLOUR, |
619 | | ID_ONE_MINUS_DEST_COLOUR, |
620 | | ID_ONE_MINUS_SRC_COLOUR, |
621 | | ID_DEST_ALPHA, |
622 | | ID_SRC_ALPHA, |
623 | | ID_ONE_MINUS_DEST_ALPHA, |
624 | | ID_ONE_MINUS_SRC_ALPHA, |
625 | | ID_SEPARATE_SCENE_BLEND, |
626 | | ID_SCENE_BLEND_OP, |
627 | | ID_REVERSE_SUBTRACT, |
628 | | ID_MIN, |
629 | | ID_MAX, |
630 | | ID_SEPARATE_SCENE_BLEND_OP, |
631 | | ID_DEPTH_CHECK, |
632 | | ID_DEPTH_WRITE, |
633 | | ID_DEPTH_FUNC, |
634 | | ID_DEPTH_BIAS, |
635 | | ID_ITERATION_DEPTH_BIAS, |
636 | | ID_ALWAYS_FAIL, |
637 | | ID_ALWAYS_PASS, |
638 | | ID_LESS_EQUAL, |
639 | | ID_LESS, |
640 | | ID_EQUAL, |
641 | | ID_NOT_EQUAL, |
642 | | ID_GREATER_EQUAL, |
643 | | ID_GREATER, |
644 | | ID_ALPHA_REJECTION, |
645 | | ID_ALPHA_TO_COVERAGE, |
646 | | ID_LIGHT_SCISSOR, |
647 | | ID_LIGHT_CLIP_PLANES, |
648 | | ID_TRANSPARENT_SORTING, |
649 | | ID_ILLUMINATION_STAGE, |
650 | | ID_DECAL, |
651 | | ID_CULL_HARDWARE, |
652 | | ID_CLOCKWISE, |
653 | | ID_ANTICLOCKWISE, |
654 | | ID_CULL_SOFTWARE, |
655 | | ID_BACK, |
656 | | ID_FRONT, |
657 | | ID_LIGHTING, |
658 | | ID_SHADING, |
659 | | ID_FLAT, |
660 | | ID_GOURAUD, |
661 | | ID_PHONG, |
662 | | ID_POLYGON_MODE, |
663 | | ID_SOLID, |
664 | | ID_WIREFRAME, |
665 | | ID_POINTS, |
666 | | ID_POLYGON_MODE_OVERRIDEABLE, |
667 | | ID_FOG_OVERRIDE, |
668 | | ID_NONE, |
669 | | ID_LINEAR, |
670 | | ID_EXP, |
671 | | ID_EXP2, |
672 | | ID_COLOUR_WRITE, |
673 | | ID_MAX_LIGHTS, |
674 | | ID_START_LIGHT, |
675 | | ID_ITERATION, |
676 | | ID_ONCE, |
677 | | ID_ONCE_PER_LIGHT, |
678 | | ID_PER_LIGHT, |
679 | | ID_PER_N_LIGHTS, |
680 | | ID_POINT, |
681 | | ID_SPOT, |
682 | | ID_DIRECTIONAL, |
683 | | ID_LIGHT_MASK, |
684 | | ID_POINT_SIZE, |
685 | | ID_POINT_SPRITES, |
686 | | ID_POINT_SIZE_ATTENUATION, |
687 | | ID_POINT_SIZE_MIN, |
688 | | ID_POINT_SIZE_MAX, |
689 | | |
690 | | ID_TEXTURE_ALIAS, |
691 | | ID_TEXTURE, |
692 | | ID_1D, |
693 | | ID_2D, |
694 | | ID_3D, |
695 | | ID_CUBIC, |
696 | | ID_2DARRAY, |
697 | | ID_2DMS, |
698 | | ID_UNLIMITED, |
699 | | ID_ALPHA, |
700 | | ID_GAMMA, |
701 | | ID_ANIM_TEXTURE, |
702 | | ID_CUBIC_TEXTURE, |
703 | | ID_SEPARATE_UV, |
704 | | ID_COMBINED_UVW, |
705 | | ID_TEX_COORD_SET, |
706 | | ID_TEX_ADDRESS_MODE, |
707 | | ID_WRAP, |
708 | | ID_CLAMP, |
709 | | ID_BORDER, |
710 | | ID_MIRROR, |
711 | | ID_TEX_BORDER_COLOUR, |
712 | | ID_FILTERING, |
713 | | ID_BILINEAR, |
714 | | ID_TRILINEAR, |
715 | | ID_ANISOTROPIC, |
716 | | ID_CMPTEST, |
717 | | ID_ON, |
718 | | ID_OFF, |
719 | | ID_CMPFUNC, |
720 | | ID_MAX_ANISOTROPY, |
721 | | ID_MIPMAP_BIAS, |
722 | | ID_COLOUR_OP, |
723 | | ID_REPLACE, |
724 | | ID_ADD, |
725 | | ID_MODULATE, |
726 | | ID_ALPHA_BLEND, |
727 | | ID_COLOUR_OP_EX, |
728 | | ID_SOURCE1, |
729 | | ID_SOURCE2, |
730 | | ID_MODULATE_X2, |
731 | | ID_MODULATE_X4, |
732 | | ID_ADD_SIGNED, |
733 | | ID_ADD_SMOOTH, |
734 | | ID_SUBTRACT, |
735 | | ID_BLEND_DIFFUSE_COLOUR, |
736 | | ID_BLEND_DIFFUSE_ALPHA, |
737 | | ID_BLEND_TEXTURE_ALPHA, |
738 | | ID_BLEND_CURRENT_ALPHA, |
739 | | ID_BLEND_MANUAL, |
740 | | ID_DOT_PRODUCT, |
741 | | ID_SRC_CURRENT, |
742 | | ID_SRC_TEXTURE, |
743 | | ID_SRC_DIFFUSE, |
744 | | ID_SRC_SPECULAR, |
745 | | ID_SRC_MANUAL, |
746 | | ID_COLOUR_OP_MULTIPASS_FALLBACK, |
747 | | ID_ALPHA_OP_EX, |
748 | | ID_ENV_MAP, |
749 | | ID_SPHERICAL, |
750 | | ID_PLANAR, |
751 | | ID_CUBIC_REFLECTION, |
752 | | ID_CUBIC_NORMAL, |
753 | | ID_SCROLL, |
754 | | ID_SCROLL_ANIM, |
755 | | ID_ROTATE, |
756 | | ID_ROTATE_ANIM, |
757 | | ID_SCALE, |
758 | | ID_WAVE_XFORM, |
759 | | ID_SCROLL_X, |
760 | | ID_SCROLL_Y, |
761 | | ID_SCALE_X, |
762 | | ID_SCALE_Y, |
763 | | ID_SINE, |
764 | | ID_TRIANGLE, |
765 | | ID_SQUARE, |
766 | | ID_SAWTOOTH, |
767 | | ID_INVERSE_SAWTOOTH, |
768 | | ID_TRANSFORM, |
769 | | ID_CONTENT_TYPE, |
770 | | ID_NAMED, |
771 | | ID_SHADOW, |
772 | | ID_TEXTURE_SOURCE, |
773 | | ID_SHARED_PARAMS, |
774 | | ID_SHARED_PARAM_NAMED, |
775 | | ID_SHARED_PARAMS_REF, |
776 | | |
777 | | ID_PARTICLE_SYSTEM, |
778 | | ID_EMITTER, |
779 | | ID_AFFECTOR, |
780 | | |
781 | | ID_COMPOSITOR, |
782 | | ID_TARGET, |
783 | | ID_TARGET_OUTPUT, |
784 | | |
785 | | ID_INPUT, |
786 | | ID_PREVIOUS, |
787 | | ID_TARGET_WIDTH, |
788 | | ID_TARGET_HEIGHT, |
789 | | ID_TARGET_WIDTH_SCALED, |
790 | | ID_TARGET_HEIGHT_SCALED, |
791 | | ID_COMPOSITOR_LOGIC, |
792 | | ID_TEXTURE_REF, |
793 | | ID_SCOPE_LOCAL, |
794 | | ID_SCOPE_CHAIN, |
795 | | ID_SCOPE_GLOBAL, |
796 | | ID_POOLED, |
797 | | //ID_GAMMA, - already registered for material |
798 | | ID_NO_FSAA, |
799 | | ID_DEPTH_POOL, |
800 | | ID_ONLY_INITIAL, |
801 | | ID_VISIBILITY_MASK, |
802 | | ID_LOD_BIAS, |
803 | | ID_MATERIAL_SCHEME, |
804 | | ID_SHADOWS_ENABLED, |
805 | | |
806 | | ID_CLEAR, |
807 | | ID_STENCIL, |
808 | | ID_RENDER_SCENE, |
809 | | ID_RENDER_QUAD, |
810 | | ID_IDENTIFIER, |
811 | | ID_FIRST_RENDER_QUEUE, |
812 | | ID_LAST_RENDER_QUEUE, |
813 | | ID_QUAD_NORMALS, |
814 | | ID_CAMERA_FAR_CORNERS_VIEW_SPACE, |
815 | | ID_CAMERA_FAR_CORNERS_WORLD_SPACE, |
816 | | |
817 | | ID_BUFFERS, |
818 | | ID_COLOUR, |
819 | | ID_DEPTH, |
820 | | ID_COLOUR_VALUE, |
821 | | ID_DEPTH_VALUE, |
822 | | ID_STENCIL_VALUE, |
823 | | |
824 | | ID_CHECK, |
825 | | ID_COMP_FUNC, |
826 | | ID_REF_VALUE, |
827 | | ID_MASK, |
828 | | ID_FAIL_OP, |
829 | | ID_KEEP, |
830 | | ID_INCREMENT, |
831 | | ID_DECREMENT, |
832 | | ID_INCREMENT_WRAP, |
833 | | ID_DECREMENT_WRAP, |
834 | | ID_INVERT, |
835 | | ID_DEPTH_FAIL_OP, |
836 | | ID_PASS_OP, |
837 | | ID_TWO_SIDED, |
838 | | // Support for shader model 5.0 |
839 | | // More program IDs |
840 | | ID_TESSELLATION_HULL_PROGRAM, |
841 | | ID_TESSELLATION_DOMAIN_PROGRAM, |
842 | | ID_COMPUTE_PROGRAM, |
843 | | ID_TESSELLATION_HULL_PROGRAM_REF, |
844 | | ID_TESSELLATION_DOMAIN_PROGRAM_REF, |
845 | | ID_COMPUTE_PROGRAM_REF, |
846 | | // More binding IDs |
847 | | ID_GEOMETRY, |
848 | | ID_TESSELLATION_HULL, |
849 | | ID_TESSELLATION_DOMAIN, |
850 | | ID_COMPUTE, |
851 | | |
852 | | // added during 1.11. re-sort for 1.12 |
853 | | ID_LINE_WIDTH, |
854 | | ID_SAMPLER, |
855 | | ID_SAMPLER_REF, |
856 | | ID_THREAD_GROUPS, |
857 | | ID_RENDER_CUSTOM, |
858 | | ID_AUTO, |
859 | | ID_CAMERA, |
860 | | ID_ALIGN_TO_FACE, |
861 | | ID_UNORDERED_ACCESS_MIP, |
862 | | ID_MESH_PROGRAM, |
863 | | ID_MESH_PROGRAM_REF, |
864 | | ID_TASK_PROGRAM, |
865 | | ID_TASK_PROGRAM_REF, |
866 | | ID_FSAA, |
867 | | ID_USE_LINEAR_COLOURS, |
868 | | ID_END_BUILTIN_IDS |
869 | | }; |
870 | | /** @} */ |
871 | | /** @} */ |
872 | | } |
873 | | |
874 | | #include "OgreHeaderSuffix.h" |
875 | | |
876 | | #endif |