• 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
Lioirc

please comment on this

9 posts in this topic

Hi I was implementing the constructor arguments feature this morning, but i dont see a good way of declaring the arguments for the constructor on the script, as simply doing this "CObject obj(REG_TYPE) will not work, to support this way requires a lot of changes in the parser as the functions will be recognized as globalvars because of the open paranthesis, so it will need to store the var type and compare to a registered type for declaring it as a global var, anyway, alot So the question is how you want (or how its a good way to do it in a script language, im a little c++ biased) the arguments to be declared in the script? a keyword? probably an assigment with the arguments enclosed in paranthesis ? a _(agrs) probably ? or CObject obj { type_reg } or a CObject obj TYPE reg_type or what ? Hope WitchLord can take a look at the jit compiler source that i posted in another thread soon WhitchLord, are interested in tutorials for your library? Well, i have continue testing these scripting libraries with my framework best regards Lioric
0

Share this post


Link to post
Share on other sites
Perhaps a better route should be to mimic the string-factory mechanism?

You could register a global function as a 'typefactory'. In C++, this function looks like "type CreateType(type*,...)". Within the angelscript compiler, parse statements such as "type identifier(...)" into a call to CreateType, passing the proper pointer of course.

If this mechanism is also used for implicit type conversion, it can replace the StringFactory mechanism completely. If a function expects a string, and you pass a const char*(string literal) the compiler can look and see if there is a registered factory for string that takes a const char*. This is exactly what the StringFactory does, except it's looking at the destination type and not the source type.
0

Share this post


Link to post
Share on other sites
Re-reading your post, I've noticed that you said the AngelScript compiler can't tell the difference between a function declaration and a constructor-call. Obviously C++ compilers can, so there must be a way to tell!

If it apears within a function, it can't be a function.
If the return-type is a built-in primitive, it can't be a variable.
If any argument lacks a type specifier, it should be treated as a variable - it will cause errors if it's a function, especially when someone tries to call it.

There is one extreme case.

Type var(Type arg1, Type arg2);

Is that a function declaration or a variable constructed from two default constructed arguments?
If any arg has it's own constructor arguments, it must be a variable.
If AngelScript doesn't need forward function declaration (I haven't checked... but if not, it shouldn't support it at all) then it must be a variable.
If it's followed by {} instead of a semi-colon, it must be a function.

Perfectly understandable if you don't want to dive in and implement all that. I'm already just doing Type obj = Factory(...) myself. A simple prefix to the argument list, though ugly, is good enough for now. A syntax like Type obj = (argument list) or Type obj : (argument list) is good. The colon is used in C++ for initializer lists, so it almost makes sense like that in AngelScript. :D!
0

Share this post


Link to post
Share on other sites
Deyja wrote :
///////////////////////////////////////
If it apears within a function, it can't be a function.
///////////////////////////////////////
void func(void) {
CObject obj(1);
CObject getObject(1);
}

obj is a Object constructor and getObjec is a function, so if it appears within a function, it can be a function, can you tell the difference just parsing the text?, we need to make extra token compares to find which is what, and that is what i dont want to do it (i dont have time)

Deyja wrote :
///////////////////////////////////////
If any argument lacks a type specifier, it should be treated as a variable - it will cause errors if it's a function, especially when someone tries to
///////////////////////////////////////

the same, see above.

I like the CObject obj : (args) syntax, what others think about it?

Lioric
0

Share this post


Link to post
Share on other sites
Quote:
obj is a Object constructor and getObjec is a function, so if it appears within a function, it can be a function, can you tell the difference just parsing the text?, we need to make extra token compares to find which is what, and that is what i dont want to do it (i dont have time)


I wasn't aware AngelScript supported function declarations inside functions. C++ does not. Of course, the compiler would detect the lack of a type specifier on 1, and assume it's an object. I'm going to assume this is what you meant by 'extra token compares'. A recursive-descent parser actually handles this pretty well! Any state-machine driven compiler should be able to handle it, though it'd probably get rather complicated fast.

Also, use [ quote ][ /quote ].
0

Share this post


Link to post
Share on other sites
If I may...

AngelScript is following the C++ syntax pretty closely so I want to continue that trend with the constructors as well. That means that local objects will be constructed with the following declaration:

CObject obj(param1, param2);

To have AngelScript support this form you will have to change the parser and the compiler. The parser is capable of looking ahead to determine how to interpret the syntax so don't worry about that. There is no need for new tokens.

The constructor should be registered with the following call:

engine->RegisterObjectBehaviour("CObject", asBEHAVE_CONSTRUCT, "void f(int, int)", asFUNCTION(ConstructCObjectWithParams), asCALL_CDECL_OBJLAST);

For this to work you'll also have to change the behaviour structure used to store the registered behaviour functions for the object, and change the RegisterObjectBehaviour() method to support constructors with different function signatures.

If you need help, in realizing these changes you're welcome to e-mail me.

As I said earlier, JIT compilation is still quite far away. I will concentrate on language features first.

Yes, I am very interested in tutorials for AngelScript. I'll post them on the site if you want, or if you prefer I'll link to your site with the tutorials.






0

Share this post


Link to post
Share on other sites

// Global variable declaration
CObject obj(parm1, param2);

// Function declaration
CObject function(int, float)
{
..
}


These are the cases you'll have to worry about in the global scope. At first they may seem similar, but the variable declaration can be identified in that it doesn't declare parameters but instead uses arguments.


// Global variable with more complex argument
CObject obj(int(parm1));


This is another case that has to be identified. You'll have to write a function that looks ahead until the first parenthesis, and then from what it finds in the parenthesis determines if it is a declaration (will find an expression) or function (will find a parameter declaration).


// Global variable with no arguments
CObject obj();


This is also a possible situation, in which case AngelScript should give an error because the variable declaration don't need the parenthesis, and the function doesn't have a body.

There are no function prototypes in AngelScript, except for imported functions that are preceeded with the keyword 'import'.

I know it is a complicated sitation, but take a look at how I solved ParseScript(). It uses the method IsGlobalVar() to determine if the global statement is a global variable declaration or a function declaration. IsGlobalVar() looks ahead several tokens in order to determine this.
0

Share this post


Link to post
Share on other sites
Thanks for your replies

I already have this feature implemented, i was not sure about the script syntax, as i said before, im c++ biased and the scripters no, but i will let it the way its implemented, like c++ object creation parameters

It took 20 minutes to do it, for now it supports , any number of parameters, enums parameters or constant integers (that is how enum are implemented) but changing it to support other data types its a matter of adding a few line in the compiler, but i dont know if i will do it because i still have not decided about what scripting library i will use in my framework ( the other lib that has jit compilation requires to have wrapper or proxy function for antive functions, and i like the angelscript way of supporting native functions directly)

WitchLord what about this script, these is where it will need extra comparations to find if its object declaration or a function call

int type1 = 1;
int type2 = 2;

void main() {
CObject obj(1, 2);
CObject getObjectByTypes(1, 2);
}

and getObjectByTypes is a global function that do whatever you want, and return a CObject, there is where the parser have problems. But now that i see it, probably checking if getObjectByType is a script or native function will do, yes, i will take a look at it later

I will send you the patch probably this weeekend or on monday

Come on, take a look at the jit source, my project will not be out of the beta stage for at least 2 or 3 months, so i hope that a quite far away its not more thatn a few months :)
And i will contribute a lot to your library, i will send you 2 tutorials with this patch

Lioric
0

Share this post


Link to post
Share on other sites
Simply put, your example isn't valid code. You can't declare a function inside a function. So getObjectByTypes MUST be a variable.
0

Share this post


Link to post
Share on other sites
Deyja is correct.


void Func()
{
CObject getObjectByTypes(1, 2);
}


This code can only be treated as a variable declaration. Even if the function CObject getObjectByTypes(int, int) existed the compiler should still treat the statement above as a variable declaration, though it might give an error because the name is already taken. (I actually don't remember right now if I put in this restriction or not).

JIT is something that will be supported, though I won't take the time to implement it at this moment. If you should want to give it a try though, it would be another excellent contribution to the library.

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