User:Saejox/AngelScript: Difference between revisions
m Robot - Removing category Articles created via the Article Wizard per CFD at Wikipedia:Categories for discussion/Log/2019 January 6. |
m →Examples: Replaced deprecated <source> tags with <syntaxhighlight> |
||
Line 38: | Line 38: | ||
'''Comments''' |
'''Comments''' |
||
< |
<syntaxhighlight lang="cpp"> |
||
// a single line comment start withs to slashes |
// a single line comment start withs to slashes |
||
/* |
/* |
||
A multi-line comments start with slash and an asterisk, ends with slash and an asterisk |
A multi-line comments start with slash and an asterisk, ends with slash and an asterisk |
||
*/ |
*/ |
||
</syntaxhighlight> |
|||
</source> |
|||
'''Functions''' |
'''Functions''' |
||
< |
<syntaxhighlight lang="cpp"> |
||
void Foo() |
void Foo() |
||
{ |
{ |
||
// statements |
// statements |
||
} |
} |
||
</syntaxhighlight> |
|||
</source> |
|||
'''Loops''' |
'''Loops''' |
||
< |
<syntaxhighlight lang="cpp"> |
||
for(uint i=0; i < 10; ++i) |
for(uint i=0; i < 10; ++i) |
||
{ |
{ |
||
Line 69: | Line 69: | ||
// statements |
// statements |
||
}while(boolean_var) |
}while(boolean_var) |
||
</syntaxhighlight> |
|||
</source> |
|||
'''Classes''' |
'''Classes''' |
||
Line 76: | Line 76: | ||
It has single inheritance for classes, and polymorphism with interfaces. |
It has single inheritance for classes, and polymorphism with interfaces. |
||
< |
<syntaxhighlight lang="cpp"> |
||
class Base |
class Base |
||
{ |
{ |
||
Line 102: | Line 102: | ||
} |
} |
||
} |
} |
||
</syntaxhighlight> |
|||
</source> |
|||
'''Handles''' |
'''Handles''' |
||
Line 116: | Line 116: | ||
An incremental [[Garbage collector (computing)]] exists to resolve possible circular references. |
An incremental [[Garbage collector (computing)]] exists to resolve possible circular references. |
||
< |
<syntaxhighlight lang="cpp"> |
||
Object obj; |
Object obj; |
||
Object @handle = obj; // handle holds a reference to obj |
Object @handle = obj; // handle holds a reference to obj |
||
Line 124: | Line 124: | ||
/* obj will not be released until handle2 is destroyed or has reference to another Object. */ |
/* obj will not be released until handle2 is destroyed or has reference to another Object. */ |
||
</syntaxhighlight> |
|||
</source> |
|||
==Used in== |
==Used in== |
Latest revision as of 17:53, 8 May 2022
This is not a Wikipedia article: It is an individual user's work-in-progress page, and may be incomplete and/or unreliable. For guidance on developing this draft, see Wikipedia:So you made a userspace draft. Find sources: Google (books · news · scholar · free images · WP refs) · FENS · JSTOR · TWL |
Paradigm | Multi-paradigm: scripting, imperative, functional, object-oriented |
---|---|
First appeared | 2003 |
Stable release | 2.41.0
/ August 7, 2012 |
Typing discipline | Static |
OS | Cross-platform |
License | zlib License |
Filename extensions | .as |
Website | angelcode.com/angelscript |
Influenced by | |
C++ |
AngelScript is a scripting language designed to be inside C/C++ applications and games. AngelScript released as open source in permissive zlib license. It is cross-platform and known to work with many platforms and compilers. [1]
Library appeared in 2003, and still actively maintained.
Language Features
[edit]- Familiar, C++ like
- Static typing, Compile time static checks to ensure strong typing.
- Handles, Pointer like operators. Maybe used in both script and C++ extensions.
- Object-oriented, Classes and interfaces. Single inheritance through classes, multiple-inheritance with interfaces.
- Compiled, script compile to bytecode before execution. Runtime compile is allowed.
- Allow direct access to C++ objects, functions and properties
- Sandbox, script are limited to what application exposes.
- Optional UTF-8 and UTF-16 encoding for script files.
- Concurrent, many scripts may be run in parallel.
Examples
[edit]Comments
// a single line comment start withs to slashes
/*
A multi-line comments start with slash and an asterisk, ends with slash and an asterisk
*/
Functions
void Foo()
{
// statements
}
Loops
for(uint i=0; i < 10; ++i)
{
//statements
}
while(boolean_var)
{
// statements
}
do
{
// statements
}while(boolean_var)
Classes
AngelScript supports object-oriented programming.
It has single inheritance for classes, and polymorphism with interfaces.
class Base
{
Base() // constructor
{
foo = 53;
}
int foo;
float Bar()
{
// statements
}
}; // semicolon optional
class Child : Base // inherits base
{
Child()
{
Base::Base(); // call Base constructor
}
~Child() // destructor. all methods are virtual
{
// statements
}
}
Handles
Handles are AngelScript's way of handling pointers.
Handles may be passed between script Virtual Machine and application without any change in address they point at.
Handles do not have pointer arithmetic.
Handles are reference counted. They are released when not needed automatically.
An incremental Garbage collector (computing) exists to resolve possible circular references.
Object obj;
Object @handle = obj; // handle holds a reference to obj
Object @handle2 = null; // handle2 is null. null is a built-in value that all handles can take
@handle2 = handle; // handle2 now holds reference to obj
@handle = null; // handle is now null. handle2 still holds reference to obj.
/* obj will not be released until handle2 is destroyed or has reference to another Object. */
Used in
[edit]- Amnesia: The Dark Descent
- Dustforce
- Penumbra (video game series)
- Warsow (video game)
- Star Ruler
- Warhammer: Mark of Chaos
- The Journey Down
- 3D Rad
- Overgrowth
See also
[edit]References
[edit]External links
[edit]- angelcode.com/angelscript Official Website
- gamedev.net/forum/49-angelcode Official Forums