Show
Ignore:
Timestamp:
07/26/07 20:06:38 (1 year ago)
Author:
KirkMcDonald
Message:

* Pyd now requires D 2.003 or later.
* Pyd now compiles with D 2.003.
* Resolved long-standing string-copying annoyance (thanks to const).

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/infrastructure/meta/Demangle.d

    r40 r120  
    2929 * Pretty-prints a mangled type string. 
    3030 */ 
    31 template demangleType(char[] str, MangledNameType wantQualifiedNames = MangledNameType.PrettyName) 
     31template demangleType(string str, MangledNameType wantQualifiedNames = MangledNameType.PrettyName) 
    3232{ 
    3333    static if (wantQualifiedNames != MangledNameType.PrettyName) { 
     
    7070// split these off because they're numerous and simple 
    7171// Note: For portability, could replace "v" with void.mangleof, etc. 
    72 template demangleBasicType(char [] str) 
     72template demangleBasicType(string str) 
    7373{ 
    7474         static if (str == "v") const char [] demangleBasicType = "void"; 
     
    106106} 
    107107 
    108 template demangleTypeConsumed(char [] str) 
     108template demangleTypeConsumed(string str) 
    109109{ 
    110110    static if (str[0]=='A') 
     
    132132 
    133133// For static arrays, count number of digits used (eg, return 3 for "674") 
    134 template countLeadingDigits(char [] str) 
     134template countLeadingDigits(string str) 
    135135{ 
    136136    static if (str.length>0 && beginsWithDigit!( str)) 
     
    147147// (this happens with templates, when the name being 'lengthed' is itself an Lname). 
    148148// We guard against this by ensuring that the L is less than the length of the string. 
    149 template getLname(char [] str) 
     149template getLname(string str) 
    150150{ 
    151151    static if (str.length <= 9+1 || !beginsWithDigit!(str[1..$]) ) 
     
    163163// Deal with the case where an Lname contains an embedded "__D". 
    164164// This can happen when classes, typedefs, etc are declared inside a function. 
    165 template pretty_Dname(char [] str, int dotnameconsumed, MangledNameType wantQualifiedNames) 
     165template pretty_Dname(string str, int dotnameconsumed, MangledNameType wantQualifiedNames) 
    166166{ 
    167167    static if ( isMangledFunction!( (str[2+dotnameconsumed]))) { 
     
    181181// Deal with the case where an Lname contains an embedded ("__D") function. 
    182182// Split into a seperate function because it's so complicated. 
    183 template pretty_Dfunction(char [] str, int dotnameconsumed, int paramlistconsumed, 
     183template pretty_Dfunction(string str, int dotnameconsumed, int paramlistconsumed, 
    184184    MangledNameType wantQualifiedNames) 
    185185{ 
     
    203203 
    204204// for an Lname that begins with "_D" 
    205 template get_DnameConsumed(char [] str) 
     205template get_DnameConsumed(string str) 
    206206{ 
    207207    const int get_DnameConsumed = 2 + getQualifiedNameConsumed!(str[2..$]) 
     
    210210 
    211211// If Lname is a template, shows it as a template 
    212 template prettyLname(char [] str, MangledNameType wantQualifiedNames) 
     212template prettyLname(string str, MangledNameType wantQualifiedNames) 
    213213{ 
    214214    static if (str.length>3 && str[0..3] == "__T") // Template instance name 
     
    231231// str must start with an lname: first chars give the length 
    232232// how many chars are taken up with length digits + the name itself 
    233 template getLnameConsumed(char [] str) 
     233template getLnameConsumed(string str) 
    234234{ 
    235235    static if (str.length==0) 
     
    245245} 
    246246 
    247 template getQualifiedName(char [] str, MangledNameType wantQualifiedNames, char [] dotstr = "") 
     247template getQualifiedName(string str, MangledNameType wantQualifiedNames, string dotstr = "") 
    248248{ 
    249249    static if (str.length==0) const char [] getQualifiedName=""; 
     
    269269} 
    270270 
    271 template getQualifiedNameConsumed (char [] str) 
     271template getQualifiedNameConsumed (string str) 
    272272{ 
    273273    static if ( str.length>1 &&  beginsWithDigit!(str) ) { 
     
    290290* or "function " or "delegate " 
    291291*/ 
    292 template demangleFunctionOrDelegate(char [] str, char [] funcOrDelegStr, MangledNameType wantQualifiedNames) 
     292template demangleFunctionOrDelegate(string str, string funcOrDelegStr, MangledNameType wantQualifiedNames) 
    293293{ 
    294294    const char [] demangleFunctionOrDelegate = demangleExtern!(( str[0] )) 
     
    301301// Special case: types that are in function parameters 
    302302// For function parameters, the type can also contain 'lazy', 'out' or 'inout'. 
    303 template demangleFunctionParamType(char[] str, MangledNameType wantQualifiedNames) 
     303template demangleFunctionParamType(string str, MangledNameType wantQualifiedNames) 
    304304{ 
    305305    static if (str[0]=='L') 
     
    313313 
    314314// Deal with 'out' and 'inout' parameters 
    315 template demangleFunctionParamTypeConsumed(char[] str) 
     315template demangleFunctionParamTypeConsumed(string str) 
    316316{ 
    317317    static if (str[0]=='K' || str[0]=='J' || str[0]=='L') 
     
    338338// Skip through the string until we find the return value. It can either be Z for normal 
    339339// functions, or Y for vararg functions. 
    340 template demangleReturnValue(char [] str, MangledNameType wantQualifiedNames) 
     340template demangleReturnValue(string str, MangledNameType wantQualifiedNames) 
    341341{ 
    342342    static assert(str.length>=1, "Demangle error(Function): No return value found"); 
     
    347347 
    348348// Stop when we get to the return value 
    349 template demangleParamList(char [] str, MangledNameType wantQualifiedNames, char[] commastr = "") 
     349template demangleParamList(string str, MangledNameType wantQualifiedNames, string commastr = "") 
    350350{ 
    351351    static if (str[0] == 'Z') 
     
    362362 
    363363// How many characters are used in the parameter list and return value 
    364 template demangleParamListAndRetValConsumed(char [] str) 
     364template demangleParamListAndRetValConsumed(string str) 
    365365{ 
    366366    static assert (str.length>0, "Demangle error(ParamList): No return value found"); 
     
    376376//              TEMPLATES 
    377377 
    378 template templateValueArgConsumed(char [] str) 
     378template templateValueArgConsumed(string str) 
    379379{ 
    380380    static if (str[0]=='n') const int templateValueArgConsumed = 1; 
     
    387387 
    388388// pretty-print a template value argument. 
    389 template prettyValueArg(char [] str) 
     389template prettyValueArg(string str) 
    390390{ 
    391391    static if (str[0]=='n') const char [] prettyValueArg = "null"; 
     
    398398 
    399399// Pretty-print a template argument 
    400 template prettyTemplateArg(char [] str, MangledNameType wantQualifiedNames) 
     400template prettyTemplateArg(string str, MangledNameType wantQualifiedNames) 
    401401{ 
    402402    static if (str[0]=='S') // symbol name 
     
    411411} 
    412412 
    413 template templateArgConsumed(char [] str) 
     413template templateArgConsumed(string str) 
    414414{ 
    415415    static if (str[0]=='S') // symbol name 
     
    425425// Like function parameter lists, template parameter lists also end in a Z, 
    426426// but they don't have a return value at the end. 
    427 template prettyTemplateArgList(char [] str, MangledNameType wantQualifiedNames, char [] commastr="") 
     427template prettyTemplateArgList(string str, MangledNameType wantQualifiedNames, string commastr="") 
    428428{ 
    429429    static if (str[0]=='Z') 
     
    435435} 
    436436 
    437 template templateArgListConsumed(char [] str) 
     437template templateArgListConsumed(string str) 
    438438{ 
    439439    static assert(str.length>0, "No Z found at end of template argument list"); 
     
    452452   * it allows us to avoid the ugly double parentheses. 
    453453   */ 
    454 template beginsWithDigit(char [] s) 
     454template beginsWithDigit(string s) 
    455455{ 
    456456  static if (s[0]>='0' && s[0]<='9')