{-# LANGUAGE DeriveDataTypeable #-}
{-# OPTIONS_GHC -fno-warn-missing-fields #-}
{-# OPTIONS_GHC -fno-warn-missing-signatures #-}
{-# OPTIONS_GHC -fno-warn-name-shadowing #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-----------------------------------------------------------------
-- Autogenerated by Thrift Compiler (0.7.0-dev)                      --
--                                                             --
-- DO NOT EDIT UNLESS YOU ARE SURE YOU KNOW WHAT YOU ARE DOING --
-----------------------------------------------------------------

module Thrift.ContentConsumer where
import Prelude ( Bool(..), Enum, Double, String, Maybe(..),
                 Eq, Show, Ord,
                 return, length, IO, fromIntegral, fromEnum, toEnum,
                 (&&), (||), (==), (++), ($), (-) )

import Control.Exception
import Data.ByteString.Lazy
import Data.Int
import Data.Typeable ( Typeable )
import qualified Data.Map as Map
import qualified Data.Set as Set

import Thrift


import Thrift.Content_Types
import qualified Thrift.ContentConsumer_Iface as Iface
-- HELPER FUNCTIONS AND STRUCTURES --

data MeshChanged_args = MeshChanged_args{f_MeshChanged_args_name :: Maybe String} deriving (Show,Eq,Ord,Typeable)
write_MeshChanged_args oprot record = do
  writeStructBegin oprot "MeshChanged_args"
  case f_MeshChanged_args_name record of {Nothing -> return (); Just _v -> do
    writeFieldBegin oprot ("name",T_STRING,1)
    writeString oprot _v
    writeFieldEnd oprot}
  writeFieldStop oprot
  writeStructEnd oprot
read_MeshChanged_args_fields iprot record = do
  (_,_t31,_id32) <- readFieldBegin iprot
  if _t31 == T_STOP then return record else
    case _id32 of 
      1 -> if _t31 == T_STRING then do
        s <- readString iprot
        read_MeshChanged_args_fields iprot record{f_MeshChanged_args_name=Just s}
        else do
          skip iprot _t31
          read_MeshChanged_args_fields iprot record
      _ -> do
        skip iprot _t31
        readFieldEnd iprot
        read_MeshChanged_args_fields iprot record
read_MeshChanged_args iprot = do
  _ <- readStructBegin iprot
  record <- read_MeshChanged_args_fields iprot (MeshChanged_args{f_MeshChanged_args_name=Nothing})
  readStructEnd iprot
  return record
data MeshChanged_result = MeshChanged_result deriving (Show,Eq,Ord,Typeable)
write_MeshChanged_result oprot record = do
  writeStructBegin oprot "MeshChanged_result"
  writeFieldStop oprot
  writeStructEnd oprot
read_MeshChanged_result_fields iprot record = do
  (_,_t36,_id37) <- readFieldBegin iprot
  if _t36 == T_STOP then return record else
    case _id37 of 
      _ -> do
        skip iprot _t36
        readFieldEnd iprot
        read_MeshChanged_result_fields iprot record
read_MeshChanged_result iprot = do
  _ <- readStructBegin iprot
  record <- read_MeshChanged_result_fields iprot (MeshChanged_result{})
  readStructEnd iprot
  return record
process_meshChanged (seqid, iprot, oprot, handler) = do
  args <- read_MeshChanged_args iprot
  readMessageEnd iprot
  rs <- return (MeshChanged_result)
  res <- (do
    Iface.meshChanged handler (f_MeshChanged_args_name args)
    return rs)
  writeMessageBegin oprot ("meshChanged", M_REPLY, seqid);
  write_MeshChanged_result oprot res
  writeMessageEnd oprot
  tFlush (getTransport oprot)
proc_ handler (iprot,oprot) (name,typ,seqid) = case name of
  "meshChanged" -> process_meshChanged (seqid,iprot,oprot,handler)
  _ -> do
    skip iprot T_STRUCT
    readMessageEnd iprot
    writeMessageBegin oprot (name,M_EXCEPTION,seqid)
    writeAppExn oprot (AppExn AE_UNKNOWN_METHOD ("Unknown function " ++ name))
    writeMessageEnd oprot
    tFlush (getTransport oprot)
process handler (iprot, oprot) = do
  (name, typ, seqid) <- readMessageBegin iprot
  proc_ handler (iprot,oprot) (name,typ,seqid)
  return True
