Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add windows swig to setlocale #488

Merged
merged 1 commit into from
May 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
224 changes: 224 additions & 0 deletions lib/setlocale/cffi_windows.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,224 @@
(uiop/package:define-package :lem-setlocale/cffi (:use :cl))
(in-package :lem-setlocale/cffi)

;;; This file was automatically generated by SWIG (http://www.swig.org).
;;; Version 3.0.12
;;;
;;; Do not make changes to this file unless you know what you are doing--modify
;;; the SWIG interface file instead.


;;;SWIG wrapper code starts here

(cl:defmacro defanonenum (cl:&body enums)
"Converts anonymous enums to defconstants."
`(cl:progn ,@(cl:loop for value in enums
for index = 0 then (cl:1+ index)
when (cl:listp value) do (cl:setf index (cl:second value)
value (cl:first value))
collect `(cl:defconstant ,value ,index))))

(cl:eval-when (:compile-toplevel :load-toplevel)
(cl:unless (cl:fboundp 'swig-lispify)
(cl:defun swig-lispify (name flag cl:&optional (package cl:*package*))
(cl:labels ((helper (lst last rest cl:&aux (c (cl:car lst)))
(cl:cond
((cl:null lst)
rest)
((cl:upper-case-p c)
(helper (cl:cdr lst) 'upper
(cl:case last
((lower digit) (cl:list* c #\- rest))
(cl:t (cl:cons c rest)))))
((cl:lower-case-p c)
(helper (cl:cdr lst) 'lower (cl:cons (cl:char-upcase c) rest)))
((cl:digit-char-p c)
(helper (cl:cdr lst) 'digit
(cl:case last
((upper lower) (cl:list* c #\- rest))
(cl:t (cl:cons c rest)))))
((cl:char-equal c #\_)
(helper (cl:cdr lst) '_ (cl:cons #\- rest)))
(cl:t
(cl:error "Invalid character: ~A" c)))))
(cl:let ((fix (cl:case flag
((constant enumvalue) "+")
(variable "*")
(cl:t ""))))
(cl:intern
(cl:concatenate
'cl:string
fix
(cl:nreverse (helper (cl:concatenate 'cl:list name) cl:nil cl:nil))
fix)
package))))))

;;;SWIG wrapper code ends here


(cl:defconstant #.(swig-lispify "LC_ALL" 'constant) 0)

(cl:export '#.(swig-lispify "LC_ALL" 'constant))

(cl:defconstant #.(swig-lispify "LC_COLLATE" 'constant) 1)

(cl:export '#.(swig-lispify "LC_COLLATE" 'constant))

(cl:defconstant #.(swig-lispify "LC_CTYPE" 'constant) 2)

(cl:export '#.(swig-lispify "LC_CTYPE" 'constant))

(cl:defconstant #.(swig-lispify "LC_MONETARY" 'constant) 3)

(cl:export '#.(swig-lispify "LC_MONETARY" 'constant))

(cl:defconstant #.(swig-lispify "LC_NUMERIC" 'constant) 4)

(cl:export '#.(swig-lispify "LC_NUMERIC" 'constant))

(cl:defconstant #.(swig-lispify "LC_TIME" 'constant) 5)

(cl:export '#.(swig-lispify "LC_TIME" 'constant))

(cl:defconstant #.(swig-lispify "LC_MIN" 'constant) 0)

(cl:export '#.(swig-lispify "LC_MIN" 'constant))

(cl:defconstant #.(swig-lispify "LC_MAX" 'constant) 5)

(cl:export '#.(swig-lispify "LC_MAX" 'constant))

(cffi:defcstruct #.(swig-lispify "lconv" 'classname)
(#.(swig-lispify "decimal_point" 'slotname) :string)
(#.(swig-lispify "thousands_sep" 'slotname) :string)
(#.(swig-lispify "grouping" 'slotname) :string)
(#.(swig-lispify "int_curr_symbol" 'slotname) :string)
(#.(swig-lispify "currency_symbol" 'slotname) :string)
(#.(swig-lispify "mon_decimal_point" 'slotname) :string)
(#.(swig-lispify "mon_thousands_sep" 'slotname) :string)
(#.(swig-lispify "mon_grouping" 'slotname) :string)
(#.(swig-lispify "positive_sign" 'slotname) :string)
(#.(swig-lispify "negative_sign" 'slotname) :string)
(#.(swig-lispify "int_frac_digits" 'slotname) :char)
(#.(swig-lispify "frac_digits" 'slotname) :char)
(#.(swig-lispify "p_cs_precedes" 'slotname) :char)
(#.(swig-lispify "p_sep_by_space" 'slotname) :char)
(#.(swig-lispify "n_cs_precedes" 'slotname) :char)
(#.(swig-lispify "n_sep_by_space" 'slotname) :char)
(#.(swig-lispify "p_sign_posn" 'slotname) :char)
(#.(swig-lispify "n_sign_posn" 'slotname) :char))

(cl:export '#.(swig-lispify "lconv" 'classname))

(cl:export '#.(swig-lispify "decimal_point" 'slotname))

(cl:export '#.(swig-lispify "thousands_sep" 'slotname))

(cl:export '#.(swig-lispify "grouping" 'slotname))

(cl:export '#.(swig-lispify "int_curr_symbol" 'slotname))

(cl:export '#.(swig-lispify "currency_symbol" 'slotname))

(cl:export '#.(swig-lispify "mon_decimal_point" 'slotname))

(cl:export '#.(swig-lispify "mon_thousands_sep" 'slotname))

(cl:export '#.(swig-lispify "mon_grouping" 'slotname))

(cl:export '#.(swig-lispify "positive_sign" 'slotname))

(cl:export '#.(swig-lispify "negative_sign" 'slotname))

(cl:export '#.(swig-lispify "int_frac_digits" 'slotname))

(cl:export '#.(swig-lispify "frac_digits" 'slotname))

(cl:export '#.(swig-lispify "p_cs_precedes" 'slotname))

(cl:export '#.(swig-lispify "p_sep_by_space" 'slotname))

(cl:export '#.(swig-lispify "n_cs_precedes" 'slotname))

(cl:export '#.(swig-lispify "n_sep_by_space" 'slotname))

(cl:export '#.(swig-lispify "p_sign_posn" 'slotname))

(cl:export '#.(swig-lispify "n_sign_posn" 'slotname))

(cl:defconstant #.(swig-lispify "_ENABLE_PER_THREAD_LOCALE" 'constant) #x1)

(cl:export '#.(swig-lispify "_ENABLE_PER_THREAD_LOCALE" 'constant))

(cl:defconstant #.(swig-lispify "_DISABLE_PER_THREAD_LOCALE" 'constant) #x2)

(cl:export '#.(swig-lispify "_DISABLE_PER_THREAD_LOCALE" 'constant))

(cl:defconstant #.(swig-lispify "_ENABLE_PER_THREAD_LOCALE_GLOBAL" 'constant) #x10)

(cl:export '#.(swig-lispify "_ENABLE_PER_THREAD_LOCALE_GLOBAL" 'constant))

(cl:defconstant #.(swig-lispify "_DISABLE_PER_THREAD_LOCALE_GLOBAL" 'constant) #x20)

(cl:export '#.(swig-lispify "_DISABLE_PER_THREAD_LOCALE_GLOBAL" 'constant))

(cl:defconstant #.(swig-lispify "_ENABLE_PER_THREAD_LOCALE_NEW" 'constant) #x100)

(cl:export '#.(swig-lispify "_ENABLE_PER_THREAD_LOCALE_NEW" 'constant))

(cl:defconstant #.(swig-lispify "_DISABLE_PER_THREAD_LOCALE_NEW" 'constant) #x200)

(cl:export '#.(swig-lispify "_DISABLE_PER_THREAD_LOCALE_NEW" 'constant))

(cffi:defcfun ("_configthreadlocale" #.(swig-lispify "_configthreadlocale" 'function)) :int
(_Flag :int))

(cl:export '#.(swig-lispify "_configthreadlocale" 'function))

(cffi:defcfun ("setlocale" #.(swig-lispify "setlocale" 'function)) :string
(_Category :int)
(_Locale :string))

(cl:export '#.(swig-lispify "setlocale" 'function))

(cffi:defcfun ("localeconv" #.(swig-lispify "localeconv" 'function)) :pointer)

(cl:export '#.(swig-lispify "localeconv" 'function))

(cffi:defcfun ("_get_current_locale" #.(swig-lispify "_get_current_locale" 'function)) :pointer)

(cl:export '#.(swig-lispify "_get_current_locale" 'function))

(cffi:defcfun ("_create_locale" #.(swig-lispify "_create_locale" 'function)) :pointer
(_Category :int)
(_Locale :string))

(cl:export '#.(swig-lispify "_create_locale" 'function))

(cffi:defcfun ("_free_locale" #.(swig-lispify "_free_locale" 'function)) :void
(_Locale :pointer))

(cl:export '#.(swig-lispify "_free_locale" 'function))

(cffi:defcfun ("__get_current_locale" #.(swig-lispify "__get_current_locale" 'function)) :pointer)

(cl:export '#.(swig-lispify "__get_current_locale" 'function))

(cffi:defcfun ("__create_locale" #.(swig-lispify "__create_locale" 'function)) :pointer
(_Category :int)
(_Locale :string))

(cl:export '#.(swig-lispify "__create_locale" 'function))

(cffi:defcfun ("__free_locale" #.(swig-lispify "__free_locale" 'function)) :void
(_Locale :pointer))

(cl:export '#.(swig-lispify "__free_locale" 'function))

(cffi:defcfun ("_wsetlocale" #.(swig-lispify "_wsetlocale" 'function)) :pointer
(_Category :int)
(_Locale :pointer))

(cl:export '#.(swig-lispify "_wsetlocale" 'function))


5 changes: 3 additions & 2 deletions lib/setlocale/lem-setlocale.asd
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
(defsystem "lem-setlocale"
:depends-on ("lem-core")
:class :package-inferred-system
:components (#-darwin(:FILE "cffi")
#+darwin(:FILE "cffi_darwin"))
:components (#-(or darwin win32)(:FILE "cffi")
#+darwin(:FILE "cffi_darwin")
#+win32(:FILE "cffi_windows"))
:author "SANO Masatoshi"
:mailto "snmsts@gmail.com")
10 changes: 7 additions & 3 deletions lib/setlocale/swig/Lakefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
(task "default" ("cffi.lisp"))

(file "cffi.lisp" ("cffi.i")
(if (uiop:os-macosx-p)
(sh #?"swig -swig-lisp -cffi -I/usr/include -D__x86_64__ -importall cffi.i")
(sh #?"${swig} -swig-lisp -cffi -I/usr/include -I/usr/include/linux -I/usr/include/x86_64-linux-gnu -D__x86_64__ -importall cffi.i")))
(cond
((uiop:os-windows-p)
(sh #?"swig -swig-lisp -cffi -cpperraswarn -D__cdecl= -D_CRTIMP= -D_WCHAR_T_DEFINED -Ic:/msys64/mingw64/x86_64-w64-mingw32/include -importall cffi.i"))
((uiop:os-macosx-p)
(sh #?"swig -swig-lisp -cffi -I/usr/include -D__x86_64__ -importall cffi.i"))
(t
(sh #?"${swig} -swig-lisp -cffi -I/usr/include -I/usr/include/linux -I/usr/include/x86_64-linux-gnu -D__x86_64__ -importall cffi.i"))))