The cornerstone of Gosu, the thing that makes it different than other languages, is the Open Type System. This is the API that allows Gosu to use various kinds of resources in a statically typed, easily toolbable manner. The beauty is that all you need to do is implement some java interfaces and, blam, you've got your custom type system.
As a concrete example, the OTS is what allows Gosu to work with WSDL types directly, without code generation.
There are two sides to the OTS: clients of the type system and tool/framework implementors who want to expose their framework in a statically typed way.
As a client, this is a good jumping-off spot to get at types:
var type = TypeSystem.getByFullName( aTypeName )It has many useful methods for exploring the type system (and plenty of hacks too).
This is the core type abstraction in Gosu, the equivalent of
This holds all the common information about types: constructors, methods, properties, etc. You can get the type info for a type like so:
var ti = someType.TypeInfoTo get all the methods on a type, you would do this:
var ti = String.Type.TypeInfo.Methods // String.Type is how you refer to the String type statically, like String.class in Java
This represents an invokable method. Let's use feature literals to get to one of these:
var methodInfo = Object#toString().MethodInfo // returns the method info for Object#toString() print( methodInfo.ReturnType ) // prints java.lang.String
Just like an
IMethodInfo but for properties.
OK, if you are client then this isn't very interesting, but if you are an implementor, this is crucial. This is what you implement to get into your type system. In particular, the
gw.lang.reflect.ITypeLoader#getIntrinsicType method, which takes a string type name and returns an IType, is where the magic begins.
If you are interested in creating a custom type system, you should take a look at the examples that come with gosu, or maybe take a look at one of my pet projects here: