Jump to content

  • Log In with Google      Sign In   
  • Create Account

- - - - -

AngelScript 1.9.0 WIP 4 (2004/08/31)


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
45 replies to this topic

#41 Andreas Jonsson   Moderators   -  Reputation: 3366

Like
0Likes
Like

Posted 31 August 2004 - 01:44 AM

I don't know either what's wrong. I have a test case in the framework that uses std::string and it works perfectly.

That said Lennart Denninger discovered yesterday a bug when doing multiple assignments in one statement:

a = b = c;

If a, b, and c are registered objects with the assignment behaviour then they won't be assigned correctly.

I've already fixed this problem in WIP4, and I'll show you how to fix it here as well:

In the file as_scriptengine.cpp:

Method RegisterObjectBehaviour():

Add this code:


if( !isGlobal )
func.objectType = type.extendedType;


after this part (aprox. 70 lines into the function):


r = bld.ParseFunctionDeclaration(decl, &func);
if( r < 0 )
return ConfigError(asINVALID_DECLARATION);


Method AddBehaviourFunction():

Add this code:


f->objectType = func.objectType;


after this part (aprox. 10 lines into the function):


asCScriptFunction *f = new asCScriptFunction;


[Edited by - WitchLord on August 31, 2004 8:44:03 AM]
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Sponsor:

#42 Andreas Jonsson   Moderators   -  Reputation: 3366

Like
0Likes
Like

Posted 31 August 2004 - 01:49 PM

I've uploaded the latest work in progress.


  • Removed GetModuleID()
  • Added GetModuleIndex(), and GetModuleNameFromIndex()
  • Changed the interface for import functions, to work with module name and imported function index, instead of a single function ID. This was done to prevent confusion between functionID and imported function indices.
  • Added GetFunctionIDByIndex() and GetGlobalVarIDByIndex()
  • bug fix: Multiple assignments in the same statement didn't work for objects. Introduced in 1.9.0 (thanks Lennart Denninger)
  • Added functions for automatically binding all functions imported in a module. New error code asCANT_BIND_ALL_FUNCTIONS
  • Added the lineOffset parameter to AddScriptSection()
  • bug fix: Saving and loading byte code is actually working now. Introduced in 1.9.0


As I mentioned earlier the changes aren't quite so drastic as I had planned.

The new method BindAllFunctions() can be used to automatically bind all imported functions after the modules have been built.

I will probably only do a few minor corrections here and there before releasing 1.9.0 as beta.


AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

#43 abrken   Members   -  Reputation: 130

Like
0Likes
Like

Posted 31 August 2004 - 10:41 PM

Yes !

I have downloaded WIP4 and everything is working like in WIP2 now !
Thank's for wathever you did to the WIP3 code !

Also I did test imported function and it's great ! (except that it took me some times to understand how BindAllImportedFunctions was working !)

I've got one question :
Why does the import statement MUST be outside a function ? (of course I ask you this because inserting an import statement in a function raised me a compile error !).

Again, great job, great thank you.





#44 Andreas Jonsson   Moderators   -  Reputation: 3366

Like
0Likes
Like

Posted 01 September 2004 - 01:48 AM

I'm glad that WIP4 is working ok.

I'll update the manual when I release version 1.9.0 as beta. It ought to explain everything about importing functions. [smile]

The import statement must be global because AngelScript doesn't understand nested functions. After the function has been declared with the import statement, the compiler will treat it just like any other function.
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

#45 Desdemona   Members   -  Reputation: 158

Like
0Likes
Like

Posted 01 September 2004 - 05:55 PM

I'm having trouble with the asFUNCTIONP/PR macros. Each of the asMETHODP/PR versions work fine, but I can't seem to get the asFUNCTIONP/PR macros to work on overloaded functions (or on a non-overloaded functions for that matter).


pEngine->RegisterGlobalFunction("void ReadFile(const string& filename, string& buffer)", asFUNCTIONP(ReadFile, (const string&, string&)), asCALL_CDECL);

d:\Code\Rpg_test\asExtensions.cpp(174): error C2664: 'asFunctionPtr' : cannot convert parameter 1 from 'void (__cdecl *)(const std::string &,std::string &)' to 'asFUNCTION_t'

// ...

pEngine->RegisterGlobalFunction("Command& CMD(string scr, string fmt)", asFUNCTIONPR(CMD, (string,string), CCommand&), asCALL_CDECL);

d:\Code\Rpg_test\asExtensions.cpp(171): error C2664: 'asFunctionPtr' : cannot convert parameter 1 from 'CCommand &(__cdecl *)(std::string,std::string)' to 'asFUNCTION_t'




#46 Andreas Jonsson   Moderators   -  Reputation: 3366

Like
0Likes
Like

Posted 02 September 2004 - 01:37 AM

I gave it a try, and found out that the macro needs one more cast to void(*)() in order to work.

The fix is to change the macros in angelscript.h to the following:

#define asFUNCTIONP(f,p) asFunctionPtr((void (*)())((void (*)p)(f)))
#define asFUNCTIONPR(f,p,r) asFunctionPtr((void (*)())((r (*)p)(f)))


AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS