To the typeloader question, yes, you can use Gosu reflection to write
Java wrappers to Gosu code. Our XML typeloader has that capability,
whereby you can turn an XSD or WSDL into a bunch of Gosu types, but
then you can also generate Java wrappers that map to those Gosu types
and call them reflectively. To do that, you still have to have the
Gosu type system initialized and all the Gosu runtime around so that
Gosu code/types can execute.
I'm guessing you're probably aware of this, but Gosu already has a
strongly-typed templating language built in, so you could also
consider just taking those types and generating Java wrappers, if the
language itself suits your purposes.
Unfortunately, the memory consumption is likely not so ideal: I don't
have any hard numbers at this point, and it entirely depends on the
amount of code you want to parse, but I'd guess that for any
significant amount of Gosu code it's closer to 100megs, simply because
we have to convert Java classes into Gosu type representations, and
then there's the overhead of the Gosu classes themselves on top of
that. We're working on memory consumption right now, since it's a
problem in editor plugins, but it's certainly far from ideal.
-Alan
> --
> You received this message because you are subscribed to the Google Groups "gosu-lang" group.
> To post to this group, send email to gosu...@googlegroups.com.
> To unsubscribe from this group, send email to gosu-lang+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/gosu-lang?hl=en.
>
>
-Alan
-Alan
package tosa.loader;
import gw.lang.reflect.IConstructorInfo;
import gw.lang.reflect.IMethodInfo;
import gw.lang.reflect.IPropertyInfo;
import gw.lang.reflect.IType;
import gw.lang.reflect.TypeSystem;
import java.util.Date;
/**
* Created by IntelliJ IDEA.
* User: alan
* Date: 5/13/11
* Time: 5:45 PM
* To change this template use File | Settings | File Templates.
*/
public class BarWrapper {
private Object _delegate;
public BarWrapper() {
this(getConstructor().getConstructor().newInstance());
}
private BarWrapper(Object delegate) {
_delegate = delegate;
}
public Integer getId() {
return (Integer) getProperty("id").getAccessor().getValue(_delegate);
}
public Date getDate() {
return (Date) getProperty("Date").getAccessor().getValue(_delegate);
}
public void setDate(Date value) {
getProperty("Date").getAccessor().setValue(_delegate, value);
}
public void update() {
getMethod("update").getCallHandler().handleCall(_delegate);
}
public static BarWrapper findFromSql(String sql) {
Object delegate = getMethod("findFromSql",
getType("java.lang.String")).getCallHandler().handleCall(null, sql);
return new BarWrapper(delegate);
}
// ----------- Private static helpers
private static IType getType(String fullName) {
return TypeSystem.getByFullName(fullName);
}
private static IType getType() {
return getType("test.testdb.Bar");
}
private static IPropertyInfo getProperty(String name) {
return getType().getTypeInfo().getProperty(name);
}
private static IMethodInfo getMethod(String name, IType... types) {
return getType().getTypeInfo().getMethod(name, types);
}
private static IConstructorInfo getConstructor(IType... types) {
return getType().getTypeInfo().getConstructor();
}
}
;)
Cheers,
Carson