static public Method

Internal.do_method_missing(package, method, klass, this, *args)

There's no documentation for this item.

Source Code

# File qt/qtruby4.rb, line 2217
def Internal.do_method_missing(package, method, klass, this, *args)
        if klass.class == Module
                classname = klass.name
        else
                classname = @@cpp_names[klass.name]
                if classname.nil?
                        if klass != Object and klass != Qt
                                return do_method_missing(package, method, klass.superclass, this, *args)
                        else
                                return nil
                        end
                end
        end

        if method == "new"
                method = classname.dup 
                method.gsub!(/^(QTextLayout|KParts|KIO|KNS|DOM|Kontact|Kate|KTextEditor|KConfigSkeleton::ItemEnum|KConfigSkeleton|KWin)::/,"")
        end
        method = "operator" + method.sub("@","") if method !~ /[a-zA-Z]+/
        # Change foobar= to setFoobar()                                      
        method = 'set' + method[0,1].upcase + method[1,method.length].sub("=", "") if method =~ /.*[^-+%\/|=]=$/ && method != 'operator='

        methods = []
        methods << method.dup
        args.each do |arg|
                if arg.nil?
                        # For each nil arg encountered, triple the number of munged method
                        # templates, in order to cover all possible types that can match nil
                        temp = []
                        methods.collect! do |meth| 
                                temp << meth + '?' 
                                temp << meth + '#'
                                meth << '$'
                        end
                        methods.concat(temp)
                elsif isObject(arg)
                        methods.collect! { |meth| meth << '#' }
                elsif arg.kind_of? Array or arg.kind_of? Hash
                        methods.collect! { |meth| meth << '?' }
                else
                        methods.collect! { |meth| meth << '$' }
                end
        end

        methodIds = []
        methods.collect { |meth| methodIds.concat( findMethod(classname, meth) ) }

        if method =~ /_/ && methodIds.length == 0
                # If the method name contains underscores, convert to camel case
                # form and try again
                method.gsub!(/(.)_(.)/) {$1 + $2.upcase}
                return do_method_missing(package, method, klass, this, *args)
        end

        if debug_level >= DebugLevel::High
                puts "classname    == #{classname}"
                puts ":: method == #{method}"
                puts "-> methodIds == #{methodIds.inspect}"
                puts "candidate list:"
                prototypes = dumpCandidates(methodIds).split("\n")
                line_len = (prototypes.collect { |p| p.length }).max
                prototypes.zip(methodIds) { 
                        |prototype,id| puts "#{prototype.ljust line_len}  (#{id})" 
                }
        end

        chosen = nil
        if methodIds.length > 0
                best_match = -1
                methodIds.each do
                        |id|
                        puts "matching => #{id}" if debug_level >= DebugLevel::High
                        current_match = 0
                        (0...args.length).each do
                                |i|
                                current_match += checkarg( getVALUEtype(args[i]), getTypeNameOfArg(id, i) )
                        end

                        # Note that if current_match > best_match, then chosen must be nil
                        if current_match > best_match
                                best_match = current_match
                                chosen = id
                        # Multiple matches are an error; the equality test below _cannot_ be commented out.
                        # If ambiguous matches occur the problem must be fixed be adjusting the relative
                        # ranking of the arg types involved in checkarg().
                        elsif current_match == best_match
                                chosen = nil
                        end
                        puts "match => #{id} score: #{current_match}" if debug_level >= DebugLevel::High
                end

                puts "Resolved to id: #{chosen}" if !chosen.nil? && debug_level >= DebugLevel::High
        end

        if debug_level >= DebugLevel::Minimal && chosen.nil? && method !~ /^operator/
                id = find_pclassid(normalize_classname(klass.name))
                hash = findAllMethods(id)
                constructor_names = nil
                if method == classname
                        puts "No matching constructor found, possibles:\n"
                        constructor_names = hash.keys.grep(/^#{classname}/)
                else
                        puts "Possible prototypes:"
                        constructor_names = hash.keys
                end
                method_ids = hash.values_at(*constructor_names).flatten
                puts dumpCandidates(method_ids)
        end

        puts "setCurrentMethod(#{chosen})" if debug_level >= DebugLevel::High
        setCurrentMethod(chosen) if chosen
        return nil
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.