Skip to content

Commit

Permalink
Merge pull request #3844 from JacquesCarette/PythonConstructors
Browse files Browse the repository at this point in the history
Added check for multiple constructors to Python
  • Loading branch information
JacquesCarette authored Jul 10, 2024
2 parents 4f5dfbc + 051c557 commit 1c41b15
Showing 1 changed file with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -703,9 +703,17 @@ instance StateVarElim PythonCode where

instance ClassSym PythonCode where
type Class PythonCode = Doc
buildClass = G.buildClass
extraClass = CP.extraClass
implementingClass = G.implementingClass
buildClass par sVars cstrs = if length cstrs <= 1
then G.buildClass par sVars cstrs
else error pyMultCstrsError
extraClass n par sVars cstrs = if
length cstrs <= 1
then CP.extraClass n par sVars cstrs
else error pyMultCstrsError
implementingClass n iNms sVars cstrs = if
length cstrs <= 1
then G.implementingClass n iNms sVars cstrs
else error pyMultCstrsError

docClass = CP.doxClass

Expand Down Expand Up @@ -1006,6 +1014,9 @@ pyClass n pn s vs fs = vcat [
| isEmpty fs = vs
| otherwise = vcat [vs, blank, fs]

pyMultCstrsError :: String
pyMultCstrsError = "Python classes cannot have multiple constructors"

pyBlockComment :: [String] -> Doc -> Doc
pyBlockComment lns cmt = vcat $ map ((<+>) cmt . text) lns

Expand Down

0 comments on commit 1c41b15

Please sign in to comment.