Hi there,
I stumbled upon an issue with using the 'private' keyword in my application. It seems AngelScript doesn't mind when I access private members from derived classes, however accessing private functions from derived classes yields an error of type: "ERR : Illegal call to private method". I see that this is mentioned in the manual and is expected behavior.
However my question is why the engine won't allow private methods to get called, as it would be more consistent, and in tune with C++/Java's 'protected' keyword. As it stands it acts like a mix of 'private' and 'protected', and can cause confusion.
The real reason I'm in need of this myself is because want to have private 'init' functions (for my serializer), which also act polymorphically. As it stands this turned out to be difficult without modifying the engine (although I did manage to hack together a solution which has yet to crash).
My solution for those interested:
I changed:
if( descr->isPrivate && descr->GetObjectType() != outFunc->GetObjectType() )
to
if( descr->isPrivate && descr->GetObjectType() != outFunc->GetObjectType() && !outFunc->GetObjectType()->DerivesFrom(descr->GetObjectType()) )
in as_compiler.cpp: void asCCompiler::PerformFunctionCall
Whats your thought on the matter?
Thanks in advance!
EDIT: Pressing tab apparenty posted my unfinished post