<commit_before>(in-package :llvm)

;; NOTE: subsequences must come after any word they're contained in
;; FIXME: this should really handle arbitrary mappings:
;;        Ptr->pointer, Get->"", Var->variable, etc.
(let ((special-words '("ABI"
                       "CFG"
                       "DCE"
                       "FP80" "FP128"
                       "FP"
                       "GC"
                       "GVN"
                       "Int8" "Int16" "Int1" "Int32" "Int64"
                       "JIT"
                       "LICM"
                       "NSW"
                       "SCCP"
                       "SI"
                       "STDIN"
                       "UI"
                       "VA"
                       "X86")))
  (defmethod cffi:lisp-name
             ((spec string) (package (eql (find-package :llvm))) &optional varp)
    "LLVMUpperCamelCase -> 'llvm:upper-camel-case"
    (intern (format nil (if varp "*~a*" "~a")
                    (translate-camelcase-name (subseq spec 4)
                                              :upper-initial-p t
                                              :special-words special-words))))
  (defmethod cffi:foreign-name
             ((spec symbol) (package (eql (find-package :llvm))) &optional varp)
    "'llvm:lisp-name -> LLVMLispName"
    (let ((name (translate-camelcase-name spec
                                          :upper-initial-p t
                                          :special-words special-words)))
      (concatenate 'string
                   (package-name (symbol-package spec))
                   (if varp
                     (subseq name 1 (1- (length name)))
                     name)))))

(define-foreign-library libllvm
  (t (:default "libLLVM")))
<commit_msg>Changed the CFFI name translators to use the new names from the latest patch.<commit_after>(in-package :llvm)

;; NOTE: subsequences must come after any word they're contained in
;; FIXME: this should really handle arbitrary mappings:
;;        Ptr->pointer, Get->"", Var->variable, etc.
(let ((special-words '("ABI"
                       "CFG"
                       "DCE"
                       "FP80" "FP128"
                       "FP"
                       "GC"
                       "GVN"
                       "Int8" "Int16" "Int1" "Int32" "Int64"
                       "JIT"
                       "LICM"
                       "NSW"
                       "SCCP"
                       "SI"
                       "STDIN"
                       "UI"
                       "VA"
                       "X86")))
  (defmethod cffi:translate-name-from-foreign
             (foreign-name (package (eql (find-package :llvm))) &optional varp)
    "LLVMUpperCamelCase -> 'llvm:upper-camel-case"
    (intern (format nil (if varp "*~a*" "~a")
                    (translate-camelcase-name (subseq foreign-name 4)
                                              :upper-initial-p t
                                              :special-words special-words))))
  (defmethod cffi:translate-name-to-foreign
             (lisp-name (package (eql (find-package :llvm))) &optional varp)
    "'llvm:lisp-name -> LLVMLispName"
    (let ((name (translate-camelcase-name lisp-name
                                          :upper-initial-p t
                                          :special-words special-words)))
      (concatenate 'string
                   (package-name (symbol-package lisp-name))
                   (if varp
                     (subseq name 1 (1- (length name)))
                     name)))))

(define-foreign-library libllvm
  (t (:default "libLLVM")))

{'fraction_non_alphanumeric': 0.11337369290038525, 'fraction_numerical': 0.009906439185470555, 'mean_word_length': 1.0938940092165899, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1000461', 'n_tokens_mistral': 991, 'n_tokens_neox': 916, 'n_words': 237}