<commit_before># Copyright (c) 2010 The Mirah project authors. All Rights Reserved.
# All contributing project authors may be found in the NOTICE file.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

require 'mirah/jvm/source_generator/builder'

module Mirah::JavaSource
  class ClassBuilder
    def build_jsni_method(name, visibility, static, exceptions, type, *args)
      finish_declaration
      type ||= Mirah::AST.type(nil, :void)
      @methods << JsniMethodBuilder.new(self,
        :name => name,
        :visibility => visibility,
        :static => static,
        :return => type,
        :args => args,
        :exceptions => exceptions)
      @methods[-1]
    end
  end

  class JsniMethodBuilder < MethodBuilder
    include Helper

    attr_accessor :name, :type, :out

    def initialize(cls, options)
      super(cls, options)
    end

    # Based on superclass's method.
    def start
      print "public#{@static} native #{@typename} #{@name}("
      @args.each_with_index do |(type, name), i|
        print ', ' unless i == 0
        print "#{type.to_source} #{name}"
      end
      print ')'
      unless @exceptions.empty?
        print ' throws '
        @exceptions.each_with_index do |exception, i|
          print ', ' unless i == 0
          print exception.name
        end
      end
      puts ' /*-{'
    end

    # Based on superclass's method.
    def stop
      puts '}-*/;'
    end
  end
end

module Mirah::JVM::Compiler
  class Base
    # arg_types must be an Array
    def create_method_builder(name, node, static, exceptions, return_type, arg_types)
      unless node.class == Mirah::AST::JsniMethodDefinition
        @class.build_method(name.to_s, node.visibility, static,
          exceptions, return_type, *arg_types)
      else
        @class.build_jsni_method(name.to_s, node.visibility, static,
          exceptions, return_type, *arg_types)
      end<commit_msg>Call original create_method_builder in default case when patching the JVM compiler in the GWT plugin.<commit_after># Copyright (c) 2010 The Mirah project authors. All Rights Reserved.
# All contributing project authors may be found in the NOTICE file.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

require 'mirah/jvm/source_generator/builder'

module Mirah::JavaSource
  class ClassBuilder
    def build_jsni_method(name, visibility, static, exceptions, type, *args)
      finish_declaration
      type ||= Mirah::AST.type(nil, :void)
      @methods << JsniMethodBuilder.new(self,
        :name => name,
        :visibility => visibility,
        :static => static,
        :return => type,
        :args => args,
        :exceptions => exceptions)
      @methods[-1]
    end
  end

  class JsniMethodBuilder < MethodBuilder
    include Helper

    attr_accessor :name, :type, :out

    def initialize(cls, options)
      super(cls, options)
    end

    # Based on superclass's method.
    def start
      print "public#{@static} native #{@typename} #{@name}("
      @args.each_with_index do |(type, name), i|
        print ', ' unless i == 0
        print "#{type.to_source} #{name}"
      end
      print ')'
      unless @exceptions.empty?
        print ' throws '
        @exceptions.each_with_index do |exception, i|
          print ', ' unless i == 0
          print exception.name
        end
      end
      puts ' /*-{'
    end

    # Based on superclass's method.
    def stop
      puts '}-*/;'
    end
  end
end

module Mirah::JVM::Compiler
  class Base
    alias :original_create_method_builder :create_method_builder
    # arg_types must be an Array
    def create_method_builder(name, node, static, exceptions, return_type, arg_types)
      unless node.class == Mirah::AST::JsniMethodDefinition
        original_create_method_builder(name, node, static, exceptions, return_type, arg_types)
      else
        @class.build_jsni_method(name.to_s, node.visibility, static,
          exceptions, return_type, *arg_types)
      end
{'fraction_non_alphanumeric': 0.09452635831145223, 'fraction_numerical': 0.00444354675823066, 'mean_word_length': 2.899212598425197, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7114103', 'n_tokens_mistral': 1430, 'n_tokens_neox': 1405, 'n_words': 486}