summaryrefslogtreecommitdiff
path: root/ruby_1_8_6/lib/wsdl/soap/classDefCreator.rb
diff options
context:
space:
mode:
Diffstat (limited to 'ruby_1_8_6/lib/wsdl/soap/classDefCreator.rb')
-rw-r--r--ruby_1_8_6/lib/wsdl/soap/classDefCreator.rb314
1 files changed, 0 insertions, 314 deletions
diff --git a/ruby_1_8_6/lib/wsdl/soap/classDefCreator.rb b/ruby_1_8_6/lib/wsdl/soap/classDefCreator.rb
deleted file mode 100644
index aeb67c0613..0000000000
--- a/ruby_1_8_6/lib/wsdl/soap/classDefCreator.rb
+++ /dev/null
@@ -1,314 +0,0 @@
-# WSDL4R - Creating class definition from WSDL
-# Copyright (C) 2002, 2003, 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
-
-# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
-# redistribute it and/or modify it under the same terms of Ruby's license;
-# either the dual license version in 2003, or any later version.
-
-
-require 'wsdl/data'
-require 'wsdl/soap/classDefCreatorSupport'
-require 'xsd/codegen'
-
-
-module WSDL
-module SOAP
-
-
-class ClassDefCreator
- include ClassDefCreatorSupport
-
- def initialize(definitions)
- @elements = definitions.collect_elements
- @simpletypes = definitions.collect_simpletypes
- @complextypes = definitions.collect_complextypes
- @faulttypes = nil
- if definitions.respond_to?(:collect_faulttypes)
- @faulttypes = definitions.collect_faulttypes
- end
- end
-
- def dump(type = nil)
- result = "require 'xsd/qname'\n"
- if type
- result = dump_classdef(type.name, type)
- else
- str = dump_element
- unless str.empty?
- result << "\n" unless result.empty?
- result << str
- end
- str = dump_complextype
- unless str.empty?
- result << "\n" unless result.empty?
- result << str
- end
- str = dump_simpletype
- unless str.empty?
- result << "\n" unless result.empty?
- result << str
- end
- end
- result
- end
-
-private
-
- def dump_element
- @elements.collect { |ele|
- if ele.local_complextype
- dump_classdef(ele.name, ele.local_complextype,
- ele.elementform == 'qualified')
- elsif ele.local_simpletype
- dump_simpletypedef(ele.name, ele.local_simpletype)
- else
- nil
- end
- }.compact.join("\n")
- end
-
- def dump_simpletype
- @simpletypes.collect { |type|
- dump_simpletypedef(type.name, type)
- }.compact.join("\n")
- end
-
- def dump_complextype
- @complextypes.collect { |type|
- case type.compoundtype
- when :TYPE_STRUCT, :TYPE_EMPTY
- dump_classdef(type.name, type)
- when :TYPE_ARRAY
- dump_arraydef(type)
- when :TYPE_SIMPLE
- dump_simpleclassdef(type)
- when :TYPE_MAP
- # mapped as a general Hash
- nil
- else
- raise RuntimeError.new(
- "unknown kind of complexContent: #{type.compoundtype}")
- end
- }.compact.join("\n")
- end
-
- def dump_simpletypedef(qname, simpletype)
- if !simpletype.restriction or simpletype.restriction.enumeration.empty?
- return nil
- end
- c = XSD::CodeGen::ModuleDef.new(create_class_name(qname))
- c.comment = "#{qname}"
- const = {}
- simpletype.restriction.enumeration.each do |value|
- constname = safeconstname(value)
- const[constname] ||= 0
- if (const[constname] += 1) > 1
- constname += "_#{const[constname]}"
- end
- c.def_const(constname, ndq(value))
- end
- c.dump
- end
-
- def dump_simpleclassdef(type_or_element)
- qname = type_or_element.name
- base = create_class_name(type_or_element.simplecontent.base)
- c = XSD::CodeGen::ClassDef.new(create_class_name(qname), base)
- c.comment = "#{qname}"
- c.dump
- end
-
- def dump_classdef(qname, typedef, qualified = false)
- if @faulttypes and @faulttypes.index(qname)
- c = XSD::CodeGen::ClassDef.new(create_class_name(qname),
- '::StandardError')
- else
- c = XSD::CodeGen::ClassDef.new(create_class_name(qname))
- end
- c.comment = "#{qname}"
- c.def_classvar('schema_type', ndq(qname.name))
- c.def_classvar('schema_ns', ndq(qname.namespace))
- c.def_classvar('schema_qualified', dq('true')) if qualified
- schema_element = []
- init_lines = ''
- params = []
- typedef.each_element do |element|
- if element.type == XSD::AnyTypeName
- type = nil
- elsif klass = element_basetype(element)
- type = klass.name
- elsif element.type
- type = create_class_name(element.type)
- else
- type = nil # means anyType.
- # do we define a class for local complexType from it's name?
- # type = create_class_name(element.name)
- # <element>
- # <complexType>
- # <seq...>
- # </complexType>
- # </element>
- end
- name = name_element(element).name
- attrname = safemethodname?(name) ? name : safemethodname(name)
- varname = safevarname(name)
- c.def_attr(attrname, true, varname)
- init_lines << "@#{varname} = #{varname}\n"
- if element.map_as_array?
- params << "#{varname} = []"
- type << '[]' if type
- else
- params << "#{varname} = nil"
- end
- # nil means @@schema_ns + varname
- eleqname =
- (varname == name && element.name.namespace == qname.namespace) ?
- nil : element.name
- schema_element << [varname, eleqname, type]
- end
- unless typedef.attributes.empty?
- define_attribute(c, typedef.attributes)
- init_lines << "@__xmlattr = {}\n"
- end
- c.def_classvar('schema_element',
- '[' +
- schema_element.collect { |varname, name, type|
- '[' +
- (
- if name
- varname.dump + ', [' + ndq(type) + ', ' + dqname(name) + ']'
- else
- varname.dump + ', ' + ndq(type)
- end
- ) +
- ']'
- }.join(', ') +
- ']'
- )
- c.def_method('initialize', *params) do
- init_lines
- end
- c.dump
- end
-
- def element_basetype(ele)
- if klass = basetype_class(ele.type)
- klass
- elsif ele.local_simpletype
- basetype_class(ele.local_simpletype.base)
- else
- nil
- end
- end
-
- def attribute_basetype(attr)
- if klass = basetype_class(attr.type)
- klass
- elsif attr.local_simpletype
- basetype_class(attr.local_simpletype.base)
- else
- nil
- end
- end
-
- def basetype_class(type)
- return nil if type.nil?
- if simpletype = @simpletypes[type]
- basetype_mapped_class(simpletype.base)
- else
- basetype_mapped_class(type)
- end
- end
-
- def define_attribute(c, attributes)
- schema_attribute = []
- attributes.each do |attribute|
- name = name_attribute(attribute)
- if klass = attribute_basetype(attribute)
- type = klass.name
- else
- type = nil
- end
- methodname = safemethodname('xmlattr_' + name.name)
- c.def_method(methodname) do <<-__EOD__
- (@__xmlattr ||= {})[#{dqname(name)}]
- __EOD__
- end
- c.def_method(methodname + '=', 'value') do <<-__EOD__
- (@__xmlattr ||= {})[#{dqname(name)}] = value
- __EOD__
- end
- schema_attribute << [name, type]
- end
- c.def_classvar('schema_attribute',
- '{' +
- schema_attribute.collect { |name, type|
- dqname(name) + ' => ' + ndq(type)
- }.join(', ') +
- '}'
- )
- end
-
- def name_element(element)
- return element.name if element.name
- return element.ref if element.ref
- raise RuntimeError.new("cannot define name of #{element}")
- end
-
- def name_attribute(attribute)
- return attribute.name if attribute.name
- return attribute.ref if attribute.ref
- raise RuntimeError.new("cannot define name of #{attribute}")
- end
-
- DEFAULT_ITEM_NAME = XSD::QName.new(nil, 'item')
-
- def dump_arraydef(complextype)
- qname = complextype.name
- c = XSD::CodeGen::ClassDef.new(create_class_name(qname), '::Array')
- c.comment = "#{qname}"
- child_type = complextype.child_type
- c.def_classvar('schema_type', ndq(child_type.name))
- c.def_classvar('schema_ns', ndq(child_type.namespace))
- child_element = complextype.find_aryelement
- schema_element = []
- if child_type == XSD::AnyTypeName
- type = nil
- elsif child_element and (klass = element_basetype(child_element))
- type = klass.name
- elsif child_type
- type = create_class_name(child_type)
- else
- type = nil
- end
- if child_element
- if child_element.map_as_array?
- type << '[]' if type
- end
- child_element_name = child_element.name
- else
- child_element_name = DEFAULT_ITEM_NAME
- end
- schema_element << [child_element_name.name, child_element_name, type]
- c.def_classvar('schema_element',
- '[' +
- schema_element.collect { |varname, name, type|
- '[' +
- (
- if name
- varname.dump + ', [' + ndq(type) + ', ' + dqname(name) + ']'
- else
- varname.dump + ', ' + ndq(type)
- end
- ) +
- ']'
- }.join(', ') +
- ']'
- )
- c.dump
- end
-end
-
-
-end
-end
lass='add'>+!if defined(icondirs)
+icondirs=$(icondirs:\=/)
+iconinc=-I$(icondirs: = -I)
+!endif
+###############
+
+VPATH = $(srcdir);$(srcdir)/missing;$(srcdir)/wince
+.SUFFIXES: .y .def .lib
+
+!if !defined(CC)
+CC = cl
+!endif
+!if !defined(CPP) || "$(CPP)" == "cl"
+CPP = $(CC) -E
+!endif
+!if !defined(YACC)
+YACC = byacc
+!endif
+AR = lib -nologo
+PURIFY =
+AUTOCONF = autoconf
+RM = $(srcdir)\win32\rm.bat
+
+!if !defined(PROCESSOR_ARCHITECTURE)
+PROCESSOR_ARCHITECTURE = x86
+!endif
+MACHINE = $(PROCESSOR_ARCHITECTURE)
+!if "$(PROCESSOR_ARCHITECTURE)" == "x86"
+!if !defined(PROCESSOR_LEVEL)
+PROCESSOR_LEVEL = 5
+!endif
+!if 6 < $(PROCESSOR_LEVEL)
+PROCESSOR_LEVEL = 6
+!endif
+PROCESSOR_FLAG = -G$(PROCESSOR_LEVEL)
+CPU = i$(PROCESSOR_LEVEL)86
+ARCH = i386
+!else
+CPU = $(PROCESSOR_ARCHITECTURE)
+ARCH = $(PROCESSOR_ARCHITECTURE)
+!endif
+!if !defined(DEBUGFLAGS)
+DEBUGFLAGS = -Zi
+!endif
+!if !defined(OPTFLAGS)
+OPTFLAGS = -w -O2b2xg-
+!endif
+!if !defined(OS) || !defined(RT)
+OS = mswince
+RT = $(OS)
+!endif
+
+!ifndef RUBY_SO_NAME
+RUBY_SO_NAME = $(RT)-$(RUBY_INSTALL_NAME)$(MAJOR)$(MINOR)
+!endif
+!ifndef RUBY_PLATFORM
+RUBY_PLATFORM = $(ARCH)-$(OS)
+!endif
+
+!if !defined(prefix)
+prefix = /usr
+!endif
+!if !defined(exec_prefix)
+exec_prefix = $(prefix)
+!endif
+!if !defined(libdir)
+libdir = $(exec_prefix)/lib
+!endif
+!if !defined(datadir)
+datadir = /share
+!endif
+!ifndef EXTOUT
+EXTOUT = .ext
+!endif
+!ifndef RIDATADIR
+RIDATADIR = $(DESTDIR)$(datadir)/ri/$(MAJOR).$(MINOR)/system
+!endif
+!ifndef RDOCTARGET
+RDOCTARGET = install-doc
+!endif
+
+OUTFLAG = -Fe
+!if !defined(CFLAGS)
+CFLAGS = $(DEBUGFLAGS) $(OPTFLAGS) $(PROCESSOR_FLAG)
+!endif
+!if !defined(CPPFLAGS)
+CPPFLAGS = $(CECPUDEF) -DUNDER_CE -D_WIN32_WCE=$(SUBSYSVERSION:.=) \
+ -DFILENAME_MAX=MAX_PATH -DTLS_OUT_OF_INDEXES=0xFFFFFFFF \
+ -DBUFSIZ=512 -D_UNICODE -DUNICODE
+!endif
+!if !defined(LDFLAGS)
+LDFLAGS = -link -incremental:yes -pdb:none -machine:$(MACHINE) -subsystem:$(SUBSYSTEM)
+!endif
+!if !defined(XLDFLAGS)
+XLDFLAGS = -stack:$(STACK) -subsystem:$(SUBSYSTEM)
+!endif
+!if !defined(RFLAGS)
+RFLAGS = -r
+!endif
+!if !defined(EXTLIBS)
+EXTLIBS =
+!endif
+LIBS = coredll.lib ceshell.lib winsock.lib $(EXTLIBS)
+MISSING = acosh.obj crypt.obj dup2.obj erf.obj hypot.obj \
+ isinf.obj isnan.obj strftime.obj win32.obj \
+ assert.obj direct.obj errno.obj io_wce.obj process_wce.obj \
+ signal_wce.obj stdio.obj stdlib.obj string_wce.obj \
+ time_wce.obj wince.obj winsock2.obj \
+ stat.obj timeb.obj utime.obj
+
+ARFLAGS = -machine:$(MACHINE) -out:
+CC = $(CC) -nologo
+LD = $(CC)
+LDSHARED = $(LD) -LD
+XCFLAGS = -DRUBY_EXPORT -I. -I$(srcdir) -I$(srcdir)/missing -I$(srcdir)/wince
+DLDFLAGS = $(LDFLAGS) -dll
+SOLIBS =
+
+LIBRUBY_LDSHARED = $(LDSHARED)
+LIBRUBY_DLDFLAGS = $(EXTLDFLAGS) -def:$(RUBYDEF)
+
+EXEEXT = .exe
+PROGRAM=$(RUBY_INSTALL_NAME)$(EXEEXT)
+RUBYDEF = $(RUBY_SO_NAME).def
+MINIRUBY = $(RUBY) -I$(MAKEDIR) -rfake
+RUNRUBY = $(MINIRUBY) "$(srcdir)/runruby.rb" --extout="$(EXTOUT)" --
+!ifndef RUBY
+RUBY = ruby
+!endif
+
+!if !defined(STACK)
+STACK = 0x200000,0x10000
+!endif
+ORGLIBPATH = $(LIB)
+
+#### End of system configuration section. ####
+
+LIBRUBY_A = $(RUBY_SO_NAME)-static.lib
+LIBRUBY_SO = $(RUBY_SO_NAME).dll
+LIBRUBY = $(RUBY_SO_NAME).lib
+LIBRUBYARG = $(LIBRUBY)
+
+PREP = fake.rb
+
+!if !defined(EXTSTATIC)
+EXTSTATIC =
+!endif
+
+OBJEXT = obj
+
+INSTALLED_LIST= .installed.list
+
+WINMAINOBJ = wincemain.$(OBJEXT)
+
+all: $(srcdir)/wince/Makefile.sub $(srcdir)/common.mk
+ruby: $(PROGRAM)
+
+CONFIG_H = ./.config.h.time
+
+config: config.status
+
+config.status: $(CONFIG_H)
+
+BANG = !
+
+!if exist(config.h)
+!include config.h
+!endif
+
+$(CONFIG_H): $(MKFILES) $(srcdir)/wince/Makefile.sub
+ @echo Creating config.h
+ @$(srcdir:/=\)\win32\ifchange.bat config.h <<
+#define STDC_HEADERS 1
+#define HAVE_SYS_TYPES_H 1
+#define HAVE_SYS_STAT_H 1
+#define HAVE_STDLIB_H 1
+#define HAVE_STRING_H 1
+#define HAVE_MEMORY_H 1
+#define HAVE_OFF_T 1
+#define SIZEOF_INT 4
+#define SIZEOF_SHORT 2
+#define SIZEOF_LONG 4
+#define SIZEOF_LONG_LONG 0
+#define SIZEOF___INT64 8
+#define SIZEOF_OFF_T 4
+#define SIZEOF_VOIDP 4
+#define SIZEOF_FLOAT 4
+#define SIZEOF_DOUBLE 8
+#define SIZEOF_TIME_T 4
+#define HAVE_PROTOTYPES 1
+#define TOKEN_PASTE(x,y) x##y
+#define HAVE_STDARG_PROTOTYPES 1
+!if $(MSC_VER) > 1100
+#define NORETURN(x) __declspec(noreturn) x
+!endif
+#define RUBY_EXTERN extern __declspec(dllimport)
+#define HAVE_DECL_SYS_NERR 1
+#define HAVE_FCNTL_H 1
+#define HAVE_SYS_UTIME_H 1
+#define HAVE_FLOAT_H 1
+#define rb_uid_t int
+#define rb_gid_t int
+#define rb_pid_t int
+#define HAVE_STRUCT_STAT_ST_RDEV 1
+#define HAVE_ST_RDEV 1
+#define GETGROUPS_T int
+#define RETSIGTYPE void
+#define HAVE_MEMCMP 1
+#define HAVE_MEMMOVE 1
+#define HAVE_MKDIR 1
+#define HAVE_STRCASECMP 1
+#define HAVE_STRNCASECMP 1
+#define HAVE_STRERROR 1
+#define HAVE_STRFTIME 1
+#define HAVE_STRCHR 1
+#define HAVE_STRSTR 1
+#define HAVE_STRTOD 1
+#define HAVE_STRTOL 1
+#define HAVE_STRTOUL 1
+#define HAVE_FLOCK 1
+#define HAVE_VSNPRINTF 1
+#define HAVE_FINITE 1
+#define HAVE_HYPOT 1
+#define HAVE_FMOD 1
+#define HAVE_FREXP 1
+#define HAVE_MODF 1
+#define HAVE_WAITPID 1
+#define HAVE_GETCWD 1
+#define HAVE_CHSIZE 0
+#define HAVE_TIMES 1
+#define HAVE_FCNTL 1
+#define HAVE_TELLDIR 1
+#define HAVE_SEEKDIR 1
+#define HAVE_MKTIME 1
+#define HAVE_COSH 1
+#define HAVE_SINH 1
+#define HAVE_TANH 1
+#define HAVE_TZNAME 1
+#define HAVE_DAYLIGHT 1
+#define SETPGRP_VOID 1
+#define RSHIFT(x,y) ((x)>>(int)y)
+#define inline __inline
+#define NEED_IO_SEEK_BETWEEN_RW 1
+#define DEFAULT_KCODE KCODE_NONE
+#define DLEXT ".so"
+#define RUBY_LIB "/lib/ruby/$(MAJOR).$(MINOR)"
+#define RUBY_SITE_LIB "/lib/ruby/site_ruby"
+#define RUBY_SITE_LIB2 "/lib/ruby/site_ruby/$(MAJOR).$(MINOR)"
+#define RUBY_PLATFORM "$(ARCH)-$(OS)"
+#define RUBY_ARCHLIB "/lib/ruby/$(MAJOR).$(MINOR)/$(ARCH)-$(OS)"
+#define RUBY_SITE_ARCHLIB "/lib/ruby/site_ruby/$(MAJOR).$(MINOR)/$(ARCH)-$(RT)"
+#define LIBRUBY_SO "$(LIBRUBY_SO)"
+#if 0
+$(BANG)if "$(RUBY_SO_NAME)"!="$$(RUBY_SO_NAME)" || "$(ARCH)-$(OS)"!="$$(ARCH)-$$(OS)"
+config.h: nul
+$(BANG)endif
+#endif
+#define GC_MALLOC_LIMIT 4000000
+#define stricmp _stricmp
+#define fopen wce_fopen
+#define open _open
+#define read _read
+#define write _write
+#define lseek _lseek
+
+#if _WIN32_WCE < 300
+ #define isascii(c) ( (c>=0x00&&c<=0x7f)?1:0 )
+ #define isspace(c) ( ((c>=0x09&&c<=0x0d)||c==0x20)?1:0 )
+ #define isdigit(c) ( (c>=0x30&&c<=0x39)?1:0 )
+ #define isupper(c) ( (c>='A'&&c<='Z')?1:0 )
+ #define isalpha(c) ( ((c>='A'&&c<='Z')||(c>='a'&&c<='z'))?1:0 )
+ #define isprint(c) ( (c>=0x20&&c<=0x7e)?1:0 )
+ #define isalnum(c) ( (isalpha(c)||isdigit(c))?1:0 )
+ #define iscntrl(c) ( ((c>=0x00&&c<=0x1f)||c==0x7f)?1:0 )
+ #define islower(c) ( (c>='a'&&c<='z')?1:0 )
+ #define ispunct(c) ( !(isalnum(c)||isspace(c))?1:0 )
+ #define isxdigit(c) ( ((c>=0&&c<=9)||(c>='A'&&c<='F')||(c>='a'&&c<='f'))?1:0 )
+#endif
+<<
+ @exit > $(@:/=\)
+
+config.status: $(MKFILES) $(srcdir)/wince/Makefile.sub $(srcdir)/common.mk
+ @echo Creating $@
+ @exit <<$@
+# Generated automatically by Makefile.sub.
+s,@SHELL@,$$(COMSPEC),;t t
+s,@BUILD_FILE_SEPARATOR@,\,;t t
+s,@PATH_SEPARATOR@,;,;t t
+s,@CFLAGS@,$(CFLAGS),;t t
+s,@CPPFLAGS@,$(CPPFLAGS),;t t
+s,@CXXFLAGS@,$(CXXFLAGS),;t t
+s,@FFLAGS@,$(FFLAGS),;t t
+s,@LDFLAGS@,,;t t
+s,@LIBS@,$(LIBS),;t t
+s,@exec_prefix@,$${prefix},;t t
+s,@prefix@,,;t t
+s,@program_transform_name@,s,,,,;t t
+s,@bindir@,$${exec_prefix}/bin,;t t
+s,@sbindir@,$${exec_prefix}/sbin,;t t
+s,@libexecdir@,$${exec_prefix}/libexec,;t t
+s,@datadir@,$${prefix}/share,;t t
+s,@sysconfdir@,$${prefix}/etc,;t t
+s,@sharedstatedir@,/etc,;t t
+s,@localstatedir@,/var,;t t
+s,@libdir@,$${exec_prefix}/lib,;t t
+s,@includedir@,$${prefix}/include,;t t
+s,@oldincludedir@,/usr/include,;t t
+s,@infodir@,$${prefix}/info,;t t
+s,@mandir@,$${prefix}/man,;t t
+s,@build@,$(CPU)-pc-$(OS),;t t
+s,@build_alias@,$(CPU)-$(OS),;t t
+s,@build_cpu@,$(CPU),;t t
+s,@build_vendor@,pc,;t t
+s,@build_os@,$(OS),;t t
+s,@host@,$(CPU)-pc-$(OS),;t t
+s,@host_alias@,$(CPU)-$(OS),;t t
+s,@host_cpu@,$(CPU),;t t
+s,@host_vendor@,pc,;t t
+s,@host_os@,$(OS),;t t
+s,@target@,$(ARCH)-pc-$(OS),;t t
+s,@target_alias@,$(ARCH)-$(OS),;t t
+s,@target_cpu@,$(ARCH),;t t
+s,@target_vendor@,pc,;t t
+s,@target_os@,$(OS),;t t
+s,@CC@,$(CC),;t t
+s,@CPP@,$(CPP),;t t
+s,@YACC@,$(YACC),;t t
+s,@RANLIB@,,;t t
+s,@AR@,$(AR),;t t
+s,@ARFLAGS@,$(ARFLAGS),;t t
+s,@LN_S@,$(LN_S),;t t
+s,@SET_MAKE@,$(SET_MAKE),;t t
+s,@CP@,copy > nul,;t t
+s,@LIBOBJS@, acosh.obj crypt.obj erf.obj win32.obj isinf.obj isnan.obj,;t t
+s,@ALLOCA@,$(ALLOCA),;t t
+s,@DEFAULT_KCODE@,$(DEFAULT_KCODE),;t t
+s,@EXEEXT@,.exe,;t t
+s,@OBJEXT@,$(OBJEXT),;t t
+s,@XCFLAGS@,$(XCFLAGS),;t t
+s,@XLDFLAGS@,$(XLDFLAGS),;t t
+s,@DLDFLAGS@,$(DLDFLAGS) $$(LIBPATH) -def:$$(DEFFILE) -implib:$$(*F:.so=)-$$(arch).lib -pdb:$$(*F:.so=)-$$(arch).pdb,;t t
+s,@ARCH_FLAG@,$(ARCH_FLAG),;t t
+s,@STATIC@,$(STATIC),;t t
+s,@CCDLFLAGS@,,;t t
+s,@LDSHARED@,$(LDSHARED),;t t
+s,@DLEXT@,so,;t t
+s,@LIBEXT@,lib,;t t
+s,@STRIP@,$(STRIP),;t t
+s,@EXTSTATIC@,$(EXTSTATIC),;t t
+s,@setup@,Setup,;t t
+s,@MINIRUBY@,$(MINIRUBY),;t t
+s,@PREP@,miniruby$(EXEEXT),;t t
+s,@RUNRUBY@,$(RUNRUBY),;t t
+s,@EXTOUT@,$(EXTOUT),;t t
+s,@ARCHFILE@,,;t t
+s,@RDOCTARGET@,,;t t
+s,@LIBRUBY_LDSHARED@,$(LIBRUBY_LDSHARED),;t t
+s,@LIBRUBY_DLDFLAGS@,$(LIBRUBY_DLDFLAGS),;t t
+s,@RUBY_INSTALL_NAME@,$(RUBY_INSTALL_NAME),;t t
+s,@rubyw_install_name@,$(RUBYW_INSTALL_NAME),;t t
+s,@RUBYW_INSTALL_NAME@,$(RUBYW_INSTALL_NAME),;t t
+s,@RUBY_SO_NAME@,$(RUBY_SO_NAME),;t t
+s,@LIBRUBY_A@,$$(RUBY_SO_NAME)-static.lib,;t t
+s,@LIBRUBY_SO@,$$(RUBY_SO_NAME).dll,;t t
+s,@LIBRUBY_ALIASES@,$(LIBRUBY_ALIASES),;t t
+s,@LIBRUBY@,$$(RUBY_SO_NAME).lib,;t t
+s,@LIBRUBYARG@,$$(LIBRUBYARG_SHARED),;t t
+s,@LIBRUBYARG_STATIC@,$$(LIBRUBY_A),;t t
+s,@LIBRUBYARG_SHARED@,$$(LIBRUBY),;t t
+s,@SOLIBS@,$(SOLIBS),;t t
+s,@DLDLIBS@,$(DLDLIBS),;t t
+s,@ENABLE_SHARED@,yes,;t t
+s,@OUTFLAG@,$(OUTFLAG),;t t
+s,@CPPOUTFILE@,-P,;t t
+s,@LIBPATHFLAG@, -libpath:"%s",;t t
+s,@RPATHFLAG@,,;t t
+s,@LIBARG@,%s.lib,;t t
+s,@LINK_SO@,$$(LDSHARED) -Fe$$(@) $$(OBJS) $$(LIBS) $$(LOCAL_LIBS) $$(DLDFLAGS),;t t
+s,@COMPILE_C@,$$(CC) $$(INCFLAGS) $$(CFLAGS) $$(CPPFLAGS) -c -Tc$$(<:\=/),;t t
+s,@COMPILE_CXX@,$$(CXX) $$(INCFLAGS) $$(CXXFLAGS) $$(CPPFLAGS) -c -Tp$$(<:\=/),;t t
+s,@COMPILE_RULES@,{$$(srcdir)}.%s{}.%s: {$$(topdir)}.%s{}.%s: {$$(hdrdir)}.%s{}.%s: .%s.%s:,;t t
+s,@RULE_SUBST@,{.;$$(srcdir);$$(topdir);$$(hdrdir)}%s,;t t
+s,@TRY_LINK@,$$(CC) -Feconftest $$(INCFLAGS) -I$$(hdrdir) $$(CPPFLAGS) $$(CFLAGS) $$(src) $$(LOCAL_LIBS) $$(LIBS) -link $$(LDFLAGS) $$(LIBPATH) $$(XLDFLAGS),;t t
+s,@COMMON_LIBS@,coredll winsock,;t t
+s,@COMMON_MACROS@,WIN32_LEAN_AND_MEAN,;t t
+s,@COMMON_HEADERS@,winsock.h windows.h,;t t
+s,@EXPORT_PREFIX@, ,;t t
+s,@arch@,$(ARCH)-$(OS),;t t
+s,@sitearch@,$(ARCH)-$(RT),;t t
+s,@sitedir@,$${prefix}/lib/ruby/site_ruby,;t t
+s,@configure_args@,--with-make-prog=nmake --enable-shared $(configure_args),;t t
+s,@configure_input@,$$configure_input,;t t
+s,@srcdir@,$(srcdir),;t t
+s,@top_srcdir@,$(srcdir),;t t
+<<KEEP
+
+$(PROGRAM): $(MAINOBJ) $(WINMAINOBJ) $(LIBRUBY_SO) $*.res
+ $(PURIFY) $(CC) $(MAINOBJ) $(WINMAINOBJ) $*.res \
+ -Fe$@ $(LIBRUBYARG) $(LDFLAGS) $(XLDFLAGS)
+
+$(LIBRUBY_A): $(OBJS) $(DMYEXT)
+ $(AR) $(ARFLAGS)$@ $(OBJS) $(DMYEXT)
+
+$(LIBRUBY): $(RUBYDEF)
+ $(AR) $(ARFLAGS)$@ -def:$(RUBYDEF)
+
+$(LIBRUBY_SO): $(LIBRUBY_A) $(DLDOBJS) $(RUBYDEF) $(RUBY_SO_NAME).res
+ @echo. $(DLDOBJS)
+ @-$(PRE_LIBRUBY_UPDATE)
+ $(LDSHARED) $(MAINOBJ) $(DLDOBJS) $(LIBRUBY_A) \
+ $(RUBY_SO_NAME).res $(LIBS) -Fe$@ $(LDFLAGS) \
+ $(LIBRUBY_DLDFLAGS)
+
+$(RUBYDEF): $(LIBRUBY_A) $(PREP)
+ $(MINIRUBY) $(srcdir)/win32/mkexports.rb \
+ -output=$@ -arch=$(ARCH) $(LIBRUBY_A)
+
+{$(srcdir)/wince}.def.lib:
+ $(AR) $(ARFLAGS)$@ -def:$<
+
+clean-local::
+ @$(RM) ext\extinit.c ext\extinit.$(OBJEXT) ext\vc*.pdb
+ @$(RM) $(RUBY_INSTALL_NAME).res $(RUBYW_INSTALL_NAME).res $(RUBY_SO_NAME).res
+
+distclean-local::
+ @$(RM) ext\config.cache $(RBCONFIG:/=\)
+ @$(RM) *.map *.pdb *.ilk *.exp $(RUBYDEF)
+ @$(RM) $(RUBY_INSTALL_NAME).rc $(RUBYW_INSTALL_NAME).rc $(RUBY_SO_NAME).rc
+
+$(RUBY_INSTALL_NAME).rc $(RUBYW_INSTALL_NAME).rc $(RUBY_SO_NAME).rc: $(RBCONFIG)
+ @$(MINIRUBY) $(srcdir)/win32/resource.rb \
+ -ruby_name=$(RUBY_INSTALL_NAME) \
+ -rubyw_name=$(RUBYW_INSTALL_NAME) \
+ -so_name=$(RUBY_SO_NAME) \
+ -wce_ver=$(SUBSYSVERSION) \
+ . $(icondirs) $(srcdir)/wince
+
+fake.rb: $(MKFILES)
+ @echo Creating <<$@
+class Object
+ CROSS_COMPILING = RUBY_PLATFORM
+ remove_const :RUBY_PLATFORM
+ remove_const :RUBY_VERSION
+ RUBY_PLATFORM = "$(ARCH)"
+ RUBY_VERSION = "$(MAJOR).$(MINOR).$(TEENY)"
+end
+class File
+ remove_const :ALT_SEPARATOR
+ ALT_SEPARATOR = "\\"
+end
+<<KEEP
+
+{$(srcdir)/missing}.c.obj:
+ $(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) -c -Tc$(<:\=/)
+{$(srcdir)/win32}.c.obj:
+ $(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) -c -Tc$(<:\=/)
+{$(srcdir)/wince}.c.obj:
+ $(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) -c -Tc$(<:\=/)
+{$(srcdir)/wince/sys}.c.obj:
+ $(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) -c -Tc$(<:\=/)
+{$(srcdir)}.c.obj:
+ $(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) -c -Tc$(<:\=/)
+.c.obj:
+ $(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) -c -Tc$(<:\=/)
+
+.rc.res:
+ $(RC) -I. -I$(<D) $(iconinc) -I$(srcdir)/win32 $(RFLAGS) -fo$@ $(<:\=/)
+
+{$(srcdir)}.y.c:
+ $(YACC) $(YFLAGS) $(<:\=/)
+ sed -e "s!^ *extern char \*getenv();!/* & */!;s/^\(#.*\)y\.tab/\1parse/" y.tab.c > $@
+ @del y.tab.c
+
+!include $(srcdir)/common.mk
+
+$(OBJS): {$(srcdir)}win32/win32.h
+
+dir.$(OBJEXT): {$(srcdir)}win32/dir.h
+
+ext/extinit.obj: ext/extinit.c $(SETUP)
+ $(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) -Fo$@ -c ext/extinit.c
diff --git a/ruby_1_8_6/wince/README.wince b/ruby_1_8_6/wince/README.wince
new file mode 100644
index 0000000000..795dc710e6
--- /dev/null
+++ b/ruby_1_8_6/wince/README.wince
@@ -0,0 +1,121 @@
+=begin
+
+= How to build ruby using eMbedded Visual C++
+
+== Requirement
+
+(1) eMbedded Visual C++ 3.0 or later.
+
+(2) If you want to run `((%nmake clean%))' or `((%nmake distclean%))'
+ properly, you must install UNIX compatible `((%rm%))' command on
+ your ((|PATH|)) if you want to clean after compile.
+
+(3) Please set environment variable (({INCLUDE})), (({LIB})), (({PATH})),
+ (({CE_TOOLS_DIR})), (({EMBEDDED_TOOLS_DIR})) to run required commands
+ properly from the command line.
+
+ Note: building ruby requires following commands.
+ * nmake
+ * clarm or clmips or shcl
+ * lib
+ * dumpbin
+
+== How to compile and install
+
+(1) Execute wince\configure.bat on your build directory.
+ You can specify the target platform as an argument.
+ For example, run `((%configure arm-hpc2k-wince%))'
+
+(2) Change ((|RUBY_INSTALL_NAME|)) and ((|RUBY_SO_NAME|)) in (({Makefile}))
+ if you want to change the name of the executable files.
+
+(3) Run `((%nmake%))'
+
+(4) Run `((%nmake DESTDIR=<install_directory> install%))'
+
+ This command will create following directories and copy (not install :-P)
+ files onto them.
+ * <install_directory>\bin
+ * <install_directory>\lib
+ * <install_directory>\lib\ruby
+ * <install_directory>\lib\ruby\<MAJOR>.<MINOR>
+ * <install_directory>\lib\ruby\<MAJOR>.<MINOR>\<PLATFORM>
+ * <install_directory>\lib\ruby\site_ruby
+ * <install_directory>\lib\ruby\site_ruby\<MAJOR>.<MINOR>
+ * <install_directory>\lib\ruby\site_ruby\<MAJOR>.<MINOR>\<PLATFORM>
+ * <install_directory>\man\man1
+ If Ruby's version is `x.y.z', the ((|<MAJOR>|)) is `x' and the ((|<MINOR>|)) is `y'.
+ In case of `mips-hpc2k-wince', The ((|<PLATFORM>|)) is `(({mips-mswince}))'.
+
+(5) Copy <install_directory> to your WindowsCE machine.
+
+== Icons
+
+Any icon files(*.ico) in the build directory, directories specified with
+((|icondirs|)) make variable and (({win32})) directory under the ruby
+source directory will be included in DLL or executable files, according
+to their base names.
+ $(RUBY_INSTALL_NAME).ico or ruby.ico --> $(RUBY_INSTALL_NAME).exe
+ $(RUBYW_INSTALL_NAME).ico or rubyw.ico --> $(RUBYW_INSTALL_NAME).exe
+ the others --> $(RUBY_SO_NAME).dll
+
+Although no icons are distributed with the ruby source or in the official
+site, you can use anything you like. For example, followings are written
+in Japanese, but you can download at least.
+
+* ((<URL:http://member.nifty.ne.jp/ueivu/rubyico.html>)) or
+ ((<zipped icons|URL:http://member.nifty.ne.jp/ueivu/Ruby_ico.zip>))
+* ((<URL:http://homepage1.nifty.com/a_nakata/ruby/>)) or
+ ((<icon itself|URL:http://homepage1.nifty.com/a_nakata/ruby/RubyIcon.ico>))
+
+== Build examples
+
+* Build on the ruby source directory.
+
+ ex.)
+ ruby source directory: C:\ruby
+ build directory: C:\ruby
+ install directory: C:\usr\local
+
+ C:
+ cd \ruby
+ win32\configure
+ nmake
+ nmake DESTDIR=/usr/local install
+
+* Build on the relative directory from the ruby source directory.
+
+ ex.)
+ ruby source directory: C:\ruby
+ build directory: C:\ruby\mswin32
+ install directory: C:\usr\local
+
+ C:
+ cd \ruby
+ mkdir mswin32
+ cd mswin32
+ ..\win32\configure
+ nmake
+ nmake DESTDIR=/usr/local install
+
+* Build on the different drive.
+
+ ex.)
+ ruby source directory: C:\src\ruby
+ build directory: D:\build\ruby
+ install directory: C:\usr\local
+
+ D:
+ cd D:\build\ruby
+ C:\src\ruby\win32\configure
+ nmake
+ nmake DESTDIR=C:/usr/local install
+
+== Bugs
+
+You can ((*NOT*)) use a path name contains any white space characters as
+the ruby source directory, this restriction comes from the behavior of
+(({!INCLUDE})) directives of (({NMAKE})).
+((- you may call it a bug. -))
+
+=end
diff --git a/ruby_1_8_6/wince/assert.c b/ruby_1_8_6/wince/assert.c
new file mode 100644
index 0000000000..0f4be68497
--- /dev/null
+++ b/ruby_1_8_6/wince/assert.c
@@ -0,0 +1,11 @@
+#include <windows.h>
+#include <tchar.h>
+#include "assert.h"
+
+
+void assert( int expression )
+{
+ if( expression==0 )
+ exit(2);
+}
+
diff --git a/ruby_1_8_6/wince/assert.h b/ruby_1_8_6/wince/assert.h
new file mode 100644
index 0000000000..c2a4e3ebb7
--- /dev/null
+++ b/ruby_1_8_6/wince/assert.h
@@ -0,0 +1,6 @@
+#ifndef _ASSERT_H_
+#define _ASSERT_H_
+
+void assert( int expression );
+
+#endif
diff --git a/ruby_1_8_6/wince/configure.bat b/ruby_1_8_6/wince/configure.bat
new file mode 100755
index 0000000000..66837bb646
--- /dev/null
+++ b/ruby_1_8_6/wince/configure.bat
@@ -0,0 +1,102 @@
+@echo off
+::: Don't set environment variable in batch file other than autoexec.bat
+::: to avoid "Out of environment space" problem on Windows 95/98.
+::: set TMPMAKE=~tmp~.mak
+
+echo> ~tmp~.mak ####
+echo>> ~tmp~.mak conf = %0
+echo>> ~tmp~.mak $(conf:\=/): nul
+echo>> ~tmp~.mak @del ~tmp~.mak
+echo>> ~tmp~.mak @-$(MAKE) -l$(MAKEFLAGS) -f $(@D)/setup.mak \
+:loop
+if "%1" == "" goto :end
+if "%1" == "--prefix" goto :prefix
+if "%1" == "--srcdir" goto :srcdir
+if "%1" == "srcdir" goto :srcdir
+if "%1" == "--target" goto :target
+if "%1" == "target" goto :target
+if "%1" == "--with-static-linked-ext" goto :extstatic
+if "%1" == "--program-suffix" goto :suffix
+if "%1" == "--program-name" goto :progname
+if "%1" == "--enable-install-doc" goto :enable-rdoc
+if "%1" == "--disable-install-doc" goto :disable-rdoc
+if "%1" == "--extout" goto :extout
+if "%1" == "-h" goto :help
+if "%1" == "--help" goto :help
+if "%1" == "CC" goto :define
+if "%1" == "EMBEDDED_TOOLS_DIR" goto :define
+if "%1" == "CE_TOOLS_DIR" goto :define
+if "%1" == "EMBEDDED_TOOLS4_DIR" goto :define
+if "%1" == "CE_TOOLS4_DIR" goto :define
+ echo>> ~tmp~.mak "%1" \
+ shift
+goto :loop
+:srcdir
+ echo>> ~tmp~.mak "srcdir=%2" \
+ shift
+ shift
+goto :loop
+:prefix
+ echo>> ~tmp~.mak "prefix=%2" \
+ shift
+ shift
+goto :loop
+:suffix
+ echo>> ~tmp~.mak "RUBY_SUFFIX=%2" \
+ shift
+ shift
+goto :loop
+:installname
+ echo>> ~tmp~.mak "RUBY_INSTALL_NAME=%2" \
+ shift
+ shift
+goto :loop
+:soname
+ echo>> ~tmp~.mak "RUBY_SO_NAME=%2" \
+ shift
+ shift
+goto :loop
+:define
+ echo>> ~tmp~.mak "%1=%2" \
+ shift
+ shift
+goto :loop
+:target
+ echo>> ~tmp~.mak "%2" \
+ shift
+ shift
+goto :loop
+:extstatic
+ echo>> ~tmp~.mak "EXTSTATIC=static" \
+ shift
+goto :loop
+:enable-rdoc
+ echo>> ~tmp~.mak "RDOCTARGET=install-doc" \
+ shift
+goto :loop
+:disable-rdoc
+ echo>> ~tmp~.mak "RDOCTARGET=install-nodoc" \
+ shift
+goto :loop
+:extout
+ echo>> ~tmp~.mak "EXTOUT=%2" \
+ shift
+ shift
+goto :loop
+:help
+ echo Configuration:
+ echo --help display this help
+ echo --srcdir=DIR find the sources in DIR [configure dir or `..']
+ echo Installation directories:
+ echo --prefix=PREFIX install files in PREFIX (ignored currently)
+ echo System types:
+ echo --target=TARGET configure for TARGET [i386-mswin32]
+ echo Optional Package:
+ echo --with-static-linked-ext link external modules statically
+ echo --enable-install-doc install rdoc indexes during install
+ del ~tmp~.mak
+goto :exit
+:end
+echo>> ~tmp~.mak WIN32DIR=$(@D)
+nmake -alf ~tmp~.mak
+:exit
diff --git a/ruby_1_8_6/wince/direct.c b/ruby_1_8_6/wince/direct.c
new file mode 100644
index 0000000000..bf0d7cd224
--- /dev/null
+++ b/ruby_1_8_6/wince/direct.c
@@ -0,0 +1,54 @@
+/***************************************************************
+ direct.c
+***************************************************************/
+
+#include <windows.h>
+#include <tchar.h>
+#include <direct.h>
+#include "wince.h" /* for wce_mbtowc */
+
+/* global for chdir, getcwd */
+char _currentdir[MAX_PATH+1];
+
+
+char *getcwd(char* buffer, int maxlen)
+{
+ strcpy( buffer, _currentdir );
+ return buffer;
+}
+
+int _chdir(const char * dirname)
+{
+ if( MAX_PATH < strlen(dirname) )
+ return -1;
+
+ strcpy( _currentdir, dirname );
+ return 0;
+}
+
+int _rmdir(const char * dir)
+{
+ wchar_t *wdir;
+ BOOL rc;
+
+ /* replace with RemoveDirectory. */
+ wdir = wce_mbtowc(dir);
+ rc = RemoveDirectoryW(wdir);
+ free(wdir);
+
+ return rc==TRUE ? 0 : -1;
+}
+
+int _mkdir(const char * dir)
+{
+ wchar_t* wdir;
+ BOOL rc;
+
+ /* replace with CreateDirectory. */
+ wdir = wce_mbtowc(dir);
+ rc = CreateDirectoryW(wdir, NULL);
+ free(wdir);
+
+ return rc==TRUE ? 0 : -1;
+}
+
diff --git a/ruby_1_8_6/wince/direct.h b/ruby_1_8_6/wince/direct.h
new file mode 100644
index 0000000000..7c859b9d3b
--- /dev/null
+++ b/ruby_1_8_6/wince/direct.h
@@ -0,0 +1,22 @@
+#ifndef DIRECT_H
+#define DIRECT_H 1
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+char *getcwd(char* buffer, int maxlen);
+int _chdir(const char * dirname);
+int _rmdir(const char * dir);
+int _mkdir(const char * dir);
+
+#ifdef __cplusplus
+};
+#endif
+
+#define chdir _chdir
+#define rmdir _rmdir
+#define mkdir _mkdir
+
+#endif
diff --git a/ruby_1_8_6/wince/errno.c b/ruby_1_8_6/wince/errno.c
new file mode 100644
index 0000000000..705b25428e
--- /dev/null
+++ b/ruby_1_8_6/wince/errno.c
@@ -0,0 +1,11 @@
+/***************************************************************
+ errno.c
+***************************************************************/
+
+#include <errno.h>
+
+
+int errno;
+int _doserrno;
+int _sys_nerr;
+
diff --git a/ruby_1_8_6/wince/errno.h b/ruby_1_8_6/wince/errno.h
new file mode 100644
index 0000000000..2fdd325b32
--- /dev/null
+++ b/ruby_1_8_6/wince/errno.h
@@ -0,0 +1,55 @@
+#ifndef ERRNO_H
+#define ERRNO_H 1
+
+
+#define EPERM 1
+#define ENOENT 2
+#define ESRCH 3
+#define EINTR 4
+#define EIO 5
+#define ENXIO 6
+#define E2BIG 7
+#define ENOEXEC 8
+#define EBADF 9
+#define ECHILD 10
+#define EAGAIN 11
+#define ENOMEM 12
+#define EACCES 13
+#define EFAULT 14
+#define EOSERR 15 // rk
+#define EBUSY 16
+#define EEXIST 17
+#define EXDEV 18
+#define ENODEV 19
+#define ENOTDIR 20
+#define EISDIR 21
+#define EINVAL 22
+#define ENFILE 23
+#define EMFILE 24
+#define ENOTTY 25
+#define EFBIG 27
+#define ENOSPC 28
+#define ESPIPE 29
+#define EROFS 30
+#define EMLINK 31
+#define EPIPE 32
+#define EDOM 33
+#define ERANGE 34
+#define EDEADLK 36
+#define ENOSYS 37
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern int errno;
+extern int _doserrno;
+extern int _sys_nerr;
+
+#define sys_nerr _sys_nerr
+
+#ifdef __cplusplus
+};
+#endif
+
+#endif
diff --git a/ruby_1_8_6/wince/fcntl.h b/ruby_1_8_6/wince/fcntl.h
new file mode 100644
index 0000000000..5a6bdc71e6
--- /dev/null
+++ b/ruby_1_8_6/wince/fcntl.h
@@ -0,0 +1,42 @@
+
+#ifndef FCNTL_H
+#define FCNTL_H 1
+
+
+#define F_SETFL 1
+#define F_SETFD 2
+#define F_GETFL 3
+
+#define _O_RDONLY 0x0000 /* open for reading only */
+#define _O_WRONLY 0x0001 /* open for writing only */
+#define _O_RDWR 0x0002 /* open for reading and writing */
+
+#define _O_NONBLOCK 0x0004
+
+#define _O_APPEND 0x0008 /* writes done at eof */
+#define _O_CREAT 0x0100 /* create and open file */
+#define _O_TRUNC 0x0200 /* open and truncate */
+#define _O_EXCL 0x0400 /* open only if file doesn't already exist */
+#define _O_TEXT 0x4000 /* file mode is text (translated) */
+#define _O_BINARY 0x8000 /* file mode is binary (untranslated) */
+#define _O_ACCMODE 0x10000
+
+#define _O_NOINHERIT 0
+#define O_NOINHERIT _O_NOINHERIT
+
+#define O_RDONLY _O_RDONLY
+#define O_WRONLY _O_WRONLY
+#define O_RDWR _O_RDWR
+
+#define O_NONBLOCK _O_NONBLOCK
+
+#define O_APPEND _O_APPEND
+#define O_CREAT _O_CREAT
+#define O_TRUNC _O_TRUNC
+#define O_EXCL _O_EXCL
+#define O_TEXT _O_TEXT
+#define O_BINARY _O_BINARY
+#define O_ACCMODE _O_ACCMODE
+
+
+#endif
diff --git a/ruby_1_8_6/wince/io.h b/ruby_1_8_6/wince/io.h
new file mode 100644
index 0000000000..eb355a4916
--- /dev/null
+++ b/ruby_1_8_6/wince/io.h
@@ -0,0 +1,76 @@
+
+#ifndef _IO_WINCE_H_
+#define _IO_WINCE_H_
+
+#ifndef _TIME_T_DEFINED
+typedef unsigned long time_t;
+#define _TIME_T_DEFINED
+#endif
+
+#ifndef _FSIZE_T_DEFINED
+typedef unsigned long _fsize_t; /* Could be 64 bits for Win32 */
+#define _FSIZE_T_DEFINED
+#endif
+
+#ifndef _FINDDATA_T_DEFINED
+struct _finddata_t {
+ unsigned attrib;
+ time_t time_create; /* -1 for FAT file systems */
+ time_t time_access; /* -1 for FAT file systems */
+ time_t time_write;
+ _fsize_t size;
+ char name[260];
+};
+#define _FINDDATA_T_DEFINED
+#endif
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int _chsize(int handle, long size);
+int _rename (const char *oldname, const char *newname);
+int _unlink(const char *file);
+int _umask(int cmask);
+int _chmod(const char *path, int mode);
+int dup( int handle );
+//int dup2( int handle1, int handle2 );
+int _isatty(int fd);
+int _pipe(int *phandles, unsigned int psize, int textmode);
+int _access(const char *filename, int flags);
+int _open_osfhandle ( long osfhandle, int flags);
+long _get_osfhandle( int filehandle );
+int _open(const char *file, int mode,...);
+int close(int fd);
+int _read(int fd, void *buffer, int length);
+int _write(int fd, const void *buffer, unsigned count);
+long _lseek(int handle, long offset, int origin);
+long _findfirst( char *filespec, struct _finddata_t *fileinfo );
+int _findnext( long handle, struct _finddata_t *fileinfo );
+int _findclose( long handle );
+
+#ifdef __cplusplus
+};
+#endif
+
+#define chmod _chmod
+#define chsize _chsize
+#define rename _rename
+#define unlink _unlink
+#define open _open
+//#define close _close
+#define read _read
+#define write _write
+#define umask _umask
+//#define dup _dup
+#define isatty _isatty
+#define access _access
+#define pipe _pipe
+#define setmode _setmode
+#define lseek _lseek
+
+#define _close close
+
+#endif
+
diff --git a/ruby_1_8_6/wince/io_wce.c b/ruby_1_8_6/wince/io_wce.c
new file mode 100644
index 0000000000..613934aa66
--- /dev/null
+++ b/ruby_1_8_6/wince/io_wce.c
@@ -0,0 +1,230 @@
+/***************************************************************
+ io.c
+
+ author : uema2
+ date : Nov 30, 2002
+
+ You can freely use, copy, modify, and redistribute
+ the whole contents.
+***************************************************************/
+
+#include <windows.h>
+#include <stdlib.h>
+#include <io.h>
+#include <fcntl.h>
+#include <time.h>
+#include <errno.h>
+#include "wince.h" /* for wce_mbtowc */
+
+extern int _errno;
+
+
+int _rename(const char *oldname, const char *newname)
+{
+ wchar_t *wold, *wnew;
+ BOOL rc;
+
+ wold = wce_mbtowc(oldname);
+ wnew = wce_mbtowc(newname);
+
+ /* replace with MoveFile. */
+ rc = MoveFileW(wold, wnew);
+
+ free(wold);
+ free(wnew);
+
+ return rc==TRUE ? 0 : -1;
+}
+
+int _unlink(const char *file)
+{
+ wchar_t *wfile;
+ BOOL rc;
+
+ /* replace with DeleteFile. */
+ wfile = wce_mbtowc(file);
+ rc = DeleteFileW(wfile);
+ free(wfile);
+
+ return rc==TRUE ? 0 : -1;
+}
+
+/* replace "open" with "CreateFile", etc. */
+int _open(const char *file, int mode, va_list arg)
+{
+ wchar_t *wfile;
+ DWORD access=0, share=0, create=0;
+ HANDLE h;
+
+ if( (mode&_O_RDWR) != 0 )
+ access = GENERIC_READ|GENERIC_WRITE;
+ else if( (mode&_O_RDONLY) != 0 )
+ access = GENERIC_READ;
+ else if( (mode&_O_WRONLY) != 0 )
+ access = GENERIC_WRITE;
+
+ if( (mode&_O_CREAT) != 0 )
+ create = CREATE_ALWAYS;
+ else
+ create = OPEN_ALWAYS;
+
+ wfile = wce_mbtowc(file);
+
+ h = CreateFileW(wfile, access, share, NULL,
+ create, 0, NULL );
+
+ free(wfile);
+ return (int)h;
+}
+
+int close(int fd)
+{
+ CloseHandle( (HANDLE)fd );
+ return 0;
+}
+
+int _read(int fd, void *buffer, int length)
+{
+ DWORD dw;
+ ReadFile( (HANDLE)fd, buffer, length, &dw, NULL );
+ return (int)dw;
+}
+
+int _write(int fd, const void *buffer, unsigned count)
+{
+ DWORD dw;
+ WriteFile( (HANDLE)fd, buffer, count, &dw, NULL );
+ return (int)dw;
+}
+
+long _lseek(int handle, long offset, int origin)
+{
+ DWORD flag, ret;
+
+ switch(origin)
+ {
+ case SEEK_SET: flag = FILE_BEGIN; break;
+ case SEEK_CUR: flag = FILE_CURRENT; break;
+ case SEEK_END: flag = FILE_END; break;
+ default: flag = FILE_CURRENT; break;
+ }
+
+ ret = SetFilePointer( (HANDLE)handle, offset, NULL, flag );
+ return ret==0xFFFFFFFF ? -1 : 0;
+}
+
+/* _findfirst, _findnext, _findclose. */
+/* replace them with FindFirstFile, etc. */
+long _findfirst( char *file, struct _finddata_t *fi )
+{
+ HANDLE h;
+ WIN32_FIND_DATAA fda;
+
+ h = FindFirstFileA( file, &fda );
+ if( h==NULL )
+ {
+ errno = EINVAL; return -1;
+ }
+
+ fi->attrib = fda.dwFileAttributes;
+ fi->time_create = wce_FILETIME2time_t( &fda.ftCreationTime );
+ fi->time_access = wce_FILETIME2time_t( &fda.ftLastAccessTime );
+ fi->time_write = wce_FILETIME2time_t( &fda.ftLastWriteTime );
+ fi->size = fda.nFileSizeLow + (fda.nFileSizeHigh<<32);
+ strcpy( fi->name, fda.cFileName );
+
+ return (long)h;
+}
+
+int _findnext( long handle, struct _finddata_t *fi )
+{
+ WIN32_FIND_DATAA fda;
+ BOOL b;
+
+ b = FindNextFileA( (HANDLE)handle, &fda );
+
+ if( b==FALSE )
+ {
+ errno = ENOENT; return -1;
+ }
+
+ fi->attrib = fda.dwFileAttributes;
+ fi->time_create = wce_FILETIME2time_t( &fda.ftCreationTime );
+ fi->time_access = wce_FILETIME2time_t( &fda.ftLastAccessTime );
+ fi->time_write = wce_FILETIME2time_t( &fda.ftLastWriteTime );
+ fi->size = fda.nFileSizeLow + (fda.nFileSizeHigh<<32);
+ strcpy( fi->name, fda.cFileName );
+
+ return 0;
+}
+
+int _findclose( long handle )
+{
+ BOOL b;
+ b = FindClose( (HANDLE)handle );
+ return b==FALSE ? -1 : 0;
+}
+
+/* below functions unsupported... */
+/* I have no idea how to replace... */
+int _chsize(int handle, long size)
+{
+ errno = EACCES;
+ return -1;
+}
+
+int _umask(int cmask)
+{
+ return 0;
+}
+
+int _chmod(const char *path, int mode)
+{
+ return 0;
+}
+
+/* WinCE doesn't have dup and dup2. */
+/* so, we cannot use missing/dup2.c. */
+int dup( int handle )
+{
+ errno = EBADF;
+ return -1;
+}
+/*
+int dup2( int handle1, int handle2 )
+{
+ errno = EBADF;
+ return -1;
+}
+*/
+int _isatty(int fd)
+{
+ if( fd==(int)_fileno(stdin) ||
+ fd==(int)_fileno(stdout)||
+ fd==(int)_fileno(stderr) )
+ return 1;
+ else
+ return 0;
+}
+
+int _pipe(int *phandles, unsigned int psize, int textmode)
+{
+ return -1;
+}
+
+int _access(const char *filename, int flags)
+{
+ return 0;
+}
+
+int _open_osfhandle( long osfhandle, int flags)
+{
+/* return 0; */
+ return (int)osfhandle;
+}
+
+long _get_osfhandle( int filehandle )
+{
+/* return 0; */
+ return (long)filehandle;
+}
diff --git a/ruby_1_8_6/wince/mkconfig_wce.rb b/ruby_1_8_6/wince/mkconfig_wce.rb
new file mode 100644
index 0000000000..4d9671cde7
--- /dev/null
+++ b/ruby_1_8_6/wince/mkconfig_wce.rb
@@ -0,0 +1,7 @@
+f = File.open(ARGV[0], File::WRONLY|File::APPEND)
+f.write <<EOM
+class Object
+ remove_const :RUBY_PLATFORM
+ RUBY_PLATFORM = Config::CONFIG[\"RUBY_PLATFORM\"]
+end
+EOM
diff --git a/ruby_1_8_6/wince/mkexports.rb b/ruby_1_8_6/wince/mkexports.rb
new file mode 100644
index 0000000000..8e96649276
--- /dev/null
+++ b/ruby_1_8_6/wince/mkexports.rb
@@ -0,0 +1,35 @@
+#!./miniruby -s
+
+SYM = {}
+
+objs = ARGV.collect {|s| p s+'\n'; s.tr('/', '\\') }
+IO.foreach("|dumpbin -symbols " + objs.join(' ')) do |l|
+ next if /^[0-9A-F]+ 0+ UNDEF / =~ l
+ next unless l.sub!(/.*\sExternal\s+\|\s+/, '')
+ if ARGV[1]=~/sh/
+ if l.sub!(/^_/, '')
+ next if /@.*@/ =~ l || /@[0-9a-f]{16}$/ =~ l
+ elsif !l.sub!(/^(\S+) \([^@?\`\']*\)$/, '\1')
+ next
+ end
+ else
+ next if /@.*@/ =~ l || /@[0-9a-f]{16}$/ =~ l
+ end
+ SYM[l.strip] = true
+end
+
+
+exports = []
+if $name
+ exports << "Name " + $name
+elsif $library
+ exports << "Library " + $library
+end
+exports << "Description " + $description.dump if $description
+exports << "EXPORTS" << SYM.keys.sort
+
+if $output
+ open($output, 'w') {|f| f.puts exports.join("\n")}
+else
+ puts exports.join("\n")
+end
diff --git a/ruby_1_8_6/wince/process.h b/ruby_1_8_6/wince/process.h
new file mode 100644
index 0000000000..2ef72a4ac1
--- /dev/null
+++ b/ruby_1_8_6/wince/process.h
@@ -0,0 +1,46 @@
+#ifndef PROCESS_H
+#define PROCESS_H 1
+
+
+#define _P_WAIT 0
+#define _P_NOWAIT 1
+#define _P_OVERLAY 2
+#define _P_DETACH 4
+
+#define P_WAIT _P_WAIT
+#define P_NOWAIT _P_NOWAIT
+#define P_DETACH _P_DETACH
+#define P_OVERLAY _P_OVERLAY
+
+#ifndef _INTPTR_T_DEFINED
+typedef int intptr_t;
+#define _INTPTR_T_DEFINED
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int _getpid(void);
+
+int _cwait(int *, int, int);
+void abort(void);
+
+int _execl(const char *, const char *, ...);
+//int _execv(const char *, const char * const *);
+int execv(const char *path, char *const argv[]);
+
+intptr_t _spawnle(int, const char *, const char *, ...);
+intptr_t _spawnvpe(int, const char *, const char * const *,
+ const char * const *);
+
+#ifdef __cplusplus
+};
+#endif
+
+//#define getpid _getpid
+#define execl _execl
+#define execv _execv
+
+
+#endif
diff --git a/ruby_1_8_6/wince/process_wce.c b/ruby_1_8_6/wince/process_wce.c
new file mode 100644
index 0000000000..4415ad024e
--- /dev/null
+++ b/ruby_1_8_6/wince/process_wce.c
@@ -0,0 +1,47 @@
+/***************************************************************
+ process.c
+***************************************************************/
+
+#include <windows.h>
+#include "process.h"
+
+int _getpid(void)
+{
+ return (int)GetCurrentProcessId();
+}
+
+/* I wonder _exec and _swawn should be replaced with CreateProcess... */
+int _execl(const char *cmdname, const char *arg0,
+ va_list va_args)
+{
+ return 0;
+}
+
+int execv(const char *path, char *const argv[])
+{
+ return 0;
+}
+
+void abort(void)
+{
+}
+
+int _cwait( int *termstat, int procHandle, int action )
+{
+ return 0;
+}
+
+intptr_t _spawnle(int mode,
+ const char *cmdname, const char *arg0,
+ va_list va_argn)
+{
+ return 0;
+}
+
+intptr_t _spawnvpe(int mode,
+ const char *cmdname, const char *const *argv,
+ const char *const *envp)
+{
+ return 0;
+}
+
diff --git a/ruby_1_8_6/wince/resource.rb b/ruby_1_8_6/wince/resource.rb
new file mode 100644