/*
 * DO NOT EDIT! generated by embed_mruby_code.pl
 * Please refer to the respective source files for copyright information.
 */

/* lib/handler/mruby/embedded/core.rb */
#define H2O_MRUBY_CODE_CORE                                                                                                        \
    "module Kernel\n"                                                                                                              \
    "  def _h2o_define_callback(name, id)\n"                                                                                       \
    "    Kernel.define_method(name) do |*args|\n"                                                                                  \
    "      ret = Fiber.yield([ id, _h2o_create_resumer(), args ])\n"                                                               \
    "      if ret.kind_of? Exception\n"                                                                                            \
    "        raise ret\n"                                                                                                          \
    "      end\n"                                                                                                                  \
    "      ret\n"                                                                                                                  \
    "    end\n"                                                                                                                    \
    "  end\n"                                                                                                                      \
    "  def _h2o_create_resumer()\n"                                                                                                \
    "    me = Fiber.current\n"                                                                                                     \
    "    Proc.new do |v|\n"                                                                                                        \
    "    me.resume(v)\n"                                                                                                           \
    "    end\n"                                                                                                                    \
    "  end\n"                                                                                                                      \
    "  def _h2o_proc_each_to_array()\n"                                                                                            \
    "    Proc.new do |o|\n"                                                                                                        \
    "      a = []\n"                                                                                                               \
    "      o.each do |x|\n"                                                                                                        \
    "        a << x\n"                                                                                                             \
    "      end\n"                                                                                                                  \
    "      a\n"                                                                                                                    \
    "    end\n"                                                                                                                    \
    "  end\n"                                                                                                                      \
    "  def _h2o_proc_app_to_fiber()\n"                                                                                             \
    "    Proc.new do |app|\n"                                                                                                      \
    "      cached = nil\n"                                                                                                         \
    "      Proc.new do |req|\n"                                                                                                    \
    "        fiber = cached\n"                                                                                                     \
    "        cached = nil\n"                                                                                                       \
    "        if !fiber\n"                                                                                                          \
    "          fiber = Fiber.new do\n"                                                                                             \
    "            self_fiber = Fiber.current\n"                                                                                     \
    "            req = Fiber.yield\n"                                                                                              \
    "            while 1\n"                                                                                                        \
    "              begin\n"                                                                                                        \
    "                while 1\n"                                                                                                    \
    "                  resp = app.call(req)\n"                                                                                     \
    "                  cached = self_fiber\n"                                                                                      \
    "                  req = Fiber.yield(resp)\n"                                                                                  \
    "                end\n"                                                                                                        \
    "              rescue => e\n"                                                                                                  \
    "                cached = self_fiber\n"                                                                                        \
    "                req = Fiber.yield([-1, e])\n"                                                                                 \
    "              end\n"                                                                                                          \
    "            end\n"                                                                                                            \
    "          end\n"                                                                                                              \
    "          fiber.resume\n"                                                                                                     \
    "        end\n"                                                                                                                \
    "        fiber.resume(req)\n"                                                                                                  \
    "      end\n"                                                                                                                  \
    "    end\n"                                                                                                                    \
    "  end\n"                                                                                                                      \
    "end\n"

/* lib/handler/mruby/embedded/http_request.rb */
#define H2O_MRUBY_CODE_HTTP_REQUEST                                                                                                \
    "module H2O\n"                                                                                                                 \
    "  class HttpRequest\n"                                                                                                        \
    "    def join\n"                                                                                                               \
    "      if !@resp\n"                                                                                                            \
    "        @resp = _h2o__http_join_response(self)\n"                                                                             \
    "      end\n"                                                                                                                  \
    "      @resp\n"                                                                                                                \
    "    end\n"                                                                                                                    \
    "    def _set_response(resp)\n"                                                                                                \
    "      @resp = resp\n"                                                                                                         \
    "    end\n"                                                                                                                    \
    "  end\n"                                                                                                                      \
    "  class HttpInputStream\n"                                                                                                    \
    "    def each\n"                                                                                                               \
    "      while c = _h2o__http_fetch_chunk(self)\n"                                                                               \
    "        yield c\n"                                                                                                            \
    "      end\n"                                                                                                                  \
    "    end\n"                                                                                                                    \
    "    def join\n"                                                                                                               \
    "      s = \"\"\n"                                                                                                             \
    "      each do |c|\n"                                                                                                          \
    "        s << c\n"                                                                                                             \
    "      end\n"                                                                                                                  \
    "      s\n"                                                                                                                    \
    "    end\n"                                                                                                                    \
    "  end\n"                                                                                                                      \
    "end\n"

/* lib/handler/mruby/embedded/chunked.rb */
#define H2O_MRUBY_CODE_CHUNKED                                                                                                     \
    "module Kernel\n"                                                                                                              \
    "  def _h2o_chunked_proc_each_to_fiber()\n"                                                                                    \
    "    Proc.new do |src|\n"                                                                                                      \
    "      fiber = Fiber.new do\n"                                                                                                 \
    "        src.each do |chunk|\n"                                                                                                \
    "          _h2o_send_chunk(chunk)\n"                                                                                           \
    "        end\n"                                                                                                                \
    "        _h2o_send_chunk_eos()\n"                                                                                              \
    "      end\n"                                                                                                                  \
    "      fiber.resume\n"                                                                                                         \
    "    end\n"                                                                                                                    \
    "  end\n"                                                                                                                      \
    "end\n"
