Commit Graph

76 Commits (f5988085a75ccf7ea5503db64262372a04aabd3a)

Author SHA1 Message Date
Nicolas Hake f5988085a7 Figure out whether a warning/error was #include'd or #appendto'd
We already notified the user on warning/error that the mistake
happened in a different script than the one we were currently
compiing. It's not too difficult to figure out whether that other
script was added due to an #include or an #appendto directive, so we
can just show the user which one it is.

We also don't show warnings in #include'd scripts anymore, since
they get compiled individually anyway and all warnings will show up
there. This way we don't duplicate warnings several times.
2018-07-24 14:35:12 +02:00
Tushar Maheshwari 3a4f49ad90 Revisit #includes
Consolidate the include statements scattered across the code in accordance
with the comment in C4Include.h. The advantages are listed in the same
comment.
Furthermore, it follows llvm-include-order which is the logical
extrapolation of the project's style guideline wherever possible
(C4Include.h being the most-frequent exception).
2017-05-15 13:24:59 +02:00
Tushar Maheshwari e58a7884e4 Automatic fixes using clang-tidy
See http://forum.openclonk.org/topic_show.pl?tid=3376 for discussion.

Close GH-41
2017-05-03 20:30:45 +02:00
Sven Eberhardt 83af5ad794 Fix a script reload bug
Thawing needs to catch some of the deeper nested proplists because they are modified in the EditorProp initialization Definition()-callbacks.
2017-03-26 13:31:55 -04:00
Sven Eberhardt ebda8193ef Replace NULL by nullptr in C++ sources
We don't support pre-C++0x any more, so nullptr should be fine everywhere (except in the plain C source files)
2016-11-02 19:58:02 -04:00
Nicolas Hake e2fd7095c1 Merge branch 'ast'
# Conflicts:
#	src/C4Include.h
#	src/script/C4AulCompiler.cpp
#	src/script/C4AulParse.cpp
#	src/script/C4AulParse.h
#	src/script/C4ScriptHost.cpp
#	src/script/C4ScriptHost.h
#	tests/CMakeLists.txt
2016-10-20 17:33:02 +02:00
Nicolas Hake 9caaf1e298 Aul: Split out error handling into a separate class for easier testing
By using an extern error handler in the script engine, we can mock that
handler and make sure something that should fail actually does, instead
of having to parse log messages.
2016-10-19 14:20:41 +02:00
Armin Burgmeier 836927d93c Don't leak static proplists with cyclic references
If a local variable in a definition was set to a proplist inside the
Definition() callback, and that proplist contained cyclic references
then those references were leaked. Typically cyclic references for
script-created proplists are broken in
C4PropListScript::ClearScriptPropLists, however definition proplists
are changed to be static proplists in
C4PropList::FreezeAndMakeStaticRecursively.

To fix this, each script host maintains a list of proplists made static
by FreezeAndMakeStaticRecursively, and explicitly deletes all of these
proplists on Clear().

This leak also leads to an assertion failure inside
C4PropListScript::ClearScriptPropLists in debug mode, and can also be
observed by C4PropList::PropLists not being empty after game clear.

The definition in Objects.ocd/Helpers.ocd/UserAction.ocd constructs
cyclic proplists in its Definition() call. A simpler, more minimal way
to provoke the leak is the following (it provokes the leak but not the
assertion failure):

    local bla;

    func Definition(def)
    {
        bla = {};
        bla.test = { Name="Test222" , Options = { Name="Test333" } };
        bla.test.Options.Link = { Name="Test444", Blub=bla.test };
    }
2016-09-30 17:50:41 -10:00
Sven Eberhardt e4b4246500 Fix freezing and assignment of static names to child proplists created in Definition()-callbacks (#1798)
Also adjust editor props for the change:
1. enum needs to create a copy, not a reference for the default value of an option if it is defined inline
2. Always use proper GetName() resolution on property group names even if a static name would be available
2016-08-27 02:04:03 -04:00
Sven Eberhardt 534e4cc745 Merge branch 'master' into qteditor
Conflicts:
	src/script/C4AulParse.cpp
2016-07-24 10:23:57 -04:00
Lukas Werling 2127e78db1 Fix c4script build 2016-07-07 22:50:13 +02:00
Lukas Werling 791315a54e Fix #include-in-#appendto, but discourage with a warning 2016-07-07 21:13:18 +02:00
Sven Eberhardt a7aa89f168 Merge branch 'master' into qteditor
Conflicts:
	planet/Objects.ocd/Structures.ocd/StoneDoor.ocd/SpinWheel.ocd/Script.c
	src/platform/C4WindowSDL.cpp
	src/script/C4AulParse.cpp
	src/script/C4Effect.cpp
2016-06-20 22:27:03 -04:00
Sven Eberhardt 397dbd867a Add DefinitionPriority property to control call order of Definition()-callbacks. 2016-06-07 18:22:43 -04:00
Günther Brammer b00b8554ab Merge branch script 2016-04-28 03:25:44 +02:00
Günther Brammer efd4724084 Script: Add Scenario effects
These work just like global effects, except that effects from CreateEffect
get the scenario as target parameter in the callbacks.
2016-04-28 02:53:21 +02:00
Günther Brammer e8811a7b21 Move global effects from ::Game to ::ScriptEngine
This even enables some simplification in the CompileFuncs, since the global
effects were already put in the same section as the other ScriptEngine
parts. The callback for updates due to relinks also fits nicely.

The reset in C4Game::Default was redundant with C4Game::Clear already.
2016-04-24 19:40:28 +02:00
Nicolas Hake eabca223f5 Update all copyright notices for 2016 2016-04-03 20:24:42 +02:00
Nicolas Hake 493c276126 Rewrite header inclusions to #include "path/to/file.h" style 2016-04-03 20:24:42 +02:00
Günther Brammer 6f98fb2e66 Remove C4AulScript class
It isn't needed to hold engine functions anymore, because those are just
put into C4PropLists.
2016-02-02 02:57:47 +01:00
Günther Brammer b21acff0c7 Move Scriptparser State into C4ScriptHost 2016-02-02 02:57:46 +01:00
Günther Brammer 9dadfba5af Move GlobalNamed.SetNameList call after Link() into Link()
It isn't clear whether that call is necessary since the C4AulScriptEngine
constructor already does this, but it is clear that duplicating the call
all over is a bad idea.
2016-01-25 00:00:58 +01:00
Günther Brammer 5a570b96f1 Remove now unnecessary stubs from C4ScriptStandaloneStubs 2016-01-24 02:09:14 +01:00
Günther Brammer e1a38ee010 Move references to ::Objects and ::MaterialMap from C4AulLink to C4Game
This changes the order in which the various parts of the engine are updated
after a definition reload, but they should not interfere with each other.
2016-01-24 02:09:14 +01:00
Nicolas Hake 617a0828fb Aul: Throw exceptions by value, not by pointer
Throwing values instead of pointers simplifies memory management at the
catch site.
2015-12-08 13:17:40 +01:00
Nicolas Hake 96fcf1389a Aul: Make engine not automatically log error summary
Getting the error summary written to the log/console automatically may
be useful for general game usage, but when testing Aul we just end up
with thousands of useless messages in the output. Let the caller log the
message if it's really desired.
2015-12-08 13:17:39 +01:00
Nicolas Hake 5562b09dc4 Remove a lot of disabled legacy code, round 2
Maybe at some point we'll be rid of all the commented-out code that
nobody has looked at in years.
2015-03-25 20:02:53 +01:00
Günther Brammer b7a022852e Revert "Move C4Aul code into separate subdirectory"
The distinction between the "aul" and "non-aul" parts of
the script engine are mostly historical accident, and the
current organization of the source code does not use
sub-subdirectories. I'd like to keep it that way.

This reverts commit 69ba06b8d0.
2014-05-12 02:24:19 +02:00
Nicolas Hake 69ba06b8d0 Move C4Aul code into separate subdirectory 2014-05-11 16:17:48 +02:00
Günther Brammer 22016e075f Replace some usages of C4ID with C4Def*
In particular those that made the c4script shell depend on C4Id.cpp.
2014-04-19 19:02:22 +02:00
Nicolas Hake e0dc30c59a Update copyright notices
As discussed in http://forum.openclonk.org/topic_show.pl?tid=2917, I
have merged all copyright notices into a single file and referenced that
merged file from each source file.

For the updated source files, the timeline has been split into three
parts:
 1. Pre-RWD code (before 2001)
 2. RWD code (2001 through 2009)
 3. OpenClonk code (2009 and later)
All pre-RWD copyright notices have been left intact, as have RWD-era
copyright notices where the file did not have a RedWolf design copyright
notice but only individual author ones. All copyright notices of the
OpenClonk era have been replaced by a single notice ranging from the
first recorded year to the current year (2013). Mape code did not get a
OpenClonk Team copyright notice because it is somewhat separate from the
main OpenClonk codebase and has only been touched by Armin Burgmeier.
2013-12-23 13:03:19 +01:00
Günther Brammer 42608c5209 Remove C4DirectExecScript, use an existing scripthost for the eval function
Since the scripthost isn't used to store the bytecode anymore,
Parse_Expression doesn't modify it anymore. So there is no need for a
temporary one.
2013-01-23 21:36:21 +01:00
Günther Brammer 864c5c7ea8 copyright notices update 2012 2013-01-12 16:31:40 +01:00
Günther Brammer a528b0d76e Silence some g++ warnings 2012-06-15 18:16:49 +02:00
Günther Brammer bd371e38c1 Make the child pointers of the scriptengine C4AulScript*s again
The rope will create a C4AulScript for the rope engine functions instead of
putting them into the global scope, and we might want to put C4Object-only
functions into a separate C4AulScript some day, too.
2012-06-07 21:07:31 +02:00
Günther Brammer c6fe23729b Replace function list from C4AulScript with proplist enumeration
This finally makes the function list in C4AulScript unnecessary.
2012-05-28 00:50:13 +02:00
Günther Brammer 487a0ea38f Store a copy of the proplist the preparser created for include/appendto
The parser now copies the contents of the proplists in the order of their
source scripts into the final proplist. This way, local variable contents
get properly included, and the list of functions has one user less.
2012-05-28 00:31:55 +02:00
Günther Brammer e26bc8e33a Move some parser implementation details to C4ScriptHost 2012-05-27 23:47:07 +02:00
Günther Brammer 7e00f3b5ad Use printf format instead of two strings for script warnings and errors 2012-05-26 00:22:22 +02:00
Günther Brammer 62bc721a65 Make the child pointers of the scriptengine C4ScriptHost*s
This only tightens up the types a bit.
2012-05-15 19:32:58 +02:00
Günther Brammer ceb9c45984 Fix Script runtime reload
Just removing the right amount of functions from the proplists is
somewhat tricky, unfortunately.
2012-05-25 17:25:53 +02:00
Günther Brammer 752e945b8d Call C4PropList::Freeze in Link, remove now empty AfterLink functions
AfterLink was otherwise only used for the TimerCalls, which are now gone.
2012-05-06 00:06:33 +02:00
Günther Brammer 67d8ac47e9 Keep functions across script reloads
For functions that are not appended/included, this is done by reusing them.
Functions that are not in the new script version are left with their code
raising and error. Appended/included functions are handled by a reference count.
2012-02-02 01:16:14 +01:00
Günther Brammer 65801a5188 Remove C4AulFunc::LinkedTo
The parser doesn't need it to find the functions it has to parse anymore.

And the global proplist can be cleared before removing the functions,
instead of having engine functions deregister themselves and script
functions being deregistered when their linked function is removed.
2012-02-13 22:20:10 +01:00
Günther Brammer 30c843925f Script: Include each script at most once
If a script includes two others which each include the same fourth, the
script only gets one copy. Which one is arbitrary and subject to change.
2012-01-25 03:50:24 +01:00
Günther Brammer 18038f45d3 Implement the function overload tree using the proplists
Instead of carefully inserting functions at the start or end of the list,
build the list just before the parser runs, at the same time as filling
the proplist where the functions are looked up.

This way, the overloaded function is simply the one that was previously in
the proplist, is not needed outside of the overloading function, and can thus
be replaced in the proplist.
2012-01-27 00:20:55 +01:00
Günther Brammer f61ebfc453 Replace C4AulScript tree structure with a list 2012-01-25 04:15:39 +01:00
Günther Brammer ae11dfd1e4 Remove #strict infrastructure
The next incompatible changes to C4Script will probably use something else
anyway.
2012-01-25 04:15:53 +01:00
Günther Brammer 0403bed306 Put functions into their proplists 2011-10-15 01:38:59 +02:00
Günther Brammer b3aff643f3 Script reloading does not clear local variable defaults
The defaults are filled in by the preparser, which is only invoked for
changed scripts.
2011-10-04 22:16:27 +02:00