Andromeda Standard Library

From HIVE
Revision as of 05:25, 6 August 2012 by DevliN (talk | contribs) (Reverted edits by 91.121.27.33 (talk) to last revision by DevliN)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

The Andromeda Standard Library, also known as astdlib, is the official standard library for Andromeda programming. It provides a standard API for Andromeda programmers to carry out a variety of common tasks, including the use of collections, enrichments and wrapper classes for Galaxy native types, and native functions in a style consistent with Andromeda programming. The library is written entirely in Andromeda.

Content

The library can be separated into three major branches, each with its own overarching theme:

  • Utility and collection classes provide standardized implementations for commonly-used objects and algorithms.
  • Native Galaxy enhancements provide enrichments and wrapper classes to provide an interface between the native Galaxy API and Andromeda design paradigms.
  • The (2D) Physics engine provides a standardized physics implementation.

Utility and Collection Classes

Andromeda Standard Library collections class hierarchy
A diagram of the class hierarchy of the collections classes in the Andromeda Standard Library. The map classes are not shown in this diagram. Light blue backgrounds represent abstract classes.

All utility and collection classes can be found in the directory a.util. Included are standard implementations of commonly-used classes and algorithms. The Math static class provides methods for carrying out basic mathematical operations, such as min/max, Euclidian modulo, and absolute value, to name a few. Key, Keyboard, and KeyboardModifierState offer an implementation for dealing with keyboard events.

A large portion of a.util is dedicated to providing standard collections implementations. Among the different collection types included are ordered and unordered sets, (dynamically-allocated and growable) arrays, linked lists, queues, and maps. All astdlib collections are implemented as generic types. This enables them to be used with any class type in Andromeda as well as any native Galaxy type that can be cast to and from (without loss of information) the int type.



Native Galaxy Enhancements

Found in a.natives and a.wrapper, this branch of astdlib provides a set of enrichments and wrapper classes that interface Galaxy API with Andromeda's design paradigms. Whereas Galaxy is a predominantly procedural language similar to C, Andromeda is an object-oriented language more akin to Java. Consequently, the use of the native Galaxy API, including functions and global variables, in Andromeda code is not appropriate and discouraged. The enhancements in astdlib provide a way for Andromeda programmers to use the pre-existing Galaxy API in a manner consistent with Andromeda's design paradigms and style guidelines.

The standard library achieves the Galaxy to Andromeda interface in two ways, through the use of enrichments and wrapper classes. Enrichments are an Andromeda construct designed to provide pseudo-OOP capabilities for native Galaxy types. They allow instances of these native types to be treated, in a limited fashion, as objects by letting the programmer define instance and static methods for native types. The enrichments found in a.natives take advantage of this feature by wrapping native Galaxy functions with instance methods in enrichments for the appropriate types. For example, using a.natives.unit, removing a unit from the game can be done with a call to u.remove() instead of UnitRemove(u).

Wrapper classes for the most basic native Galaxy types are included in a.wrapper. These constructs are real Andromeda classes - not enrichments - and can be used as such. They should only be used in situations where enrichments cannot offer the same functionality since they do incur an overhead cost that is greater than that of enrichments.

2D Physics Engine

See Also

Links