{-# LANGUAGE ForeignFunctionInterface, TypeFamilies, MultiParamTypeClasses, 
             FlexibleInstances, TypeSynonymInstances, EmptyDataDecls, 
             OverlappingInstances, IncoherentInstances #-}

module HROOT.Hist.TH2Poly.Implementation where


import FFICXX.Runtime.Cast

import HROOT.Hist.TH2Poly.RawType
import HROOT.Hist.TH2Poly.FFI
import HROOT.Hist.TH2Poly.Interface
import HROOT.Hist.TH2Poly.Cast
import HROOT.Hist.TH1D.RawType
import HROOT.Hist.TH1D.Cast
import HROOT.Hist.TH1D.Interface
import HROOT.Hist.TF1.RawType
import HROOT.Hist.TF1.Cast
import HROOT.Hist.TF1.Interface
import HROOT.Core.TObjArray.RawType
import HROOT.Core.TObjArray.Cast
import HROOT.Core.TObjArray.Interface
import HROOT.Core.TDirectory.RawType
import HROOT.Core.TDirectory.Cast
import HROOT.Core.TDirectory.Interface
import HROOT.Core.TArrayD.RawType
import HROOT.Core.TArrayD.Cast
import HROOT.Core.TArrayD.Interface
import HROOT.Hist.TAxis.RawType
import HROOT.Hist.TAxis.Cast
import HROOT.Hist.TAxis.Interface
import HROOT.Core.TClass.RawType
import HROOT.Core.TClass.Cast
import HROOT.Core.TClass.Interface
import HROOT.Hist.TH2.RawType
import HROOT.Hist.TH2.Cast
import HROOT.Hist.TH2.Interface
import HROOT.Hist.TH1.RawType
import HROOT.Hist.TH1.Cast
import HROOT.Hist.TH1.Interface
import HROOT.Core.TObject.RawType
import HROOT.Core.TObject.Cast
import HROOT.Core.TObject.Interface
import HROOT.Core.TAttLine.RawType
import HROOT.Core.TAttLine.Cast
import HROOT.Core.TAttLine.Interface
import HROOT.Core.TAttFill.RawType
import HROOT.Core.TAttFill.Cast
import HROOT.Core.TAttFill.Interface
import HROOT.Core.TAttMarker.RawType
import HROOT.Core.TAttMarker.Cast
import HROOT.Core.TAttMarker.Interface
import HROOT.Core.Deletable.RawType
import HROOT.Core.Deletable.Cast
import HROOT.Core.Deletable.Interface

import Data.Word
import Foreign.C
import Foreign.Ptr 
import Foreign.ForeignPtr

import System.IO.Unsafe


instance ITH2Poly TH2Poly where
instance ITH2 TH2Poly where
  fill2 = xform2 c_th2poly_fill2
  fill2w = xform3 c_th2poly_fill2w
  fillN2 = xform5 c_th2poly_filln2
  fillRandom2 = xform2 c_th2poly_fillrandom2
  findFirstBinAbove2 = xform2 c_th2poly_findfirstbinabove2
  findLastBinAbove2 = xform2 c_th2poly_findlastbinabove2
  fitSlicesX = xform6 c_th2poly_fitslicesx
  fitSlicesY = xform6 c_th2poly_fitslicesy
  getCorrelationFactor2 = xform2 c_th2poly_getcorrelationfactor2
  getCovariance2 = xform2 c_th2poly_getcovariance2
  integral2 = xform5 c_th2poly_integral2
  rebinX2 = xform2 c_th2poly_rebinx2
  rebinY2 = xform2 c_th2poly_rebiny2
  rebin2D = xform3 c_th2poly_rebin2d
  setShowProjectionX = xform1 c_th2poly_setshowprojectionx
  setShowProjectionY = xform1 c_th2poly_setshowprojectiony
instance ITH1 TH2Poly where
  add = xform2 c_th2poly_add
  addBinContent = xform2 c_th2poly_addbincontent
  chi2Test = xform3 c_th2poly_chi2test
  computeIntegral = xform0 c_th2poly_computeintegral
  directoryAutoAdd = xform1 c_th2poly_directoryautoadd
  divide = xform5 c_th2poly_divide
  drawCopyTH1 = xform1 c_th2poly_drawcopyth1
  drawNormalized = xform2 c_th2poly_drawnormalized
  drawPanelTH1 = xform0 c_th2poly_drawpanelth1
  bufferEmpty = xform1 c_th2poly_bufferempty
  evalF = xform2 c_th2poly_evalf
  fFT = xform2 c_th2poly_fft
  fill1 = xform1 c_th2poly_fill1
  fill1w = xform2 c_th2poly_fill1w
  fillN1 = xform4 c_th2poly_filln1
  fillRandom = xform2 c_th2poly_fillrandom
  findBin = xform3 c_th2poly_findbin
  findFixBin = xform3 c_th2poly_findfixbin
  findFirstBinAbove = xform2 c_th2poly_findfirstbinabove
  findLastBinAbove = xform2 c_th2poly_findlastbinabove
  fitPanelTH1 = xform0 c_th2poly_fitpanelth1
  getNdivisionA = xform1 c_th2poly_getndivisiona
  getAxisColorA = xform1 c_th2poly_getaxiscolora
  getLabelColorA = xform1 c_th2poly_getlabelcolora
  getLabelFontA = xform1 c_th2poly_getlabelfonta
  getLabelOffsetA = xform1 c_th2poly_getlabeloffseta
  getLabelSizeA = xform1 c_th2poly_getlabelsizea
  getTitleFontA = xform1 c_th2poly_gettitlefonta
  getTitleOffsetA = xform1 c_th2poly_gettitleoffseta
  getTitleSizeA = xform1 c_th2poly_gettitlesizea
  getTickLengthA = xform1 c_th2poly_getticklengtha
  getBarOffset = xform0 c_th2poly_getbaroffset
  getBarWidth = xform0 c_th2poly_getbarwidth
  getContour = xform1 c_th2poly_getcontour
  getContourLevel = xform1 c_th2poly_getcontourlevel
  getContourLevelPad = xform1 c_th2poly_getcontourlevelpad
  getBin = xform3 c_th2poly_getbin
  getBinCenter = xform1 c_th2poly_getbincenter
  getBinContent1 = xform1 c_th2poly_getbincontent1
  getBinContent2 = xform2 c_th2poly_getbincontent2
  getBinContent3 = xform3 c_th2poly_getbincontent3
  getBinError1 = xform1 c_th2poly_getbinerror1
  getBinError2 = xform2 c_th2poly_getbinerror2
  getBinError3 = xform3 c_th2poly_getbinerror3
  getBinLowEdge = xform1 c_th2poly_getbinlowedge
  getBinWidth = xform1 c_th2poly_getbinwidth
  getCellContent = xform2 c_th2poly_getcellcontent
  getCellError = xform2 c_th2poly_getcellerror
  getEntries = xform0 c_th2poly_getentries
  getEffectiveEntries = xform0 c_th2poly_geteffectiveentries
  getFunction = xform1 c_th2poly_getfunction
  getDimension = xform0 c_th2poly_getdimension
  getKurtosis = xform1 c_th2poly_getkurtosis
  getLowEdge = xform1 c_th2poly_getlowedge
  getMaximumTH1 = xform1 c_th2poly_getmaximumth1
  getMaximumBin = xform0 c_th2poly_getmaximumbin
  getMaximumStored = xform0 c_th2poly_getmaximumstored
  getMinimumTH1 = xform1 c_th2poly_getminimumth1
  getMinimumBin = xform0 c_th2poly_getminimumbin
  getMinimumStored = xform0 c_th2poly_getminimumstored
  getMean = xform1 c_th2poly_getmean
  getMeanError = xform1 c_th2poly_getmeanerror
  getNbinsX = xform0 c_th2poly_getnbinsx
  getNbinsY = xform0 c_th2poly_getnbinsy
  getNbinsZ = xform0 c_th2poly_getnbinsz
  getQuantilesTH1 = xform3 c_th2poly_getquantilesth1
  getRandom = xform0 c_th2poly_getrandom
  getStats = xform1 c_th2poly_getstats
  getSumOfWeights = xform0 c_th2poly_getsumofweights
  getSumw2 = xform0 c_th2poly_getsumw2
  getSumw2N = xform0 c_th2poly_getsumw2n
  getRMS = xform1 c_th2poly_getrms
  getRMSError = xform1 c_th2poly_getrmserror
  getSkewness = xform1 c_th2poly_getskewness
  integral1 = xform3 c_th2poly_integral1
  interpolate1 = xform1 c_th2poly_interpolate1
  interpolate2 = xform2 c_th2poly_interpolate2
  interpolate3 = xform3 c_th2poly_interpolate3
  kolmogorovTest = xform2 c_th2poly_kolmogorovtest
  labelsDeflate = xform1 c_th2poly_labelsdeflate
  labelsInflate = xform1 c_th2poly_labelsinflate
  labelsOption = xform2 c_th2poly_labelsoption
  multiflyF = xform2 c_th2poly_multiflyf
  multiply = xform5 c_th2poly_multiply
  putStats = xform1 c_th2poly_putstats
  rebin = xform3 c_th2poly_rebin
  rebinAxis = xform2 c_th2poly_rebinaxis
  rebuild = xform1 c_th2poly_rebuild
  recursiveRemove = xform1 c_th2poly_recursiveremove
  reset = xform1 c_th2poly_reset
  resetStats = xform0 c_th2poly_resetstats
  scale = xform2 c_th2poly_scale
  setAxisColorA = xform2 c_th2poly_setaxiscolora
  setAxisRange = xform3 c_th2poly_setaxisrange
  setBarOffset = xform1 c_th2poly_setbaroffset
  setBarWidth = xform1 c_th2poly_setbarwidth
  setBinContent1 = xform2 c_th2poly_setbincontent1
  setBinContent2 = xform3 c_th2poly_setbincontent2
  setBinContent3 = xform4 c_th2poly_setbincontent3
  setBinError1 = xform2 c_th2poly_setbinerror1
  setBinError2 = xform3 c_th2poly_setbinerror2
  setBinError3 = xform4 c_th2poly_setbinerror3
  setBins1 = xform2 c_th2poly_setbins1
  setBins2 = xform4 c_th2poly_setbins2
  setBins3 = xform6 c_th2poly_setbins3
  setBinsLength = xform1 c_th2poly_setbinslength
  setBuffer = xform2 c_th2poly_setbuffer
  setCellContent = xform3 c_th2poly_setcellcontent
  setContent = xform1 c_th2poly_setcontent
  setContour = xform2 c_th2poly_setcontour
  setContourLevel = xform2 c_th2poly_setcontourlevel
  setDirectory = xform1 c_th2poly_setdirectory
  setEntries = xform1 c_th2poly_setentries
  setError = xform1 c_th2poly_seterror
  setLabelColorA = xform2 c_th2poly_setlabelcolora
  setLabelSizeA = xform2 c_th2poly_setlabelsizea
  setLabelFontA = xform2 c_th2poly_setlabelfonta
  setLabelOffsetA = xform2 c_th2poly_setlabeloffseta
  setMaximum = xform1 c_th2poly_setmaximum
  setMinimum = xform1 c_th2poly_setminimum
  setNormFactor = xform1 c_th2poly_setnormfactor
  setStats = xform1 c_th2poly_setstats
  setOption = xform1 c_th2poly_setoption
  setXTitle = xform1 c_th2poly_setxtitle
  setYTitle = xform1 c_th2poly_setytitle
  setZTitle = xform1 c_th2poly_setztitle
  showBackground = xform2 c_th2poly_showbackground
  showPeaks = xform3 c_th2poly_showpeaks
  smooth = xform2 c_th2poly_smooth
  sumw2 = xform0 c_th2poly_sumw2
instance ITObject TH2Poly where
  draw = xform1 c_th2poly_draw
  findObject = xform1 c_th2poly_findobject
  getName = xform0 c_th2poly_getname
  isA = xform0 c_th2poly_isa
  paint = xform1 c_th2poly_paint
  printObj = xform1 c_th2poly_printobj
  saveAs = xform2 c_th2poly_saveas
  write = xform3 c_th2poly_write
instance ITAttLine TH2Poly where
  getLineColor = xform0 c_th2poly_getlinecolor
  getLineStyle = xform0 c_th2poly_getlinestyle
  getLineWidth = xform0 c_th2poly_getlinewidth
  resetAttLine = xform1 c_th2poly_resetattline
  setLineAttributes = xform0 c_th2poly_setlineattributes
  setLineColor = xform1 c_th2poly_setlinecolor
  setLineStyle = xform1 c_th2poly_setlinestyle
  setLineWidth = xform1 c_th2poly_setlinewidth
instance ITAttFill TH2Poly where
  setFillColor = xform1 c_th2poly_setfillcolor
  setFillStyle = xform1 c_th2poly_setfillstyle
instance ITAttMarker TH2Poly where
  getMarkerColor = xform0 c_th2poly_getmarkercolor
  getMarkerStyle = xform0 c_th2poly_getmarkerstyle
  getMarkerSize = xform0 c_th2poly_getmarkersize
  resetAttMarker = xform1 c_th2poly_resetattmarker
  setMarkerAttributes = xform0 c_th2poly_setmarkerattributes
  setMarkerColor = xform1 c_th2poly_setmarkercolor
  setMarkerStyle = xform1 c_th2poly_setmarkerstyle
  setMarkerSize = xform1 c_th2poly_setmarkersize
instance IDeletable TH2Poly where
  delete = xform0 c_th2poly_delete

instance ITH2Poly (Exist TH2Poly) where

instance ITH2 (Exist TH2Poly) where
  fill2 (ETH2Poly x) = fill2 x
  fill2w (ETH2Poly x) = fill2w x
  fillN2 (ETH2Poly x) = fillN2 x
  fillRandom2 (ETH2Poly x) = fillRandom2 x
  findFirstBinAbove2 (ETH2Poly x) = findFirstBinAbove2 x
  findLastBinAbove2 (ETH2Poly x) = findLastBinAbove2 x
  fitSlicesX (ETH2Poly x) = fitSlicesX x
  fitSlicesY (ETH2Poly x) = fitSlicesY x
  getCorrelationFactor2 (ETH2Poly x) = getCorrelationFactor2 x
  getCovariance2 (ETH2Poly x) = getCovariance2 x
  integral2 (ETH2Poly x) = integral2 x
  rebinX2 (ETH2Poly x) = rebinX2 x
  rebinY2 (ETH2Poly x) = rebinY2 x
  rebin2D (ETH2Poly x) = rebin2D x
  setShowProjectionX (ETH2Poly x) = setShowProjectionX x
  setShowProjectionY (ETH2Poly x) = setShowProjectionY x
instance ITH1 (Exist TH2Poly) where
  add (ETH2Poly x) = add x
  addBinContent (ETH2Poly x) = addBinContent x
  chi2Test (ETH2Poly x) = chi2Test x
  computeIntegral (ETH2Poly x) = computeIntegral x
  directoryAutoAdd (ETH2Poly x) = directoryAutoAdd x
  divide (ETH2Poly x) = divide x
  drawCopyTH1 (ETH2Poly x) a1 = return . ETH2Poly =<< drawCopyTH1 x a1
  drawNormalized (ETH2Poly x) = drawNormalized x
  drawPanelTH1 (ETH2Poly x) = drawPanelTH1 x
  bufferEmpty (ETH2Poly x) = bufferEmpty x
  evalF (ETH2Poly x) = evalF x
  fFT (ETH2Poly x) = fFT x
  fill1 (ETH2Poly x) = fill1 x
  fill1w (ETH2Poly x) = fill1w x
  fillN1 (ETH2Poly x) = fillN1 x
  fillRandom (ETH2Poly x) = fillRandom x
  findBin (ETH2Poly x) = findBin x
  findFixBin (ETH2Poly x) = findFixBin x
  findFirstBinAbove (ETH2Poly x) = findFirstBinAbove x
  findLastBinAbove (ETH2Poly x) = findLastBinAbove x
  fitPanelTH1 (ETH2Poly x) = fitPanelTH1 x
  getNdivisionA (ETH2Poly x) = getNdivisionA x
  getAxisColorA (ETH2Poly x) = getAxisColorA x
  getLabelColorA (ETH2Poly x) = getLabelColorA x
  getLabelFontA (ETH2Poly x) = getLabelFontA x
  getLabelOffsetA (ETH2Poly x) = getLabelOffsetA x
  getLabelSizeA (ETH2Poly x) = getLabelSizeA x
  getTitleFontA (ETH2Poly x) = getTitleFontA x
  getTitleOffsetA (ETH2Poly x) = getTitleOffsetA x
  getTitleSizeA (ETH2Poly x) = getTitleSizeA x
  getTickLengthA (ETH2Poly x) = getTickLengthA x
  getBarOffset (ETH2Poly x) = getBarOffset x
  getBarWidth (ETH2Poly x) = getBarWidth x
  getContour (ETH2Poly x) = getContour x
  getContourLevel (ETH2Poly x) = getContourLevel x
  getContourLevelPad (ETH2Poly x) = getContourLevelPad x
  getBin (ETH2Poly x) = getBin x
  getBinCenter (ETH2Poly x) = getBinCenter x
  getBinContent1 (ETH2Poly x) = getBinContent1 x
  getBinContent2 (ETH2Poly x) = getBinContent2 x
  getBinContent3 (ETH2Poly x) = getBinContent3 x
  getBinError1 (ETH2Poly x) = getBinError1 x
  getBinError2 (ETH2Poly x) = getBinError2 x
  getBinError3 (ETH2Poly x) = getBinError3 x
  getBinLowEdge (ETH2Poly x) = getBinLowEdge x
  getBinWidth (ETH2Poly x) = getBinWidth x
  getCellContent (ETH2Poly x) = getCellContent x
  getCellError (ETH2Poly x) = getCellError x
  getEntries (ETH2Poly x) = getEntries x
  getEffectiveEntries (ETH2Poly x) = getEffectiveEntries x
  getFunction (ETH2Poly x) = getFunction x
  getDimension (ETH2Poly x) = getDimension x
  getKurtosis (ETH2Poly x) = getKurtosis x
  getLowEdge (ETH2Poly x) = getLowEdge x
  getMaximumTH1 (ETH2Poly x) = getMaximumTH1 x
  getMaximumBin (ETH2Poly x) = getMaximumBin x
  getMaximumStored (ETH2Poly x) = getMaximumStored x
  getMinimumTH1 (ETH2Poly x) = getMinimumTH1 x
  getMinimumBin (ETH2Poly x) = getMinimumBin x
  getMinimumStored (ETH2Poly x) = getMinimumStored x
  getMean (ETH2Poly x) = getMean x
  getMeanError (ETH2Poly x) = getMeanError x
  getNbinsX (ETH2Poly x) = getNbinsX x
  getNbinsY (ETH2Poly x) = getNbinsY x
  getNbinsZ (ETH2Poly x) = getNbinsZ x
  getQuantilesTH1 (ETH2Poly x) = getQuantilesTH1 x
  getRandom (ETH2Poly x) = getRandom x
  getStats (ETH2Poly x) = getStats x
  getSumOfWeights (ETH2Poly x) = getSumOfWeights x
  getSumw2 (ETH2Poly x) = getSumw2 x
  getSumw2N (ETH2Poly x) = getSumw2N x
  getRMS (ETH2Poly x) = getRMS x
  getRMSError (ETH2Poly x) = getRMSError x
  getSkewness (ETH2Poly x) = getSkewness x
  integral1 (ETH2Poly x) = integral1 x
  interpolate1 (ETH2Poly x) = interpolate1 x
  interpolate2 (ETH2Poly x) = interpolate2 x
  interpolate3 (ETH2Poly x) = interpolate3 x
  kolmogorovTest (ETH2Poly x) = kolmogorovTest x
  labelsDeflate (ETH2Poly x) = labelsDeflate x
  labelsInflate (ETH2Poly x) = labelsInflate x
  labelsOption (ETH2Poly x) = labelsOption x
  multiflyF (ETH2Poly x) = multiflyF x
  multiply (ETH2Poly x) = multiply x
  putStats (ETH2Poly x) = putStats x
  rebin (ETH2Poly x) = rebin x
  rebinAxis (ETH2Poly x) = rebinAxis x
  rebuild (ETH2Poly x) = rebuild x
  recursiveRemove (ETH2Poly x) = recursiveRemove x
  reset (ETH2Poly x) = reset x
  resetStats (ETH2Poly x) = resetStats x
  scale (ETH2Poly x) = scale x
  setAxisColorA (ETH2Poly x) = setAxisColorA x
  setAxisRange (ETH2Poly x) = setAxisRange x
  setBarOffset (ETH2Poly x) = setBarOffset x
  setBarWidth (ETH2Poly x) = setBarWidth x
  setBinContent1 (ETH2Poly x) = setBinContent1 x
  setBinContent2 (ETH2Poly x) = setBinContent2 x
  setBinContent3 (ETH2Poly x) = setBinContent3 x
  setBinError1 (ETH2Poly x) = setBinError1 x
  setBinError2 (ETH2Poly x) = setBinError2 x
  setBinError3 (ETH2Poly x) = setBinError3 x
  setBins1 (ETH2Poly x) = setBins1 x
  setBins2 (ETH2Poly x) = setBins2 x
  setBins3 (ETH2Poly x) = setBins3 x
  setBinsLength (ETH2Poly x) = setBinsLength x
  setBuffer (ETH2Poly x) = setBuffer x
  setCellContent (ETH2Poly x) = setCellContent x
  setContent (ETH2Poly x) = setContent x
  setContour (ETH2Poly x) = setContour x
  setContourLevel (ETH2Poly x) = setContourLevel x
  setDirectory (ETH2Poly x) = setDirectory x
  setEntries (ETH2Poly x) = setEntries x
  setError (ETH2Poly x) = setError x
  setLabelColorA (ETH2Poly x) = setLabelColorA x
  setLabelSizeA (ETH2Poly x) = setLabelSizeA x
  setLabelFontA (ETH2Poly x) = setLabelFontA x
  setLabelOffsetA (ETH2Poly x) = setLabelOffsetA x
  setMaximum (ETH2Poly x) = setMaximum x
  setMinimum (ETH2Poly x) = setMinimum x
  setNormFactor (ETH2Poly x) = setNormFactor x
  setStats (ETH2Poly x) = setStats x
  setOption (ETH2Poly x) = setOption x
  setXTitle (ETH2Poly x) = setXTitle x
  setYTitle (ETH2Poly x) = setYTitle x
  setZTitle (ETH2Poly x) = setZTitle x
  showBackground (ETH2Poly x) = showBackground x
  showPeaks (ETH2Poly x) = showPeaks x
  smooth (ETH2Poly x) = smooth x
  sumw2 (ETH2Poly x) = sumw2 x
instance ITObject (Exist TH2Poly) where
  draw (ETH2Poly x) = draw x
  findObject (ETH2Poly x) = findObject x
  getName (ETH2Poly x) = getName x
  isA (ETH2Poly x) = isA x
  paint (ETH2Poly x) = paint x
  printObj (ETH2Poly x) = printObj x
  saveAs (ETH2Poly x) = saveAs x
  write (ETH2Poly x) = write x
instance ITAttLine (Exist TH2Poly) where
  getLineColor (ETH2Poly x) = getLineColor x
  getLineStyle (ETH2Poly x) = getLineStyle x
  getLineWidth (ETH2Poly x) = getLineWidth x
  resetAttLine (ETH2Poly x) = resetAttLine x
  setLineAttributes (ETH2Poly x) = setLineAttributes x
  setLineColor (ETH2Poly x) = setLineColor x
  setLineStyle (ETH2Poly x) = setLineStyle x
  setLineWidth (ETH2Poly x) = setLineWidth x
instance ITAttFill (Exist TH2Poly) where
  setFillColor (ETH2Poly x) = setFillColor x
  setFillStyle (ETH2Poly x) = setFillStyle x
instance ITAttMarker (Exist TH2Poly) where
  getMarkerColor (ETH2Poly x) = getMarkerColor x
  getMarkerStyle (ETH2Poly x) = getMarkerStyle x
  getMarkerSize (ETH2Poly x) = getMarkerSize x
  resetAttMarker (ETH2Poly x) = resetAttMarker x
  setMarkerAttributes (ETH2Poly x) = setMarkerAttributes x
  setMarkerColor (ETH2Poly x) = setMarkerColor x
  setMarkerStyle (ETH2Poly x) = setMarkerStyle x
  setMarkerSize (ETH2Poly x) = setMarkerSize x
instance IDeletable (Exist TH2Poly) where
  delete (ETH2Poly x) = delete x







instance FPtr (Exist TH2Poly) where
  type Raw (Exist TH2Poly) = RawTH2Poly
  get_fptr (ETH2Poly obj) = castForeignPtr (get_fptr obj)
  cast_fptr_to_obj fptr = ETH2Poly (cast_fptr_to_obj (fptr :: ForeignPtr RawTH2Poly) :: TH2Poly)