static public Method

Internal.checkarg(argtype, typename)

There's no documentation for this item.

Source Code

# File qt/qtruby4.rb, line 2099
def Internal.checkarg(argtype, typename)
        puts "      #{typename} (#{argtype})" if debug_level >= DebugLevel::High
        if argtype == 'i'
                if typename =~ /^int&?$|^signed int&?$|^signed$|^qint32&?$|^quint32&?$/
                        return 2
                elsif typename =~ /^(?:short|ushort|unsigned short int|uchar|uint|long|ulong|unsigned long int|unsigned|float|double|WId|Q_PID|^quint16&?$|^qint16&?$)$/
                        return 1
                elsif typename =~ /^(quint|qint|qulong|qlong|qreal)/
                        return 1
                else 
                        t = typename.sub(/^const\s+/, '')
                        t.sub!(/[&*]$/, '')
                        if isEnum(t)
                                return 0
                        end
                end
        elsif argtype == 'n'
                if typename =~ /^double$|^qreal$/
                        return 2
                elsif typename =~ /^float$/
                        return 1
                elsif typename =~ /^int&?$/
                        return 0
                elsif typename =~ /^(?:short|ushort|uint|long|ulong|signed|unsigned|float|double)$/
                        return 0
                else 
                        t = typename.sub(/^const\s+/, '')
                        t.sub!(/[&*]$/, '')
                        if isEnum(t)
                                return 0
                        end
                end
        elsif argtype == 'B'
                if typename =~ /^(?:bool)[*&]?$/
                        return 0
                end
        elsif argtype == 's'
                if typename =~ /^(const )?((QChar)[*&]?)$/
                        return 1
                elsif typename =~ /^(?:u?char\*|const u?char\*|(?:const )?(Q(C?)String)[*&]?)$/
                        qstring = !$1.nil?
                        c = ("C" == $2)
                        return c ? 2 : (qstring ? 3 : 0)
                end
        elsif argtype == 'a'
                # FIXME: shouldn't be hardcoded. Installed handlers should tell what ruby type they expect.
                if typename =~ /^(?:
                                const\ QCOORD\*|
                                (?:const\ )?
                                (?:
                                    QStringList[\*&]?|
                                    QValueList<int>[\*&]?|
                                    QRgb\*|
                                    char\*\*
                                )
                                )$/x
                        return 0
                end
        elsif argtype == 'u'
                # Give nil matched against string types a higher score than anything else
                if typename =~ /^(?:u?char\*|const u?char\*|(?:const )?((Q(C?)String))[*&]?)$/
                        return 1
                # Numerics will give a runtime conversion error, so they fail the match
                elsif typename =~ /^(?:short|ushort|uint|long|ulong|signed|unsigned|int)$/
                        return -99
                else
                        return 0
                end
        elsif argtype == 'U'
                if typename =~ /QStringList/
                        return 1
                else
                        return 0
                end
        else
                t = typename.sub(/^const\s+/, '')
                t.sub!(/[&*]$/, '')
                if argtype == t
                        return 1
                elsif classIsa(argtype, t)
                        return 0
                elsif isEnum(argtype) and 
                                (t =~ /int|qint32|uint|quint32|long|ulong/ or isEnum(t))
                        return 0
                end
        end
        return -99
end
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.