diff --git a/uppsrc/CppBase/Parser.cpp b/uppsrc/CppBase/Parser.cpp index c1a3b8033..ea4ff41ec 100644 --- a/uppsrc/CppBase/Parser.cpp +++ b/uppsrc/CppBase/Parser.cpp @@ -1102,6 +1102,18 @@ Array Parser::Declaration(bool l0, bool more, const String& tname, } return r; } + const char *b = lex.Pos(); + if(Key(tk_using) && lex.IsId()) { + String name = lex.GetId(); + Key('='); + Array r; + Decl& d = r.Add(); + ReadType(d, tname, tparam); + d.name = name; + d.natural = String(b, lex.Pos()); + d.type_def = true; + return r; + } return Declaration0(l0, more, tname, tparam); } @@ -1420,7 +1432,8 @@ void Parser::Enum() bool Parser::UsingNamespace() { - if(Key(tk_using)) { + if(lex == tk_using && !(lex.IsId(1) && lex[2] == '=')) { + ++lex; if(Key(tk_namespace)) while(lex.IsId()) { Vector h = Split(context.namespace_using, ';'); @@ -1530,30 +1543,47 @@ void Parser::Do() else { String tnames; String tparam = TemplateParams(tnames); - if(!Scope(tparam, tnames)) { + if(lex == tk_using) { //C++11 template alias template <...> using ID = Array r = Declaration(true, true, tnames, tparam); - CppItem *functionItem = 0; - bool body = lex == '{'; for(int i = 0; i < r.GetCount(); i++) { - Decl& d = r[i]; - if(!d.isfriend && d.function) { - CppItem& m = Fn(d, "template " + tparam + ' ', body, tnames, tparam); - functionItem = &m; + Decla& d = r[i]; + if(d.type_def) { + String scope = context.scope; + ScopeCat(scope, d.name); + CppItem& im = Item(scope, context.namespace_using, "typedef", d.name); + im.natural = Purify(d.natural); + im.type = d.type; + im.access = context.access; + im.kind = TYPEDEF; } } - if(body && functionItem && whenFnEnd) { - symbolsOutsideFunctions.Merge( lex.FinishStatCollection() ); - lex.StartStatCollection(); // start collection of function symbols + } + else { + if(!Scope(tparam, tnames)) { + Array r = Declaration(true, true, tnames, tparam); + CppItem *functionItem = 0; + bool body = lex == '{'; + for(int i = 0; i < r.GetCount(); i++) { + Decl& d = r[i]; + if(!d.isfriend && d.function) { + CppItem& m = Fn(d, "template " + tparam + ' ', body, tnames, tparam); + functionItem = &m; + } + } + if(body && functionItem && whenFnEnd) { + symbolsOutsideFunctions.Merge( lex.FinishStatCollection() ); + lex.StartStatCollection(); // start collection of function symbols + } + EatBody(); + if(body && functionItem && whenFnEnd) { + whenFnEnd(FunctionStat(current_scope, *functionItem, + lex.FinishStatCollection(), maxScopeDepth)); + lex.StartStatCollection(); // start collection of orphan symbols + } + Key(';'); } EatBody(); - if(body && functionItem && whenFnEnd) { - whenFnEnd(FunctionStat(current_scope, *functionItem, - lex.FinishStatCollection(), maxScopeDepth)); - lex.StartStatCollection(); // start collection of orphan symbols - } - Key(';'); } - EatBody(); } } else diff --git a/uppsrc/ide/ide.lay b/uppsrc/ide/ide.lay index 60a725e33..475511f9d 100644 --- a/uppsrc/ide/ide.lay +++ b/uppsrc/ide/ide.lay @@ -53,21 +53,21 @@ LAYOUT(CustomLayout, 608, 410) ITEM(Button, exit, SetLabel(t_("Close")).RightPosZ(4, 80).BottomPosZ(4, 22)) END_LAYOUT -LAYOUT(RunLayout, 420, 172) +LAYOUT(RunLayout, 440, 172) ITEM(Label, dv___0, SetLabel(t_("&Program arguments:")).LeftPosZ(4, 112).TopPosZ(4, 19)) - ITEM(WithDropChoice, arg, HSizePosZ(120, 4).TopPosZ(4, 19)) + ITEM(WithDropChoice, arg, HSizePosZ(120, 8).TopPosZ(4, 19)) ITEM(Label, dv___2, SetLabel(t_("&Working directory:")).LeftPosZ(4, 112).TopPosZ(28, 19)) - ITEM(EditString, dir, HSizePosZ(120, 4).TopPosZ(28, 19)) + ITEM(EditString, dir, HSizePosZ(120, 8).TopPosZ(28, 19)) ITEM(Label, stdout_file_lbl, SetLabel(t_("STDOUT file:")).LeftPosZ(4, 112).TopPosZ(52, 19)) - ITEM(WithDropChoice, stdout_file, HSizePosZ(120, 4).TopPosZ(52, 19)) + ITEM(WithDropChoice, stdout_file, HSizePosZ(120, 8).TopPosZ(52, 19)) ITEM(Label, dv___6, SetLabel(t_("Standard output:")).LeftPosZ(4, 112).TopPosZ(76, 19)) - ITEM(Switch, runmode, SetLabel(t_("&Standalone\n&Console\n&File")).HSizePosZ(120, 104).TopPosZ(76, 19)) - ITEM(Option, external, SetLabel(t_("&External application")).HSizePosZ(120, 168).TopPosZ(96, 15)) - ITEM(Switch, consolemode, SetLabel(t_("Auto\nAlways\nNever")).HSizePosZ(120, 4).TopPosZ(116, 20)) - ITEM(Button, ok, SetLabel(t_("OK")).RightPosZ(72, 64).BottomPosZ(8, 24)) - ITEM(Button, cancel, SetLabel(t_("Cancel")).RightPosZ(4, 64).BottomPosZ(8, 24)) + ITEM(Switch, runmode, SetLabel(t_("&Standalone\n&Console\n&File")).HSizePosZ(120, 112).TopPosZ(76, 19)) + ITEM(Option, external, SetLabel(t_("&External application")).HSizePosZ(120, 112).TopPosZ(96, 15)) + ITEM(Switch, consolemode, SetLabel(t_("Auto\nAlways\nNever")).HSizePosZ(120, 24).TopPosZ(116, 20)) + ITEM(Button, ok, SetLabel(t_("OK")).RightPosZ(76, 64).BottomPosZ(8, 24)) + ITEM(Button, cancel, SetLabel(t_("Cancel")).RightPosZ(8, 64).BottomPosZ(8, 24)) ITEM(Label, console_lable, SetLabel(t_("Open console:")).LeftPosZ(4, 112).TopPosZ(116, 20)) - ITEM(Option, utf8, SetLabel(t_("Output is UTF-8")).LeftPosZ(316, 104).TopPosZ(76, 20)) + ITEM(Option, utf8, SetLabel(t_("Output is UTF-8")).LeftPosZ(328, 112).TopPosZ(76, 20)) END_LAYOUT LAYOUT(FindInFilesLayout, 568, 152)