Suggestion for AngelScript Editors

Started by
7 comments, last by WitchLord 19 years, 8 months ago
Hi, Actually, I have well integrated AngelScript in my project. This project consist in two programs : - The viewer that mainly use AngelScript - The editor that let input what the viewer display and also, the scripts that the viewer will execute. The idea that I would like AngelScript author to think about is on the editor part. I would like that asIScriptEngine to expose some new methods that allow to access to registered functions, variables, class, class properties and methods. This way, it could be possible to get AngelScript Editors (not only the one I working on) to get dynamic help for script writers. I have already tested the fact that you can register a function like this :

in_pAsEngine->RegisterObjectMethod("CXPNTree", "bool AskForNavigate(const CString &csWhere /*Page To Navigate To*/)",asMETHOD(CXPNTree, AskForNavigate), asCALL_THISCALL);
The asCScriptFunction object can store this "pure" declaration that include comments that could be presented to the script writter. This is just a wish, Think about it ! AbrKen.
Advertisement
I think this is beyond the scope of what AS tries to provide. You could probably implement a class yourself that does this. That way you can make it do exactly what you want.
Quote:
I think this is beyond the scope of what AS tries to provide


Please get to AngelScript intro page and re-read the first paragraph that says :

Quote:
It has been designed from the beginning to be an easy to use component, both for the application programmer and the script writer.


If a script writer must use notepad with and help file, I don't think that the abilities that provide AS to your programm will be used. I'm a programmer, script writers are end users. Personnaly I use MSVC and contextual help is what I was looking for years before.

Quote:
You could probably implement a class yourself that does this


Of course I can reinvent the wheel ! Why referencing two times the same things in a programm ?

Quote:
That way you can make it do exactly what you want


No, there is a big difference between the two solutions. Mine is to provide the script writer exactly what will be understood by AS before compiling.

I remember the times I was programming unix with vi, nowadays, end users use VisualBasic for application with integrated editors that provide contextual help.
It shouldn't be too hard to be able to store&retrieve the original function-definition for a specific function from AS I think.

Who knows, maybe Andreas is up for it :)
_-=[ "If there's anything more important than my ego around, I want it caught and shot now." ]=--=[ BeatHarness ]=-=[ Guerrilla Games ]=-=[ KillZone ]=-
While your idea is good, I don't think I will include it in the main library.

I really think that this is an application specific thing, and not something that belong in the library. Who better knows how the function documentation should be stored and presented than the application that registered the functions? AngelScript doesn't store the actual declaration of the registered functions, instead it just stores the function name and the parameter types.

The AngelScript library is only a compiler and a virtual machine, the editor is the application that uses this library.

If you should want to make this into a reusable add-on library then I would be more than happy to host it on the angelscript site.

You are correct in pointing out that I've designed AngelScript to be easy to use, but I have to balance this with another goal, which is that the library should be light-weight and not include stuff that most applications might not even use.

Regards,
Andreas

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

Back again on the editor ...

I will make most of the things but I need little help.

The idea was to overload the RegisterObjectType and other function of the asIScriptEngine to get a keyword list that would be highlighted in the editor.

How can I do this ?

Other thing, by contextual help you should have read code completion and call tips .
I suggest that you start with one thing at a time.

If I was to do an editor like this I would store the keywords that need highlighting in a xml. I would also store the system functions that the target application registers in the xml. This would allow each application to provide their own xml, and even let the end user make their own changes as necessary.

With the xml you would also be able to have your editor do all the necessary registration so that the script can actually be compiled.

For your editor you'll need a tokenizer so that you can determine how to colorize each token.

If you want code completion you'll also need a parser, and a semantic checker, that is able to understand the context of the code.

You'll probably be able to take advantage of a lot of the code in AngelScript for this. At least to learn from it.

Regards,
Andreas

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

I think I'm very bad in english ...


As you can see the editor is ok !
Syntax, etc...

But to show the list box you can see near the xmlPresenter-> I am using angelscript referenced objects and methods.

I was just wondering how to do it. Ofcourse I have already done it but ... I have build a asCScriptEngine wrapper class that have the same methods name that asIScriptEngine has. This wrapper class internaly reference object types, methods et so on (using AngelScript code :) ). I think there is a better way to do it !.

int CAsScriptEngineWrapperXPN::RegisterObjectMethod(const char *obj, const char *declaration, asUPtr funcPointer, int callConv){	asCScriptFunction func;	asCBuilder bld((asCScriptEngine *)GetEngine(), 0);	if(bld.ParseFunctionDeclaration(declaration, &func) == asSUCCESS) 	{		CString csType = obj;		_stObjectDef *ptrDef;		if (m_mapTypes.Lookup(csType, (LPVOID&)ptrDef) && ptrDef != NULL) {			ptrDef->lFunc.AddTail(func);		}	}	return m_pAsIScriptEngine->RegisterObjectMethod(obj, declaration, funcPointer, callConv);}


I can't think of any way to improve on that.

If it is working already I don't see why you need to change it. Unless the performance isn't good enough for you, of course.

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

This topic is closed to new replies.

Advertisement