start with niches, we can have the nullary one :-)

-- Modeling Opetopes
-- here is Eric's editor: http://sma.epfl.ch/~finster/opetope/opetope.html
--
-- Note: Kock et al. use a similar scheme, where
--          - dots    <-->   lines
--          - spheres <-->   dots
--          - lines disappear
--          -                spheres appear

-- Note: In Eric's new work (at IAS) there are no
--       dots any more, instead he uses 'output cards', so
--          - (output) cards   <-->  lines
--          - space between stacked cards <--> output cards
--          - lines disappear
--          -                (regular) cards appear

import "../tests/Nat.prg"

kind Trees = NoTree | Pre (Tree d) Trees deriving syntax (ts) List(NoTree, Pre)

data ZoomCompley :: Tree e ~> Tree f ~> * where
  Nily :: ZoomCompley a a
  Consy :: Stack a b -> ZoomCompley b c -> ZoomCompley a c
 deriving List(cply)

data ZoomComplex :: Trees ~> * where
  Nilx :: ZoomComplex [()tr]ts
  Endx :: Stack a b -> ZoomComplex [a, b]ts
  Consx :: Stack a b -> ZoomComplex [b; c]ts -> ZoomComplex [a, b; c]ts
 deriving syntax (cplx) List(Nilx, Consx) Item(Endx)

data Dir :: *2 where
  Hor :: Dir
  Ver :: Dir

-- define the Tree kind, a rose tree
-- note: we may need a two-level kind, since we need to track disjointness
--       of subtrees
-- todo: later we may want to have a label kind parameter too

data Tree :: Dir ~> *1 where
  Unit :: Tree Ver
  Ni :: Tree Hor
  Fork :: Tree d ~> Tree Hor ~> Tree Hor
 deriving syntax (tr) List(Ni, Fork) Unit(Unit)

-- make it singleton

data Tree' :: Tree d ~> * where
  In :: Tree' ()tr
  Fork :: Tree' head -> Tree' tail -> Tree' [head; tail]tr
  Done :: Tree' []tr
 deriving syntax (ar) List(Done, Fork) Unit(In) -- "arbre"
-- http://www.papoulipoesique.com/wp-content/uploads/2013/06/arbre.jpg

-- define a proposition for subtrees
-- to be checked: TakeHead must ensure that all the node is consumed

prop Subtree :: Tree d ~> Tree e ~> * where
  UnitSub :: Subtree ()tr tr
  BothNil :: Subtree []tr []tr
  TakeHead :: Subtree head head' -> Subtree tail tail' -> Subtree [head; tail]tr [head'; tail']tr

-- now we can stack cards (these are zooms in Kock et al. parlance)

data Stack :: Tree d ~> Tree e ~> * where
  Empty :: Corolla tr => Tree' tr -> Stack tr ()tr
  SubDone :: Stack ()tr []tr
  SubCont :: Stack ()tr tr -> Stack ()tr [tr]tr
  --Subdivision :: Stack ()tr sub -> Stack tr rest -> Stack tr [sub; rest]tr
  Encompass :: Subtree consumed tr => Stack consumed prod -> Stack tr prod
  -- the following three grab a node (and possibly its offsprings) and incorporate it into a single card
  NodeDone :: Stack []tr [()tr]tr
  Pick :: {- EntireNode => -} Stack head prodhead -> Stack tail prodtail -> Stack [head; tail]tr [prodhead; prodtail]tr
  Exclude :: {- EntireNode => -} Stack tail prod -> Stack [()tr; tail]tr prod
  -- we need a way to sequence cards
  -- MultiCard :: ??? Disjoint a b 0 => Subtree a -> Subtree b -> Stack tr a [proda, prodb]tr

  On :: (Subtree tr' tr, Pointers 1t at out) => Stack tr' out' -> Stack tr out -> Tree' at -> Stack tr {graft out' at out}

  -- building niches
  NicheDone :: Stack ()tr []tr
  Also :: () -- (Pointers 1t at tr)
         => Tree' at -> Stack tr' [out']tr -> Stack tr out -> Stack {extgraft tr' at tr} [out'; out]tr

  -- WARNING: [out']tr ---> one sibling for now

-- it remains to define corollas

prop Corolla :: Tree d ~> * where
  None' :: Corolla []tr
  One' :: Corolla tail -> Corolla [()tr; tail]tr

--  o   --->  |
--  |         |

lolliCell :: Stack []tr ()tr
lolliCell = Empty Done

--  |         |
--  o   --->  |
--  |         |

dolliCell :: Stack [()tr]tr ()tr
dolliCell = Empty $ Fork In Done

--              |
--  [o]   --->  o
--   |          |

lolliFrame :: Stack []tr [()tr]tr
lolliFrame = Encompass NodeDone

--   |          |
--  [o]   --->  o
--   |          |

dolliFrame :: Stack [()tr]tr [()tr]tr
dolliFrame = Encompass (Exclude NodeDone)

--   |          |
--   |          o
-- [[o]]  --->  |
--   |          o
--   |          |

stacked :: Stack [()tr]tr [[()tr]tr]tr
stacked = (dolliFrame `On` dolliFrame) (In `Fork` Done)

--   |
--  [|]   --->  o
--   |          |

crossed :: Stack ()tr []tr
crossed = SubDone

-- we can now join things
--
dolliForever = [dolliFrame; dolliForever]cply
nopetope = [crossed, lolliFrame; dolliForever]cply

-- back to unit as fast as possible...
--
stopetope = [crossed, lolliFrame, dolliCell]cply
neverstopetope = [crossed, lolliFrame, dolliCell; neverstopetope]cply
stopetope' = [crossed, lolliFrame; (dolliCell)cplx]cplx
stopetope'' = [crossed, lolliFrame, dolliCell]cplx

--   |          o
-- [[|]]  --->  |
--   |          o
--   |          |

drossed :: Stack ()tr [[]tr]tr
drossed = SubCont SubDone
-- drossed = (SubDone `On` NodeDone) In
-- Note: can we find a way to graft here? Then On would be feasible

--  |          +
--  |          |

-- this is a niche, but assume to be a frame
niche0 :: Stack ()tr []tr
niche0 = NicheDone

--  |           |
-- [|]          +
--  |           |

-- this is a niche, but assume to be a frame
--niche1 :: Stack ()tr [[]tr, []tr]tr
--niche1 = Also ()ar SubDone NicheDone

--  |         o   o
-- [|]  --->   \ /
-- [|]          +
--  |           |

-- this is a niche, but assume to be a frame
--niche2 :: Stack ()tr [[]tr, []tr]tr
--niche2 = Also ()ar SubDone SubDone

--                |
--  |         o   o
-- [o]  --->   \ /
-- [|]          o
--  |           |

--paste :: Stack [()tr]tr [[]tr, ()tr]tr
--paste = Also ()ar SubDone (Exclude NodeDone)

--                    |
--    |           o   o
-- | [o] |  --->   \ /
-- | [|] |          o
--    |             |

--cyclops :: Stack [()tr]tr [[]tr, ()tr]tr
--cyclops = Pick (Beside ()ar ()ar SubDone (Exclude NodeDone)) NodeDone

-- Stacking, Valence, Affine subtree, Substitute at an affine position

-- counting Units in a tree

valence :: Tree d ~> Nat
{valence []tr} = 0t
{valence [head; tail]tr} = {plus {valence head} {valence tail}}
{valence ()tr} = 1t

-- counting siblings of a tree

nodeValence :: Tree d ~> Nat
{nodeValence []tr} = 0t
{nodeValence [head; tail]tr} = (1+{nodeValence tail})t

-- nodeValenceAt: given a (multi)pointer, determine the node valences at those positions
--               WHERE     IN
nodeValenceAt :: Tree d ~> Tree e ~> Nat
{nodeValenceAt ()tr tree} = {nodeValence tree}
{nodeValenceAt []tr []tr} = 0t
{nodeValenceAt [head'; tail']tr [head; tail]tr} = {plus {nodeValenceAt head' head} {nodeValenceAt tail' tail}}

-- a pointer is a valence-1 subtree of a tree
-- it is used to mark a unit in a tree where substitution will occur
--
prop Pointers :: Nat ~> Tree d ~> Tree e ~> * where
  Finger :: Pointers 1t ()tr ()tr
  Finished :: Pointers 0t []tr []tr
  ThisWay :: Pointers 1t head' head -> Pointers n tail' tail -> Pointers (1+n)t [head'; tail']tr [head; tail]tr
  ElseWhere :: Pointers n tail' tail -> Pointers n [[]tr; tail']tr [head; tail]tr

-- http://en.wikipedia.org/wiki/Grafting
--
-- graft WHAT      WHERE     IN
graft :: Tree d ~> Tree e ~> Tree f ~> Tree f
{graft what ()tr ()tr} = what
{graft what []tr tr} = tr
{graft what [head'; tail']tr [head; tail]tr} = [{graft what head' head}; {graft what tail' tail}]tr

extgraft :: Tree what ~> Tree wher ~> Tree tree ~> Tree tree'
{extgraft what ()tr ()tr} = what
{extgraft what []tr ()tr} = ()tr
{extgraft what [head; tail]tr ()tr} = [{extgraft what head ()tr}; {extgraft what tail ()tr}]tr
{extgraft what []tr []tr} = []tr
{extgraft what []tr [head; tail]tr} = [head; tail]tr
{extgraft what [head'; tail']tr [head; tail]tr} = [{extgraft what head' head}; {extgraft what tail' tail}]tr

{- TODO? multiGraft :: Treelist -> where -> in -}

{- NOTE: we have an Omega bug here:

prompt> :norm {graft []tr ()tr ()tr}
Normalizes to:
  []tr

prompt> :kind []tr
[]tr :: Tree Hor  = []tr

prompt> :kind {graft []tr ()tr ()tr}
{graft []tr ()tr ()tr} :: Tree Ver  = {graft []tr ()tr ()tr}

... BUT: Hor /= Ver :-(
-}

-- substitution: replace a pointed node (of valence n) in a tree with an
-- other tree of (valence n) -- TODO

-- HERE IS A NICE RESEARCH QUESTION:
-- is it possible to "proof search" a Zoom?
-- i.e.
{-

class ZoomLike (int :: Tree) (out :: Tree) where
  zoom :: (Nodes int ~ Valence out) => Zoom int out

-}

-- Modeling Opetopes
-- here is Eric's editor: http://sma.epfl.ch/~finster/opetope/opetope.html
--
-- Note: Kock et al. use a similar scheme, where
--          - dots    <-->   lines
--          - spheres <-->   dots
--          - lines disappear
--          -                spheres appear

-- Note: In Eric's new work (at IAS) there are no
--       dots any more, instead he uses 'output cards', so
--          - (output) cards   <-->  lines
--          - space between stacked cards <--> output cards
--          - lines disappear
--          -                (regular) cards appear

import "../tests/Nat.prg"

kind Trees = NoTree | Pre (Tree d) Trees deriving syntax (ts) List(NoTree, Pre)

data ZoomCompley :: Tree e ~> Tree f ~> * where
  Nily :: ZoomCompley a a
  Consy :: Stack a b -> ZoomCompley b c -> ZoomCompley a c
 deriving List(cply)

data ZoomComplex :: Trees ~> * where
  Nilx :: ZoomComplex [()tr]ts
  Endx :: Stack a b -> ZoomComplex [a, b]ts
  Consx :: Stack a b -> ZoomComplex [b; c]ts -> ZoomComplex [a, b; c]ts
 deriving syntax (cplx) List(Nilx, Consx) Item(Endx)

data Dir :: *2 where
  Hor :: Dir
  Ver :: Dir

-- define the Tree kind, a rose tree
-- note: we may need a two-level kind, since we need to track disjointness
--       of subtrees
-- todo: later we may want to have a label kind parameter too

data Tree :: Dir ~> *1 where
  Unit :: Tree Ver
  Ni :: Tree Hor
  Fork :: Tree d ~> Tree Hor ~> Tree Hor
 deriving syntax (tr) List(Ni, Fork) Unit(Unit)

-- make it singleton

data Tree' :: Tree d ~> * where
  In :: Tree' ()tr
  Fork :: Tree' head -> Tree' tail -> Tree' [head; tail]tr
  Done :: Tree' []tr
 deriving syntax (ar) List(Done, Fork) Unit(In) -- "arbre"
-- http://www.papoulipoesique.com/wp-content/uploads/2013/06/arbre.jpg

-- define a proposition for subtrees
-- to be checked: TakeHead must ensure that all the node is consumed

prop Subtree :: Tree d ~> Tree e ~> * where
  UnitSub :: Subtree ()tr tr
  BothNil :: Subtree []tr []tr
  TakeHead :: Subtree head head' -> Subtree tail tail' -> Subtree [head; tail]tr [head'; tail']tr

-- now we can stack cards (these are zooms in Kock et al. parlance)

data Stack :: Tree d ~> Tree e ~> * where
  Empty :: Corolla tr => Tree' tr -> Stack tr ()tr
  SubDone :: Stack ()tr []tr
  SubCont :: Stack ()tr tr -> Stack ()tr [tr]tr
  --Subdivision :: Stack ()tr sub -> Stack tr rest -> Stack tr [sub; rest]tr
  Encompass :: Subtree consumed tr => Stack consumed prod -> Stack tr prod
  -- the following three grab a node (and possibly its offsprings) and incorporate it into a single card
  NodeDone :: Stack []tr [()tr]tr
  Pick :: {- EntireNode => -} Stack head prodhead -> Stack tail prodtail -> Stack [head; tail]tr [prodhead; prodtail]tr
  Exclude :: {- EntireNode => -} Stack tail prod -> Stack [()tr; tail]tr prod
  -- we need a way to sequence cards
  -- MultiCard :: ??? Disjoint a b 0 => Subtree a -> Subtree b -> Stack tr a [proda, prodb]tr

  On :: (Subtree tr' tr, Pointers 1t at out) => Stack tr' out' -> Stack tr out -> Tree' at -> Stack tr {graft out' at out}
  Beside :: () -- (Pointers 1t at tr, Pointers 1t {graft skipping at at} {graft skipping at tr})
         => Tree' at -> Tree' skipping -> Stack tr' [out']tr -> Stack tr out -> Stack {graft tr' {graft skipping at at} {graft skipping at tr}} [out'; out]tr

  -- WARNING: [out']tr ---> one sibling for now

-- it remains to define corollas

prop Corolla :: Tree d ~> * where
  None' :: Corolla []tr
  One' :: Corolla tail -> Corolla [()tr; tail]tr

--  o   --->  |
--  |         |

lolliCell :: Stack []tr ()tr
lolliCell = Empty Done

--  |         |
--  o   --->  |
--  |         |

dolliCell :: Stack [()tr]tr ()tr
dolliCell = Empty $ Fork In Done

--              |
--  [o]   --->  o
--   |          |

lolliFrame :: Stack []tr [()tr]tr
lolliFrame = Encompass NodeDone

--   |          |
--  [o]   --->  o
--   |          |

dolliFrame :: Stack [()tr]tr [()tr]tr
dolliFrame = Encompass (Exclude NodeDone)

--   |          |
--   |          o
-- [[o]]  --->  |
--   |          o
--   |          |

stacked :: Stack [()tr]tr [[()tr]tr]tr
stacked = (dolliFrame `On` dolliFrame) (In `Fork` Done)

--   |
--  [|]   --->  o
--   |          |

crossed :: Stack ()tr []tr
crossed = SubDone

-- we can now join things
--
dolliForever = [dolliFrame; dolliForever]cply
nopetope = [crossed, lolliFrame; dolliForever]cply

-- back to unit as fast as possible...
--
stopetope = [crossed, lolliFrame, dolliCell]cply
neverstopetope = [crossed, lolliFrame, dolliCell; neverstopetope]cply
stopetope' = [crossed, lolliFrame; (dolliCell)cplx]cplx
stopetope'' = [crossed, lolliFrame, dolliCell]cplx

--   |          o
-- [[|]]  --->  |
--   |          o
--   |          |

drossed :: Stack ()tr [[]tr]tr
drossed = SubCont SubDone
-- drossed = (SubDone `On` NodeDone) In
-- Note: can we find a way to graft here? Then On would be feasible

--                    |
--    |           o   o
-- | [o] |  --->   \ /
-- | [|] |          o
--    |             |

--cyclops :: Stack [()tr]tr [[]tr, ()tr]tr
--cyclops = Pick (Beside ()ar ()ar SubDone (Exclude NodeDone)) NodeDone

-- Stacking, Valence, Affine subtree, Substitute at an affine position

-- counting Units in a tree

valence :: Tree d ~> Nat
{valence []tr} = 0t
{valence [head; tail]tr} = {plus {valence head} {valence tail}}
{valence ()tr} = 1t

-- counting siblings of a tree

nodeValence :: Tree d ~> Nat
{nodeValence []tr} = 0t
{nodeValence [head; tail]tr} = (1+{nodeValence tail})t

-- nodeValenceAt: given a (multi)pointer, determine the node valences at those positions
--               WHERE     IN
nodeValenceAt :: Tree d ~> Tree e ~> Nat
{nodeValenceAt ()tr tree} = {nodeValence tree}
{nodeValenceAt []tr []tr} = 0t
{nodeValenceAt [head'; tail']tr [head; tail]tr} = {plus {nodeValenceAt head' head} {nodeValenceAt tail' tail}}

-- a pointer is a valence-1 subtree of a tree
-- it is used to mark a unit in a tree where substitution will occur
--
prop Pointers :: Nat ~> Tree d ~> Tree e ~> * where
  Finger :: Pointers 1t ()tr ()tr
  Finished :: Pointers 0t []tr []tr
  ThisWay :: Pointers 1t head' head -> Pointers n tail' tail -> Pointers (1+n)t [head'; tail']tr [head; tail]tr
  ElseWhere :: Pointers n tail' tail -> Pointers n [[]tr; tail']tr [head; tail]tr

-- http://en.wikipedia.org/wiki/Grafting
--
-- graft WHAT      WHERE     IN
graft :: Tree d ~> Tree e ~> Tree f ~> Tree f
{graft what ()tr ()tr} = what
{graft what []tr tr} = tr
{graft what [head'; tail']tr [head; tail]tr} = [{graft what head' head}; {graft what tail' tail}]tr

extgraft :: Tree what ~> Tree wher ~> Tree tree ~> Tree tree'
{extgraft what ()tr ()tr} = what
{extgraft what []tr ()tr} = ()tr
{extgraft what [head; tail]tr ()tr} = [{extgraft what head ()tr}; {extgraft what tail ()tr}]tr
{extgraft what []tr []tr} = []tr
{extgraft what []tr [head; tail]tr} = [head; tail]tr
{extgraft what [head'; tail']tr [head; tail]tr} = [{extgraft what head' head}; {extgraft what tail' tail}]tr

{- TODO? multiGraft :: Treelist -> where -> in -}

{- NOTE: we have an Omega bug here:

prompt> :norm {graft []tr ()tr ()tr}
Normalizes to:
  []tr

prompt> :kind []tr
[]tr :: Tree Hor  = []tr

prompt> :kind {graft []tr ()tr ()tr}
{graft []tr ()tr ()tr} :: Tree Ver  = {graft []tr ()tr ()tr}

... BUT: Hor /= Ver :-(
-}

-- substitution: replace a pointed node (of valence n) in a tree with an
-- other tree of (valence n) -- TODO

-- HERE IS A NICE RESEARCH QUESTION:
-- is it possible to "proof search" a Zoom?
-- i.e.
{-

class ZoomLike (int :: Tree) (out :: Tree) where
  zoom :: (Nodes int ~ Valence out) => Zoom int out

-}


An Exception in OleAutoObject.NoMethod was not forwarded "as is" but as an argument exception.

//
// Copyright (c) XSharp B.V.  All Rights Reserved.
// Licensed under the Apache License, Version 2.0.
// See License.txt in the project root for license information.
//

USING System.Diagnostics
USING System.Reflection
USING System.Runtime.Remoting
USING System.Runtime.InteropServices
USING System.Runtime.CompilerServices
USING XSharp.Internal
/// VO Compatible OLE Automation class
[AllowLateBinding];
[DebuggerDisplay( "Type= {__ComObject}", Type := "OleAutoObject" )];
CLASS XSharp.OleAutoObject
	PROTECTED oComObject AS OBJECT
	PROTECTED lOk        AS LOGIC
	PROTECTED _liFuncs   AS LONG
	PROTECTED _liVars    AS LONG
	PROTECTED oType      AS System.Type
	PROTECTED lDateTimeAsDate   AS LOGIC

	#region Constructors
	INTERNAL CONSTRUCTOR
		_liFuncs                := _liVars := -1
		lOk                     := FALSE
		oComObject              := NULL
		oType                   := NULL
		SELF:lDateTimeAsDate    := OleDateTimeAsDate()
		RETURN

   /// Construct an OleAutoObject
	CONSTRUCTOR(cProgId AS STRING)
		SELF()
		oComObject        := OleCreateObject(cProgId)
		lOk := oComObject != NULL
		IF lOk
			oType := oComObject:GetType()
		ENDIF

		RETURN

   /// Construct an OleAutoObject
	CONSTRUCTOR(cProgId AS STRING, fRotCheck AS LOGIC)
		SELF()
		IF fRotCheck
			oComObject := OleGetObject(cProgId)
		ENDIF
		IF oComObject == NULL
			oComObject := OleCreateObject(cProgId)
		ENDIF
		lOk := oComObject != NULL
		IF lOk
			oType := oComObject:GetType()
		ENDIF
		RETURN

	// Builds an OleAutoObject on Any OBJECT (including another AutoObject)
   /// Construct an OleAutoObject
	CONSTRUCTOR(oObject AS OBJECT)
		SELF()
		oComObject :=  OleUnWrapObject(oObject)
		lOk := oComObject != NULL
		IF lOk
			oType := oComObject:GetType()
		ENDIF

		RETURN

		// Builds an OleAutoObject on Any OBJECT (including another AutoObject). Type already known
   /// Construct an OleAutoObject
	CONSTRUCTOR(oObject AS OBJECT, _type AS System.Type)
		SELF()
		oComObject	:=  OleUnWrapObject(oObject)
		oType		:= _type
		lOk			:= oComObject != NULL
		RETURN

	#endregion

	#region No..() EntryPoints

	// ? oObject:Property
	    /// <exclude />
    METHOD NoIVarGet(cName AS STRING ) AS USUAL STRICT
		LOCAL oRet AS OBJECT
		oRet := OleAutoObject.__OleIvarGet(oComObject,oType, cName, NULL)
		RETURN OleAutoObject.OleWrapObject(oRet, lDateTimeAsDate)

		// oObject:Property := Value
	    /// <exclude />
	METHOD NoIvarPut(cName AS STRING, uValue AS USUAL) AS VOID STRICT
		OleAutoObject.__OleIVarPut(oComObject, oType, cName , uValue, NULL)
		RETURN

	    /// <exclude />
	METHOD NoMethod( ) AS USUAL CLIPPER
		LOCAL cName AS STRING
		LOCAL args  AS USUAL[]
		LOCAL nArg, nArgs  AS INT
		LOCAL oRet  AS OBJECT
		nArgs := PCOUNT()
        IF RuntimeState.Dialect == XSharpDialect.Vulcan
		    cName := NoMethod()
		    args  := USUAL[]{nArgs-1}
		    FOR nArg := 2 TO nArgs
			    args[nArg-1] :=  _GetMParam(nArg)
            NEXT
        ELSE
		    cName := NoMethod()
		    args  := USUAL[]{nArgs}
		    FOR nArg := 1 TO nArgs
			    args[nArg] :=  _GetMParam(nArg)
            NEXT
        ENDIF
		oRet := OleAutoObject.OleSend(oComObject, oType, cName, args)

		RETURN OleAutoObject.OleWrapObject(oRet, lDateTimeAsDate)

	// ? oObject:Property[dims]
	// The compiler needs to be changed to look for this method
	    /// <exclude />
	METHOD NoIVarGetCollection(cName AS STRING, dims AS USUAL[]) AS USUAL
		LOCAL oRet AS OBJECT
		oRet := OleAutoObject.OleIvarGet(oComObject, cName, dims)
		RETURN OleAutoObject.OleWrapObject(oRet, lDateTimeAsDate)

	// ? oObject:Property[dims] := Value
	// The compiler needs to be changed to look for this method
	    /// <exclude />
	METHOD NoIVarPutCollection(cName AS STRING, uValue AS USUAL, dims AS USUAL[]) AS VOID
		OleAutoObject.OleIVarPut(oComObject, cName, uValue , dims )
		RETURN
	#endregion

	#region VO Compatibility Accesses
	    /// <exclude />

	ACCESS dwFuncs  AS LONG
		IF (lOk)
			LOCAL t AS System.Type
			IF (_liFuncs < 0)
				t := oComObject:GetType()
				_liFuncs := t:GetMethods():Length
			ENDIF
			RETURN _liFuncs
		ENDIF
		RETURN 0

	ASSIGN dwFuncs(value AS LONG)
		SELF:_liFuncs := value
		RETURN

	    /// <exclude />
	ACCESS dwVars   AS LONG
		IF (lOk)
			LOCAL t AS System.Type
			IF (_liVars < 0)
				t := oComObject:GetType()
				_liVars := t:GetProperties():Length
			ENDIF
			RETURN _liVars
		ENDIF
		RETURN 0

	    /// <exclude />
	ACCESS fInit    AS LOGIC
		RETURN lOk

	#endregion

	#region	INTERNAL Properties

	// Access to OBJECT inside AutoObject
    /// <exclude />

    ACCESS __ComObject AS OBJECT
		RETURN SELF:oComObject

	#endregion

	#region STATIC Methods
	    /// <exclude />
	STATIC METHOD OleCreateObject(cProgId AS STRING) AS OBJECT
		LOCAL oComObject := NULL AS OBJECT
		LOCAL objecttype AS System.Type
		TRY
			objecttype        := System.Type.GetTypeFromProgID(cProgId, FALSE)
			IF objecttype != NULL
				oComObject        := System.Activator.CreateInstance (objecttype)
			ENDIF
		CATCH AS Exception
			// We catch the exception but do not process it
		END TRY
		RETURN oComObject

    /// <exclude />
	STATIC METHOD  OleGetObject(cProgId AS STRING) AS OBJECT
		LOCAL oComObject AS OBJECT
		TRY
			oComObject := Marshal.GetActiveObject(cProgId)
		CATCH AS Exception
			oComObject := NULL
		END TRY
		RETURN oComObject

	#region Wrapping Objects
    /// <exclude />
    STATIC METHOD  OleWrapObject(oObject AS OBJECT,lDateTimeAsDate AS LOGIC) AS USUAL
		LOCAL t  AS System.Type
		LOCAL tc  AS System.TypeCode
		LOCAL oDt AS OleDateTime
		LOCAL uResult := NIL AS USUAL
		IF (oObject != NULL)
			t := oObject:GetType()
			tc := Type.GetTypeCode(t)
			IF tc == TypeCode.DateTime
				IF (lDateTimeAsDate)
					LOCAL oD AS System.DateTime
					oD := (System.DateTime)oObject
					uResult := XSharp.__Date{oD}
				ELSE
					oDt := (DateTime) oObject
					uResult := oDt
				ENDIF
			ELSE
				IF t:IsCOMObject
					uResult := OleAutoObject{oObject,t}
				ELSE
					uResult := oObject
				ENDIF
			ENDIF
		ENDIF
		RETURN uResult

    /// <exclude />
	STATIC METHOD  OleUnWrapObject(oObject AS OBJECT) AS OBJECT
		LOCAL oAuto AS OleAutoObject
		IF oObject != NULL
			IF oObject IS OleAutoObject
				oAuto := (OleAutoObject) oObject
				oObject := oAuto:__ComObject
			ENDIF
		ENDIF
		RETURN oObject

	#endregion

	#region OBJECT Properties

    /// <exclude />
	STATIC METHOD  OleIvarGet(oObject AS OBJECT,strName AS STRING) AS OBJECT
		RETURN OleAutoObject.__OleIvarGet(oObject, oObject:GetType(), strName, NULL)

    /// <exclude />
	STATIC METHOD  OleIvarGet(oObject AS OBJECT, symName AS STRING, dims  AS USUAL[]) AS OBJECT
		RETURN OleAutoObject.__OleIvarGet(oObject, oObject:GetType(), symName, dims)

    /// <exclude />
	STATIC METHOD  OleIvarGet(oObject AS OBJECT, symName AS STRING, index  AS USUAL) AS OBJECT
		LOCAL dims AS USUAL[]
		dims := USUAL[]{1}
		dims[1] := index
		RETURN OleAutoObject.__OleIvarGet(oObject, oObject:GetType(), symName, dims)

    /// <exclude />
	STATIC METHOD  OleIVarPut(oObject AS OBJECT, symName AS STRING, uValue AS USUAL) AS VOID
		OleAutoObject.__OleIVarPut(oObject, oObject:GetType(), symName, uValue, NULL)
		RETURN

    /// <exclude />
	STATIC METHOD  OleIVarPut(oObject AS OBJECT, symName AS STRING, uValue AS USUAL, dims AS USUAL[]) AS VOID
		OleAutoObject.__OleIVarPut(oObject, oObject:GetType(), symName, uValue, dims)
		RETURN

    /// <exclude />
	STATIC METHOD  OleIVarPut(oObject AS OBJECT, symName AS STRING, uValue AS USUAL, index AS USUAL) AS VOID
		LOCAL dims AS USUAL[]
		dims := USUAL[]{1}
		dims[1] := index
		OleAutoObject.__OleIVarPut(oObject, oObject:GetType(), symName, uValue, dims)
		RETURN

	#endregion

	#region Worker Functions

    /// <exclude />
	STATIC METHOD  __OleIvarGet(oComObject AS OBJECT, oType AS System.Type, cName AS STRING, dims AS USUAL[]) AS OBJECT
		LOCAL fi       AS FieldInfo
		LOCAL oRet     AS OBJECT
		LOCAL t        AS System.Type
		LOCAL lIndexed AS LOGIC
		LOCAL cMethod  AS STRING
		LOCAL bf AS BindingFlags

		cMethod := __ENTITY__
		IF oComObject == NULL
			THROW Error.NullArgumentError( cMethod, "oComObject", 1 )
		ENDIF
		lIndexed := (dims != NULL)
		t  := oType
		oComObject := OleUnWrapObject( oComObject )
		bf := BindingFlags.FlattenHierarchy | BindingFlags.GetField | ;
		BindingFlags.IgnoreCase | BindingFlags.GetProperty |  BindingFlags.Instance | BindingFlags.Public ;

		fi :=t:GetField( cName, bf )

		IF fi != NULL
			IF ! fi:IsPublic
				THROW Error.VOError( EG_NOVARMETHOD,  cMethod, "cMethod", 2,  <OBJECT>{cName } )
			ELSE
				oRet := fi:GetValue( oComObject )
			ENDIF
		ELSE
			IF lIndexed

				LOCAL oArgs AS OBJECT[]
				LOCAL i     AS INT
				oArgs := OBJECT[]{dims:Length }
				FOR i := 1 UPTO dims:Length
					oArgs[i] :=  OleUnWrapObject(dims[i])
				NEXT
				oRet := oType:InvokeMember(cName,bf ,NULL, oComObject,oArgs)
			ELSE
				oRet := oType:InvokeMember(cName, bf,NULL, oComObject, NULL)
			ENDIF
		ENDIF
		RETURN oRet

		#endregion

#region Putting OBJECT Properties

    /// <exclude />
STATIC METHOD  __OleIVarPut(oComObject AS OBJECT, oType AS System.Type, cName AS STRING, uValue AS USUAL, dims AS USUAL[]) AS VOID
	LOCAL t        AS System.Type
	LOCAL fi       AS FieldInfo
	LOCAL lIndexed AS LOGIC
	LOCAL cMethod  AS STRING
	cMethod := __ENTITY__

	IF oComObject == NULL
		THROW Error.NullArgumentError( cMethod, NAMEOF(oComObject), 1 )
	ENDIF

	// Get the inner OBJECT from OleAutoObjects
	// For both the Target and the value
	oComObject  := OleUnWrapObject( oComObject)
	uValue      := OleUnWrapObject( uValue )

	t := oType

	lIndexed := (dims != NULL)

	fi := t:GetField( cName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.IgnoreCase  )

	IF fi != NULL
		fi:SetValue( oComObject, uValue )
	ELSE
		LOCAL bf      AS BindingFlags
		LOCAL oArgs   AS OBJECT[]
		bf := BindingFlags.FlattenHierarchy | BindingFlags.SetField | ;
		BindingFlags.IgnoreCase | BindingFlags.SetProperty
		IF lIndexed
			LOCAL i     AS INT
			oArgs := OBJECT[]{dims:Length+1 }
			FOR i := 1 UPTO dims:Length
				oArgs[i+1] := OleUnWrapObject(dims[i])
			NEXT
		ELSE
			oArgs := OBJECT[]{1 }
		ENDIF
		oArgs[1] := uValue
		TRY
			oType:InvokeMember(cName, bf,NULL, oComObject, oArgs)
			CATCH e AS Exception
			THROW e
		END TRY

	ENDIF

	RETURN

	#endregion
    /// <exclude />

STATIC METHOD  OleSend(oComObject AS OBJECT, oType AS System.Type, cName AS STRING, args AS USUAL[]) AS OBJECT
	LOCAL mi       AS MethodInfo
	LOCAL pi       AS ParameterInfo[]
	LOCAL t        AS Type
	LOCAL cMethod  AS STRING
	LOCAL x        AS INT
	LOCAL bf       AS BindingFlags

	LOCAL retval := NULL AS OBJECT
	cMethod  := __ENTITY__

	IF oComObject == NULL
		THROW Error.NullArgumentError( __ENTITY__, NAMEOF(oComObject), 1 )
	ENDIF
	t  :=oType
	oComObject := OleUnWrapObject(oComObject)
	bf :=  BindingFlags.Instance | BindingFlags.Public | BindingFlags.FlattenHierarchy| BindingFlags.InvokeMethod |  BindingFlags.IgnoreCase

	TRY
		mi := t:GetMethod( cName, bf)
		IF mi == NULL
			mi := t:GetMethod( cName)
		ENDIF

		IF mi == NULL
			// Ok we know nothing, just try to Invoke the method
			TRY

				VAR oArgs1 := OBJECT[] {args:Length} // Array of arguments for call to Invoke
				FOR x := 1 UPTO args:Length
					oArgs1[x] := OleUnWrapObject(args[x])
				NEXT
				retval := t:InvokeMember(cName, bf, NULL, oComObject, oArgs1)
			CATCH AS ArgumentException
				THROW Error.VOError(EG_ARG,  cMethod,"args", 4, <OBJECT>{args} )
			CATCH AS TargetException
				THROW Error.VOError(EG_ARG,  cMethod, "args", 4, <OBJECT>{args})
			CATCH AS MissingMethodException
				THROW Error.VOError(EG_NOMETHOD,  cMethod, "cName", 2,  <OBJECT>{cName}  )
			CATCH e AS Exception
				THROW Error{e}
			END TRY
		ELSE
			pi := mi:GetParameters()
			IF pi:Length == 1 .AND. mi:IsDefined( TYPEOF( XSharp.Internal.ClipperCallingConventionAttribute ), FALSE )
				retval := mi:Invoke(oComObject, <OBJECT>{args})
			ELSEIF pi:Length == 0
				retval := mi:Invoke(oComObject, NULL )
			ELSE
				LOCAL nArgs          AS INT   // # of arguments passed in
				LOCAL pArg           AS USUAL PTR   // This is used to derefence arguments
				LOCAL nLastUnNamed   AS INT  // Last unnamed argument passed in
				LOCAL lFound         AS LOGIC // Was the Named Arg Found

				VAR nDefArgs := pi:Length			// # of arguments defined for method
				VAR oArgs := OBJECT[]{ nDefArgs }	// Array of arguments for call to Invoke
				IF args != NULL
					nArgs := args:Length
					nArgs := Math.Min( nArgs, nDefArgs )
				ELSE
					nArgs := 0
				ENDIF
				nLastUnNamed := nArgs
				FOR x := 1 UPTO nArgs
					VAR oArg := OleUnWrapObject(args[x])

					IF IsPtr(oArg)
						// By Reference ?
						pArg     := Usual{oArg}
						oArgs[x] := pArg[1]

					ELSEIF oArg IS NamedArg
						// Named Argument ?
						nLastUnNamed:= Math.Min( x - 1, nLastUnNamed )
						VAR oNamedArg   := (NamedArg) oArg
						VAR cArgName    := oNamedArg:ArgName
						lFound      := FALSE
						FOR VAR y := 1 TO  nDefArgs
							VAR paramInfo := pi[y]
							IF String.Compare( paramInfo:Name, cArgName, StringComparison.OrdinalIgnoreCase ) == 0
								oArgs[y] := oNamedArg:Value
								lFound   := TRUE
								EXIT
							ENDIF
						NEXT
						IF ! lFound
							THROW Error.VOError(EG_ARG,  cMethod, cArgName, (DWORD) x, <OBJECT>{oNamedArg} )
						ENDIF

					ELSE
						// Normal argument
						oArgs[x] := oArg
					ENDIF
				NEXT
				// Fill in missing method parameter values
				// nLastUnNamed has # of last unnamed argument
				FOR x :=nLastUnNamed+1 TO nDefArgs
					IF oArgs[x] == NULL
						// When no value, fill in the default
						VAR paramInfo := pi[x]
						oArgs[x] := paramInfo:DefaultValue
					ENDIF
				NEXT
				LOCAL lOk AS LOGIC
				// Try MethodInfo:Invoke first.
				TRY
					retval := mi:Invoke(oComObject, oArgs)
					lOk := TRUE
					// return Out parameters
					FOR x := 1 TO nArgs
						VAR paramInfo := pi[x]
						IF paramInfo:Attributes:HasFlag( ParameterAttributes.Out)
							IF IsPtr(args[x])
								pArg := args[x]
								pArg[1] := oArgs[x]
							ENDIF
						ENDIF
					NEXT
				CATCH AS Exception
					lOk := FALSE
				END TRY
				// If that fails we try t:InvokeMember. You never know if that will work...
				IF ! lOk
					TRY
						retval := t:InvokeMember(cName, bf, NULL, oComObject, oArgs)
						lOk    := TRUE
					CATCH AS ArgumentException
						THROW Error.VOError(EG_ARG,  cMethod, cMethod, 1, <OBJECT>{args})
						//lOk := FALSE
					CATCH AS TargetException
						THROW Error.VOError(EG_ARG,  cMethod, cMethod, 1, <OBJECT>{args} )
						//lOk := FALSE
					CATCH AS MissingMethodException
						THROW Error.VOError(EG_NOMETHOD,  cMethod, "cName", 2, <OBJECT>{cName}  )
						//lOk := FALSE
					CATCH AS Exception
						lOk := FALSE
					END TRY
				ENDIF
				IF ! lOk
					THROW Error.VOError(EG_ARG,  cMethod, cMethod, 1, <OBJECT>{args}  )
				ENDIF
			ENDIF
		ENDIF
	CATCH AS AmbiguousMatchException
		THROW Error.VOError( EG_AMBIGUOUSMETHOD,  cMethod, "cMethod", 2, <OBJECT>{cMethod} )
	END TRY
	RETURN retval
	#endregion

END CLASS

//
// Copyright (c) XSharp B.V.  All Rights Reserved.
// Licensed under the Apache License, Version 2.0.
// See License.txt in the project root for license information.
//

USING System.Diagnostics
USING System.Reflection
USING System.Runtime.Remoting
USING System.Runtime.InteropServices
USING System.Runtime.CompilerServices
USING XSharp.Internal
/// VO Compatible OLE Automation class
[AllowLateBinding];
[DebuggerDisplay( "Type= {__ComObject}", Type := "OleAutoObject" )];
CLASS XSharp.OleAutoObject
	PROTECTED oComObject AS OBJECT
	PROTECTED lOk        AS LOGIC
	PROTECTED _liFuncs   AS LONG
	PROTECTED _liVars    AS LONG
	PROTECTED oType      AS System.Type
	PROTECTED lDateTimeAsDate   AS LOGIC

	#region Constructors
	INTERNAL CONSTRUCTOR
		_liFuncs                := _liVars := -1
		lOk                     := FALSE
		oComObject              := NULL
		oType                   := NULL
		SELF:lDateTimeAsDate    := OleDateTimeAsDate()
		RETURN

   /// Construct an OleAutoObject
	CONSTRUCTOR(cProgId AS STRING)
		SELF()
		oComObject        := OleCreateObject(cProgId)
		lOk := oComObject != NULL
		IF lOk
			oType := oComObject:GetType()
		ENDIF

		RETURN

   /// Construct an OleAutoObject
	CONSTRUCTOR(cProgId AS STRING, fRotCheck AS LOGIC)
		SELF()
		IF fRotCheck
			oComObject := OleGetObject(cProgId)
		ENDIF
		IF oComObject == NULL
			oComObject := OleCreateObject(cProgId)
		ENDIF
		lOk := oComObject != NULL
		IF lOk
			oType := oComObject:GetType()
		ENDIF
		RETURN

	// Builds an OleAutoObject on Any OBJECT (including another AutoObject)
   /// Construct an OleAutoObject
	CONSTRUCTOR(oObject AS OBJECT)
		SELF()
		oComObject :=  OleUnWrapObject(oObject)
		lOk := oComObject != NULL
		IF lOk
			oType := oComObject:GetType()
		ENDIF

		RETURN

		// Builds an OleAutoObject on Any OBJECT (including another AutoObject). Type already known
   /// Construct an OleAutoObject
	CONSTRUCTOR(oObject AS OBJECT, _type AS System.Type)
		SELF()
		oComObject	:=  OleUnWrapObject(oObject)
		oType		:= _type
		lOk			:= oComObject != NULL
		RETURN

	#endregion

	#region No..() EntryPoints

	// ? oObject:Property
	    /// <exclude />
    METHOD NoIVarGet(cName AS STRING ) AS USUAL STRICT
		LOCAL oRet AS OBJECT
		oRet := OleAutoObject.__OleIvarGet(oComObject,oType, cName, NULL)
		RETURN OleAutoObject.OleWrapObject(oRet, lDateTimeAsDate)

		// oObject:Property := Value
	    /// <exclude />
	METHOD NoIvarPut(cName AS STRING, uValue AS USUAL) AS VOID STRICT
		OleAutoObject.__OleIVarPut(oComObject, oType, cName , uValue, NULL)
		RETURN

	    /// <exclude />
	METHOD NoMethod( ) AS USUAL CLIPPER
		LOCAL cName AS STRING
		LOCAL args  AS USUAL[]
		LOCAL nArg, nArgs  AS INT
		LOCAL oRet  AS OBJECT
		nArgs := PCOUNT()
        IF RuntimeState.Dialect == XSharpDialect.Vulcan
		    cName := NoMethod()
		    args  := USUAL[]{nArgs-1}
		    FOR nArg := 2 TO nArgs
			    args[nArg-1] :=  _GetMParam(nArg)
            NEXT
        ELSE
		    cName := NoMethod()
		    args  := USUAL[]{nArgs}
		    FOR nArg := 1 TO nArgs
			    args[nArg] :=  _GetMParam(nArg)
            NEXT
        ENDIF
		oRet := OleAutoObject.OleSend(oComObject, oType, cName, args)

		RETURN OleAutoObject.OleWrapObject(oRet, lDateTimeAsDate)

	// ? oObject:Property[dims]
	// The compiler needs to be changed to look for this method
	    /// <exclude />
	METHOD NoIVarGetCollection(cName AS STRING, dims AS USUAL[]) AS USUAL
		LOCAL oRet AS OBJECT
		oRet := OleAutoObject.OleIvarGet(oComObject, cName, dims)
		RETURN OleAutoObject.OleWrapObject(oRet, lDateTimeAsDate)

	// ? oObject:Property[dims] := Value
	// The compiler needs to be changed to look for this method
	    /// <exclude />
	METHOD NoIVarPutCollection(cName AS STRING, uValue AS USUAL, dims AS USUAL[]) AS VOID
		OleAutoObject.OleIVarPut(oComObject, cName, uValue , dims )
		RETURN
	#endregion

	#region VO Compatibility Accesses
	    /// <exclude />

	ACCESS dwFuncs  AS LONG
		IF (lOk)
			LOCAL t AS System.Type
			IF (_liFuncs < 0)
				t := oComObject:GetType()
				_liFuncs := t:GetMethods():Length
			ENDIF
			RETURN _liFuncs
		ENDIF
		RETURN 0

	ASSIGN dwFuncs(value AS LONG)
		SELF:_liFuncs := value
		RETURN

	    /// <exclude />
	ACCESS dwVars   AS LONG
		IF (lOk)
			LOCAL t AS System.Type
			IF (_liVars < 0)
				t := oComObject:GetType()
				_liVars := t:GetProperties():Length
			ENDIF
			RETURN _liVars
		ENDIF
		RETURN 0

	    /// <exclude />
	ACCESS fInit    AS LOGIC
		RETURN lOk

	#endregion

	#region	INTERNAL Properties

	// Access to OBJECT inside AutoObject
    /// <exclude />

    ACCESS __ComObject AS OBJECT
		RETURN SELF:oComObject

	#endregion

	#region STATIC Methods
	    /// <exclude />
	STATIC METHOD OleCreateObject(cProgId AS STRING) AS OBJECT
		LOCAL oComObject := NULL AS OBJECT
		LOCAL objecttype AS System.Type
		TRY
			objecttype        := System.Type.GetTypeFromProgID(cProgId, FALSE)
			IF objecttype != NULL
				oComObject        := System.Activator.CreateInstance (objecttype)
			ENDIF
		CATCH AS Exception
			// We catch the exception but do not process it
		END TRY
		RETURN oComObject

    /// <exclude />
	STATIC METHOD  OleGetObject(cProgId AS STRING) AS OBJECT
		LOCAL oComObject AS OBJECT
		TRY
			oComObject := Marshal.GetActiveObject(cProgId)
		CATCH AS Exception
			oComObject := NULL
		END TRY
		RETURN oComObject

	#region Wrapping Objects
    /// <exclude />
    STATIC METHOD  OleWrapObject(oObject AS OBJECT,lDateTimeAsDate AS LOGIC) AS USUAL
		LOCAL t  AS System.Type
		LOCAL tc  AS System.TypeCode
		LOCAL oDt AS OleDateTime
		LOCAL uResult := NIL AS USUAL
		IF (oObject != NULL)
			t := oObject:GetType()
			tc := Type.GetTypeCode(t)
			IF tc == TypeCode.DateTime
				IF (lDateTimeAsDate)
					LOCAL oD AS System.DateTime
					oD := (System.DateTime)oObject
					uResult := XSharp.__Date{oD}
				ELSE
					oDt := (DateTime) oObject
					uResult := oDt
				ENDIF
			ELSE
				IF t:IsCOMObject
					uResult := OleAutoObject{oObject,t}
				ELSE
					uResult := oObject
				ENDIF
			ENDIF
		ENDIF
		RETURN uResult

    /// <exclude />
	STATIC METHOD  OleUnWrapObject(oObject AS OBJECT) AS OBJECT
		LOCAL oAuto AS OleAutoObject
		IF oObject != NULL
			IF oObject IS OleAutoObject
				oAuto := (OleAutoObject) oObject
				oObject := oAuto:__ComObject
			ENDIF
		ENDIF
		RETURN oObject

	#endregion

	#region OBJECT Properties

    /// <exclude />
	STATIC METHOD  OleIvarGet(oObject AS OBJECT,strName AS STRING) AS OBJECT
		RETURN OleAutoObject.__OleIvarGet(oObject, oObject:GetType(), strName, NULL)

    /// <exclude />
	STATIC METHOD  OleIvarGet(oObject AS OBJECT, symName AS STRING, dims  AS USUAL[]) AS OBJECT
		RETURN OleAutoObject.__OleIvarGet(oObject, oObject:GetType(), symName, dims)

    /// <exclude />
	STATIC METHOD  OleIvarGet(oObject AS OBJECT, symName AS STRING, index  AS USUAL) AS OBJECT
		LOCAL dims AS USUAL[]
		dims := USUAL[]{1}
		dims[1] := index
		RETURN OleAutoObject.__OleIvarGet(oObject, oObject:GetType(), symName, dims)

    /// <exclude />
	STATIC METHOD  OleIVarPut(oObject AS OBJECT, symName AS STRING, uValue AS USUAL) AS VOID
		OleAutoObject.__OleIVarPut(oObject, oObject:GetType(), symName, uValue, NULL)
		RETURN

    /// <exclude />
	STATIC METHOD  OleIVarPut(oObject AS OBJECT, symName AS STRING, uValue AS USUAL, dims AS USUAL[]) AS VOID
		OleAutoObject.__OleIVarPut(oObject, oObject:GetType(), symName, uValue, dims)
		RETURN

    /// <exclude />
	STATIC METHOD  OleIVarPut(oObject AS OBJECT, symName AS STRING, uValue AS USUAL, index AS USUAL) AS VOID
		LOCAL dims AS USUAL[]
		dims := USUAL[]{1}
		dims[1] := index
		OleAutoObject.__OleIVarPut(oObject, oObject:GetType(), symName, uValue, dims)
		RETURN

	#endregion

	#region Worker Functions

    /// <exclude />
	STATIC METHOD  __OleIvarGet(oComObject AS OBJECT, oType AS System.Type, cName AS STRING, dims AS USUAL[]) AS OBJECT
		LOCAL fi       AS FieldInfo
		LOCAL oRet     AS OBJECT
		LOCAL t        AS System.Type
		LOCAL lIndexed AS LOGIC
		LOCAL cMethod  AS STRING
		LOCAL bf AS BindingFlags

		cMethod := __ENTITY__
		IF oComObject == NULL
			THROW Error.NullArgumentError( cMethod, "oComObject", 1 )
		ENDIF
		lIndexed := (dims != NULL)
		t  := oType
		oComObject := OleUnWrapObject( oComObject )
		bf := BindingFlags.FlattenHierarchy | BindingFlags.GetField | ;
		BindingFlags.IgnoreCase | BindingFlags.GetProperty |  BindingFlags.Instance | BindingFlags.Public ;

		fi :=t:GetField( cName, bf )

		IF fi != NULL
			IF ! fi:IsPublic
				THROW Error.VOError( EG_NOVARMETHOD,  cMethod, "cMethod", 2,  <OBJECT>{cName } )
			ELSE
				oRet := fi:GetValue( oComObject )
			ENDIF
		ELSE
			IF lIndexed

				LOCAL oArgs AS OBJECT[]
				LOCAL i     AS INT
				oArgs := OBJECT[]{dims:Length }
				FOR i := 1 UPTO dims:Length
					oArgs[i] :=  OleUnWrapObject(dims[i])
				NEXT
				oRet := oType:InvokeMember(cName,bf ,NULL, oComObject,oArgs)
			ELSE
				oRet := oType:InvokeMember(cName, bf,NULL, oComObject, NULL)
			ENDIF
		ENDIF
		RETURN oRet

		#endregion

#region Putting OBJECT Properties

    /// <exclude />
STATIC METHOD  __OleIVarPut(oComObject AS OBJECT, oType AS System.Type, cName AS STRING, uValue AS USUAL, dims AS USUAL[]) AS VOID
	LOCAL t        AS System.Type
	LOCAL fi       AS FieldInfo
	LOCAL lIndexed AS LOGIC
	LOCAL cMethod  AS STRING
	cMethod := __ENTITY__

	IF oComObject == NULL
		THROW Error.NullArgumentError( cMethod, NAMEOF(oComObject), 1 )
	ENDIF

	// Get the inner OBJECT from OleAutoObjects
	// For both the Target and the value
	oComObject  := OleUnWrapObject( oComObject)
	uValue      := OleUnWrapObject( uValue )

	t := oType

	lIndexed := (dims != NULL)

	fi := t:GetField( cName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.IgnoreCase  )

	IF fi != NULL
		fi:SetValue( oComObject, uValue )
	ELSE
		LOCAL bf      AS BindingFlags
		LOCAL oArgs   AS OBJECT[]
		bf := BindingFlags.FlattenHierarchy | BindingFlags.SetField | ;
		BindingFlags.IgnoreCase | BindingFlags.SetProperty
		IF lIndexed
			LOCAL i     AS INT
			oArgs := OBJECT[]{dims:Length+1 }
			FOR i := 1 UPTO dims:Length
				oArgs[i+1] := OleUnWrapObject(dims[i])
			NEXT
		ELSE
			oArgs := OBJECT[]{1 }
		ENDIF
		oArgs[1] := uValue
		TRY
			oType:InvokeMember(cName, bf,NULL, oComObject, oArgs)
			CATCH e AS Exception
			THROW e
		END TRY

	ENDIF

	RETURN

	#endregion
    /// <exclude />

STATIC METHOD  OleSend(oComObject AS OBJECT, oType AS System.Type, cName AS STRING, args AS USUAL[]) AS OBJECT
	LOCAL mi       AS MethodInfo
	LOCAL pi       AS ParameterInfo[]
	LOCAL t        AS Type
	LOCAL cMethod  AS STRING
	LOCAL x        AS INT
	LOCAL bf       AS BindingFlags

	LOCAL retval := NULL AS OBJECT
	cMethod  := __ENTITY__

	IF oComObject == NULL
		THROW Error.NullArgumentError( __ENTITY__, NAMEOF(oComObject), 1 )
	ENDIF
	t  :=oType
	oComObject := OleUnWrapObject(oComObject)
	bf :=  BindingFlags.Instance | BindingFlags.Public | BindingFlags.FlattenHierarchy| BindingFlags.InvokeMethod |  BindingFlags.IgnoreCase

	TRY
		mi := t:GetMethod( cName, bf)
		IF mi == NULL
			mi := t:GetMethod( cName)
		ENDIF

		IF mi == NULL
			// Ok we know nothing, just try to Invoke the method
			TRY

				VAR oArgs1 := OBJECT[] {args:Length} // Array of arguments for call to Invoke
				FOR x := 1 UPTO args:Length
					oArgs1[x] := OleUnWrapObject(args[x])
				NEXT
				retval := t:InvokeMember(cName, bf, NULL, oComObject, oArgs1)
			CATCH AS ArgumentException
				THROW Error.VOError(EG_ARG,  cMethod,"args", 4, <OBJECT>{args} )
			CATCH AS TargetException
				THROW Error.VOError(EG_ARG,  cMethod, "args", 4, <OBJECT>{args})
			CATCH AS MissingMethodException
				THROW Error.VOError(EG_NOMETHOD,  cMethod, "cName", 2,  <OBJECT>{cName}  )
			CATCH AS Exception
				THROW Error.VOError( EG_ARG , cMethod, "args", 4,  <OBJECT>{args}  )
			END TRY
		ELSE
			pi := mi:GetParameters()
			IF pi:Length == 1 .AND. mi:IsDefined( TYPEOF( XSharp.Internal.ClipperCallingConventionAttribute ), FALSE )
				retval := mi:Invoke(oComObject, <OBJECT>{args})
			ELSEIF pi:Length == 0
				retval := mi:Invoke(oComObject, NULL )
			ELSE
				LOCAL nArgs          AS INT   // # of arguments passed in
				LOCAL pArg           AS USUAL PTR   // This is used to derefence arguments
				LOCAL nLastUnNamed   AS INT  // Last unnamed argument passed in
				LOCAL lFound         AS LOGIC // Was the Named Arg Found

				VAR nDefArgs := pi:Length			// # of arguments defined for method
				VAR oArgs := OBJECT[]{ nDefArgs }	// Array of arguments for call to Invoke
				IF args != NULL
					nArgs := args:Length
					nArgs := Math.Min( nArgs, nDefArgs )
				ELSE
					nArgs := 0
				ENDIF
				nLastUnNamed := nArgs
				FOR x := 1 UPTO nArgs
					VAR oArg := OleUnWrapObject(args[x])

					IF IsPtr(oArg)
						// By Reference ?
						pArg     := Usual{oArg}
						oArgs[x] := pArg[1]

					ELSEIF oArg IS NamedArg
						// Named Argument ?
						nLastUnNamed:= Math.Min( x - 1, nLastUnNamed )
						VAR oNamedArg   := (NamedArg) oArg
						VAR cArgName    := oNamedArg:ArgName
						lFound      := FALSE
						FOR VAR y := 1 TO  nDefArgs
							VAR paramInfo := pi[y]
							IF String.Compare( paramInfo:Name, cArgName, StringComparison.OrdinalIgnoreCase ) == 0
								oArgs[y] := oNamedArg:Value
								lFound   := TRUE
								EXIT
							ENDIF
						NEXT
						IF ! lFound
							THROW Error.VOError(EG_ARG,  cMethod, cArgName, (DWORD) x, <OBJECT>{oNamedArg} )
						ENDIF

					ELSE
						// Normal argument
						oArgs[x] := oArg
					ENDIF
				NEXT
				// Fill in missing method parameter values
				// nLastUnNamed has # of last unnamed argument
				FOR x :=nLastUnNamed+1 TO nDefArgs
					IF oArgs[x] == NULL
						// When no value, fill in the default
						VAR paramInfo := pi[x]
						oArgs[x] := paramInfo:DefaultValue
					ENDIF
				NEXT
				LOCAL lOk AS LOGIC
				// Try MethodInfo:Invoke first.
				TRY
					retval := mi:Invoke(oComObject, oArgs)
					lOk := TRUE
					// return Out parameters
					FOR x := 1 TO nArgs
						VAR paramInfo := pi[x]
						IF paramInfo:Attributes:HasFlag( ParameterAttributes.Out)
							IF IsPtr(args[x])
								pArg := args[x]
								pArg[1] := oArgs[x]
							ENDIF
						ENDIF
					NEXT
				CATCH AS Exception
					lOk := FALSE
				END TRY
				// If that fails we try t:InvokeMember. You never know if that will work...
				IF ! lOk
					TRY
						retval := t:InvokeMember(cName, bf, NULL, oComObject, oArgs)
						lOk    := TRUE
					CATCH AS ArgumentException
						THROW Error.VOError(EG_ARG,  cMethod, cMethod, 1, <OBJECT>{args})
						//lOk := FALSE
					CATCH AS TargetException
						THROW Error.VOError(EG_ARG,  cMethod, cMethod, 1, <OBJECT>{args} )
						//lOk := FALSE
					CATCH AS MissingMethodException
						THROW Error.VOError(EG_NOMETHOD,  cMethod, "cName", 2, <OBJECT>{cName}  )
						//lOk := FALSE
					CATCH AS Exception
						lOk := FALSE
					END TRY
				ENDIF
				IF ! lOk
					THROW Error.VOError(EG_ARG,  cMethod, cMethod, 1, <OBJECT>{args}  )
				ENDIF
			ENDIF
		ENDIF
	CATCH AS AmbiguousMatchException
		THROW Error.VOError( EG_AMBIGUOUSMETHOD,  cMethod, "cMethod", 2, <OBJECT>{cMethod} )
	END TRY
	RETURN retval
	#endregion

END CLASS


QtSerialPort: module updated

QtSerialPort: module updated

Modified:
source/QtSerialPort/QSerialPort.prg

/*

  Qt5xHb - bibliotecas de ligao entre Harbour/xHarbour e Qt Framework 5

  Copyright (C) 2017 Marcos Antonio Gambeta <marcosgambeta AT outlook DOT com>

*/

#include "hbclass.ch"

CLASS QSerialPort INHERIT QIODevice

   METHOD new1
   METHOD new2
   METHOD new3
   METHOD new
   METHOD delete
   METHOD setPortName
   METHOD portName
   METHOD setPort
   METHOD open
   METHOD close
   METHOD setSettingsRestoredOnClose
   METHOD settingsRestoredOnClose
   METHOD setBaudRate
   METHOD baudRate
   METHOD setDataBits
   METHOD dataBits
   METHOD setParity
   METHOD parity
   METHOD setStopBits
   METHOD stopBits
   METHOD setFlowControl
   METHOD flowControl
   METHOD setDataTerminalReady
   METHOD isDataTerminalReady
   METHOD setRequestToSend
   METHOD isRequestToSend
   METHOD pinoutSignals
   METHOD flush
   METHOD clear
   METHOD atEnd
   METHOD setDataErrorPolicy
   METHOD dataErrorPolicy
   METHOD error
   METHOD clearError
   METHOD readBufferSize
   METHOD setReadBufferSize
   METHOD isSequential
   METHOD bytesAvailable
   METHOD bytesToWrite
   METHOD canReadLine
   METHOD waitForReadyRead
   METHOD waitForBytesWritten
   METHOD sendBreak
   METHOD setBreakEnabled

   METHOD onBaudRateChanged
   METHOD onDataBitsChanged
   METHOD onParityChanged
   METHOD onStopBitsChanged
   METHOD onFlowControlChanged
   METHOD onDataErrorPolicyChanged
   METHOD onDataTerminalReadyChanged
   METHOD onRequestToSendChanged
   METHOD onError
   METHOD onSettingsRestoredOnCloseChanged

   DESTRUCTOR destroyObject

END CLASS

PROCEDURE destroyObject () CLASS QSerialPort
   IF ::self_destruction
      ::delete()
   ENDIF
RETURN

#pragma BEGINDUMP

#include <Qt>

#ifndef __XHARBOUR__
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
#include <QSerialPort>
#endif
#endif

#include "qt5xhb_common.h"
#include "qt5xhb_macros.h"
#include "qt5xhb_utils.h"

#ifdef __XHARBOUR__
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
#include <QSerialPort>
#endif
#endif

/*
QSerialPort(QObject *parent = 0)
*/
HB_FUNC_STATIC( QSERIALPORT_NEW1 )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  QSerialPort * o = new QSerialPort ( OPQOBJECT(1,0) );
  _qt5xhb_storePointerAndFlag( o, false );
#endif
}

/*
QSerialPort(const QString &name, QObject *parent = 0)
*/
HB_FUNC_STATIC( QSERIALPORT_NEW2 )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  QSerialPort * o = new QSerialPort ( PQSTRING(1), OPQOBJECT(2,0) );
  _qt5xhb_storePointerAndFlag( o, false );
#endif
}

/*
QSerialPort(const QSerialPortInfo &info, QObject *parent = 0)
*/
HB_FUNC_STATIC( QSERIALPORT_NEW3 )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  QSerialPort * o = new QSerialPort ( *PQSERIALPORTINFO(1), OPQOBJECT(2,0) );
  _qt5xhb_storePointerAndFlag( o, false );
#endif
}

//[1]QSerialPort(QObject *parent = 0)
//[2]QSerialPort(const QString &name, QObject *parent = 0)
//[3]QSerialPort(const QSerialPortInfo &info, QObject *parent = 0)

// TODO: resolver conflito entre [1] e [2] quando for 1 parmetro do tipo O

HB_FUNC_STATIC( QSERIALPORT_NEW )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  if( ISBETWEEN(0,1) && ISOPTQOBJECT(1) )
  {
    HB_FUNC_EXEC( QSERIALPORT_NEW1 );
  }
  else if( ISBETWEEN(1,2) && ISCHAR(1) && ISOPTQOBJECT(2) )
  {
    HB_FUNC_EXEC( QSERIALPORT_NEW2 );
  }
  else if( ISBETWEEN(1,2) && ISQSERIALPORTINFO(1) && ISOPTQOBJECT(2) )
  {
    HB_FUNC_EXEC( QSERIALPORT_NEW3 );
  }
  else
  {
    hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
  }
#endif
}

HB_FUNC_STATIC( QSERIALPORT_DELETE )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  QSerialPort * obj = (QSerialPort *) hb_itemGetPtr( hb_objSendMsg( hb_stackSelfItem(), "POINTER", 0 ) );
  if( obj )
  {
    delete obj;
    obj = NULL;
    PHB_ITEM self = hb_stackSelfItem();
    PHB_ITEM ptr = hb_itemPutPtr( NULL, NULL );
    hb_objSendMsg( self, "_pointer", 1, ptr );
    hb_itemRelease( ptr );
  }
  hb_itemReturn( hb_stackSelfItem() );
#endif
}

/*
void setPortName(const QString &name)
*/
HB_FUNC_STATIC( QSERIALPORT_SETPORTNAME )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  QSerialPort * obj = (QSerialPort *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    obj->setPortName ( PQSTRING(1) );
  }
  hb_itemReturn( hb_stackSelfItem() );
#endif
}

/*
QString portName() const
*/
HB_FUNC_STATIC( QSERIALPORT_PORTNAME )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  QSerialPort * obj = (QSerialPort *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    RQSTRING( obj->portName () );
  }
#endif
}

/*
void setPort(const QSerialPortInfo &info)
*/
HB_FUNC_STATIC( QSERIALPORT_SETPORT )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  QSerialPort * obj = (QSerialPort *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    obj->setPort ( *PQSERIALPORTINFO(1) );
  }
  hb_itemReturn( hb_stackSelfItem() );
#endif
}

/*
bool open(OpenMode mode) Q_DECL_OVERRIDE
*/
HB_FUNC_STATIC( QSERIALPORT_OPEN )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  QSerialPort * obj = (QSerialPort *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    RBOOL( obj->open ( (QIODevice::OpenMode) hb_parni(1) ) );
  }
#endif
}

/*
void close() Q_DECL_OVERRIDE
*/
HB_FUNC_STATIC( QSERIALPORT_CLOSE )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  QSerialPort * obj = (QSerialPort *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    obj->close ();
  }
  hb_itemReturn( hb_stackSelfItem() );
#endif
}

/*
void setSettingsRestoredOnClose(bool restore)
*/
HB_FUNC_STATIC( QSERIALPORT_SETSETTINGSRESTOREDONCLOSE )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  QSerialPort * obj = (QSerialPort *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    obj->setSettingsRestoredOnClose ( PBOOL(1) );
  }
  hb_itemReturn( hb_stackSelfItem() );
#endif
}

/*
bool settingsRestoredOnClose() const
*/
HB_FUNC_STATIC( QSERIALPORT_SETTINGSRESTOREDONCLOSE )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  QSerialPort * obj = (QSerialPort *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    RBOOL( obj->settingsRestoredOnClose () );
  }
#endif
}

/*
bool setBaudRate(qint32 baudRate, Directions dir = AllDirections)
*/
HB_FUNC_STATIC( QSERIALPORT_SETBAUDRATE )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  QSerialPort * obj = (QSerialPort *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    int par2 = ISNIL(2)? (int) QSerialPort::AllDirections : hb_parni(2);
    RBOOL( obj->setBaudRate ( PQINT32(1), (QSerialPort::Directions) par2 ) );
  }
#endif
}

/*
qint32 baudRate(Directions dir = AllDirections) const
*/
HB_FUNC_STATIC( QSERIALPORT_BAUDRATE )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  QSerialPort * obj = (QSerialPort *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    int par1 = ISNIL(1)? (int) QSerialPort::AllDirections : hb_parni(1);
    RQINT32( obj->baudRate ( (QSerialPort::Directions) par1 ) );
  }
#endif
}

/*
bool setDataBits(DataBits dataBits)
*/
HB_FUNC_STATIC( QSERIALPORT_SETDATABITS )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  QSerialPort * obj = (QSerialPort *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    RBOOL( obj->setDataBits ( (QSerialPort::DataBits) hb_parni(1) ) );
  }
#endif
}

/*
DataBits dataBits() const
*/
HB_FUNC_STATIC( QSERIALPORT_DATABITS )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  QSerialPort * obj = (QSerialPort *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    hb_retni( obj->dataBits () );
  }
#endif
}

/*
bool setParity(Parity parity)
*/
HB_FUNC_STATIC( QSERIALPORT_SETPARITY )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  QSerialPort * obj = (QSerialPort *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    RBOOL( obj->setParity ( (QSerialPort::Parity) hb_parni(1) ) );
  }
#endif
}

/*
Parity parity() const
*/
HB_FUNC_STATIC( QSERIALPORT_PARITY )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  QSerialPort * obj = (QSerialPort *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    hb_retni( obj->parity () );
  }
#endif
}

/*
bool setStopBits(StopBits stopBits)
*/
HB_FUNC_STATIC( QSERIALPORT_SETSTOPBITS )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  QSerialPort * obj = (QSerialPort *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    RBOOL( obj->setStopBits ( (QSerialPort::StopBits) hb_parni(1) ) );
  }
#endif
}

/*
StopBits stopBits() const
*/
HB_FUNC_STATIC( QSERIALPORT_STOPBITS )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  QSerialPort * obj = (QSerialPort *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    hb_retni( obj->stopBits () );
  }
#endif
}

/*
bool setFlowControl(FlowControl flow)
*/
HB_FUNC_STATIC( QSERIALPORT_SETFLOWCONTROL )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  QSerialPort * obj = (QSerialPort *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    RBOOL( obj->setFlowControl ( (QSerialPort::FlowControl) hb_parni(1) ) );
  }
#endif
}

/*
FlowControl flowControl() const
*/
HB_FUNC_STATIC( QSERIALPORT_FLOWCONTROL )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  QSerialPort * obj = (QSerialPort *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    hb_retni( obj->flowControl () );
  }
#endif
}

/*
bool setDataTerminalReady(bool set)
*/
HB_FUNC_STATIC( QSERIALPORT_SETDATATERMINALREADY )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  QSerialPort * obj = (QSerialPort *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    RBOOL( obj->setDataTerminalReady ( PBOOL(1) ) );
  }
#endif
}

/*
bool isDataTerminalReady()
*/
HB_FUNC_STATIC( QSERIALPORT_ISDATATERMINALREADY )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  QSerialPort * obj = (QSerialPort *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    RBOOL( obj->isDataTerminalReady () );
  }
#endif
}

/*
bool setRequestToSend(bool set)
*/
HB_FUNC_STATIC( QSERIALPORT_SETREQUESTTOSEND )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  QSerialPort * obj = (QSerialPort *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    RBOOL( obj->setRequestToSend ( PBOOL(1) ) );
  }
#endif
}

/*
bool isRequestToSend()
*/
HB_FUNC_STATIC( QSERIALPORT_ISREQUESTTOSEND )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  QSerialPort * obj = (QSerialPort *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    RBOOL( obj->isRequestToSend () );
  }
#endif
}

/*
PinoutSignals pinoutSignals()
*/
HB_FUNC_STATIC( QSERIALPORT_PINOUTSIGNALS )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  QSerialPort * obj = (QSerialPort *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    hb_retni( obj->pinoutSignals () );
  }
#endif
}

/*
bool flush()
*/
HB_FUNC_STATIC( QSERIALPORT_FLUSH )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  QSerialPort * obj = (QSerialPort *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    RBOOL( obj->flush () );
  }
#endif
}

/*
bool clear(Directions dir = AllDirections)
*/
HB_FUNC_STATIC( QSERIALPORT_CLEAR )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  QSerialPort * obj = (QSerialPort *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    int par1 = ISNIL(1)? (int) QSerialPort::AllDirections : hb_parni(1);
    RBOOL( obj->clear ( (QSerialPort::Directions) par1 ) );
  }
#endif
}

/*
bool atEnd() const Q_DECL_OVERRIDE
*/
HB_FUNC_STATIC( QSERIALPORT_ATEND )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  QSerialPort * obj = (QSerialPort *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    RBOOL( obj->atEnd () );
  }
#endif
}

/*
bool setDataErrorPolicy(DataErrorPolicy policy = IgnorePolicy)
*/
HB_FUNC_STATIC( QSERIALPORT_SETDATAERRORPOLICY )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  QSerialPort * obj = (QSerialPort *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    int par1 = ISNIL(1)? (int) QSerialPort::IgnorePolicy : hb_parni(1);
    RBOOL( obj->setDataErrorPolicy ( (QSerialPort::DataErrorPolicy) par1 ) );
  }
#endif
}

/*
DataErrorPolicy dataErrorPolicy() const
*/
HB_FUNC_STATIC( QSERIALPORT_DATAERRORPOLICY )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  QSerialPort * obj = (QSerialPort *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    hb_retni( obj->dataErrorPolicy () );
  }
#endif
}

/*
SerialPortError error() const
*/
HB_FUNC_STATIC( QSERIALPORT_ERROR )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  QSerialPort * obj = (QSerialPort *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    hb_retni( obj->error () );
  }
#endif
}

/*
void clearError()
*/
HB_FUNC_STATIC( QSERIALPORT_CLEARERROR )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  QSerialPort * obj = (QSerialPort *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    obj->clearError ();
  }
  hb_itemReturn( hb_stackSelfItem() );
#endif
}

/*
qint64 readBufferSize() const
*/
HB_FUNC_STATIC( QSERIALPORT_READBUFFERSIZE )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  QSerialPort * obj = (QSerialPort *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    RQINT64( obj->readBufferSize () );
  }
#endif
}

/*
void setReadBufferSize(qint64 size)
*/
HB_FUNC_STATIC( QSERIALPORT_SETREADBUFFERSIZE )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  QSerialPort * obj = (QSerialPort *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    obj->setReadBufferSize ( PQINT64(1) );
  }
  hb_itemReturn( hb_stackSelfItem() );
#endif
}

/*
bool isSequential() const Q_DECL_OVERRIDE
*/
HB_FUNC_STATIC( QSERIALPORT_ISSEQUENTIAL )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  QSerialPort * obj = (QSerialPort *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    RBOOL( obj->isSequential () );
  }
#endif
}

/*
qint64 bytesAvailable() const Q_DECL_OVERRIDE
*/
HB_FUNC_STATIC( QSERIALPORT_BYTESAVAILABLE )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  QSerialPort * obj = (QSerialPort *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    RQINT64( obj->bytesAvailable () );
  }
#endif
}

/*
qint64 bytesToWrite() const Q_DECL_OVERRIDE
*/
HB_FUNC_STATIC( QSERIALPORT_BYTESTOWRITE )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  QSerialPort * obj = (QSerialPort *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    RQINT64( obj->bytesToWrite () );
  }
#endif
}

/*
bool canReadLine() const Q_DECL_OVERRIDE
*/
HB_FUNC_STATIC( QSERIALPORT_CANREADLINE )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  QSerialPort * obj = (QSerialPort *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    RBOOL( obj->canReadLine () );
  }
#endif
}

/*
bool waitForReadyRead(int msecs) Q_DECL_OVERRIDE
*/
HB_FUNC_STATIC( QSERIALPORT_WAITFORREADYREAD )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  QSerialPort * obj = (QSerialPort *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    RBOOL( obj->waitForReadyRead ( PINT(1) ) );
  }
#endif
}

/*
bool waitForBytesWritten(int msecs) Q_DECL_OVERRIDE
*/
HB_FUNC_STATIC( QSERIALPORT_WAITFORBYTESWRITTEN )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  QSerialPort * obj = (QSerialPort *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    RBOOL( obj->waitForBytesWritten ( PINT(1) ) );
  }
#endif
}

/*
bool sendBreak(int duration = 0)
*/
HB_FUNC_STATIC( QSERIALPORT_SENDBREAK )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  QSerialPort * obj = (QSerialPort *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    RBOOL( obj->sendBreak ( OPINT(1,0) ) );
  }
#endif
}

/*
bool setBreakEnabled(bool set = true)
*/
HB_FUNC_STATIC( QSERIALPORT_SETBREAKENABLED )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  QSerialPort * obj = (QSerialPort *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    RBOOL( obj->setBreakEnabled ( OPBOOL(1,true) ) );
  }
#endif
}

#pragma ENDDUMP

/*

  Qt5xHb - bibliotecas de ligao entre Harbour/xHarbour e Qt Framework 5

  Copyright (C) 2017 Marcos Antonio Gambeta <marcosgambeta AT outlook DOT com>

*/

#include "hbclass.ch"

CLASS QSerialPort INHERIT QIODevice

   DATA self_destruction INIT .F.

   METHOD new1
   METHOD new2
   METHOD new3
   METHOD new
   METHOD delete
   METHOD setPortName
   METHOD portName
   METHOD setPort
   METHOD open
   METHOD close
   METHOD setSettingsRestoredOnClose
   METHOD settingsRestoredOnClose
   METHOD setBaudRate
   METHOD baudRate
   METHOD setDataBits
   METHOD dataBits
   METHOD setParity
   METHOD parity
   METHOD setStopBits
   METHOD stopBits
   METHOD setFlowControl
   METHOD flowControl
   METHOD setDataTerminalReady
   METHOD isDataTerminalReady
   METHOD setRequestToSend
   METHOD isRequestToSend
   METHOD pinoutSignals
   METHOD flush
   METHOD clear
   METHOD atEnd
   METHOD setDataErrorPolicy
   METHOD dataErrorPolicy
   METHOD error
   METHOD clearError
   METHOD readBufferSize
   METHOD setReadBufferSize
   METHOD isSequential
   METHOD bytesAvailable
   METHOD bytesToWrite
   METHOD canReadLine
   METHOD waitForReadyRead
   METHOD waitForBytesWritten
   METHOD sendBreak
   METHOD setBreakEnabled

   METHOD onBaudRateChanged
   METHOD onDataBitsChanged
   METHOD onParityChanged
   METHOD onStopBitsChanged
   METHOD onFlowControlChanged
   METHOD onDataErrorPolicyChanged
   METHOD onDataTerminalReadyChanged
   METHOD onRequestToSendChanged
   METHOD onError
   METHOD onSettingsRestoredOnCloseChanged

   DESTRUCTOR destroyObject

END CLASS

PROCEDURE destroyObject () CLASS QSerialPort
   IF ::self_destruction
      ::delete()
   ENDIF
RETURN

#pragma BEGINDUMP

#include <Qt>

#ifndef __XHARBOUR__
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
#include <QSerialPort>
#endif
#endif

#include "qt5xhb_common.h"
#include "qt5xhb_macros.h"
#include "qt5xhb_utils.h"

#ifdef __XHARBOUR__
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
#include <QSerialPort>
#endif
#endif

/*
QSerialPort(QObject *parent = 0)
*/
HB_FUNC_STATIC( QSERIALPORT_NEW1 )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  QSerialPort * o = new QSerialPort ( OPQOBJECT(1,0) );
  _qt5xhb_storePointerAndFlag( o, false );
#endif
}

/*
QSerialPort(const QString &name, QObject *parent = 0)
*/
HB_FUNC_STATIC( QSERIALPORT_NEW2 )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  QSerialPort * o = new QSerialPort ( PQSTRING(1), OPQOBJECT(2,0) );
  _qt5xhb_storePointerAndFlag( o, false );
#endif
}

/*
QSerialPort(const QSerialPortInfo &info, QObject *parent = 0)
*/
HB_FUNC_STATIC( QSERIALPORT_NEW3 )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  QSerialPort * o = new QSerialPort ( *PQSERIALPORTINFO(1), OPQOBJECT(2,0) );
  _qt5xhb_storePointerAndFlag( o, false );
#endif
}

//[1]QSerialPort(QObject *parent = 0)
//[2]QSerialPort(const QString &name, QObject *parent = 0)
//[3]QSerialPort(const QSerialPortInfo &info, QObject *parent = 0)

// TODO: resolver conflito entre [1] e [2] quando for 1 parmetro do tipo O

HB_FUNC_STATIC( QSERIALPORT_NEW )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  if( ISBETWEEN(0,1) && ISOPTQOBJECT(1) )
  {
    HB_FUNC_EXEC( QSERIALPORT_NEW1 );
  }
  else if( ISBETWEEN(1,2) && ISCHAR(1) && ISOPTQOBJECT(2) )
  {
    HB_FUNC_EXEC( QSERIALPORT_NEW2 );
  }
  else if( ISBETWEEN(1,2) && ISQSERIALPORTINFO(1) && ISOPTQOBJECT(2) )
  {
    HB_FUNC_EXEC( QSERIALPORT_NEW3 );
  }
  else
  {
    hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
  }
#endif
}

HB_FUNC_STATIC( QSERIALPORT_DELETE )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  QSerialPort * obj = (QSerialPort *) hb_itemGetPtr( hb_objSendMsg( hb_stackSelfItem(), "POINTER", 0 ) );
  if( obj )
  {
    delete obj;
    obj = NULL;
    PHB_ITEM self = hb_stackSelfItem();
    PHB_ITEM ptr = hb_itemPutPtr( NULL, NULL );
    hb_objSendMsg( self, "_pointer", 1, ptr );
    hb_itemRelease( ptr );
  }
  hb_itemReturn( hb_stackSelfItem() );
#endif
}

/*
void setPortName(const QString &name)
*/
HB_FUNC_STATIC( QSERIALPORT_SETPORTNAME )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  QSerialPort * obj = (QSerialPort *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    obj->setPortName ( PQSTRING(1) );
  }
  hb_itemReturn( hb_stackSelfItem() );
#endif
}

/*
QString portName() const
*/
HB_FUNC_STATIC( QSERIALPORT_PORTNAME )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  QSerialPort * obj = (QSerialPort *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    RQSTRING( obj->portName () );
  }
#endif
}

/*
void setPort(const QSerialPortInfo &info)
*/
HB_FUNC_STATIC( QSERIALPORT_SETPORT )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  QSerialPort * obj = (QSerialPort *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    obj->setPort ( *PQSERIALPORTINFO(1) );
  }
  hb_itemReturn( hb_stackSelfItem() );
#endif
}

/*
bool open(OpenMode mode) Q_DECL_OVERRIDE
*/
HB_FUNC_STATIC( QSERIALPORT_OPEN )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  QSerialPort * obj = (QSerialPort *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    RBOOL( obj->open ( (QIODevice::OpenMode) hb_parni(1) ) );
  }
#endif
}

/*
void close() Q_DECL_OVERRIDE
*/
HB_FUNC_STATIC( QSERIALPORT_CLOSE )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  QSerialPort * obj = (QSerialPort *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    obj->close ();
  }
  hb_itemReturn( hb_stackSelfItem() );
#endif
}

/*
void setSettingsRestoredOnClose(bool restore)
*/
HB_FUNC_STATIC( QSERIALPORT_SETSETTINGSRESTOREDONCLOSE )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  QSerialPort * obj = (QSerialPort *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    obj->setSettingsRestoredOnClose ( PBOOL(1) );
  }
  hb_itemReturn( hb_stackSelfItem() );
#endif
}

/*
bool settingsRestoredOnClose() const
*/
HB_FUNC_STATIC( QSERIALPORT_SETTINGSRESTOREDONCLOSE )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  QSerialPort * obj = (QSerialPort *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    RBOOL( obj->settingsRestoredOnClose () );
  }
#endif
}

/*
bool setBaudRate(qint32 baudRate, Directions dir = AllDirections)
*/
HB_FUNC_STATIC( QSERIALPORT_SETBAUDRATE )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  QSerialPort * obj = (QSerialPort *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    int par2 = ISNIL(2)? (int) QSerialPort::AllDirections : hb_parni(2);
    RBOOL( obj->setBaudRate ( PQINT32(1), (QSerialPort::Directions) par2 ) );
  }
#endif
}

/*
qint32 baudRate(Directions dir = AllDirections) const
*/
HB_FUNC_STATIC( QSERIALPORT_BAUDRATE )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  QSerialPort * obj = (QSerialPort *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    int par1 = ISNIL(1)? (int) QSerialPort::AllDirections : hb_parni(1);
    RQINT32( obj->baudRate ( (QSerialPort::Directions) par1 ) );
  }
#endif
}

/*
bool setDataBits(DataBits dataBits)
*/
HB_FUNC_STATIC( QSERIALPORT_SETDATABITS )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  QSerialPort * obj = (QSerialPort *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    RBOOL( obj->setDataBits ( (QSerialPort::DataBits) hb_parni(1) ) );
  }
#endif
}

/*
DataBits dataBits() const
*/
HB_FUNC_STATIC( QSERIALPORT_DATABITS )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  QSerialPort * obj = (QSerialPort *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    hb_retni( obj->dataBits () );
  }
#endif
}

/*
bool setParity(Parity parity)
*/
HB_FUNC_STATIC( QSERIALPORT_SETPARITY )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  QSerialPort * obj = (QSerialPort *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    RBOOL( obj->setParity ( (QSerialPort::Parity) hb_parni(1) ) );
  }
#endif
}

/*
Parity parity() const
*/
HB_FUNC_STATIC( QSERIALPORT_PARITY )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  QSerialPort * obj = (QSerialPort *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    hb_retni( obj->parity () );
  }
#endif
}

/*
bool setStopBits(StopBits stopBits)
*/
HB_FUNC_STATIC( QSERIALPORT_SETSTOPBITS )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  QSerialPort * obj = (QSerialPort *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    RBOOL( obj->setStopBits ( (QSerialPort::StopBits) hb_parni(1) ) );
  }
#endif
}

/*
StopBits stopBits() const
*/
HB_FUNC_STATIC( QSERIALPORT_STOPBITS )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  QSerialPort * obj = (QSerialPort *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    hb_retni( obj->stopBits () );
  }
#endif
}

/*
bool setFlowControl(FlowControl flow)
*/
HB_FUNC_STATIC( QSERIALPORT_SETFLOWCONTROL )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  QSerialPort * obj = (QSerialPort *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    RBOOL( obj->setFlowControl ( (QSerialPort::FlowControl) hb_parni(1) ) );
  }
#endif
}

/*
FlowControl flowControl() const
*/
HB_FUNC_STATIC( QSERIALPORT_FLOWCONTROL )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  QSerialPort * obj = (QSerialPort *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    hb_retni( obj->flowControl () );
  }
#endif
}

/*
bool setDataTerminalReady(bool set)
*/
HB_FUNC_STATIC( QSERIALPORT_SETDATATERMINALREADY )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  QSerialPort * obj = (QSerialPort *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    RBOOL( obj->setDataTerminalReady ( PBOOL(1) ) );
  }
#endif
}

/*
bool isDataTerminalReady()
*/
HB_FUNC_STATIC( QSERIALPORT_ISDATATERMINALREADY )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  QSerialPort * obj = (QSerialPort *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    RBOOL( obj->isDataTerminalReady () );
  }
#endif
}

/*
bool setRequestToSend(bool set)
*/
HB_FUNC_STATIC( QSERIALPORT_SETREQUESTTOSEND )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  QSerialPort * obj = (QSerialPort *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    RBOOL( obj->setRequestToSend ( PBOOL(1) ) );
  }
#endif
}

/*
bool isRequestToSend()
*/
HB_FUNC_STATIC( QSERIALPORT_ISREQUESTTOSEND )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  QSerialPort * obj = (QSerialPort *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    RBOOL( obj->isRequestToSend () );
  }
#endif
}

/*
PinoutSignals pinoutSignals()
*/
HB_FUNC_STATIC( QSERIALPORT_PINOUTSIGNALS )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  QSerialPort * obj = (QSerialPort *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    hb_retni( obj->pinoutSignals () );
  }
#endif
}

/*
bool flush()
*/
HB_FUNC_STATIC( QSERIALPORT_FLUSH )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  QSerialPort * obj = (QSerialPort *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    RBOOL( obj->flush () );
  }
#endif
}

/*
bool clear(Directions dir = AllDirections)
*/
HB_FUNC_STATIC( QSERIALPORT_CLEAR )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  QSerialPort * obj = (QSerialPort *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    int par1 = ISNIL(1)? (int) QSerialPort::AllDirections : hb_parni(1);
    RBOOL( obj->clear ( (QSerialPort::Directions) par1 ) );
  }
#endif
}

/*
bool atEnd() const Q_DECL_OVERRIDE
*/
HB_FUNC_STATIC( QSERIALPORT_ATEND )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  QSerialPort * obj = (QSerialPort *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    RBOOL( obj->atEnd () );
  }
#endif
}

/*
bool setDataErrorPolicy(DataErrorPolicy policy = IgnorePolicy)
*/
HB_FUNC_STATIC( QSERIALPORT_SETDATAERRORPOLICY )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  QSerialPort * obj = (QSerialPort *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    int par1 = ISNIL(1)? (int) QSerialPort::IgnorePolicy : hb_parni(1);
    RBOOL( obj->setDataErrorPolicy ( (QSerialPort::DataErrorPolicy) par1 ) );
  }
#endif
}

/*
DataErrorPolicy dataErrorPolicy() const
*/
HB_FUNC_STATIC( QSERIALPORT_DATAERRORPOLICY )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  QSerialPort * obj = (QSerialPort *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    hb_retni( obj->dataErrorPolicy () );
  }
#endif
}

/*
SerialPortError error() const
*/
HB_FUNC_STATIC( QSERIALPORT_ERROR )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  QSerialPort * obj = (QSerialPort *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    hb_retni( obj->error () );
  }
#endif
}

/*
void clearError()
*/
HB_FUNC_STATIC( QSERIALPORT_CLEARERROR )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  QSerialPort * obj = (QSerialPort *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    obj->clearError ();
  }
  hb_itemReturn( hb_stackSelfItem() );
#endif
}

/*
qint64 readBufferSize() const
*/
HB_FUNC_STATIC( QSERIALPORT_READBUFFERSIZE )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  QSerialPort * obj = (QSerialPort *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    RQINT64( obj->readBufferSize () );
  }
#endif
}

/*
void setReadBufferSize(qint64 size)
*/
HB_FUNC_STATIC( QSERIALPORT_SETREADBUFFERSIZE )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  QSerialPort * obj = (QSerialPort *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    obj->setReadBufferSize ( PQINT64(1) );
  }
  hb_itemReturn( hb_stackSelfItem() );
#endif
}

/*
bool isSequential() const Q_DECL_OVERRIDE
*/
HB_FUNC_STATIC( QSERIALPORT_ISSEQUENTIAL )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  QSerialPort * obj = (QSerialPort *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    RBOOL( obj->isSequential () );
  }
#endif
}

/*
qint64 bytesAvailable() const Q_DECL_OVERRIDE
*/
HB_FUNC_STATIC( QSERIALPORT_BYTESAVAILABLE )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  QSerialPort * obj = (QSerialPort *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    RQINT64( obj->bytesAvailable () );
  }
#endif
}

/*
qint64 bytesToWrite() const Q_DECL_OVERRIDE
*/
HB_FUNC_STATIC( QSERIALPORT_BYTESTOWRITE )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  QSerialPort * obj = (QSerialPort *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    RQINT64( obj->bytesToWrite () );
  }
#endif
}

/*
bool canReadLine() const Q_DECL_OVERRIDE
*/
HB_FUNC_STATIC( QSERIALPORT_CANREADLINE )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  QSerialPort * obj = (QSerialPort *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    RBOOL( obj->canReadLine () );
  }
#endif
}

/*
bool waitForReadyRead(int msecs) Q_DECL_OVERRIDE
*/
HB_FUNC_STATIC( QSERIALPORT_WAITFORREADYREAD )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  QSerialPort * obj = (QSerialPort *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    RBOOL( obj->waitForReadyRead ( PINT(1) ) );
  }
#endif
}

/*
bool waitForBytesWritten(int msecs) Q_DECL_OVERRIDE
*/
HB_FUNC_STATIC( QSERIALPORT_WAITFORBYTESWRITTEN )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  QSerialPort * obj = (QSerialPort *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    RBOOL( obj->waitForBytesWritten ( PINT(1) ) );
  }
#endif
}

/*
bool sendBreak(int duration = 0)
*/
HB_FUNC_STATIC( QSERIALPORT_SENDBREAK )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  QSerialPort * obj = (QSerialPort *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    RBOOL( obj->sendBreak ( OPINT(1,0) ) );
  }
#endif
}

/*
bool setBreakEnabled(bool set = true)
*/
HB_FUNC_STATIC( QSERIALPORT_SETBREAKENABLED )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
  QSerialPort * obj = (QSerialPort *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    RBOOL( obj->setBreakEnabled ( OPBOOL(1,true) ) );
  }
#endif
}

#pragma ENDDUMP


source/QtScriptTools: updated

source/QtScriptTools: updated

Modified:
source/QtScriptTools/QScriptEngineDebugger.prg

/*

  Qt4xHb - Bindings libraries for Harbour/xHarbour and Qt Framework 4

  Copyright (C) 2020 Marcos Antonio Gambeta <marcosgambeta AT outlook DOT com>

*/

/*
  DO NOT EDIT THIS FILE - the content was created using a source code generator
*/

#include "hbclass.ch"

#ifndef QT4XHB_NO_REQUESTS
REQUEST QACTION
REQUEST QMAINWINDOW
REQUEST QMENU
REQUEST QTOOLBAR
REQUEST QWIDGET
#endif

CLASS QScriptEngineDebugger INHERIT QObject

   METHOD new
   METHOD delete
   METHOD action
   METHOD attachTo
   METHOD autoShowStandardWindow
   METHOD createStandardMenu
   METHOD createStandardToolBar
   METHOD detach
   METHOD setAutoShowStandardWindow
   METHOD standardWindow
   METHOD state
   METHOD widget

   METHOD onEvaluationResumed
   METHOD onEvaluationSuspended

   DESTRUCTOR destroyObject

END CLASS

PROCEDURE destroyObject() CLASS QScriptEngineDebugger
   IF ::self_destruction
      ::delete()
   ENDIF
RETURN

#pragma BEGINDUMP

#include <QtScriptTools/QScriptEngineDebugger>

#include "qt4xhb_common.h"
#include "qt4xhb_macros.h"
#include "qt4xhb_utils.h"
#include "qt4xhb_events.h"
#include "qt4xhb_signals.h"

#include <QtGui/QAction>
#include <QtGui/QMenu>
#include <QtGui/QToolBar>
#include <QtGui/QMainWindow>

/*
QScriptEngineDebugger( QObject * parent = 0 )
*/
HB_FUNC_STATIC( QSCRIPTENGINEDEBUGGER_NEW )
{
  if( ISBETWEEN(0,1) && (ISQOBJECT(1)||ISNIL(1)) )
  {
    QScriptEngineDebugger * obj = new QScriptEngineDebugger( OPQOBJECT(1,0) );
    Qt4xHb::returnNewObject( obj, false );
  }
  else
  {
    hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
  }
}

HB_FUNC_STATIC( QSCRIPTENGINEDEBUGGER_DELETE )
{
  QScriptEngineDebugger * obj = (QScriptEngineDebugger *) Qt4xHb::itemGetPtrStackSelfItem();

  if( obj )
  {
    Qt4xHb::Events_disconnect_all_events( obj, true );
    Qt4xHb::Signals_disconnect_all_signals( obj, true );
    delete obj;
    obj = NULL;
    PHB_ITEM self = hb_stackSelfItem();
    PHB_ITEM ptr = hb_itemPutPtr( NULL, NULL );
    hb_objSendMsg( self, "_pointer", 1, ptr );
    hb_itemRelease( ptr );
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
QAction * action( QScriptEngineDebugger::DebuggerAction action ) const
*/
HB_FUNC_STATIC( QSCRIPTENGINEDEBUGGER_ACTION )
{
  QScriptEngineDebugger * obj = (QScriptEngineDebugger *) Qt4xHb::itemGetPtrStackSelfItem();

  if( obj )
  {
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    if( ISNUMPAR(1) && ISNUM(1) )
    {
#endif
      QAction * ptr = obj->action( (QScriptEngineDebugger::DebuggerAction) hb_parni(1) );
      Qt4xHb::createReturnQObjectClass( ptr, "QACTION" );
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
#endif
  }
}

/*
void attachTo( QScriptEngine * engine )
*/
HB_FUNC_STATIC( QSCRIPTENGINEDEBUGGER_ATTACHTO )
{
  QScriptEngineDebugger * obj = (QScriptEngineDebugger *) Qt4xHb::itemGetPtrStackSelfItem();

  if( obj )
  {
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    if( ISNUMPAR(1) && ISQSCRIPTENGINE(1) )
    {
#endif
      obj->attachTo( PQSCRIPTENGINE(1) );
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
#endif
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
bool autoShowStandardWindow() const
*/
HB_FUNC_STATIC( QSCRIPTENGINEDEBUGGER_AUTOSHOWSTANDARDWINDOW )
{
  QScriptEngineDebugger * obj = (QScriptEngineDebugger *) Qt4xHb::itemGetPtrStackSelfItem();

  if( obj )
  {
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    if( ISNUMPAR(0) )
    {
#endif
      RBOOL( obj->autoShowStandardWindow() );
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
#endif
  }
}

/*
QMenu * createStandardMenu( QWidget * parent = 0 )
*/
HB_FUNC_STATIC( QSCRIPTENGINEDEBUGGER_CREATESTANDARDMENU )
{
  QScriptEngineDebugger * obj = (QScriptEngineDebugger *) Qt4xHb::itemGetPtrStackSelfItem();

  if( obj )
  {
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    if( ISBETWEEN(0,1) && (ISQWIDGET(1)||ISNIL(1)) )
    {
#endif
      QMenu * ptr = obj->createStandardMenu( OPQWIDGET(1,0) );
      Qt4xHb::createReturnQObjectClass( ptr, "QMENU" );
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
#endif
  }
}

/*
QToolBar * createStandardToolBar( QWidget * parent = 0 )
*/
HB_FUNC_STATIC( QSCRIPTENGINEDEBUGGER_CREATESTANDARDTOOLBAR )
{
  QScriptEngineDebugger * obj = (QScriptEngineDebugger *) Qt4xHb::itemGetPtrStackSelfItem();

  if( obj )
  {
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    if( ISBETWEEN(0,1) && (ISQWIDGET(1)||ISNIL(1)) )
    {
#endif
      QToolBar * ptr = obj->createStandardToolBar( OPQWIDGET(1,0) );
      Qt4xHb::createReturnQObjectClass( ptr, "QTOOLBAR" );
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
#endif
  }
}

/*
void detach()
*/
HB_FUNC_STATIC( QSCRIPTENGINEDEBUGGER_DETACH )
{
  QScriptEngineDebugger * obj = (QScriptEngineDebugger *) Qt4xHb::itemGetPtrStackSelfItem();

  if( obj )
  {
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    if( ISNUMPAR(0) )
    {
#endif
      obj->detach();
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
#endif
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setAutoShowStandardWindow( bool autoShow )
*/
HB_FUNC_STATIC( QSCRIPTENGINEDEBUGGER_SETAUTOSHOWSTANDARDWINDOW )
{
  QScriptEngineDebugger * obj = (QScriptEngineDebugger *) Qt4xHb::itemGetPtrStackSelfItem();

  if( obj )
  {
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    if( ISNUMPAR(1) && ISLOG(1) )
    {
#endif
      obj->setAutoShowStandardWindow( PBOOL(1) );
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
#endif
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
QMainWindow * standardWindow() const
*/
HB_FUNC_STATIC( QSCRIPTENGINEDEBUGGER_STANDARDWINDOW )
{
  QScriptEngineDebugger * obj = (QScriptEngineDebugger *) Qt4xHb::itemGetPtrStackSelfItem();

  if( obj )
  {
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    if( ISNUMPAR(0) )
    {
#endif
      QMainWindow * ptr = obj->standardWindow();
      Qt4xHb::createReturnQObjectClass( ptr, "QMAINWINDOW" );
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
#endif
  }
}

/*
QScriptEngineDebugger::DebuggerState state() const
*/
HB_FUNC_STATIC( QSCRIPTENGINEDEBUGGER_STATE )
{
  QScriptEngineDebugger * obj = (QScriptEngineDebugger *) Qt4xHb::itemGetPtrStackSelfItem();

  if( obj )
  {
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    if( ISNUMPAR(0) )
    {
#endif
      RENUM( obj->state() );
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
#endif
  }
}

/*
QWidget * widget( QScriptEngineDebugger::DebuggerWidget widget ) const
*/
HB_FUNC_STATIC( QSCRIPTENGINEDEBUGGER_WIDGET )
{
  QScriptEngineDebugger * obj = (QScriptEngineDebugger *) Qt4xHb::itemGetPtrStackSelfItem();

  if( obj )
  {
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    if( ISNUMPAR(1) && ISNUM(1) )
    {
#endif
      QWidget * ptr = obj->widget( (QScriptEngineDebugger::DebuggerWidget) hb_parni(1) );
      Qt4xHb::createReturnQWidgetClass( ptr, "QWIDGET" );
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
#endif
  }
}

void QScriptEngineDebuggerSlots_connect_signal( const QString & signal, const QString & slot );

HB_FUNC_STATIC( QSCRIPTENGINEDEBUGGER_ONEVALUATIONRESUMED )
{
  QScriptEngineDebuggerSlots_connect_signal( "evaluationResumed()", "evaluationResumed()" );
}

HB_FUNC_STATIC( QSCRIPTENGINEDEBUGGER_ONEVALUATIONSUSPENDED )
{
  QScriptEngineDebuggerSlots_connect_signal( "evaluationSuspended()", "evaluationSuspended()" );
}

#pragma ENDDUMP

/*

  Qt4xHb - Bindings libraries for Harbour/xHarbour and Qt Framework 4

  Copyright (C) 2020 Marcos Antonio Gambeta <marcosgambeta AT outlook DOT com>

*/

/*
  DO NOT EDIT THIS FILE - the content was created using a source code generator
*/

#include "hbclass.ch"

#ifndef QT4XHB_NO_REQUESTS
REQUEST QACTION
REQUEST QMAINWINDOW
REQUEST QMENU
REQUEST QTOOLBAR
REQUEST QWIDGET
#endif

CLASS QScriptEngineDebugger INHERIT QObject

   METHOD new
   METHOD delete
   METHOD action
   METHOD attachTo
   METHOD autoShowStandardWindow
   METHOD createStandardMenu
   METHOD createStandardToolBar
   METHOD detach
   METHOD setAutoShowStandardWindow
   METHOD standardWindow
   METHOD state
   METHOD widget

   METHOD onEvaluationResumed
   METHOD onEvaluationSuspended

   DESTRUCTOR destroyObject

END CLASS

PROCEDURE destroyObject() CLASS QScriptEngineDebugger
   IF ::self_destruction
      ::delete()
   ENDIF
RETURN

#pragma BEGINDUMP

#include <QtScriptTools/QScriptEngineDebugger>

#include "qt4xhb_common.h"
#include "qt4xhb_macros.h"
#include "qt4xhb_utils.h"
#include "qt4xhb_events.h"
#include "qt4xhb_signals.h"

#include <QtGui/QAction>
#include <QtGui/QMenu>
#include <QtGui/QToolBar>
#include <QtGui/QMainWindow>

/*
QScriptEngineDebugger ( QObject * parent = 0 )
*/
HB_FUNC_STATIC( QSCRIPTENGINEDEBUGGER_NEW )
{
  if( ISBETWEEN(0,1) && (ISQOBJECT(1)||ISNIL(1)) )
  {
    QScriptEngineDebugger * obj = new QScriptEngineDebugger( OPQOBJECT(1,0) );
    Qt4xHb::returnNewObject( obj, false );
  }
  else
  {
    hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
  }
}

HB_FUNC_STATIC( QSCRIPTENGINEDEBUGGER_DELETE )
{
  QScriptEngineDebugger * obj = (QScriptEngineDebugger *) Qt4xHb::itemGetPtrStackSelfItem();

  if( obj )
  {
    Qt4xHb::Events_disconnect_all_events( obj, true );
    Qt4xHb::Signals_disconnect_all_signals( obj, true );
    delete obj;
    obj = NULL;
    PHB_ITEM self = hb_stackSelfItem();
    PHB_ITEM ptr = hb_itemPutPtr( NULL, NULL );
    hb_objSendMsg( self, "_pointer", 1, ptr );
    hb_itemRelease( ptr );
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
QAction * action( QScriptEngineDebugger::DebuggerAction action ) const
*/
HB_FUNC_STATIC( QSCRIPTENGINEDEBUGGER_ACTION )
{
  QScriptEngineDebugger * obj = (QScriptEngineDebugger *) Qt4xHb::itemGetPtrStackSelfItem();

  if( obj )
  {
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    if( ISNUMPAR(1) && ISNUM(1) )
    {
#endif
      QAction * ptr = obj->action( (QScriptEngineDebugger::DebuggerAction) hb_parni(1) );
      Qt4xHb::createReturnQObjectClass( ptr, "QACTION" );
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
#endif
  }
}

/*
void attachTo( QScriptEngine * engine )
*/
HB_FUNC_STATIC( QSCRIPTENGINEDEBUGGER_ATTACHTO )
{
  QScriptEngineDebugger * obj = (QScriptEngineDebugger *) Qt4xHb::itemGetPtrStackSelfItem();

  if( obj )
  {
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    if( ISNUMPAR(1) && ISQSCRIPTENGINE(1) )
    {
#endif
      obj->attachTo( PQSCRIPTENGINE(1) );
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
#endif
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
bool autoShowStandardWindow() const
*/
HB_FUNC_STATIC( QSCRIPTENGINEDEBUGGER_AUTOSHOWSTANDARDWINDOW )
{
  QScriptEngineDebugger * obj = (QScriptEngineDebugger *) Qt4xHb::itemGetPtrStackSelfItem();

  if( obj )
  {
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    if( ISNUMPAR(0) )
    {
#endif
      RBOOL( obj->autoShowStandardWindow() );
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
#endif
  }
}

/*
QMenu * createStandardMenu( QWidget * parent = 0 )
*/
HB_FUNC_STATIC( QSCRIPTENGINEDEBUGGER_CREATESTANDARDMENU )
{
  QScriptEngineDebugger * obj = (QScriptEngineDebugger *) Qt4xHb::itemGetPtrStackSelfItem();

  if( obj )
  {
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    if( ISBETWEEN(0,1) && (ISQWIDGET(1)||ISNIL(1)) )
    {
#endif
      QMenu * ptr = obj->createStandardMenu( OPQWIDGET(1,0) );
      Qt4xHb::createReturnQObjectClass( ptr, "QMENU" );
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
#endif
  }
}

/*
QToolBar * createStandardToolBar( QWidget * parent = 0 )
*/
HB_FUNC_STATIC( QSCRIPTENGINEDEBUGGER_CREATESTANDARDTOOLBAR )
{
  QScriptEngineDebugger * obj = (QScriptEngineDebugger *) Qt4xHb::itemGetPtrStackSelfItem();

  if( obj )
  {
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    if( ISBETWEEN(0,1) && (ISQWIDGET(1)||ISNIL(1)) )
    {
#endif
      QToolBar * ptr = obj->createStandardToolBar( OPQWIDGET(1,0) );
      Qt4xHb::createReturnQObjectClass( ptr, "QTOOLBAR" );
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
#endif
  }
}

/*
void detach()
*/
HB_FUNC_STATIC( QSCRIPTENGINEDEBUGGER_DETACH )
{
  QScriptEngineDebugger * obj = (QScriptEngineDebugger *) Qt4xHb::itemGetPtrStackSelfItem();

  if( obj )
  {
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    if( ISNUMPAR(0) )
    {
#endif
      obj->detach();
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
#endif
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setAutoShowStandardWindow( bool autoShow )
*/
HB_FUNC_STATIC( QSCRIPTENGINEDEBUGGER_SETAUTOSHOWSTANDARDWINDOW )
{
  QScriptEngineDebugger * obj = (QScriptEngineDebugger *) Qt4xHb::itemGetPtrStackSelfItem();

  if( obj )
  {
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    if( ISNUMPAR(1) && ISLOG(1) )
    {
#endif
      obj->setAutoShowStandardWindow( PBOOL(1) );
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
#endif
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
QMainWindow * standardWindow() const
*/
HB_FUNC_STATIC( QSCRIPTENGINEDEBUGGER_STANDARDWINDOW )
{
  QScriptEngineDebugger * obj = (QScriptEngineDebugger *) Qt4xHb::itemGetPtrStackSelfItem();

  if( obj )
  {
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    if( ISNUMPAR(0) )
    {
#endif
      QMainWindow * ptr = obj->standardWindow();
      Qt4xHb::createReturnQObjectClass( ptr, "QMAINWINDOW" );
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
#endif
  }
}

/*
QScriptEngineDebugger::DebuggerState state() const
*/
HB_FUNC_STATIC( QSCRIPTENGINEDEBUGGER_STATE )
{
  QScriptEngineDebugger * obj = (QScriptEngineDebugger *) Qt4xHb::itemGetPtrStackSelfItem();

  if( obj )
  {
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    if( ISNUMPAR(0) )
    {
#endif
      RENUM( obj->state() );
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
#endif
  }
}

/*
QWidget * widget( QScriptEngineDebugger::DebuggerWidget widget ) const
*/
HB_FUNC_STATIC( QSCRIPTENGINEDEBUGGER_WIDGET )
{
  QScriptEngineDebugger * obj = (QScriptEngineDebugger *) Qt4xHb::itemGetPtrStackSelfItem();

  if( obj )
  {
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    if( ISNUMPAR(1) && ISNUM(1) )
    {
#endif
      QWidget * ptr = obj->widget( (QScriptEngineDebugger::DebuggerWidget) hb_parni(1) );
      Qt4xHb::createReturnQWidgetClass( ptr, "QWIDGET" );
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
#endif
  }
}

void QScriptEngineDebuggerSlots_connect_signal( const QString & signal, const QString & slot );

HB_FUNC_STATIC( QSCRIPTENGINEDEBUGGER_ONEVALUATIONRESUMED )
{
  QScriptEngineDebuggerSlots_connect_signal( "evaluationResumed()", "evaluationResumed()" );
}

HB_FUNC_STATIC( QSCRIPTENGINEDEBUGGER_ONEVALUATIONSUSPENDED )
{
  QScriptEngineDebuggerSlots_connect_signal( "evaluationSuspended()", "evaluationSuspended()" );
}

#pragma ENDDUMP