<commit_before>{-# LANGUAGE OverloadedStrings #-}
module Smoke.Gen.Util (
  locationForClass,
  classModuleName,
  skipClass
  ) where

import qualified Data.Text as T
import System.FilePath

import Smoke.C
import Smoke.Gen.Monad

locationForClass :: SmokeClass -> Gen FilePath
locationForClass c = do
  moduleName <- askModuleName
  destDir <- askModuleConf generatorDestDir
  modNameMap <- askModuleConf generatorModuleNameMap
  let modPath = moduleToPath (modNameMap moduleName)
  return $ destDir </> "src" </> modPath </> typeModuleName <.> "hs"
  where
    cname = smokeClassName c
    typeModuleName = T.unpack $ T.replace "::" "/" cname

skipClass :: SmokeClass -> Bool
skipClass c = classIsUndefined c || isIterator
  where
    isIterator = T.isInfixOf "::iterator" (smokeClassName c)

classModuleName :: SmokeClass -> Gen String
classModuleName c = do
  moduleName <- askModuleName
  modNameMap <- askModuleConf generatorModuleNameMap
  return $ T.unpack (modNameMap moduleName) <.> T.unpack typeModuleName
  where
    cname = smokeClassName c
    typeModuleName = T.replace "::" "." cname<commit_msg>Do not treat QGlobalSpace as a class<commit_after>{-# LANGUAGE OverloadedStrings #-}
module Smoke.Gen.Util (
  locationForClass,
  classModuleName,
  skipClass
  ) where

import qualified Data.Text as T
import System.FilePath

import Smoke.C
import Smoke.Gen.Monad

locationForClass :: SmokeClass -> Gen FilePath
locationForClass c = do
  moduleName <- askModuleName
  destDir <- askModuleConf generatorDestDir
  modNameMap <- askModuleConf generatorModuleNameMap
  let modPath = moduleToPath (modNameMap moduleName)
  return $ destDir </> "src" </> modPath </> typeModuleName <.> "hs"
  where
    cname = smokeClassName c
    typeModuleName = T.unpack $ T.replace "::" "/" cname

skipClass :: SmokeClass -> Bool
skipClass c = classIsUndefined c || isIterator || isGlobalSpace
  where
    -- This is a fake class that holds all of the globals in Qt.  This
    -- should probably be handled separately.
    isGlobalSpace = "QGlobalSpace" == smokeClassName c
    isIterator = T.isInfixOf "::iterator" (smokeClassName c)

classModuleName :: SmokeClass -> Gen String
classModuleName c = do
  moduleName <- askModuleName
  modNameMap <- askModuleConf generatorModuleNameMap
  return $ T.unpack (modNameMap moduleName) <.> T.unpack typeModuleName
  where
    cname = smokeClassName c
    typeModuleName = T.replace "::" "." cname
{'fraction_non_alphanumeric': 0.09161873459326211, 'fraction_numerical': 0.0, 'mean_word_length': 4.0623700623700625, 'pattern_counts': {'":': 6, '<': 23, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3586558', 'n_tokens_mistral': 757, 'n_tokens_neox': 742, 'n_words': 215}