/// <param name="il">Il.</param>
public static void emitSetCurInterface(ILGenerator il){
il.Emit (OpCodes.Ldloc_0);
- il.Emit (OpCodes.Ldarg_2);
+ il.Emit (OpCodes.Ldarg_1);
il.Emit (OpCodes.Stfld, miSetCurIface);
}
{
RootType = rootType;
dm = new DynamicMethod ("dyn_instantiator",
- typeof (void), new Type [] { typeof (Instantiator), typeof (object), typeof (Interface) }, true);
+ CompilerServices.TObject, new Type [] { typeof (Instantiator), typeof (Interface) }, true);
il = dm.GetILGenerator (256);
- initILGen ();
+ il.DeclareLocal (typeof (GraphicObject));
+ il.Emit (OpCodes.Nop);
+ //set local GraphicObject to root object
+ il.Emit (OpCodes.Newobj, rootType.GetConstructors () [0]);
+ il.Emit (OpCodes.Stloc_0);
+ CompilerServices.emitSetCurInterface (il);
}
public NodeAddress CurrentNodeAddress {
bd.ResolveTargetName (resolvedNA);
}
- void initILGen ()
- {
- il.DeclareLocal (typeof (GraphicObject));
- il.Emit (OpCodes.Nop);
- //set local GraphicObject to root object passed as 1st argument
- il.Emit (OpCodes.Ldarg_1);
- il.Emit (OpCodes.Stloc_0);
- CompilerServices.emitSetCurInterface (il);
- }
-
/// <summary>
/// Emits cached delegate handler addition in the context of instantiator (ctx)
/// </summary>
namespace Crow
{
- public delegate void InstanciatorInvoker(object instance, Interface iface);
+ public delegate object InstanciatorInvoker(Interface iface);
/// <summary>
/// Instantiator
}
#endregion
- public GraphicObject CreateInstance(Interface iface){
- GraphicObject tmp = (GraphicObject)Activator.CreateInstance(RootType);
- loader (tmp, iface);
- return tmp;
+ public GraphicObject CreateInstance(Interface iface){
+ return loader (iface) as GraphicObject;
}
List<DynamicMethod> dsValueChangedDynMeths = new List<DynamicMethod>();
emitBindingDelegates (ctx);
+ ctx.il.Emit (OpCodes.Ldloc_0);//load root obj to return
ctx.il.Emit(OpCodes.Ret);
reader.Read ();//close tag
if (string.IsNullOrEmpty (templatePath)) {
ctx.il.Emit (OpCodes.Ldnull);//default template loading
} else {
- ctx.il.Emit (OpCodes.Ldarg_2);//load currentInterface
+ ctx.il.Emit (OpCodes.Ldarg_1);//load currentInterface
ctx.il.Emit (OpCodes.Ldstr, templatePath); //Load template path string
ctx.il.Emit (OpCodes.Callvirt,//call Interface.Load(path)
CompilerServices.miIFaceLoad);