Jump to content

  • Log In with Google      Sign In   
  • Create Account

Quittouff

Member Since 08 Dec 2010
Offline Last Active Dec 17 2012 02:53 AM

Topics I've Started

Problems in C++ header paths in xCode

07 September 2012 - 12:52 PM

Hi everyone,

We bought an iMac to port our game from PC to mac, and I'm a true beginner with xCode. Our (in-house) engine and game are fully in C++ and I'm currently trying to make the projects under xCode. But I'm not very far in the process as I spent my entire first day with a header path problem...

Note: I'm using xCode 4.4 under OS X 10.8.1 (Mountain Lion)

So the problem is that the compiler seems to mess up header paths. Here is the deal:

I have my xproject in Sources/MakeFiles/xCode/Base/base.xproject
I have all my project sources (headers and cpp) in Sources/Base/
Now I added all the files to the project, no problem, but it couldn't find the headers, so I go to the options, add ../../../ to "Header Search path" (so the root of the include directory is "Sources"), I don't check the recursive option, it now finds my headers.

But when I include <string> which includes <string.h>(via some nested headers like cstring), the compiler go for a file located in Sources/Base/String/String.h. But I haven't checked the "recursive" checkbox!

So I know I could rename my headers or change every includes to use "" instead of <>. But it's a fairly big project (2500+ files) and I really don't want to mess all up for something which looks like a bug on xCode part, or silly misuse on mine.

I tried a lot of things, including copying all system headers in a custom dir and adding this dir first in "Header Search path", it always includes my Base/String/String.h instead of <string.h>

Am I missing something? I feel so dumb! I spent nearly 12 hours on this, googling, trying tons of insane stuff, I'm in a dead end, please help!

Odd thing with references

02 February 2012 - 03:11 PM

Hi,

I got a very odd thing going on with my strings when I use const references in the script.
I exposed these methods:
const CString& GetString(const CString&in);
void SetText(const CString&in);

then in the script i do something like:
SetText(GetString("foo"));

All is right until the destructor is called on the string returned by GetString and it destroys the original string. I can't understand why it would call the destructor when I only use references.

The thing is, I use an 'old' version of AngelScript (v2.22.0 WIP changelist 1010). If this issue is corrected after my version, tell me. I didn't change to newer version because I'd like to have a "final" version as my shipping date approach.

Garbage collection bug?

07 October 2011 - 04:12 PM

Hi again,

I have some crash in angelscript when I close my program. It seems that the garbage collector is doing something odd: deleting all functions table on every types and then ask for the GetRefCount (set to 0) on one of the types, but only under some specific circumstances. I spent hours trying to find out what is going on and narrowing it down to a very simple example so I could have a basic example that should allow you to reproduce the issue:

C++ code:
[source lang="cpp"] class CFoo { public: CFoo() : m_Ref(1) { } void SetScriptObject(AngelScript::asIScriptObject* _pObject) { m_pObject = _pObject; } void AddRef() { m_Ref++; } void Release() { if( --m_Ref == 0 ) { delete this; } } static CFoo* CreateObject() { return new CFoo; } private: AngelScript::asIScriptObject* m_pObject; uint32 m_Ref; }; class CDummy { public: CDummy() {} void AddRef() {} void Release() {} private: uint32 m_DummyMember; }; pEngine->RegisterInterface("IMyInterface"); pEngine->RegisterObjectType("CFoo", sizeof(CFoo), AngelScript::asOBJ_REF); pEngine->RegisterObjectBehaviour("CFoo", AngelScript::asBEHAVE_ADDREF, "void f()", AngelScript::asMETHOD(CFoo, AddRef), AngelScript::asCALL_THISCALL); pEngine->RegisterObjectBehaviour("CFoo", AngelScript::asBEHAVE_RELEASE, "void f()", AngelScript::asMETHOD(CFoo, Release), AngelScript::asCALL_THISCALL); pEngine->RegisterObjectBehaviour("CFoo", AngelScript::asBEHAVE_FACTORY, "CFoo@ f()", AngelScript::asFUNCTION(&CFoo::CreateObject), AngelScript::asCALL_CDECL); pEngine->RegisterObjectMethod("CFoo", "void SetObject(IMyInterface@)", AngelScript::asMETHOD(CFoo, SetScriptObject), AngelScript::asCALL_THISCALL); pEngine->RegisterObjectType("CDummy", sizeof(CDummy), AngelScript::asOBJ_REF); pEngine->RegisterObjectBehaviour("CDummy", AngelScript::asBEHAVE_ADDREF, "void f()", AngelScript::asMETHOD(CFoo, AddRef), AngelScript::asCALL_THISCALL); pEngine->RegisterObjectBehaviour("CDummy", AngelScript::asBEHAVE_RELEASE, "void f()", AngelScript::asMETHOD(CFoo, Release), AngelScript::asCALL_THISCALL);[/source]


Script code
[source lang="cpp"]CBar test;class CBase : IMyInterface{ CDummy@ m_dummy; //Comment only this and everything is ok}class CBar : CBase{ CBar() { m_foo.SetObject(this); //Comment only this and everything is ok } CFoo m_foo;};[/source]

Note: I'm still at the version 2.21.0 as I didn't see that it may be corrected in next versions

References and copy operator

07 October 2011 - 10:20 AM

Hi,

I'm little confused as it seems that using only references still requires a copy operator. Here is the configuration:
I declare a MyObject type with flags asOBJ_POD |asOBJ_VALUE | asOBJ_APP_CLASS_CD
then 2 functions with the signatures "const MyObject& GetMyObject()const" and "void SetMyObject(const MyObject&in)" and when i do:

SetMyObject(GetMyObject()); in the script I get the "ERROR: There is no copy operator for this type available."

why would I need a copy operator exposed to angelscript when all I use is some const refs?
Is there anything I can do to work around this without adding some copy operator?

Task: Reduce memory allocations for value types

30 April 2011 - 12:51 AM

Have you any idea when you'll be able to spend some time on this big task?
I'm asking because I did a couple of stress tests on some scripts (on PC platform), and profile results showed that a lot of the time spent in AngleScript (between 40 et 60% depending on the tests) is actually spent in memory alloc and dealloc due to returns and params handling.
So I don't know what your priorities are on your task list, if optimization/perf is high priority or not, but I think this one could make huge improvements.
Performances is a serious concern for me on AngelScript (as it may already showed in previous posts), but I really like the way AS is done and I'd rather spend some time to improve it than to switch script language. I'm aware it's a big task and that it might impact all platforms, and even if I'm not familiar with AS code for now, I would be glad to give you a hand on this matter if you need it. Don't hesitate to point me where to look first or maybe detail a bit more this task, I'll be glad to help.

PARTNERS