• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Papirosnik

opEquals now doen't work

13 posts in this topic

Hi.
I've got one question and one suggestion (not related).

[b]The questions[/b] is: What happened with opEquals operator?
In earlier versions this code worked properly:
[CODE]r |= ase->RegisterObjectMethod("Color", "bool opEquals(const Color &in) const", asMETHODPR(Color, operator==, (const Color &in) const, bool), asCALL_THISCALL);
r |= ase->RegisterObjectMethod("Color", "bool opEquals(const Color &in) const", asMETHODPR(Color, operator!=, (const Color &in) const, bool), asCALL_THISCALL);[/CODE]
But in 2.25.1 I get r = -1 after execution of the second line.
How can I get working operator!= ?

[b]the suggestion[/b]:
I use angelscript within marmalade sdk and upon the whole all works fine...excluding one moment:
The marmalade memory manager doesn't like static non-POD (plain of data) objects. Often in that case It detects that there are some memory leaks. Are there really memory leaks or not - I can't judge, but those assertions are annoying.
In particular, within StringFactory function (scriptstdstring.cpp) there is such line:
static string dummy;
Marmalade memory manager considers that here is memory leak.
My workaround is take out this line from StringFactory body:
[CODE]static string dummy;
static const string &StringFactory(asUINT length, const char *s)[/CODE]
I can't say why this workaround works but it works.
Now marmalade doesn't see any memory leaks.
0

Share this post


Link to post
Share on other sites
You shouldn't register the operator!=() method. AngelScript handles both == and != with the same opEquals() method. In previous versions AngelScript wasn't detecting that you registered the same method multiple times but this doesn't mean that it worked the way you think. In fact it only worked for you because AngelScript ignored the registration of the operator!=() method, since it only expected a single method to be found.

About the warning in Marmalade. I think you should take this up with the Marmalade developers. It's not a memory leak to return a static local variable. In fact a static local variable is identical to a global variable, except that it is only visible from within the function, and only initialized upon first entry. The variable will be uninitialized upon exiting the application just like any other global variable.
0

Share this post


Link to post
Share on other sites
Andreas, thank you for your answer.

operator!= is thrown now from the registration list )

About memory leak...actually there is no real  memory leak there.
But if some memory deallocations on the heap occur after the marmalade memory manager finalization - it considers that there is a memory leak.
Many of static objects (on the heap) will be deallocated after last line of code (where memory manager will be finalized).
The order of their allocation/deallocation may be a bit confusing.
And Marmalade developers cannot do anything with such static objects behaviour.
The only thing that they can do is to recommend don't use static non-POD objects.

So I'm happy that I managed to find the workaround that allows to shut up that annoying assertions.
I am sure that the windows with assertions about memory leaks irritate not only me (someone can  even get scared). Edited by Papirosnik
0

Share this post


Link to post
Share on other sites
The problem is that Marmalade tries to detect the memory leaks before the program has even finished. The memory manager needs to replace the default memory manager in the runtime library itself so it is there even before the main function is invoked, and still there after the main function ends. It seems to me that Marmalade already uses their own runtime library so it doesn't seem like it should be that difficult to keep the memory manager until the very end.

Still, I don't mean to question them. I just don't like being forced not to use proper C++, i.e. static local variables, due to limitations in a third party library.
0

Share this post


Link to post
Share on other sites
Yes, you are right.
With marmalade we need to initialize graph unit via IwGxInit invoking and finalize it before the completion of the application (via IwGxTerminate).
and the marmalade memory manager is initialized and finalized inside this functions.
We cannot affect it and static objects are freed after the memory manager has completed its work.
But my workaround for some reason works.
You are not forced don't use static string variable. My suggestion is just declare it a bit in another place.
Thank you anyway.
0

Share this post


Link to post
Share on other sites
My guess is that it works because by moving the static variable out of the function it will be initialized before you call lwGxInit, and thus won't be accounted for when lwGxTerminate is called.

My problem with this is that it restricts the use of static local variables which is a common optimization technique. Declaring the variables globally works, but clutters the global namespace with variables that shouldn't be seen there.

Still, I'll probably change it. After all, my goal with AngelScript is to keep it as portable as possible.
0

Share this post


Link to post
Share on other sites
what's about namespace and/or unique names?

[CODE]namespace AngelScript
{
ststic string dummyStringForStringFactoryRoutineToAvoidProblemsWithMarmaladeMemoryManager; // :)
}

static const string &StringFactory(asUINT length, const char *s)
{
...
AngelScript::dummyStringForStringFactoryRoutineToAvoidProblemsWithMarmaladeMemoryManager = "";
...
}[/CODE]
Edited by Papirosnik
0

Share this post


Link to post
Share on other sites
I think you'll agree with me that it is not a very nice solution. :)

But don't worry this. I'd prefer using static local variables but as these don't work, static global variables are the next best thing.
0

Share this post


Link to post
Share on other sites
[quote name='Andreas Jonsson' timestamp='1353073757' post='5001537']
I think you'll agree with me that it is not a very nice solution. [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]
[/quote]

Yes, of course. )

And advantages of AngelScript are so strong that we can close our eyes even if there will be real memory leaks.
Thank for your work.
Have fun with your creativity. Edited by Papirosnik
0

Share this post


Link to post
Share on other sites
I've changed the static variable, and the comment style in the assembler code.

Would you mind testing revision 1474 with Marmalade to see if there is anything else that needs changes?
0

Share this post


Link to post
Share on other sites
I've tested 1474 revision.
it seems all works properly.....
The comments are correct from now
Fake warnings about memory leaks went away...although

There is a lot of warnings about comparison between signed and unsigned integer expressions

for example in scriptsstdstrings.cpp:
bool leftJustify = options.find("l") != -1;

I also wrote earlier so because it is very short and convenient way. But marmalade gcc compiler doesn't like such scriptures.
It wants something like this:

bool leftJustify = options.find("l") != std::string::npos;
or at least
bool leftJustify = options.find("l") != 0xFFFFFFFF;

Those warnings can be boldly ignored
But their count is significant and
between them may be overlooked some important warnings

PS. MS VS compiler silently permits those comparisons. Edited by Papirosnik
0

Share this post


Link to post
Share on other sites
If you can post the full compiler output I'll gladly take a look at it and fix what I can. Some compiler are overly critical on the code, but usually it is just smaller adjustments needed to make the compiler happy.
0

Share this post


Link to post
Share on other sites
Notice also
as_scriptengine.cpp(3586): warning : 'stdcall' attribute directive ignored

[CODE]1>------ Build started: Project: TheStack_vc10, Configuration: GCC ARM Release Win32 ------
1>Build started 11/20/2012 12:23:54 PM.
1>InitializeBuildStatus:
1> Creating "Release_TheStack_vc10_gcc_arm\TheStack_vc10.unsuccessfulbuild" because "AlwaysCreate" was specified.
1>CustomBuild:
1> All outputs are up-to-date.
1>ClCompile:
1> ARM Compiling(GCC) d:\bumper\_prj\_thestack\src\age\3rd_party\angelscript\source\as_scriptengine.cpp ...
1> d:/bumper/_prj/_thestack/src/age/3rd_party/angelscript/source/as_scriptengine.cpp( In member function 'void* asCScriptEngine) ::CallGlobalFunctionRetPtr(asSSystemFunctionInterface*, asCScriptFunction*)':
1>
1>
1>d:/bumper/_prj/_thestack/src/age/3rd_party/angelscript/source/as_scriptengine.cpp(3586): warning : 'stdcall' attribute directive ignored
1>
1>
1>d:/bumper/_prj/_thestack/src/age/3rd_party/angelscript/source/as_scriptengine.cpp(3586): warning : 'stdcall' attribute directive ignored
1>
1>
1> d:/bumper/_prj/_thestack/src/age/3rd_party/angelscript/source/as_scriptengine.cpp( In member function 'void* asCScriptEngine) ::CallGlobalFunctionRetPtr(asSSystemFunctionInterface*, asCScriptFunction*, void*)':
1>
1>
1>d:/bumper/_prj/_thestack/src/age/3rd_party/angelscript/source/as_scriptengine.cpp(3607): warning : 'stdcall' attribute directive ignored
1>
1>
1>d:/bumper/_prj/_thestack/src/age/3rd_party/angelscript/source/as_scriptengine.cpp(3607): warning : 'stdcall' attribute directive ignored
1>
1>
1> d:/bumper/_prj/_thestack/src/age/3rd_party/angelscript/source/as_scriptengine.cpp( In member function 'void asCScriptEngine) ::CallGlobalFunction(void*, void*, asSSystemFunctionInterface*, asCScriptFunction*)':
1>
1>
1>d:/bumper/_prj/_thestack/src/age/3rd_party/angelscript/source/as_scriptengine.cpp(3707): warning : 'stdcall' attribute directive ignored
1>
1>
1>d:/bumper/_prj/_thestack/src/age/3rd_party/angelscript/source/as_scriptengine.cpp(3707): warning : 'stdcall' attribute directive ignored
1>
1>
1> d:/bumper/_prj/_thestack/src/age/3rd_party/angelscript/source/as_scriptengine.cpp( In member function 'bool asCScriptEngine) ::CallGlobalFunctionRetBool(void*, void*, asSSystemFunctionInterface*, asCScriptFunction*)':
1>
1>
1>d:/bumper/_prj/_thestack/src/age/3rd_party/angelscript/source/as_scriptengine.cpp(3727): warning : 'stdcall' attribute directive ignored
1>
1>
1>d:/bumper/_prj/_thestack/src/age/3rd_party/angelscript/source/as_scriptengine.cpp(3727): warning : 'stdcall' attribute directive ignored
1>
1>
1> d:/bumper/_prj/_thestack/src/age/3rd_party/angelscript/add_on/scriptstdstring/scriptstdstring.cpp( In function '_STL) ::string formatInt(asINT64, const _STL::string&, asUINT)':
1>
1>
1>d:/bumper/_prj/_thestack/src/age/3rd_party/angelscript/add_on/scriptstdstring/scriptstdstring.cpp(344): warning : comparison between signed and unsigned integer expressions
1>
1>
1>d:/bumper/_prj/_thestack/src/age/3rd_party/angelscript/add_on/scriptstdstring/scriptstdstring.cpp(345): warning : comparison between signed and unsigned integer expressions
1>
1>
1>d:/bumper/_prj/_thestack/src/age/3rd_party/angelscript/add_on/scriptstdstring/scriptstdstring.cpp(346): warning : comparison between signed and unsigned integer expressions
1>
1>
1>d:/bumper/_prj/_thestack/src/age/3rd_party/angelscript/add_on/scriptstdstring/scriptstdstring.cpp(347): warning : comparison between signed and unsigned integer expressions
1>
1>
1>d:/bumper/_prj/_thestack/src/age/3rd_party/angelscript/add_on/scriptstdstring/scriptstdstring.cpp(348): warning : comparison between signed and unsigned integer expressions
1>
1>
1>d:/bumper/_prj/_thestack/src/age/3rd_party/angelscript/add_on/scriptstdstring/scriptstdstring.cpp(349): warning : comparison between signed and unsigned integer expressions
1>
1>
1> d:/bumper/_prj/_thestack/src/age/3rd_party/angelscript/add_on/scriptstdstring/scriptstdstring.cpp( In function '_STL) ::string formatFloat(double, const _STL::string&, asUINT, asUINT)':
1>
1>
1>d:/bumper/_prj/_thestack/src/age/3rd_party/angelscript/add_on/scriptstdstring/scriptstdstring.cpp(388): warning : comparison between signed and unsigned integer expressions
1>
1>
1>d:/bumper/_prj/_thestack/src/age/3rd_party/angelscript/add_on/scriptstdstring/scriptstdstring.cpp(389): warning : comparison between signed and unsigned integer expressions
1>
1>
1>d:/bumper/_prj/_thestack/src/age/3rd_party/angelscript/add_on/scriptstdstring/scriptstdstring.cpp(390): warning : comparison between signed and unsigned integer expressions
1>
1>
1>d:/bumper/_prj/_thestack/src/age/3rd_party/angelscript/add_on/scriptstdstring/scriptstdstring.cpp(391): warning : comparison between signed and unsigned integer expressions
1>
1>
1>d:/bumper/_prj/_thestack/src/age/3rd_party/angelscript/add_on/scriptstdstring/scriptstdstring.cpp(392): warning : comparison between signed and unsigned integer expressions
1>
1>
1>d:/bumper/_prj/_thestack/src/age/3rd_party/angelscript/add_on/scriptstdstring/scriptstdstring.cpp(393): warning : comparison between signed and unsigned integer expressions
1>
1>
1>Link:
1> ARM Linking(GCC) ...
1> TheStack_vc10.vcxproj -> d:\Bumper\_Prj\_TheStack\bin\TheStack.s3e
1>PostBuildEvent:
1> D:\Marmalade\6.1\s3e\python\python.exe .\process_map.py "d:\Bumper\_Prj\_TheStack\bin\TheStack.s3e"
1>FinalizeBuildStatus:
1> Deleting file "Release_TheStack_vc10_gcc_arm\TheStack_vc10.unsuccessfulbuild".
1> Touching "Release_TheStack_vc10_gcc_arm\TheStack_vc10.lastbuildstate".
1>
1>Build succeeded.
1>
1>Time Elapsed 00:01:08.01
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========[/CODE]
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0