aboutsummaryrefslogtreecommitdiffstatsci
path: root/src/CompilerServices
diff options
context:
space:
mode:
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>2018-02-09 18:46:40 +0100
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>2018-02-09 18:46:40 +0100
commitd783669223da5bfe8caa1b95c0ff6e1c5046e09e (patch)
tree08e156330c147d73aff48d018d60df6bfa50e259 /src/CompilerServices
parent8678c71d24bd88ceca04dc71b0d1b93a2f51cecf (diff)
Squashed commit devel branch:
commit 7f91f7c2e83f7cfb2922ea83586f156f03f88a59 Author: Jean-Philippe Bruyère <jp_bruyere@hotmail.com> Date: Fri Feb 9 18:13:59 2018 +0100 go back to OpenTK-2, waiting for an official release commit 125f32758a584c4976d3536eab3702fd37a8a7a9 Author: Jean-Philippe Bruyère <jp_bruyere@hotmail.com> Date: Fri Feb 9 17:26:00 2018 +0100 LoadInterface replaced by AddWidget overload, [ide] property view item templates in separate template file commit 7c48cd2f0332d2ec82006edb755fcd37ab1f2b4a Author: Jean-Philippe Bruyère <jp_bruyere@hotmail.com> Date: Fri Feb 9 12:10:13 2018 +0100 Tooltips, CrowIDE improvements, Fetch subdata when test not eq TypeOf, debug listener in basicTest, RemoveWidget in iface modifié : Crow.ControlsLib/Crow.ControlsLib.csproj modifié : Crow.csproj modifié : Crow.sln modifié : CrowIDE/CrowIDE.csproj modifié : CrowIDE/src/CrowIDE.cs modifié : CrowIDE/src/ImlVisualEditor.cs nouveau fichier : CrowIDE/src/Project.cs nouveau fichier : CrowIDE/src/Solution.cs nouveau fichier : CrowIDE/src/VerticalLine.cs nouveau fichier : CrowIDE/ui/ProjectProperties.crow nouveau fichier : CrowIDE/ui/ProjectTree.template nouveau fichier : CrowIDE/ui/TreeExpandable.template modifié : CrowIDE/ui/imlEditor.crow modifié : Default.style nouveau fichier : Icons/assembly.svg nouveau fichier : Templates/Tooltip.template modifié : Tests/BasicTests.cs modifié : Tests/HelloWorld.cs modifié : Tests/Interfaces/Divers/0.crow modifié : Tests/Interfaces/Divers/testShape.crow modifié : Tests/Interfaces/Divers/welcome.crow modifié : Tests/Tests.csproj modifié : src/CompilerServices/CompilerServices.cs modifié : src/GraphicObjects/FileDialog.cs modifié : src/GraphicObjects/GraphicObject.cs modifié : src/GraphicObjects/MessageBox.cs modifié : src/Instantiator.cs modifié : src/Interface.cs modifié : src/ItemTemplate.cs
Diffstat (limited to 'src/CompilerServices')
-rw-r--r--src/CompilerServices/CompilerServices.cs60
1 files changed, 44 insertions, 16 deletions
diff --git a/src/CompilerServices/CompilerServices.cs b/src/CompilerServices/CompilerServices.cs
index cb8b75b5..16d28490 100644
--- a/src/CompilerServices/CompilerServices.cs
+++ b/src/CompilerServices/CompilerServices.cs
@@ -67,6 +67,7 @@ namespace Crow.IML
internal static MethodInfo miGetValWithRefx = typeof(CompilerServices).GetMethod("getValueWithReflexion", BindingFlags.Static | BindingFlags.NonPublic);
internal static MethodInfo miCreateDel = typeof(CompilerServices).GetMethod ("createDel", BindingFlags.Static | BindingFlags.NonPublic);
internal static MethodInfo miGetImplOp = typeof(CompilerServices).GetMethod ("getImplicitOp", BindingFlags.Static | BindingFlags.NonPublic);
+ internal static MethodInfo miGetDataTypeAndFetch = typeof(CompilerServices).GetMethod("getDataTypeAndFetch", BindingFlags.Static | BindingFlags.NonPublic);
internal static MethodInfo miGoUpLevels = typeof(CompilerServices).GetMethod("goUpNbLevels", BindingFlags.Static | BindingFlags.NonPublic);
@@ -92,7 +93,7 @@ namespace Crow.IML
internal static MethodInfo miGetITempFromDic = typeof(Dictionary<string, ItemTemplate>).GetMethod ("get_Item", new Type[] { typeof(string) });
internal static FieldInfo fldItemTemplates = typeof(TemplatedGroup).GetField("ItemTemplates");
internal static MethodInfo miCreateExpDel = typeof(ItemTemplate).GetMethod ("CreateExpandDelegate");
-
+ internal static FieldInfo fiFetchMethodName = typeof(ItemTemplate).GetField("fetchMethodName", BindingFlags.Instance | BindingFlags.NonPublic);
#region tree handling methods
internal static FieldInfo fiChild = typeof(PrivateContainer).GetField ("child", BindingFlags.Instance | BindingFlags.NonPublic);
internal static MethodInfo miSetChild = typeof (Container).GetMethod ("SetChild");
@@ -330,22 +331,27 @@ namespace Crow.IML
Type dstType = null;
if (mi == null)
return null;
- if (mi.MemberType == MemberTypes.Property) {
- PropertyInfo pi = mi as PropertyInfo;
- tmp = pi.GetValue (instance);
- dstType = pi.PropertyType;
- }
- if (mi.MemberType == MemberTypes.Field) {
- FieldInfo fi = mi as FieldInfo;
- tmp = fi.GetValue (instance);
- dstType = fi.FieldType;
- }
- if (tmp != null)
- return tmp;
- if (dstType == typeof(string) || dstType == CompilerServices.TObject)//TODO:object should be allowed to return null and not ""
+ try {
+ if (mi.MemberType == MemberTypes.Property) {
+ PropertyInfo pi = mi as PropertyInfo;
+ tmp = pi.GetValue (instance);
+ dstType = pi.PropertyType;
+ }
+ if (mi.MemberType == MemberTypes.Field) {
+ FieldInfo fi = mi as FieldInfo;
+ tmp = fi.GetValue (instance);
+ dstType = fi.FieldType;
+ }
+ if (tmp != null)
+ return tmp;
+ if (dstType == typeof(string) || dstType == CompilerServices.TObject)//TODO:object should be allowed to return null and not ""
+ return "";
+ if (dstType.IsValueType)
+ return Activator.CreateInstance (dstType);
+ } catch (Exception ex) {
+ Debug.WriteLine (ex.ToString ());
return "";
- if (dstType.IsValueType)
- return Activator.CreateInstance (dstType);
+ }
return null;
}
@@ -863,6 +869,28 @@ namespace Crow.IML
}
return null;
}
+
+ internal static object getDataTypeAndFetch (object data, string fetchMethod){
+ Type dataType = data.GetType();
+ MethodInfo miGetDatas = dataType.GetMethod (fetchMethod, new Type[] {});
+ if (miGetDatas == null)
+ miGetDatas = CompilerServices.SearchExtMethod (dataType, fetchMethod);
+
+ if (miGetDatas == null) {//in last resort, search among properties
+ PropertyInfo piDatas = dataType.GetProperty (fetchMethod);
+ if (piDatas == null) {
+ FieldInfo fiDatas = dataType.GetField (fetchMethod);
+ if (fiDatas == null)//and among fields
+ throw new Exception ("Fetch data member not found in ItemTemplate: " + fetchMethod);
+ return fiDatas.GetValue (data);
+ }
+ miGetDatas = piDatas.GetGetMethod ();
+ if (miGetDatas == null)
+ throw new Exception ("Read only property for fetching data in ItemTemplate: " + fetchMethod);
+ }
+ object tmp = miGetDatas.Invoke (data, null);
+ return tmp;
+ }
}
}