summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--BCT/BytecodeTranslator/MetadataTraverser.cs27
-rw-r--r--BCT/BytecodeTranslator/Phone/PhoneInitializationTraverser.cs39
-rw-r--r--BCT/TranslationPlugins/PhoneControlsPlugin.cs4
3 files changed, 58 insertions, 12 deletions
diff --git a/BCT/BytecodeTranslator/MetadataTraverser.cs b/BCT/BytecodeTranslator/MetadataTraverser.cs
index d5e19fb0..f1f7e714 100644
--- a/BCT/BytecodeTranslator/MetadataTraverser.cs
+++ b/BCT/BytecodeTranslator/MetadataTraverser.cs
@@ -70,7 +70,7 @@ namespace BytecodeTranslator {
var savedPrivateTypes = this.privateTypes;
this.privateTypes = new List<ITypeDefinition>();
- trackPageNameVariableName(typeDefinition);
+ trackPhonePageNameVariableName(typeDefinition);
trackPhoneApplicationClassname(typeDefinition);
if (typeDefinition.IsClass) {
@@ -117,7 +117,7 @@ namespace BytecodeTranslator {
}
}
- private void trackPageNameVariableName(ITypeDefinition typeDef) {
+ private void trackPhonePageNameVariableName(ITypeDefinition typeDef) {
if (PhoneCodeHelper.instance().PhonePlugin != null && typeDef.isPhoneApplicationPageClass(sink.host)) {
INamespaceTypeDefinition namedTypeDef = typeDef as INamespaceTypeDefinition;
string fullyQualifiedName = namedTypeDef.ToString();
@@ -130,6 +130,29 @@ namespace BytecodeTranslator {
}
}
+ /*
+ private void translateAnonymousControlsForPage(ITypeDefinition typeDef) {
+ if (PhoneCodeHelper.instance().PhonePlugin != null && typeDef.isPhoneApplicationPageClass(sink.host)) {
+ IEnumerable<ControlInfoStructure> pageCtrls= PhoneCodeHelper.instance().PhonePlugin.getControlsForPage(typeDef.ToString());
+ foreach (ControlInfoStructure ctrlInfo in pageCtrls) {
+ if (ctrlInfo.Name.Contains(PhoneControlsPlugin.BOOGIE_DUMMY_CONTROL)) {
+ string anonymousControlName = ctrlInfo.Name;
+ IFieldDefinition fieldDef = new FieldDefinition() {
+ ContainingTypeDefinition = typeDef,
+ Name = sink.host.NameTable.GetNameFor(anonymousControlName),
+ InternFactory = sink.host.InternFactory,
+ Visibility = TypeMemberVisibility.Public,
+ Type = sink.host.PlatformType.SystemObject,
+ IsStatic = false,
+ };
+ (typeDef as Microsoft.Cci.MutableCodeModel.NamespaceTypeDefinition).Fields.Add(fieldDef);
+ //sink.FindOrCreateFieldVariable(fieldDef);
+ }
+ }
+ }
+ }
+ * */
+
private void CreateDefaultStructConstructor(ITypeDefinition typeDefinition) {
Contract.Requires(typeDefinition.IsStruct);
diff --git a/BCT/BytecodeTranslator/Phone/PhoneInitializationTraverser.cs b/BCT/BytecodeTranslator/Phone/PhoneInitializationTraverser.cs
index d79d2c00..d809b752 100644
--- a/BCT/BytecodeTranslator/Phone/PhoneInitializationTraverser.cs
+++ b/BCT/BytecodeTranslator/Phone/PhoneInitializationTraverser.cs
@@ -102,17 +102,38 @@ namespace BytecodeTranslator.Phone {
phoneAssembly = host.FindAssembly(MSPhoneAssemblyId);
phoneSystemWindowsAssembly = host.FindAssembly(MSPhoneSystemWindowsAssemblyId);
MSPhoneControlsAssembly= host.FindAssembly(MSPhoneControlsAssemblyId);
+ // TODO BUG / XAML DEPENDENCE If a control is declared in XAML, it may be one from a library *not* linked! So, assemblies could be dummy here
// TODO determine the needed types dynamically
- appBarIconButtonType= platform.CreateReference(phoneAssembly, "Microsoft", "Phone", "Shell", "ApplicationBarIconButton");
- checkBoxType = platform.CreateReference(phoneSystemWindowsAssembly, "System", "Windows", "Controls", "CheckBox");
- radioButtonType = platform.CreateReference(phoneSystemWindowsAssembly, "System", "Windows", "Controls", "RadioButton");
- buttonType = platform.CreateReference(phoneSystemWindowsAssembly, "System", "Windows", "Controls", "Button");
- buttonBaseType = platform.CreateReference(phoneSystemWindowsAssembly, "System", "Windows", "Controls", "Primitives", "ButtonBase");
- toggleButtonType = platform.CreateReference(phoneSystemWindowsAssembly, "System", "Windows", "Controls", "Primitives", "ToggleButton");
- controlType = platform.CreateReference(phoneSystemWindowsAssembly, "System", "Windows", "Controls", "Control");
- uiElementType = platform.CreateReference(phoneSystemWindowsAssembly, "System", "Windows", "UIElement");
- pivotType = platform.CreateReference(MSPhoneControlsAssembly, "Microsoft", "Phone", "Controls", "Pivot");
+ if (phoneAssembly != Dummy.Assembly) {
+ appBarIconButtonType = platform.CreateReference(phoneAssembly, "Microsoft", "Phone", "Shell", "ApplicationBarIconButton");
+ } else {
+ appBarIconButtonType = host.PlatformType.SystemObject;
+ }
+
+ if (phoneSystemWindowsAssembly != Dummy.Assembly) {
+ checkBoxType = platform.CreateReference(phoneSystemWindowsAssembly, "System", "Windows", "Controls", "CheckBox");
+ radioButtonType = platform.CreateReference(phoneSystemWindowsAssembly, "System", "Windows", "Controls", "RadioButton");
+ buttonType = platform.CreateReference(phoneSystemWindowsAssembly, "System", "Windows", "Controls", "Button");
+ buttonBaseType = platform.CreateReference(phoneSystemWindowsAssembly, "System", "Windows", "Controls", "Primitives", "ButtonBase");
+ toggleButtonType = platform.CreateReference(phoneSystemWindowsAssembly, "System", "Windows", "Controls", "Primitives", "ToggleButton");
+ controlType = platform.CreateReference(phoneSystemWindowsAssembly, "System", "Windows", "Controls", "Control");
+ uiElementType = platform.CreateReference(phoneSystemWindowsAssembly, "System", "Windows", "UIElement");
+ } else {
+ checkBoxType = host.PlatformType.SystemObject;
+ radioButtonType = host.PlatformType.SystemObject;
+ buttonType = host.PlatformType.SystemObject;
+ buttonBaseType = host.PlatformType.SystemObject;
+ toggleButtonType = host.PlatformType.SystemObject;
+ controlType = host.PlatformType.SystemObject;
+ uiElementType = host.PlatformType.SystemObject;
+ }
+
+ if (MSPhoneControlsAssembly != Dummy.Assembly) {
+ pivotType = platform.CreateReference(MSPhoneControlsAssembly, "Microsoft", "Phone", "Controls", "Pivot");
+ } else {
+ pivotType = host.PlatformType.SystemObject;
+ }
trueConstant = new CompileTimeConstant() {
Type = platform.SystemBoolean,
diff --git a/BCT/TranslationPlugins/PhoneControlsPlugin.cs b/BCT/TranslationPlugins/PhoneControlsPlugin.cs
index f0c75a4c..60af90c0 100644
--- a/BCT/TranslationPlugins/PhoneControlsPlugin.cs
+++ b/BCT/TranslationPlugins/PhoneControlsPlugin.cs
@@ -109,6 +109,8 @@ namespace TranslationPlugins {
private static int SELECTIONCHANGED_HANDLER_FIELD = 10;
private static int BPL_NAME_FIELD = 11;
+ public const string BOOGIE_DUMMY_CONTROL = "__BOOGIE_DUMMY_CONTROLNAME_";
+
private IDictionary<string, PageStructure> pageStructureInfo;
public static string getURILastPath(string uri) {
@@ -302,7 +304,7 @@ namespace TranslationPlugins {
controlClass = inputLine[CONTROL_CLASS_FIELD].Trim();
controlName = inputLine[CONTROL_NAME_FIELD].Trim();
if (string.IsNullOrEmpty(controlName))
- controlName = "__BOOGIE_DUMMY_CONTROLNAME_" + dummyControlNameIndex++;
+ controlName = BOOGIE_DUMMY_CONTROL + dummyControlNameIndex++;
enabled = inputLine[ENABLED_FIELD].Trim();
visibility = inputLine[VISIBILITY_FIELD].Trim();