require 'gen/ConstGenerator'
def gen_lasterror_java(options)
  options[:LastError] = true
  ConstGenerator.new 'platform.lasterror', options do |cg|
    cg.include "Winerror.h"
    cg.include "string.h"
    cg.include "windows.h"
    cg.unknown_range=[20000, 20999]
    consts = %w[
      ERROR_INVALID_FUNCTION
      ERROR_INVALID_FUNCTION
      ERROR_FILE_NOT_FOUND
      ERROR_PATH_NOT_FOUND
      ERROR_TOO_MANY_OPEN_FILES
      ERROR_ACCESS_DENIED
      ERROR_INVALID_HANDLE
      ERROR_ARENA_TRASHED
      ERROR_NOT_ENOUGH_MEMORY
      ERROR_INVALID_BLOCK
      ERROR_BAD_ENVIRONMENT
      ERROR_BAD_FORMAT
      ERROR_INVALID_ACCESS
      ERROR_INVALID_DATA
      ERROR_INVALID_DRIVE
      ERROR_CURRENT_DIRECTORY
      ERROR_NOT_SAME_DEVICE
      ERROR_NO_MORE_FILES
      ERROR_WRITE_PROTECT
      ERROR_BAD_UNIT
      ERROR_NOT_READY
      ERROR_BAD_COMMAND
      ERROR_CRC
      ERROR_BAD_LENGTH
      ERROR_SEEK
      ERROR_NOT_DOS_DISK
      ERROR_SECTOR_NOT_FOUND
      ERROR_OUT_OF_PAPER
      ERROR_WRITE_FAULT
      ERROR_READ_FAULT
      ERROR_GEN_FAILURE
      ERROR_LOCK_VIOLATION
      ERROR_SHARING_VIOLATION
      ERROR_WRONG_DISK
      ERROR_SHARING_BUFFER_EXCEEDED
      ERROR_BAD_NETPATH
      ERROR_NETWORK_ACCESS_DENIED
      ERROR_BAD_NET_NAME
      ERROR_FILE_EXISTS
      ERROR_CANNOT_MAKE
      ERROR_FAIL_I24
      ERROR_INVALID_PARAMETER
      ERROR_NO_PROC_SLOTS
      ERROR_DRIVE_LOCKED
      ERROR_BROKEN_PIPE
      ERROR_DISK_FULL
      ERROR_INVALID_TARGET_HANDLE
      ERROR_INVALID_HANDLE
      ERROR_WAIT_NO_CHILDREN
      ERROR_CHILD_NOT_COMPLETE
      ERROR_DIRECT_ACCESS_HANDLE
      ERROR_NEGATIVE_SEEK
      ERROR_SEEK_ON_DEVICE
      ERROR_DIR_NOT_EMPTY
      ERROR_DIRECTORY
      ERROR_NOT_LOCKED
      ERROR_BAD_PATHNAME
      ERROR_MAX_THRDS_REACHED
      ERROR_LOCK_FAILED
      ERROR_ALREADY_EXISTS
      ERROR_INVALID_STARTING_CODESEG
      ERROR_INVALID_STACKSEG
      ERROR_INVALID_MODULETYPE
      ERROR_INVALID_EXE_SIGNATURE
      ERROR_EXE_MARKED_INVALID
      ERROR_BAD_EXE_FORMAT
      ERROR_ITERATED_DATA_EXCEEDS_64k
      ERROR_INVALID_MINALLOCSIZE
      ERROR_DYNLINK_FROM_INVALID_RING
      ERROR_IOPL_NOT_ENABLED
      ERROR_INVALID_SEGDPL
      ERROR_AUTODATASEG_EXCEEDS_64k
      ERROR_RING2SEG_MUST_BE_MOVABLE
      ERROR_RELOC_CHAIN_XEEDS_SEGLIM
      ERROR_INFLOOP_IN_RELOC_CHAIN
      ERROR_FILENAME_EXCED_RANGE
      ERROR_NESTING_NOT_ALLOWED
      ERROR_PIPE_LOCAL
      ERROR_PIPE_LOCAL
      ERROR_BAD_PIPE
      ERROR_PIPE_BUSY
      ERROR_NO_DATA
      ERROR_PIPE_NOT_CONNECTED
      ERROR_OPERATION_ABORTED
      ERROR_NOT_ENOUGH_QUOTA
      ERROR_MOD_NOT_FOUND
      WSAENAMETOOLONG
      WSAENOTEMPTY
      WSAEINTR
      WSAEBADF
      WSAEACCES
      WSAEFAULT
      WSAEINVAL
      WSAEMFILE
    ]
    consts.each { |c| cg.const(c, '%ld') }
  end
end
