Welcome to the "trac"-ing site of soap4r!
[soap4r] [httpclient] [openpgp4u] [pkcs1] [logger] [csv] [vtr]

Changeset 1791

Show
Ignore:
Timestamp:
05/20/07 17:57:20 (2 years ago)
Author:
nahi
Message:
  • let safeconstname check default Module.constants. closes #337.
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/xsd/codegen/gensupport.rb

    r1763 r1791  
    1111 
    1212# from the file 'keywords' in 1.9. 
    13 KEYWORD = {} 
     13KEYWORDS = {} 
    1414%w( 
    1515__LINE__ 
     
    5353while 
    5454yield 
    55 ).each { |k| KEYWORD[k] = nil } 
     55).each { |k| KEYWORDS[k] = nil } 
     56 
     57# from Module.constants from 1.8 & 1.9 
     58CONSTANTS = {} 
     59%w( 
     60ARGF 
     61ARGV 
     62ArgumentError 
     63Array 
     64BasicObject 
     65Bignum 
     66Binding 
     67Class 
     68Comparable 
     69Continuation 
     70Data 
     71Dir 
     72ENV 
     73EOFError 
     74Enumerable 
     75Errno 
     76Exception 
     77FALSE 
     78FalseClass 
     79File 
     80FileTest 
     81Fixnum 
     82Float 
     83FloatDomainError 
     84GC 
     85Hash 
     86IO 
     87IOError 
     88IndexError 
     89Integer 
     90Interrupt 
     91Kernel 
     92KeyError 
     93LoadError 
     94LocalJumpError 
     95Marshal 
     96MatchData 
     97MatchingData 
     98Math 
     99Method 
     100Module 
     101Mutex 
     102NIL 
     103NameError 
     104NilClass 
     105NoMemoryError 
     106NoMethodError 
     107NotImplementedError 
     108Numeric 
     109Object 
     110ObjectSpace 
     111PLATFORM 
     112Precision 
     113Proc 
     114Process 
     115RELEASE_DATE 
     116RUBY_PATCHLEVEL 
     117RUBY_PLATFORM 
     118RUBY_RELEASE_DATE 
     119RUBY_VERSION 
     120Range 
     121RangeError 
     122Regexp 
     123RegexpError 
     124RuntimeError 
     125STDERR 
     126STDIN 
     127STDOUT 
     128ScriptError 
     129SecurityError 
     130Signal 
     131SignalException 
     132StandardError 
     133String 
     134Struct 
     135Symbol 
     136SyntaxError 
     137SystemCallError 
     138SystemExit 
     139SystemStackError 
     140TOPLEVEL_BINDING 
     141TRUE 
     142Thread 
     143ThreadError 
     144ThreadGroup 
     145Time 
     146TrueClass 
     147TypeError 
     148UnboundMethod 
     149VERSION 
     150VM 
     151ZeroDivisionError 
     152).each { |c| CONSTANTS[c] = nil } 
     153 
    56154 
    57155module GenSupport 
     
    70168      GenSupport.capitalize(ele) 
    71169    }.join 
    72     if /\A[A-Z]/ !~ safename or keyword?(safename) 
     170    if /\A[A-Z]/ !~ safename or keyword?(safename) or constant?(safename) 
    73171      "C_#{safename}" 
    74172    else 
     
    117215 
    118216  def keyword?(word) 
    119     KEYWORD.key?(word) 
     217    KEYWORDS.key?(word) 
    120218  end 
    121219  module_function :keyword? 
     220 
     221  def constant?(word) 
     222    CONSTANTS.key?(word) 
     223  end 
     224  module_function :constant? 
    122225 
    123226  def format(str, indent = nil)