public string GetCode(int baseIndentDepth, CodeGenType codeGenType = CodeGenType.Parent) { var baseIndent = CodeGenHelpers.GetIndentString(baseIndentDepth); string scriptPrefix = ""; string scriptSuffix = ""; string blockvariableName = ""; var sb = new StringBuilder(); if (codeGenType == CodeGenType.Parent) // The parent needs to have a variable name { blockvariableName = this.Key; } string objectDescriptionComment = (this.ObjectDescription.Trim() == "") ? "" : " # " + this.ObjectDescription; sb.AppendLine(baseIndent + scriptPrefix + DscObjectType + " " + blockvariableName + objectDescriptionComment); sb.AppendLine(baseIndent + "{"); foreach (var a in this.Attributes) { sb.AppendLine(baseIndent + CodeGenHelpers.Indent + a.Code + a.Comment); } sb.Append(this.GetChildCode(baseIndentDepth + 1)); sb.AppendLine(baseIndent + "}" + scriptSuffix); return(sb.ToString()); }
public string GetCode(int baseIndentDepth, CodeGenType codeGenType = CodeGenType.Parent) { var baseIndent = CodeGenHelpers.GetIndentString(baseIndentDepth); string scriptPrefix = ""; string scriptSuffix = ""; string blockvariableName = ""; var sb = new StringBuilder(); if (codeGenType == CodeGenType.Parent) // The parent needs to have a variable name blockvariableName = this.Key; string objectDescriptionComment = (this.ObjectDescription.Trim() == "") ? "" : " # " + this.ObjectDescription; sb.AppendLine(baseIndent + scriptPrefix + DscObjectType + " " + blockvariableName + objectDescriptionComment); sb.AppendLine(baseIndent + "{"); foreach (var a in this.Attributes) { sb.AppendLine(baseIndent + CodeGenHelpers.Indent + a.Code + a.Comment); } sb.Append(this.GetChildCode(baseIndentDepth + 1)); sb.AppendLine(baseIndent + "}" + scriptSuffix); return sb.ToString(); }
public static CodeGenData Calculate(ParsedData parsedData, ExternStructInfo[] externStructs) { var typesMemInfo = new Dictionary <string, TypeMemoryInfo>(Primitives); foreach (var structInfo in externStructs) { DefaultValueInfo dvi; switch (structInfo.Kind) { case ExternStructInfo.StructKind.WithoutValues: dvi = DefaultValueInfo.WriteZeroes(); break; case ExternStructInfo.StructKind.WithEnumeratedValues: dvi = DefaultValueInfo.AssignTypeMember(structInfo.Values[0]); break; case ExternStructInfo.StructKind.PlainBuffersStruct: dvi = DefaultValueInfo.CallWriteDefaultMethod(); break; default: throw new ArgumentOutOfRangeException(); } typesMemInfo.Add(structInfo.Name, new TypeMemoryInfo(structInfo.Size, structInfo.Alignment, dvi)); } var codeGenTypes = new CodeGenType[parsedData.Types.Length]; for (var i = 0; i < parsedData.Types.Length; i++) { CodeGenType codeGenType; switch (parsedData.Types[i]) { case ParsedEnum pdEnum: codeGenType = HandleEnum(pdEnum, typesMemInfo); break; case ParsedArray pdArray: codeGenType = HandleArray(pdArray, typesMemInfo); break; case ParsedStruct pdStruct: codeGenType = HandleStruct(pdStruct, typesMemInfo); break; default: throw new Exception($"Unknown type variant {parsedData.Types[i].GetType().Name}"); } codeGenTypes[i] = codeGenType; } return(new CodeGenData(parsedData.Namespace, codeGenTypes)); }
public FrmWinFormGen(DbSchema dbSchema, CodeGenType codeGenType) { InitializeComponent(); lstCheckInputFileds.MouseEnter += ListMouseEnter; lstEditShowFileds.MouseEnter += ListMouseEnter; lstQueryFileds.MouseEnter += ListMouseEnter; lstShowFileds.MouseEnter += ListMouseEnter; m_dbSchema = dbSchema; m_codeGenType = codeGenType; SetVisible(); }
private DataTable GenTableByCheckColumns(CodeGenType genType) { DataTable dt = new DataTable(); switch (genType) { case CodeGenType.WinFromSimpleQuery: break; } return(dt); }
public FrmNestQuerySetting(DbSchema dbSchema, CodeGenType codeGenType) { InitializeComponent(); m_codeGenType = codeGenType; m_dbSchema = dbSchema; grdQuery.AutoGenerateColumns = false; if (codeGenType == CodeGenType.WinFromNestQuery) { cboNestType.SelectedIndex = 0; txtSql.Document.HighlightingStrategy = HighlightingStrategyFactory.CreateHighlightingStrategy("TSQL"); txtSql1.Document.HighlightingStrategy = HighlightingStrategyFactory.CreateHighlightingStrategy("TSQL"); txtSql2.Document.HighlightingStrategy = HighlightingStrategyFactory.CreateHighlightingStrategy("TSQL"); } }
// Methods used to generate types declaration // public static CodeGenType GetCodeGenType(TypeReference type) { if (_types.ContainsKey(type)) { return(_types[type]); // skip, type has already been emitted. } // Create and register type // CodeGenType td = new CodeGenType(type); _types[type] = td; return(td); }
private void EmitOpCodeStfld(FieldReference field) { Trace.Assert(field != null); Trace.Assert(_stack.Count >= 2); Trace.Assert(field.IsDefinition); CodeGenType ty = Cil2Llvm.GetCodeGenType(field.DeclaringType); FieldDefinition f = field as FieldDefinition; uint offset = ty.GetFieldOffset(f); LLVM.Value val = _stack.Pop(); LLVM.Value obj = ConvertToType(_stack.Pop(), ty.Type.GetPointerTo()); LLVM.Value ptr = _builder.CreateStructGEP(obj, offset, field.Name + " pointer"); _builder.CreateStore(val, ptr); }
private string CheckInput(CodeGenType mCodeGenType) { string strRetrunMsg = string.Empty; if (mCodeGenType == CodeGenType.WinFromNestQuery) { if (txtClassName.Text.Trim() == string.Empty) { txtClassName.Select(); return("请输入窗体类名"); } if (txtSql.Text.Trim() == string.Empty) { txtSql.Select(); return("请输入主表查询语句"); } if (txtKey.Text.Trim() == string.Empty) { txtKey.Select(); return("请输入关联键"); } if (txtSql1.Text.Trim() == string.Empty) { txtSql1.Select(); return("请输入子表查询语句"); } if (txtKey1.Text.Trim() == string.Empty) { txtKey.Select(); return("请输入主表关联键"); } if (cboNestType.Text == @"三层") { if (txtSql2.Text.Trim() == string.Empty) { txtSql2.Select(); return("请输入明细表查询语句"); } if (txtKey2.Text.Trim() == string.Empty) { txtKey.Select(); return("请输入子表关联键"); } } } return(strRetrunMsg); }
public FrmWinFormGen2(DbSchema dbSchema, CodeGenType codeGenType) { InitializeComponent(); lstCheckInputFileds.MouseEnter += ListMouseEnter; lstEditShowFileds.MouseEnter += ListMouseEnter; lstQueryFileds.MouseEnter += ListMouseEnter; lstShowFileds.MouseEnter += ListMouseEnter; lstDontRepeatFileds.MouseEnter += ListMouseEnter; if (codeGenType == CodeGenType.WinFromParentChildEditWithDialog) { lstCheckInputFiledsDetail.MouseEnter += ListMouseEnter; lstEditShowFiledsDetail.MouseEnter += ListMouseEnter; lstShowFiledsDetail.MouseEnter += ListMouseEnter; lstDontRepeatFiledsDetail.MouseEnter += ListMouseEnter; } m_dbSchema = dbSchema; m_codeGenType = codeGenType; SetVisible(); }
private void SetGlobal(BaseParameter baseParameter) { switch (baseParameter.CodeGenType) { #region WinFromSimpleQuery case CodeGenType.WinFromSimpleQuery: SimpleQueryParameter simpleQueryParameter = baseParameter as SimpleQueryParameter; if (simpleQueryParameter != null) { m_strQueryColumns = simpleQueryParameter.QueryColumns; m_strShowColumns = simpleQueryParameter.ShowColumns; m_databaseTable = simpleQueryParameter.DatabaseTable; m_codeGenType = simpleQueryParameter.CodeGenType; m_frameworkType = simpleQueryParameter.FrameworkType; m_uiStyle = simpleQueryParameter.UiStyle; m_listBindType = simpleQueryParameter.ListBindType; gridVEdit.Visible = false; tabPageEdit.Parent = null; tabPageEdit.Hide(); gridVShow.Visible = true; tabPageShow.Parent = tabControl1; tabPageShow.Show(); } break; #endregion #region WinFromEditWithDialog/WinFromTreeEditWithDialog case CodeGenType.WinFromEditWithDialog: case CodeGenType.WinFromTreeEditWithDialog: EditDialogParameter editDialogParameter = baseParameter as EditDialogParameter; if (editDialogParameter != null) { m_strQueryColumns = editDialogParameter.QueryColumns; m_strShowColumns = editDialogParameter.ShowColumns; m_databaseTable = editDialogParameter.DatabaseTable; m_codeGenType = editDialogParameter.CodeGenType; m_frameworkType = editDialogParameter.FrameworkType; m_uiStyle = editDialogParameter.UiStyle; m_listBindType = editDialogParameter.ListBindType; m_strEditColumns = editDialogParameter.EditColumns; m_strCheckInputColumns = editDialogParameter.CheckInputColumns; m_strDontRepeatColumns = editDialogParameter.DontRepeatColumns; gridVEdit.Visible = true; tabPageEdit.Parent = tabControl1; tabPageEdit.Show(); gridVShow.Visible = true; tabPageShow.Parent = tabControl1; tabPageShow.Show(); } break; #endregion #region WinFromNestQuery case CodeGenType.WinFromNestQuery: NestQueryParameter nestQueryParameter = baseParameter as NestQueryParameter; if (nestQueryParameter != null) { m_strQueryColumns = nestQueryParameter.QueryColumns; m_codeGenType = nestQueryParameter.CodeGenType; gridVEdit.Visible = false; tabPageShow.Parent = null; tabPageShow.Hide(); gridVShow.Visible = false; tabPageEdit.Parent = null; tabPageEdit.Hide(); } break; #endregion #region WinFromParentChildEditWithDialog case CodeGenType.WinFromParentChildEditWithDialog: ParentChildEditDialogParameter parentChildDialogParameter = baseParameter as ParentChildEditDialogParameter; if (parentChildDialogParameter != null) { m_databaseTable = parentChildDialogParameter.DatabaseTable; m_codeGenType = parentChildDialogParameter.CodeGenType; m_frameworkType = parentChildDialogParameter.FrameworkType; m_uiStyle = parentChildDialogParameter.UiStyle; m_listBindType = parentChildDialogParameter.ListBindType; m_strQueryColumns = parentChildDialogParameter.QueryColumns; m_strShowColumns = parentChildDialogParameter.ShowColumns; m_strEditColumns = parentChildDialogParameter.EditColumns; m_strCheckInputColumns = parentChildDialogParameter.CheckInputColumns; m_strDontRepeatColumns = parentChildDialogParameter.DontRepeatColumns; m_strShowColumnsDetail = parentChildDialogParameter.ShowColumnsDetail; m_strEditColumnsDetail = parentChildDialogParameter.EditColumnsDetail; m_strCheckInputColumnsDetail = parentChildDialogParameter.CheckInputColumnsDetail; m_strDontRepeatColumnsDetail = parentChildDialogParameter.DontRepeatColumnsDetail; m_databaseTableDetail = parentChildDialogParameter.DatabaseTableDetail; m_strKeyMaster = parentChildDialogParameter.KeyMaster; m_strKeyDetail = parentChildDialogParameter.KeyDetail; gridVEdit.Visible = true; tabPageEdit.Parent = tabControl1; tabPageEdit.Show(); gridVShow.Visible = true; tabPageShow.Parent = tabControl1; tabPageShow.Show(); } break; #endregion } if (baseParameter.CodeGenType != CodeGenType.WinFromParentChildEditWithDialog) { tabPageEditDetail.Parent = null; tabPageShowDetail.Parent = null; tabPageEditDetail.Hide(); tabPageShowDetail.Hide(); } else { tabPageEditDetail.Parent = tabControl1; tabPageShowDetail.Parent = tabControl1; tabPageEditDetail.Show(); tabPageShowDetail.Show(); } }
// Methods used to generate types declaration // public static CodeGenType GetCodeGenType(TypeReference type) { if (_types.ContainsKey(type)) { return _types[type]; // skip, type has already been emitted. } // Create and register type // CodeGenType td = new CodeGenType(type); _types[type] = td; return td; }