[rdd][dbf] Fix inbuffer write

[rdd][dbf] Fix inbuffer write

//
// 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.
//

// Please note that this code code expects zero based arrays
#pragma options ("az", ON)

USING System
USING System.Collections.Generic
USING System.Text
USING System.IO
USING XSharp.RDD.Enums
USING XSharp.RDD.Support

BEGIN NAMESPACE XSharp.RDD

	CLASS InputBuffer
        CONST INBUFFER_MAX_SIZE := 16384 AS INT

        PROTECT _stream        AS Stream
        PROTECT _name          AS STRING
        PROTECT _recordLength  AS LONG
        PROTECT _headerLength  AS LONG
        PROTECT _shared        AS LOGIC

        PROTECT _look_ahead    AS INT
        PROTECT _look_behind   AS INT
        PROTECT _inBuffer      AS BYTE[]
        PROTECT PROPERTY _inBufferOfs AS LONG GET _weakBuffer:InBufferOfs SET _weakBuffer:InBufferOfs := VALUE
        PROTECT PROPERTY _inBufferLen   AS LONG GET _weakBuffer:InBufferLen SET _weakBuffer:InBufferLen := VALUE
        PROTECT PROPERTY _inBufferTick  AS INT GET _weakBuffer:InBufferTick SET _weakBuffer:InBufferTick := VALUE

        PRIVATE _weakBuffer    AS WeakBuffer

        CLASS WeakBuffer
            INTERNAL RefCount := 1      AS WORD
            INTERNAL Buffer             AS BYTE[]
            INTERNAL InBufferOfs := 0   AS LONG
            INTERNAL InBufferLen := 0   AS LONG
            INTERNAL InBufferTick := 0  AS INT
            CONSTRUCTOR(size AS LONG)
                Buffer := BYTE[]{size}
            INTERNAL METHOD Resize(size AS LONG) AS VOID
                System.Array.Resize(REF Buffer, size)
        END CLASS

        PRIVATE STATIC BufferCache := Dictionary<STRING, WeakBuffer>{} AS Dictionary<STRING, WeakBuffer>

        CONSTRUCTOR(stream AS Stream, headerLength AS INT, recordLength AS INT, shared AS LOGIC) AS VOID
            _stream := stream
            _name := (stream ASTYPE FileStream)?:Name
            _recordLength := recordLength
            _headerLength := headerLength
            _shared := shared

            VAR nRec := INBUFFER_MAX_SIZE / SELF:_recordLength
            _look_ahead := nRec - nRec/4
            _look_behind := nRec - _look_ahead - 1

            IF _look_ahead > 0 && _look_behind >= 0
                VAR size := (1+SELF:_look_ahead+SELF:_look_behind)*SELF:_recordLength
                IF _name != NULL
                    BEGIN LOCK BufferCache
                        LOCAL t AS WeakBuffer
                        IF BufferCache:TryGetValue(_name, OUT t)
                            t:RefCount += 1
                            IF size != t:Buffer:Length
                                t:Resize(size)
                            ENDIF
                        ELSE
                            t := WeakBuffer{size}
                            BufferCache:Add(_name, t)
                        ENDIF
                        _weakBuffer := t
                        _inBuffer := t:Buffer
                    END LOCK
                ELSE
                    _weakBuffer := WeakBuffer{size}
                    _inBuffer := _weakBuffer:Buffer
                ENDIF
            ELSE
                _weakBuffer := NULL
                _inBuffer := NULL
            ENDIF

            RETURN

        DESTRUCTOR()
                IF _name != NULL
                    BEGIN LOCK BufferCache
                        LOCAL t AS WeakBuffer
                        IF BufferCache:TryGetValue(_name, OUT t)
                            t:RefCount -= 1
                            IF t:RefCount < 1
                                BufferCache:Remove(_name)
                            ENDIF
                        ENDIF
                    END LOCK
                ENDIF
            RETURN

        PRIVATE METHOD ReadAt(position AS LONG, buffer AS BYTE[], offset AS LONG, length AS LONG) AS LONG
            LOCAL result AS LONG
            TRY
                _stream:Position := position
                result := _stream:Read(buffer, offset, length)
            CATCH
                result := -1
            END TRY
            RETURN result

        PRIVATE METHOD WriteAt(position AS LONG, buffer AS BYTE[], offset AS LONG, length AS LONG) AS LOGIC
            LOCAL result AS LOGIC
            TRY
                _stream:Position := position
                _stream:Write(buffer, offset, length)
                result := TRUE
            CATCH
                result := FALSE
            END TRY
            RETURN result

        METHOD Read(offset AS LONG, buffer AS BYTE[], size AS LONG) AS LOGIC
            LOCAL tick := 0 AS INT
            IF _inBuffer == NULL
                RETURN SELF:ReadAt(offset, buffer, 0, size) == size
            ENDIF
            BEGIN LOCK _weakBuffer
                IF SELF:_shared
                    VAR refresh := XSharp.RuntimeState.GetValue<REAL8>(Set.Refresh)
                    IF refresh < 0
                        RETURN SELF:ReadAt(offset, buffer, 0, size) == size
                    ENDIF
                    tick := System.Environment.TickCount
                    IF refresh > 0 .AND. (tick - _inBufferTick) >= 1000*refresh
                        _inBufferLen := 0
                    ENDIF
                ENDIF
                IF _inBufferOfs > offset .OR. _inBufferOfs+_inBufferLen < offset+size
                    LOCAL ofs AS LONG
                    IF offset > _inBufferOfs
                        ofs := offset - SELF:_look_behind*SELF:_recordLength
                    ELSE
                        ofs := offset - SELF:_look_ahead*SELF:_recordLength
                    ENDIF
                    IF ofs < SELF:_headerLength
                        ofs := SELF:_headerLength
                    ENDIF
                    VAR len := _inBuffer:Length
                    VAR bwd := FALSE
                    IF ofs > _inBufferOfs .AND. ofs < _inBufferOfs+_inBufferLen
                        VAR delta := ofs - _inBufferOfs
                        _inBufferLen -= delta
                        _inBufferOfs := ofs
                        ofs += _inBufferLen
                        len -= _inBufferLen
                        Array.Copy(_inBuffer, delta, _inBuffer, 0, _inBufferLen)
                    ELSEIF ofs < _inBufferOfs .AND. ofs+len > _inBufferOfs .AND. _inBufferLen > 0
                        VAR delta := _inBufferOfs - ofs
                        IF _inBufferLen+delta > len
                            _inBufferLen -= _inBufferLen + delta - len
                        ENDIF
                        _inBufferOfs := ofs
                        len := delta
                        bwd := TRUE
                        Array.Copy(_inBuffer, 0, _inBuffer, delta, _inBufferLen)
                    ELSE
                        _inBufferLen := 0
                        _inBufferOfs := ofs
                    ENDIF

                    _inBufferTick := tick
                    VAR res := SELF:ReadAt(ofs, _inBuffer, ofs-_inBufferOfs, len)
                    IF res > 0
                        _inBufferLen += res
                        IF bwd .AND. res != len
                            _inBufferLen := res
                        ENDIF
                    ELSE
                        _inBufferLen := 0
                    ENDIF

                    IF _inBufferOfs+_inBufferLen < offset+size
                        RETURN FALSE
                    ENDIF
                ENDIF
                Array.Copy( _inBuffer, offset - _inBufferOfs, buffer, 0, size )
            END LOCK
            RETURN TRUE

        METHOD Write(offset AS LONG, buffer AS BYTE[], size AS LONG) AS LOGIC
            VAR res := SELF:WriteAt(offset, buffer, 0, size)
            IF res .AND. _inBuffer != NULL
                BEGIN LOCK _weakBuffer
                    IF offset < _inBufferOfs+_inBufferLen .AND. offset+size > _inBufferOfs
                        VAR buffer_ofs := Math.Max( 0, _inBufferOfs - offset )
                        VAR inbuffer_ofs := Math.Max( 0, offset - _inBufferOfs )
                        VAR buffer_size := Math.Min( size - buffer_ofs, _inBufferLen - inbuffer_ofs )
                        Array.Copy( buffer, buffer_ofs, _inBuffer, inbuffer_ofs, buffer_size )
                    ENDIF
                END LOCK
            ENDIF
            RETURN res

        METHOD Invalidate() AS VOID
            BEGIN LOCK _weakBuffer
                _inBufferOfs := 0
                _inBufferLen := 0
            END LOCK
            RETURN
    END CLASS

END NAMESPACE // XSharp.RDD

//
// 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.
//

// Please note that this code code expects zero based arrays
#pragma options ("az", ON)

USING System
USING System.Collections.Generic
USING System.Text
USING System.IO
USING XSharp.RDD.Enums
USING XSharp.RDD.Support

BEGIN NAMESPACE XSharp.RDD

	CLASS InputBuffer
        CONST INBUFFER_MAX_SIZE := 16384 AS INT

        PROTECT _stream        AS Stream
        PROTECT _name          AS STRING
        PROTECT _recordLength  AS LONG
        PROTECT _headerLength  AS LONG
        PROTECT _shared        AS LOGIC

        PROTECT _look_ahead    AS INT
        PROTECT _look_behind   AS INT
        PROTECT _inBuffer      AS BYTE[]
        PROTECT PROPERTY _inBufferOfs AS LONG GET _weakBuffer:InBufferOfs SET _weakBuffer:InBufferOfs := VALUE
        PROTECT PROPERTY _inBufferLen   AS LONG GET _weakBuffer:InBufferLen SET _weakBuffer:InBufferLen := VALUE
        PROTECT PROPERTY _inBufferTick  AS INT GET _weakBuffer:InBufferTick SET _weakBuffer:InBufferTick := VALUE

        PRIVATE _weakBuffer    AS WeakBuffer

        CLASS WeakBuffer
            INTERNAL RefCount := 1      AS WORD
            INTERNAL Buffer             AS BYTE[]
            INTERNAL InBufferOfs := 0   AS LONG
            INTERNAL InBufferLen := 0   AS LONG
            INTERNAL InBufferTick := 0  AS INT
            CONSTRUCTOR(size AS LONG)
                Buffer := BYTE[]{size}
            INTERNAL METHOD Resize(size AS LONG) AS VOID
                System.Array.Resize(REF Buffer, size)
        END CLASS

        PRIVATE STATIC BufferCache := Dictionary<STRING, WeakBuffer>{} AS Dictionary<STRING, WeakBuffer>

        CONSTRUCTOR(stream AS Stream, headerLength AS INT, recordLength AS INT, shared AS LOGIC) AS VOID
            _stream := stream
            _name := (stream ASTYPE FileStream)?:Name
            _recordLength := recordLength
            _headerLength := headerLength
            _shared := shared

            VAR nRec := INBUFFER_MAX_SIZE / SELF:_recordLength
            _look_ahead := nRec - nRec/4
            _look_behind := nRec - _look_ahead - 1

            IF _look_ahead > 0 && _look_behind >= 0
                VAR size := (1+SELF:_look_ahead+SELF:_look_behind)*SELF:_recordLength
                IF _name != NULL
                    BEGIN LOCK BufferCache
                        LOCAL t AS WeakBuffer
                        IF BufferCache:TryGetValue(_name, OUT t)
                            t:RefCount += 1
                            IF size != t:Buffer:Length
                                t:Resize(size)
                            ENDIF
                        ELSE
                            t := WeakBuffer{size}
                            BufferCache:Add(_name, t)
                        ENDIF
                        _weakBuffer := t
                        _inBuffer := t:Buffer
                    END LOCK
                ELSE
                    _weakBuffer := WeakBuffer{size}
                    _inBuffer := _weakBuffer:Buffer
                ENDIF
            ELSE
                _weakBuffer := NULL
                _inBuffer := NULL
            ENDIF

            RETURN

        DESTRUCTOR()
                IF _name != NULL
                    BEGIN LOCK BufferCache
                        LOCAL t AS WeakBuffer
                        IF BufferCache:TryGetValue(_name, OUT t)
                            t:RefCount -= 1
                            IF t:RefCount < 1
                                BufferCache:Remove(_name)
                            ENDIF
                        ENDIF
                    END LOCK
                ENDIF
            RETURN

        PRIVATE METHOD ReadAt(position AS LONG, buffer AS BYTE[], offset AS LONG, length AS LONG) AS LONG
            LOCAL result AS LONG
            TRY
                _stream:Position := position
                result := _stream:Read(buffer, offset, length)
            CATCH
                result := -1
            END TRY
            RETURN result

        PRIVATE METHOD WriteAt(position AS LONG, buffer AS BYTE[], offset AS LONG, length AS LONG) AS LOGIC
            LOCAL result AS LOGIC
            TRY
                _stream:Position := position
                _stream:Write(buffer, offset, length)
                result := TRUE
            CATCH
                result := FALSE
            END TRY
            RETURN result

        METHOD Read(offset AS LONG, buffer AS BYTE[], size AS LONG) AS LOGIC
            LOCAL tick := 0 AS INT
            IF _inBuffer == NULL
                RETURN SELF:ReadAt(offset, buffer, 0, size) == size
            ENDIF
            BEGIN LOCK _weakBuffer
                IF SELF:_shared
                    VAR refresh := XSharp.RuntimeState.GetValue<REAL8>(Set.Refresh)
                    IF refresh < 0
                        RETURN SELF:ReadAt(offset, buffer, 0, size) == size
                    ENDIF
                    tick := System.Environment.TickCount
                    IF refresh > 0 .AND. (tick - _inBufferTick) >= 1000*refresh
                        _inBufferLen := 0
                    ENDIF
                ENDIF
                IF _inBufferOfs > offset .OR. _inBufferOfs+_inBufferLen < offset+size
                    LOCAL ofs AS LONG
                    IF offset > _inBufferOfs
                        ofs := offset - SELF:_look_behind*SELF:_recordLength
                    ELSE
                        ofs := offset - SELF:_look_ahead*SELF:_recordLength
                    ENDIF
                    IF ofs < SELF:_headerLength
                        ofs := SELF:_headerLength
                    ENDIF
                    VAR len := _inBuffer:Length
                    VAR bwd := FALSE
                    IF ofs > _inBufferOfs .AND. ofs < _inBufferOfs+_inBufferLen
                        VAR delta := ofs - _inBufferOfs
                        _inBufferLen -= delta
                        _inBufferOfs := ofs
                        ofs += _inBufferLen
                        len -= _inBufferLen
                        Array.Copy(_inBuffer, delta, _inBuffer, 0, _inBufferLen)
                    ELSEIF ofs < _inBufferOfs .AND. ofs+len > _inBufferOfs .AND. _inBufferLen > 0
                        VAR delta := _inBufferOfs - ofs
                        IF _inBufferLen+delta > len
                            _inBufferLen -= _inBufferLen + delta - len
                        ENDIF
                        _inBufferOfs := ofs
                        len := delta
                        bwd := TRUE
                        Array.Copy(_inBuffer, 0, _inBuffer, delta, _inBufferLen)
                    ELSE
                        _inBufferLen := 0
                        _inBufferOfs := ofs
                    ENDIF

                    _inBufferTick := tick
                    VAR res := SELF:ReadAt(ofs, _inBuffer, ofs-_inBufferOfs, len)
                    IF res > 0
                        _inBufferLen += res
                        IF bwd .AND. res != len
                            _inBufferLen := res
                        ENDIF
                    ELSE
                        _inBufferLen := 0
                    ENDIF

                    IF _inBufferOfs+_inBufferLen < offset+size
                        RETURN FALSE
                    ENDIF
                ENDIF
                Array.Copy( _inBuffer, offset - _inBufferOfs, buffer, 0, size )
            END LOCK
            RETURN TRUE

        METHOD Write(offset AS LONG, buffer AS BYTE[], size AS LONG) AS LOGIC
            VAR res := SELF:WriteAt(offset, buffer, 0, size)
            IF res .AND. _inBuffer != NULL
                BEGIN LOCK _weakBuffer
                    IF offset <= _inBufferOfs+_inBufferLen .AND. offset+size >= _inBufferOfs
                        VAR buffer_ofs := Math.Max( 0, _inBufferOfs - offset )
                        Array.Copy( buffer, buffer_ofs, _inBuffer, Math.Max( 0, offset - _inBufferOfs), size - buffer_ofs )
                    ENDIF
                END LOCK
            ENDIF
            RETURN res

        METHOD Invalidate() AS VOID
            _inBufferOfs := 0
            _inBufferLen := 0
            RETURN
    END CLASS

END NAMESPACE // XSharp.RDD


QtScriptTools module updated to use the file qt5xhb_common.h

/*

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

  Copyright (C) 2012-2017 Marcos Antonio Gambeta <marcosgambeta@uol.com.br>

*/

#include "hbclass.ch"
#include "qt5xhb_clsid.ch"

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

CLASS QScriptEngineDebugger INHERIT QObject

   DATA class_id INIT Class_Id_QScriptEngineDebugger
   DATA class_flags INIT 1
   DATA self_destruction INIT .F.

   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 <Qt>

#ifndef __XHARBOUR__
#include <QScriptEngineDebugger>
#endif

#include "qt5xhb_common.h"
#include "qt5xhb_clsid.h"
#include "qt5xhb_utils.h"

#ifdef __XHARBOUR__
#include <QScriptEngineDebugger>
#endif

/*
QScriptEngineDebugger(QObject * parent = 0)
*/
HB_FUNC_STATIC( QSCRIPTENGINEDEBUGGER_NEW )
{
  QObject * par1 = ISNIL(1)? 0 : (QObject *) _qt5xhb_itemGetPtr(1);
  QScriptEngineDebugger * o = new QScriptEngineDebugger ( par1 );
  PHB_ITEM self = hb_stackSelfItem();
  PHB_ITEM ptr = hb_itemPutPtr( NULL,(QScriptEngineDebugger *) o );
  hb_objSendMsg( self, "_pointer", 1, ptr );
  hb_itemRelease( ptr );
  hb_itemReturn( self );
}

HB_FUNC_STATIC( QSCRIPTENGINEDEBUGGER_DELETE )
{
  QScriptEngineDebugger * obj = (QScriptEngineDebugger *) 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() );
}

/*
QAction * action(DebuggerAction action) const
*/
HB_FUNC_STATIC( QSCRIPTENGINEDEBUGGER_ACTION )
{
  QScriptEngineDebugger * obj = (QScriptEngineDebugger *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    int par1 = hb_parni(1);
    QAction * ptr = obj->action (  (QScriptEngineDebugger::DebuggerAction) par1 );
    _qt5xhb_createReturnClass ( ptr, "QACTION" );
  }
}

/*
void attachTo(QScriptEngine * engine)
*/
HB_FUNC_STATIC( QSCRIPTENGINEDEBUGGER_ATTACHTO )
{
  QScriptEngineDebugger * obj = (QScriptEngineDebugger *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QScriptEngine * par1 = (QScriptEngine *) _qt5xhb_itemGetPtr(1);
    obj->attachTo ( par1 );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
bool autoShowStandardWindow() const
*/
HB_FUNC_STATIC( QSCRIPTENGINEDEBUGGER_AUTOSHOWSTANDARDWINDOW )
{
  QScriptEngineDebugger * obj = (QScriptEngineDebugger *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    hb_retl( obj->autoShowStandardWindow (  ) );
  }
}

/*
QMenu * createStandardMenu(QWidget * parent = 0)
*/
HB_FUNC_STATIC( QSCRIPTENGINEDEBUGGER_CREATESTANDARDMENU )
{
  QScriptEngineDebugger * obj = (QScriptEngineDebugger *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QWidget * par1 = ISNIL(1)? 0 : (QWidget *) _qt5xhb_itemGetPtr(1);
    QMenu * ptr = obj->createStandardMenu ( par1 );
    _qt5xhb_createReturnClass ( ptr, "QMENU" );
  }
}

/*
QToolBar * createStandardToolBar(QWidget * parent = 0)
*/
HB_FUNC_STATIC( QSCRIPTENGINEDEBUGGER_CREATESTANDARDTOOLBAR )
{
  QScriptEngineDebugger * obj = (QScriptEngineDebugger *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QWidget * par1 = ISNIL(1)? 0 : (QWidget *) _qt5xhb_itemGetPtr(1);
    QToolBar * ptr = obj->createStandardToolBar ( par1 );
    _qt5xhb_createReturnClass ( ptr, "QTOOLBAR" );
  }
}

/*
void detach()
*/
HB_FUNC_STATIC( QSCRIPTENGINEDEBUGGER_DETACH )
{
  QScriptEngineDebugger * obj = (QScriptEngineDebugger *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    obj->detach (  );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setAutoShowStandardWindow(bool autoShow)
*/
HB_FUNC_STATIC( QSCRIPTENGINEDEBUGGER_SETAUTOSHOWSTANDARDWINDOW )
{
  QScriptEngineDebugger * obj = (QScriptEngineDebugger *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    obj->setAutoShowStandardWindow ( (bool) hb_parl(1) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
QMainWindow * standardWindow() const
*/
HB_FUNC_STATIC( QSCRIPTENGINEDEBUGGER_STANDARDWINDOW )
{
  QScriptEngineDebugger * obj = (QScriptEngineDebugger *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QMainWindow * ptr = obj->standardWindow (  );
    _qt5xhb_createReturnClass ( ptr, "QMAINWINDOW" );
  }
}

/*
DebuggerState state() const
*/
HB_FUNC_STATIC( QSCRIPTENGINEDEBUGGER_STATE )
{
  QScriptEngineDebugger * obj = (QScriptEngineDebugger *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    hb_retni( obj->state (  ) );
  }
}

/*
QWidget * widget(DebuggerWidget widget) const
*/
HB_FUNC_STATIC( QSCRIPTENGINEDEBUGGER_WIDGET )
{
  QScriptEngineDebugger * obj = (QScriptEngineDebugger *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    int par1 = hb_parni(1);
    QWidget * ptr = obj->widget (  (QScriptEngineDebugger::DebuggerWidget) par1 );
    _qt5xhb_createReturnQWidgetClass ( ptr, "QWIDGET" );
  }
}

#pragma ENDDUMP

/*

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

  Copyright (C) 2012-2017 Marcos Antonio Gambeta <marcosgambeta@uol.com.br>

*/

#include "hbclass.ch"
#include "qt5xhb_clsid.ch"

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

CLASS QScriptEngineDebugger INHERIT QObject

   DATA class_id INIT Class_Id_QScriptEngineDebugger
   DATA class_flags INIT 1
   DATA self_destruction INIT .F.

   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 <Qt>

#ifndef __XHARBOUR__
#include <QScriptEngineDebugger>
#endif

#include "hbapi.h"
#include "hbapiitm.h"
#include "hbapierr.h"
#include "hbvm.h"
#include "hbstack.h"

#ifndef __XHARBOUR__
#include "hbapicls.h"
#define ISNIL HB_ISNIL
#define ISLOG HB_ISLOG
#define ISNUM HB_ISNUM
#define ISCHAR HB_ISCHAR
#define ISPOINTER HB_ISPOINTER
#define ISOBJECT HB_ISOBJECT
#define ISARRAY HB_ISARRAY
#endif

#include "qt5xhb_clsid.h"
#include "qt5xhb_utils.h"

#ifdef __XHARBOUR__
#include <QScriptEngineDebugger>
#endif

/*
QScriptEngineDebugger(QObject * parent = 0)
*/
HB_FUNC_STATIC( QSCRIPTENGINEDEBUGGER_NEW )
{
  QObject * par1 = ISNIL(1)? 0 : (QObject *) _qt5xhb_itemGetPtr(1);
  QScriptEngineDebugger * o = new QScriptEngineDebugger ( par1 );
  PHB_ITEM self = hb_stackSelfItem();
  PHB_ITEM ptr = hb_itemPutPtr( NULL,(QScriptEngineDebugger *) o );
  hb_objSendMsg( self, "_pointer", 1, ptr );
  hb_itemRelease( ptr );
  hb_itemReturn( self );
}

HB_FUNC_STATIC( QSCRIPTENGINEDEBUGGER_DELETE )
{
  QScriptEngineDebugger * obj = (QScriptEngineDebugger *) 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() );
}

/*
QAction * action(DebuggerAction action) const
*/
HB_FUNC_STATIC( QSCRIPTENGINEDEBUGGER_ACTION )
{
  QScriptEngineDebugger * obj = (QScriptEngineDebugger *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    int par1 = hb_parni(1);
    QAction * ptr = obj->action (  (QScriptEngineDebugger::DebuggerAction) par1 );
    _qt5xhb_createReturnClass ( ptr, "QACTION" );
  }
}

/*
void attachTo(QScriptEngine * engine)
*/
HB_FUNC_STATIC( QSCRIPTENGINEDEBUGGER_ATTACHTO )
{
  QScriptEngineDebugger * obj = (QScriptEngineDebugger *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QScriptEngine * par1 = (QScriptEngine *) _qt5xhb_itemGetPtr(1);
    obj->attachTo ( par1 );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
bool autoShowStandardWindow() const
*/
HB_FUNC_STATIC( QSCRIPTENGINEDEBUGGER_AUTOSHOWSTANDARDWINDOW )
{
  QScriptEngineDebugger * obj = (QScriptEngineDebugger *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    hb_retl( obj->autoShowStandardWindow (  ) );
  }
}

/*
QMenu * createStandardMenu(QWidget * parent = 0)
*/
HB_FUNC_STATIC( QSCRIPTENGINEDEBUGGER_CREATESTANDARDMENU )
{
  QScriptEngineDebugger * obj = (QScriptEngineDebugger *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QWidget * par1 = ISNIL(1)? 0 : (QWidget *) _qt5xhb_itemGetPtr(1);
    QMenu * ptr = obj->createStandardMenu ( par1 );
    _qt5xhb_createReturnClass ( ptr, "QMENU" );
  }
}

/*
QToolBar * createStandardToolBar(QWidget * parent = 0)
*/
HB_FUNC_STATIC( QSCRIPTENGINEDEBUGGER_CREATESTANDARDTOOLBAR )
{
  QScriptEngineDebugger * obj = (QScriptEngineDebugger *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QWidget * par1 = ISNIL(1)? 0 : (QWidget *) _qt5xhb_itemGetPtr(1);
    QToolBar * ptr = obj->createStandardToolBar ( par1 );
    _qt5xhb_createReturnClass ( ptr, "QTOOLBAR" );
  }
}

/*
void detach()
*/
HB_FUNC_STATIC( QSCRIPTENGINEDEBUGGER_DETACH )
{
  QScriptEngineDebugger * obj = (QScriptEngineDebugger *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    obj->detach (  );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setAutoShowStandardWindow(bool autoShow)
*/
HB_FUNC_STATIC( QSCRIPTENGINEDEBUGGER_SETAUTOSHOWSTANDARDWINDOW )
{
  QScriptEngineDebugger * obj = (QScriptEngineDebugger *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    obj->setAutoShowStandardWindow ( (bool) hb_parl(1) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
QMainWindow * standardWindow() const
*/
HB_FUNC_STATIC( QSCRIPTENGINEDEBUGGER_STANDARDWINDOW )
{
  QScriptEngineDebugger * obj = (QScriptEngineDebugger *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QMainWindow * ptr = obj->standardWindow (  );
    _qt5xhb_createReturnClass ( ptr, "QMAINWINDOW" );
  }
}

/*
DebuggerState state() const
*/
HB_FUNC_STATIC( QSCRIPTENGINEDEBUGGER_STATE )
{
  QScriptEngineDebugger * obj = (QScriptEngineDebugger *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    hb_retni( obj->state (  ) );
  }
}

/*
QWidget * widget(DebuggerWidget widget) const
*/
HB_FUNC_STATIC( QSCRIPTENGINEDEBUGGER_WIDGET )
{
  QScriptEngineDebugger * obj = (QScriptEngineDebugger *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    int par1 = hb_parni(1);
    QWidget * ptr = obj->widget (  (QScriptEngineDebugger::DebuggerWidget) par1 );
    _qt5xhb_createReturnQWidgetClass ( ptr, "QWIDGET" );
  }
}

#pragma ENDDUMP


[runtime] Fixed a problem with calculating first key node in Crypt() and added CryptRaw() which treats string characters as bytes, ignoring their high byte.

//
// 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.Globalization
USING System.Text

/// <summary>
/// Encrypt or decrypt a string.
/// </summary>
/// <param name="cSource"></param>
/// <param name="cKey"></param>
/// <returns>
/// </returns>
FUNCTION Crypt(cSource AS STRING,cKey AS STRING) AS STRING
	LOCAL bSource AS BYTE[]
	LOCAL bDest  AS BYTE[]
	LOCAL bKey  AS BYTE[]
    LOCAL enc     AS Encoding
    IF cSource?:Length == 0 .OR. cKey?:Length < 2
        RETURN cSource
    ENDIF
    enc         := StringHelpers.WinEncoding
    bSource     := enc:GetBytes(cSource)
    bKey        := enc:GetBytes(cKey)
    bDest 		:= Crypt(bSource, bKey)
    cSource 	:= enc:GetString(bDest)
	RETURN cSource

/// <summary>
/// Encrypt or decrypt a string handling its characters as single bytes (high order byte is ignored)
/// </summary>
/// <param name="cSource"></param>
/// <param name="cKey"></param>
/// <returns>
/// </returns>
FUNCTION CryptRaw(cSource AS STRING,cKey AS STRING) AS STRING
	LOCAL bSource AS BYTE[]
	LOCAL bDest  AS BYTE[]
	LOCAL bKey  AS BYTE[]
    IF cSource?:Length == 0 .OR. cKey?:Length < 2
        RETURN cSource
    ENDIF
    bSource     := BYTE[]{cSource:Length}
    FOR LOCAL n := 1 AS INT UPTO cSource:Length
    	bSource[n] := unchecked( (BYTE)cSource[n-1] )
    NEXT
    bKey     := BYTE[]{cKey:Length}
    FOR LOCAL n := 1 AS INT UPTO cKey:Length
    	bKey[n] := unchecked( (BYTE)cKey[n-1] )
    NEXT

    bDest := Crypt(bSource, bKey)

    LOCAL sDest AS StringBuilder
    sDest := StringBuilder{cSource:Length}
    FOREACH b AS BYTE IN bDest
    	sDest:Append((Char)b)
    NEXT

	RETURN sDest:ToString()

/// <summary>
/// Encrypt or decrypt an array of bytes.
/// </summary>
/// <param name="bSource"></param>
/// <param name="cKey"></param>
/// <returns>
/// </returns>
FUNCTION Crypt(bSource AS BYTE[],bKey AS BYTE[]) AS BYTE[]
	LOCAL bDest   AS BYTE[]
    LOCAL keyLen  AS INT
    LOCAL sourceLen AS INT
    LOCAL uiCode1 AS WORD
    LOCAL uiCode2 AS WORD
    LOCAL uiRotate AS WORD
    LOCAL uiCounter AS WORD
    LOCAL bNibble  AS BYTE
    LOCAL nPos     AS INT
    LOCAL nKeyPos  AS INT
    LOCAL bCurrent AS BYTE
    IF bSource:Length == 0 .OR. bKey?:Length < 2
        RETURN bSource
    ENDIF
    keyLen      := bKey:Length
    sourceLen   := bSource:Length
/*  IF lCreateNewArray
	    bDest       := BYTE[]{sourceLen}
	    System.Array.Copy(bSource, bDest, sourceLen)
    ELSE*/
    	bDest := bSource
//  END IF
    uiCode1     := (WORD) (bKey[1] ~ keyLen)
    uiCode1     := (WORD) (((DWORD)bKey[1] + (DWORD)bKey[2] * (DWORD)256) ~ (DWORD)keyLen)
    uiCode2     := 0xAAAA
    nPos        := 1
    nKeyPos     := keyLen+1
    bNibble     := 0
    DO WHILE nPos <= sourceLen
        IF nKeyPos > keyLen
            nKeyPos := 1
        ENDIF
        bCurrent  := bSource[nPos]  ~ bKey[nKeyPos]
        uiCode1   := (WORD) (uiCode1 ~ (uiCode1 >> 8))
        uiRotate  := (WORD) (uiCode1 & 0x0F)
        uiCode1   := (WORD) ((uiCode1 >> uiRotate)  | (uiCode1 << (16 - UiRotate)))
        uiCode1   := (WORD) (uICode1 ~ uiCode2)
        uiCode1   += 0x10
        uiCounter := (WORD) (uiCode1 & 0x1E)
        uiCounter += 2
        DO WHILE uiCounter > 0
            uiCounter --
            uiRotate := (BYTE) (uiCounter & 0x0F)
            uiCode2 := (WORD) ((uiCode2 >> uiRotate) | (uiCode2 << (16 - uiRotate)) )
            uiCode2 := (WORD) ((uiCode2 << 8) | (INT)( ( (uiCode2 >> 8) ~ 0xFF) ) )
            uiCode2 := (WORD) ((uiCode2 << 1) | (uiCode2 >> 15) )
            uiCode2 := (WORD)(uiCode2 ~ 0xAAAA )
            bNibble := (BYTE)(uiCode2 & 0xFF)

            bNibble := (BYTE)( (bNibble << 1) | (bNibble >> 7) )
            uiCode2 := (WORD)( (uiCode2 & 0xFF00) | bNibble )
            uiCounter--
        ENDDO
        bDest[nPos] := bCurrent ~ bNibble
        nPos ++
        nKeyPos++
    ENDDO
	RETURN bDest

/// <summary>
/// Encrypt or decrypt a string, changing the contents of the original string as well as returning the encrypted string.
/// </summary>
/// <param name="cSource"></param>
/// <param name="cKey"></param>
/// <returns>
/// </returns>
FUNCTION CryptA(cSource AS STRING,cKey AS STRING) AS STRING
	cSource := Crypt(cSource, cKey)
	RETURN cSource

//
// 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.Globalization
USING System.Text

/// <summary>
/// Encrypt or decrypt a string.
/// </summary>
/// <param name="cSource"></param>
/// <param name="cKey"></param>
/// <returns>
/// </returns>
FUNCTION Crypt(cSource AS STRING,cKey AS STRING) AS STRING
	LOCAL bSource AS BYTE[]
	LOCAL bDest  AS BYTE[]
    LOCAL enc     AS Encoding
    IF cSource?:Length == 0 .OR. cKey?:Length == 0
        RETURN cSource
    ENDIF
    enc         := StringHelpers.WinEncoding
    bSource     := enc:GetBytes(cSource)
    bDest := Crypt(bSource, cKey, FALSE)
    cSource := enc:GetString(bDest)
	RETURN cSource

/// <summary>
/// Encrypt or decrypt an array of bytes.
/// </summary>
/// <param name="bSource"></param>
/// <param name="cKey"></param>
/// <returns>
/// </returns>
FUNCTION Crypt(bSource AS BYTE[],cKey AS STRING) AS BYTE[]
	RETURN Crypt(bSource, cKey, TRUE)

FUNCTION Crypt(bSource AS BYTE[],cKey AS STRING,lCreateNewArray AS LOGIC) AS BYTE[]
	LOCAL bDest   AS BYTE[]
    LOCAL bKey    AS BYTE[]
    LOCAL enc     AS Encoding
    LOCAL keyLen  AS INT
    LOCAL sourceLen AS INT
    LOCAL uiCode1 AS WORD
    LOCAL uiCode2 AS WORD
    LOCAL uiRotate AS WORD
    LOCAL uiCounter AS WORD
    LOCAL bNibble  AS BYTE
    LOCAL nPos     AS INT
    LOCAL nKeyPos  AS INT
    LOCAL bCurrent AS BYTE
    IF bSource:Length == 0 .OR. cKey?:Length == 0
        RETURN bSource
    ENDIF
    enc         := StringHelpers.WinEncoding
    bKey        := enc:GetBytes(cKey)
    keyLen      := cKey:Length
    sourceLen   := bSource:Length
    IF lCreateNewArray
	    bDest       := BYTE[]{sourceLen}
	    System.Array.Copy(bSource, bDest, sourceLen)
    ELSE
    	bDest := bSource
    END IF
    uiCode1     := (WORD) (bKey[1] ~ keyLen)
    uiCode2     := 0xAAAA
    nPos        := 1
    nKeyPos     := keyLen+1
    bNibble     := 0
    DO WHILE nPos <= sourceLen
        IF nKeyPos > keyLen
            nKeyPos := 1
        ENDIF
        bCurrent  := bSource[nPos]  ~ bKey[nKeyPos]
        uiCode1   := (WORD) (uiCode1 ~ (uiCode1 >> 8))
        uiRotate  := (WORD) (uiCode1 & 0x0F)
        uiCode1   := (WORD) ((uiCode1 >> uiRotate)  | (uiCode1 << (16 - UiRotate)))
        uiCode1   := (WORD) (uICode1 ~ uiCode2)
        uiCode1   += 0x10
        uiCounter := (WORD) (uiCode1 & 0x1E)
        uiCounter += 2
        DO WHILE uiCounter > 0
            uiCounter --
            uiRotate := (BYTE) (uiCounter & 0x0F)
            uiCode2 := (WORD) ((uiCode2 >> uiRotate) | (uiCode2 << (16 - uiRotate)) )
            uiCode2 := (WORD) ((uiCode2 << 8) | (INT)( ( (uiCode2 >> 8) ~ 0xFF) ) )
            uiCode2 := (WORD) ((uiCode2 << 1) | (uiCode2 >> 15) )
            uiCode2 := (WORD)(uiCode2 ~ 0xAAAA )
            bNibble := (BYTE)(uiCode2 & 0xFF)

            bNibble := (BYTE)( (bNibble << 1) | (bNibble >> 7) )
            uiCode2 := (WORD)( (uiCode2 & 0xFF00) | bNibble )
            uiCounter--
        ENDDO
        bDest[nPos] := bCurrent ~ bNibble
        nPos ++
        nKeyPos++
    ENDDO
	RETURN bDest

/// <summary>
/// Encrypt or decrypt a string, changing the contents of the original string as well as returning the encrypted string.
/// </summary>
/// <param name="cSource"></param>
/// <param name="cKey"></param>
/// <returns>
/// </returns>
FUNCTION CryptA(cSource AS STRING,cKey AS STRING) AS STRING
	cSource := Crypt(cSource, cKey)
	RETURN cSource


QtTest: module updated (extra methods)

QtTest: module updated (extra methods)

Modified:
source/QtTest/QTestEventListClass.prg

/*

  Qt4xHb - bibliotecas de ligao entre Harbour/xHarbour e Qt Framework 4

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

*/

#include "hbclass.ch"

CLASS QTestEventList

   DATA pointer
   DATA self_destruction INIT .F.

   METHOD new1
   METHOD new2
   METHOD new
   METHOD delete
   METHOD addDelay
   METHOD addKeyClick1
   METHOD addKeyClick2
   METHOD addKeyClick
   METHOD addKeyClicks
   METHOD addKeyPress1
   METHOD addKeyPress2
   METHOD addKeyPress
   METHOD addKeyRelease1
   METHOD addKeyRelease2
   METHOD addKeyRelease
   METHOD addMouseClick
   METHOD addMouseDClick
   METHOD addMouseMove
   METHOD addMousePress
   METHOD addMouseRelease
   METHOD clear
   METHOD simulate
   METHOD newFrom
   METHOD newFromObject
   METHOD newFromPointer
   METHOD selfDestruction
   METHOD setSelfDestruction
   DESTRUCTOR destroyObject

END CLASS

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

#pragma BEGINDUMP

#include <QTestEventList>

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

/*
QTestEventList ()
*/
HB_FUNC_STATIC( QTESTEVENTLIST_NEW1 )
{
  QTestEventList * o = new QTestEventList ();
  _qt4xhb_storePointerAndFlag ( o, false );
}

/*
QTestEventList ( const QTestEventList & other )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_NEW2 )
{
  QTestEventList * o = new QTestEventList ( *PQTESTEVENTLIST(1) );
  _qt4xhb_storePointerAndFlag ( o, false );
}

//[1]QTestEventList ()
//[2]QTestEventList ( const QTestEventList & other )

HB_FUNC_STATIC( QTESTEVENTLIST_NEW )
{
  if( ISNUMPAR(0) )
  {
    HB_FUNC_EXEC( QTESTEVENTLIST_NEW1 );
  }
  else if( ISNUMPAR(1) && ISQTESTEVENTLIST(1) )
  {
    HB_FUNC_EXEC( QTESTEVENTLIST_NEW2 );
  }
  else
  {
    hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
  }
}

HB_FUNC_STATIC( QTESTEVENTLIST_DELETE )
{
  QTestEventList * obj = (QTestEventList *) 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() );
}

/*
void addDelay ( int msecs )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_ADDDELAY )
{
  QTestEventList * obj = (QTestEventList *) hb_itemGetPtr( hb_objSendMsg( hb_stackSelfItem(), "POINTER", 0 ) );
  if( obj )
  {
    obj->addDelay ( PINT(1) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void addKeyClick ( Qt::Key qtKey, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1 )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_ADDKEYCLICK1 )
{
  QTestEventList * obj = (QTestEventList *) hb_itemGetPtr( hb_objSendMsg( hb_stackSelfItem(), "POINTER", 0 ) );
  if( obj )
  {
    obj->addKeyClick ( (Qt::Key) hb_parni(1), ISNIL(2)? Qt::NoModifier : (Qt::KeyboardModifiers) hb_parni(2), OPINT(3,-1) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void addKeyClick ( char ascii, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1 )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_ADDKEYCLICK2 )
{
  QTestEventList * obj = (QTestEventList *) hb_itemGetPtr( hb_objSendMsg( hb_stackSelfItem(), "POINTER", 0 ) );
  if( obj )
  {
    char par1 = ISCHAR(1)? (char) hb_parc(1)[0] : (ISNUM(1)? hb_parni(1) : 0);
    obj->addKeyClick ( par1, ISNIL(2)? Qt::NoModifier : (Qt::KeyboardModifiers) hb_parni(2), OPINT(3,-1) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

//[1]void addKeyClick ( Qt::Key qtKey, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1 )
//[2]void addKeyClick ( char ascii, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1 )

HB_FUNC_STATIC( QTESTEVENTLIST_ADDKEYCLICK )
{
  if( ISBETWEEN(1,3) && ISNUM(1) && (ISNUM(2)||ISNIL(2)) && (ISNUM(3)||ISNIL(3)) )
  {
    HB_FUNC_EXEC( QTESTEVENTLIST_ADDKEYCLICK1 );
  }
  else if( ISBETWEEN(1,3) && ISCHAR(1) && (ISNUM(2)||ISNIL(2)) && (ISNUM(3)||ISNIL(3)) )
  {
    HB_FUNC_EXEC( QTESTEVENTLIST_ADDKEYCLICK2 );
  }
}

/*
void addKeyClicks ( const QString & keys, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1 )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_ADDKEYCLICKS )
{
  QTestEventList * obj = (QTestEventList *) hb_itemGetPtr( hb_objSendMsg( hb_stackSelfItem(), "POINTER", 0 ) );
  if( obj )
  {
    obj->addKeyClicks ( PQSTRING(1), ISNIL(2)? Qt::NoModifier : (Qt::KeyboardModifiers) hb_parni(2), OPINT(3,-1) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void addKeyPress ( Qt::Key qtKey, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1 )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_ADDKEYPRESS1 )
{
  QTestEventList * obj = (QTestEventList *) hb_itemGetPtr( hb_objSendMsg( hb_stackSelfItem(), "POINTER", 0 ) );
  if( obj )
  {
    obj->addKeyPress ( (Qt::Key) hb_parni(1), ISNIL(2)? Qt::NoModifier : (Qt::KeyboardModifiers) hb_parni(2), OPINT(3,-1) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void addKeyPress ( char ascii, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1 )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_ADDKEYPRESS2 )
{
  QTestEventList * obj = (QTestEventList *) hb_itemGetPtr( hb_objSendMsg( hb_stackSelfItem(), "POINTER", 0 ) );
  if( obj )
  {
    char par1 = ISCHAR(1)? (char) hb_parc(1)[0] : (ISNUM(1)? hb_parni(1) : 0);
    obj->addKeyPress ( par1, ISNIL(2)? Qt::NoModifier : (Qt::KeyboardModifiers) hb_parni(2), OPINT(3,-1) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

//[1]void addKeyPress ( Qt::Key qtKey, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1 )
//[2]void addKeyPress ( char ascii, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1 )

HB_FUNC_STATIC( QTESTEVENTLIST_ADDKEYPRESS )
{
  if( ISBETWEEN(1,3) && ISNUM(1) && (ISNUM(2)||ISNIL(2)) && (ISNUM(3)||ISNIL(3)) )
  {
    HB_FUNC_EXEC( QTESTEVENTLIST_ADDKEYPRESS1 );
  }
  else if( ISBETWEEN(1,3) && ISCHAR(1) && (ISNUM(2)||ISNIL(2)) && (ISNUM(3)||ISNIL(3)) )
  {
    HB_FUNC_EXEC( QTESTEVENTLIST_ADDKEYPRESS2 );
  }
}

/*
void addKeyRelease ( Qt::Key qtKey, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1 )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_ADDKEYRELEASE1 )
{
  QTestEventList * obj = (QTestEventList *) hb_itemGetPtr( hb_objSendMsg( hb_stackSelfItem(), "POINTER", 0 ) );
  if( obj )
  {
    obj->addKeyRelease ( (Qt::Key) hb_parni(1), ISNIL(2)? Qt::NoModifier : (Qt::KeyboardModifiers) hb_parni(2), OPINT(3,-1) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void addKeyRelease ( char ascii, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1 )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_ADDKEYRELEASE2 )
{
  QTestEventList * obj = (QTestEventList *) hb_itemGetPtr( hb_objSendMsg( hb_stackSelfItem(), "POINTER", 0 ) );
  if( obj )
  {
    char par1 = ISCHAR(1)? (char) hb_parc(1)[0] : (ISNUM(1)? hb_parni(1) : 0);
    obj->addKeyRelease ( par1, ISNIL(2)? Qt::NoModifier : (Qt::KeyboardModifiers) hb_parni(2), OPINT(3,-1) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

//[1]void addKeyRelease ( Qt::Key qtKey, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1 )
//[2]void addKeyRelease ( char ascii, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1 )

HB_FUNC_STATIC( QTESTEVENTLIST_ADDKEYRELEASE )
{
  if( ISBETWEEN(1,3) && ISNUM(1) && (ISNUM(2)||ISNIL(2)) && (ISNUM(3)||ISNIL(3)) )
  {
    HB_FUNC_EXEC( QTESTEVENTLIST_ADDKEYRELEASE1 );
  }
  else if( ISBETWEEN(1,3) && ISCHAR(1) && (ISNUM(2)||ISNIL(2)) && (ISNUM(3)||ISNIL(3)) )
  {
    HB_FUNC_EXEC( QTESTEVENTLIST_ADDKEYRELEASE2 );
  }
}

/*
void addMouseClick ( Qt::MouseButton button, Qt::KeyboardModifiers modifiers = 0, QPoint pos = QPoint(), int delay = -1 )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_ADDMOUSECLICK )
{
  QTestEventList * obj = (QTestEventList *) hb_itemGetPtr( hb_objSendMsg( hb_stackSelfItem(), "POINTER", 0 ) );
  int par2 = ISNIL(2)? 0 :  hb_parni(2);
  if( obj )
  {
    QPoint par3 = ISNIL(3)? QPoint() : *(QPoint *) hb_itemGetPtr( hb_objSendMsg( hb_param(3, HB_IT_OBJECT ), "POINTER", 0 ) );
    obj->addMouseClick ( (Qt::MouseButton) hb_parni(1), (Qt::KeyboardModifiers) par2, par3, OPINT(4,-1) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void addMouseDClick ( Qt::MouseButton button, Qt::KeyboardModifiers modifiers = 0, QPoint pos = QPoint(), int delay = -1 )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_ADDMOUSEDCLICK )
{
  QTestEventList * obj = (QTestEventList *) hb_itemGetPtr( hb_objSendMsg( hb_stackSelfItem(), "POINTER", 0 ) );
  int par2 = ISNIL(2)? 0 :  hb_parni(2);
  if( obj )
  {
    QPoint par3 = ISNIL(3)? QPoint() : *(QPoint *) hb_itemGetPtr( hb_objSendMsg( hb_param(3, HB_IT_OBJECT ), "POINTER", 0 ) );
    obj->addMouseDClick ( (Qt::MouseButton) hb_parni(1), (Qt::KeyboardModifiers) par2, par3, OPINT(4,-1) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void addMouseMove ( QPoint pos = QPoint(), int delay = -1 )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_ADDMOUSEMOVE )
{
  QTestEventList * obj = (QTestEventList *) hb_itemGetPtr( hb_objSendMsg( hb_stackSelfItem(), "POINTER", 0 ) );
  if( obj )
  {
    QPoint par1 = ISNIL(1)? QPoint() : *(QPoint *) hb_itemGetPtr( hb_objSendMsg( hb_param(1, HB_IT_OBJECT ), "POINTER", 0 ) );
    obj->addMouseMove ( par1, OPINT(2,-1) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void addMousePress ( Qt::MouseButton button, Qt::KeyboardModifiers modifiers = 0, QPoint pos = QPoint(), int delay = -1 )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_ADDMOUSEPRESS )
{
  QTestEventList * obj = (QTestEventList *) hb_itemGetPtr( hb_objSendMsg( hb_stackSelfItem(), "POINTER", 0 ) );
  int par2 = ISNIL(2)? 0 :  hb_parni(2);
  if( obj )
  {
    QPoint par3 = ISNIL(3)? QPoint() : *(QPoint *) hb_itemGetPtr( hb_objSendMsg( hb_param(3, HB_IT_OBJECT ), "POINTER", 0 ) );
    obj->addMousePress ( (Qt::MouseButton) hb_parni(1), (Qt::KeyboardModifiers) par2, par3, OPINT(4,-1) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void addMouseRelease ( Qt::MouseButton button, Qt::KeyboardModifiers modifiers = 0, QPoint pos = QPoint(), int delay = -1 )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_ADDMOUSERELEASE )
{
  QTestEventList * obj = (QTestEventList *) hb_itemGetPtr( hb_objSendMsg( hb_stackSelfItem(), "POINTER", 0 ) );
  int par2 = ISNIL(2)? 0 :  hb_parni(2);
  if( obj )
  {
    QPoint par3 = ISNIL(3)? QPoint() : *(QPoint *) hb_itemGetPtr( hb_objSendMsg( hb_param(3, HB_IT_OBJECT ), "POINTER", 0 ) );
    obj->addMouseRelease ( (Qt::MouseButton) hb_parni(1), (Qt::KeyboardModifiers) par2, par3, OPINT(4,-1) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void clear ()
*/
HB_FUNC_STATIC( QTESTEVENTLIST_CLEAR )
{
  QTestEventList * obj = (QTestEventList *) hb_itemGetPtr( hb_objSendMsg( hb_stackSelfItem(), "POINTER", 0 ) );
  if( obj )
  {
    obj->clear ();
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void simulate ( QWidget * w )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_SIMULATE )
{
  QTestEventList * obj = (QTestEventList *) hb_itemGetPtr( hb_objSendMsg( hb_stackSelfItem(), "POINTER", 0 ) );
  if( obj )
  {
    obj->simulate ( PQWIDGET(1) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

HB_FUNC_STATIC( QTESTEVENTLIST_NEWFROM )
{
  PHB_ITEM self = hb_stackSelfItem();

  if( hb_pcount() == 1 && ISOBJECT(1) )
  {
    PHB_ITEM ptr = hb_itemPutPtr( NULL, (void *) hb_itemGetPtr( hb_objSendMsg( hb_param(1, HB_IT_OBJECT ), "POINTER", 0 ) ) );
    hb_objSendMsg( self, "_pointer", 1, ptr );
    hb_itemRelease( ptr );
    PHB_ITEM des = hb_itemPutL( NULL, false );
    hb_objSendMsg( self, "_self_destruction", 1, des );
    hb_itemRelease( des );
  }
  else if( hb_pcount() == 1 && ISPOINTER(1) )
  {
    PHB_ITEM ptr = hb_itemPutPtr( NULL, (void *) hb_itemGetPtr( hb_param(1, HB_IT_POINTER ) ) );
    hb_objSendMsg( self, "_pointer", 1, ptr );
    hb_itemRelease( ptr );
    PHB_ITEM des = hb_itemPutL( NULL, false );
    hb_objSendMsg( self, "_self_destruction", 1, des );
    hb_itemRelease( des );
  }
  else
  {
    hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
  }

  hb_itemReturn( self );
}

HB_FUNC_STATIC( QTESTEVENTLIST_NEWFROMOBJECT )
{
  HB_FUNC_EXEC( QTESTEVENTLIST_NEWFROM );
}

HB_FUNC_STATIC( QTESTEVENTLIST_NEWFROMPOINTER )
{
  HB_FUNC_EXEC( QTESTEVENTLIST_NEWFROM );
}

HB_FUNC_STATIC( QTESTEVENTLIST_SELFDESTRUCTION )
{
  hb_retl( (bool) hb_itemGetL( hb_objSendMsg( hb_stackSelfItem(), "SELF_DESTRUCTION", 0 ) ) );
}

HB_FUNC_STATIC( QTESTEVENTLIST_SETSELFDESTRUCTION )
{
  PHB_ITEM self = hb_stackSelfItem();

  if( hb_pcount() == 1 && ISLOG(1) )
  {
    PHB_ITEM des = hb_itemPutL( NULL, hb_parl(1) );
    hb_objSendMsg( self, "_self_destruction", 1, des );
    hb_itemRelease( des );
  }
  else
  {
    hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
  }

  hb_itemReturn( self );
}

#pragma ENDDUMP

/*

  Qt4xHb - bibliotecas de ligao entre Harbour/xHarbour e Qt Framework 4

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

*/

#include "hbclass.ch"

CLASS QTestEventList

   DATA pointer
   DATA self_destruction INIT .F.

   METHOD new1
   METHOD new2
   METHOD new
   METHOD delete
   METHOD addDelay
   METHOD addKeyClick1
   METHOD addKeyClick2
   METHOD addKeyClick
   METHOD addKeyClicks
   METHOD addKeyPress1
   METHOD addKeyPress2
   METHOD addKeyPress
   METHOD addKeyRelease1
   METHOD addKeyRelease2
   METHOD addKeyRelease
   METHOD addMouseClick
   METHOD addMouseDClick
   METHOD addMouseMove
   METHOD addMousePress
   METHOD addMouseRelease
   METHOD clear
   METHOD simulate
   METHOD newFrom
   METHOD newFromObject
   METHOD newFromPointer
   METHOD selfDestruction
   METHOD setSelfDestruction
   DESTRUCTOR destroyObject

END CLASS

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

#pragma BEGINDUMP

#include <QTestEventList>

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

/*
QTestEventList ()
*/
HB_FUNC_STATIC( QTESTEVENTLIST_NEW1 )
{
  QTestEventList * o = new QTestEventList ();
  _qt4xhb_storePointerAndFlag ( o, false );
}

/*
QTestEventList ( const QTestEventList & other )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_NEW2 )
{
  QTestEventList * o = new QTestEventList ( *PQTESTEVENTLIST(1) );
  _qt4xhb_storePointerAndFlag ( o, false );
}

//[1]QTestEventList ()
//[2]QTestEventList ( const QTestEventList & other )

HB_FUNC_STATIC( QTESTEVENTLIST_NEW )
{
  if( ISNUMPAR(0) )
  {
    HB_FUNC_EXEC( QTESTEVENTLIST_NEW1 );
  }
  else if( ISNUMPAR(1) && ISQTESTEVENTLIST(1) )
  {
    HB_FUNC_EXEC( QTESTEVENTLIST_NEW2 );
  }
  else
  {
    hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
  }
}

HB_FUNC_STATIC( QTESTEVENTLIST_DELETE )
{
  QTestEventList * obj = (QTestEventList *) 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() );
}

/*
void addDelay ( int msecs )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_ADDDELAY )
{
  QTestEventList * obj = (QTestEventList *) hb_itemGetPtr( hb_objSendMsg( hb_stackSelfItem(), "POINTER", 0 ) );
  if( obj )
  {
    obj->addDelay ( PINT(1) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void addKeyClick ( Qt::Key qtKey, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1 )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_ADDKEYCLICK1 )
{
  QTestEventList * obj = (QTestEventList *) hb_itemGetPtr( hb_objSendMsg( hb_stackSelfItem(), "POINTER", 0 ) );
  if( obj )
  {
    obj->addKeyClick ( (Qt::Key) hb_parni(1), ISNIL(2)? Qt::NoModifier : (Qt::KeyboardModifiers) hb_parni(2), OPINT(3,-1) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void addKeyClick ( char ascii, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1 )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_ADDKEYCLICK2 )
{
  QTestEventList * obj = (QTestEventList *) hb_itemGetPtr( hb_objSendMsg( hb_stackSelfItem(), "POINTER", 0 ) );
  if( obj )
  {
    char par1 = ISCHAR(1)? (char) hb_parc(1)[0] : (ISNUM(1)? hb_parni(1) : 0);
    obj->addKeyClick ( par1, ISNIL(2)? Qt::NoModifier : (Qt::KeyboardModifiers) hb_parni(2), OPINT(3,-1) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

//[1]void addKeyClick ( Qt::Key qtKey, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1 )
//[2]void addKeyClick ( char ascii, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1 )

HB_FUNC_STATIC( QTESTEVENTLIST_ADDKEYCLICK )
{
  if( ISBETWEEN(1,3) && ISNUM(1) && (ISNUM(2)||ISNIL(2)) && (ISNUM(3)||ISNIL(3)) )
  {
    HB_FUNC_EXEC( QTESTEVENTLIST_ADDKEYCLICK1 );
  }
  else if( ISBETWEEN(1,3) && ISCHAR(1) && (ISNUM(2)||ISNIL(2)) && (ISNUM(3)||ISNIL(3)) )
  {
    HB_FUNC_EXEC( QTESTEVENTLIST_ADDKEYCLICK2 );
  }
}

/*
void addKeyClicks ( const QString & keys, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1 )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_ADDKEYCLICKS )
{
  QTestEventList * obj = (QTestEventList *) hb_itemGetPtr( hb_objSendMsg( hb_stackSelfItem(), "POINTER", 0 ) );
  if( obj )
  {
    obj->addKeyClicks ( PQSTRING(1), ISNIL(2)? Qt::NoModifier : (Qt::KeyboardModifiers) hb_parni(2), OPINT(3,-1) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void addKeyPress ( Qt::Key qtKey, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1 )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_ADDKEYPRESS1 )
{
  QTestEventList * obj = (QTestEventList *) hb_itemGetPtr( hb_objSendMsg( hb_stackSelfItem(), "POINTER", 0 ) );
  if( obj )
  {
    obj->addKeyPress ( (Qt::Key) hb_parni(1), ISNIL(2)? Qt::NoModifier : (Qt::KeyboardModifiers) hb_parni(2), OPINT(3,-1) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void addKeyPress ( char ascii, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1 )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_ADDKEYPRESS2 )
{
  QTestEventList * obj = (QTestEventList *) hb_itemGetPtr( hb_objSendMsg( hb_stackSelfItem(), "POINTER", 0 ) );
  if( obj )
  {
    char par1 = ISCHAR(1)? (char) hb_parc(1)[0] : (ISNUM(1)? hb_parni(1) : 0);
    obj->addKeyPress ( par1, ISNIL(2)? Qt::NoModifier : (Qt::KeyboardModifiers) hb_parni(2), OPINT(3,-1) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

//[1]void addKeyPress ( Qt::Key qtKey, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1 )
//[2]void addKeyPress ( char ascii, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1 )

HB_FUNC_STATIC( QTESTEVENTLIST_ADDKEYPRESS )
{
  if( ISBETWEEN(1,3) && ISNUM(1) && (ISNUM(2)||ISNIL(2)) && (ISNUM(3)||ISNIL(3)) )
  {
    HB_FUNC_EXEC( QTESTEVENTLIST_ADDKEYPRESS1 );
  }
  else if( ISBETWEEN(1,3) && ISCHAR(1) && (ISNUM(2)||ISNIL(2)) && (ISNUM(3)||ISNIL(3)) )
  {
    HB_FUNC_EXEC( QTESTEVENTLIST_ADDKEYPRESS2 );
  }
}

/*
void addKeyRelease ( Qt::Key qtKey, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1 )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_ADDKEYRELEASE1 )
{
  QTestEventList * obj = (QTestEventList *) hb_itemGetPtr( hb_objSendMsg( hb_stackSelfItem(), "POINTER", 0 ) );
  if( obj )
  {
    obj->addKeyRelease ( (Qt::Key) hb_parni(1), ISNIL(2)? Qt::NoModifier : (Qt::KeyboardModifiers) hb_parni(2), OPINT(3,-1) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void addKeyRelease ( char ascii, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1 )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_ADDKEYRELEASE2 )
{
  QTestEventList * obj = (QTestEventList *) hb_itemGetPtr( hb_objSendMsg( hb_stackSelfItem(), "POINTER", 0 ) );
  if( obj )
  {
    char par1 = ISCHAR(1)? (char) hb_parc(1)[0] : (ISNUM(1)? hb_parni(1) : 0);
    obj->addKeyRelease ( par1, ISNIL(2)? Qt::NoModifier : (Qt::KeyboardModifiers) hb_parni(2), OPINT(3,-1) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

//[1]void addKeyRelease ( Qt::Key qtKey, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1 )
//[2]void addKeyRelease ( char ascii, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1 )

HB_FUNC_STATIC( QTESTEVENTLIST_ADDKEYRELEASE )
{
  if( ISBETWEEN(1,3) && ISNUM(1) && (ISNUM(2)||ISNIL(2)) && (ISNUM(3)||ISNIL(3)) )
  {
    HB_FUNC_EXEC( QTESTEVENTLIST_ADDKEYRELEASE1 );
  }
  else if( ISBETWEEN(1,3) && ISCHAR(1) && (ISNUM(2)||ISNIL(2)) && (ISNUM(3)||ISNIL(3)) )
  {
    HB_FUNC_EXEC( QTESTEVENTLIST_ADDKEYRELEASE2 );
  }
}

/*
void addMouseClick ( Qt::MouseButton button, Qt::KeyboardModifiers modifiers = 0, QPoint pos = QPoint(), int delay = -1 )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_ADDMOUSECLICK )
{
  QTestEventList * obj = (QTestEventList *) hb_itemGetPtr( hb_objSendMsg( hb_stackSelfItem(), "POINTER", 0 ) );
  int par2 = ISNIL(2)? 0 :  hb_parni(2);
  if( obj )
  {
    QPoint par3 = ISNIL(3)? QPoint() : *(QPoint *) hb_itemGetPtr( hb_objSendMsg( hb_param(3, HB_IT_OBJECT ), "POINTER", 0 ) );
    obj->addMouseClick ( (Qt::MouseButton) hb_parni(1), (Qt::KeyboardModifiers) par2, par3, OPINT(4,-1) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void addMouseDClick ( Qt::MouseButton button, Qt::KeyboardModifiers modifiers = 0, QPoint pos = QPoint(), int delay = -1 )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_ADDMOUSEDCLICK )
{
  QTestEventList * obj = (QTestEventList *) hb_itemGetPtr( hb_objSendMsg( hb_stackSelfItem(), "POINTER", 0 ) );
  int par2 = ISNIL(2)? 0 :  hb_parni(2);
  if( obj )
  {
    QPoint par3 = ISNIL(3)? QPoint() : *(QPoint *) hb_itemGetPtr( hb_objSendMsg( hb_param(3, HB_IT_OBJECT ), "POINTER", 0 ) );
    obj->addMouseDClick ( (Qt::MouseButton) hb_parni(1), (Qt::KeyboardModifiers) par2, par3, OPINT(4,-1) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void addMouseMove ( QPoint pos = QPoint(), int delay = -1 )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_ADDMOUSEMOVE )
{
  QTestEventList * obj = (QTestEventList *) hb_itemGetPtr( hb_objSendMsg( hb_stackSelfItem(), "POINTER", 0 ) );
  if( obj )
  {
    QPoint par1 = ISNIL(1)? QPoint() : *(QPoint *) hb_itemGetPtr( hb_objSendMsg( hb_param(1, HB_IT_OBJECT ), "POINTER", 0 ) );
    obj->addMouseMove ( par1, OPINT(2,-1) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void addMousePress ( Qt::MouseButton button, Qt::KeyboardModifiers modifiers = 0, QPoint pos = QPoint(), int delay = -1 )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_ADDMOUSEPRESS )
{
  QTestEventList * obj = (QTestEventList *) hb_itemGetPtr( hb_objSendMsg( hb_stackSelfItem(), "POINTER", 0 ) );
  int par2 = ISNIL(2)? 0 :  hb_parni(2);
  if( obj )
  {
    QPoint par3 = ISNIL(3)? QPoint() : *(QPoint *) hb_itemGetPtr( hb_objSendMsg( hb_param(3, HB_IT_OBJECT ), "POINTER", 0 ) );
    obj->addMousePress ( (Qt::MouseButton) hb_parni(1), (Qt::KeyboardModifiers) par2, par3, OPINT(4,-1) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void addMouseRelease ( Qt::MouseButton button, Qt::KeyboardModifiers modifiers = 0, QPoint pos = QPoint(), int delay = -1 )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_ADDMOUSERELEASE )
{
  QTestEventList * obj = (QTestEventList *) hb_itemGetPtr( hb_objSendMsg( hb_stackSelfItem(), "POINTER", 0 ) );
  int par2 = ISNIL(2)? 0 :  hb_parni(2);
  if( obj )
  {
    QPoint par3 = ISNIL(3)? QPoint() : *(QPoint *) hb_itemGetPtr( hb_objSendMsg( hb_param(3, HB_IT_OBJECT ), "POINTER", 0 ) );
    obj->addMouseRelease ( (Qt::MouseButton) hb_parni(1), (Qt::KeyboardModifiers) par2, par3, OPINT(4,-1) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void clear ()
*/
HB_FUNC_STATIC( QTESTEVENTLIST_CLEAR )
{
  QTestEventList * obj = (QTestEventList *) hb_itemGetPtr( hb_objSendMsg( hb_stackSelfItem(), "POINTER", 0 ) );
  if( obj )
  {
    obj->clear ();
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void simulate ( QWidget * w )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_SIMULATE )
{
  QTestEventList * obj = (QTestEventList *) hb_itemGetPtr( hb_objSendMsg( hb_stackSelfItem(), "POINTER", 0 ) );
  if( obj )
  {
    obj->simulate ( PQWIDGET(1) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

HB_FUNC_STATIC( QTESTEVENTLIST_NEWFROM )
{
  PHB_ITEM self = hb_stackSelfItem();

  if( hb_pcount() == 1 && ISOBJECT(1) )
  {
    PHB_ITEM ptr = hb_itemPutPtr( NULL, (void *) hb_itemGetPtr( hb_objSendMsg( hb_param(1, HB_IT_OBJECT ), "POINTER", 0 ) ) );
    hb_objSendMsg( self, "_pointer", 1, ptr );
    hb_itemRelease( ptr );
    PHB_ITEM des = hb_itemPutL( NULL, false );
    hb_objSendMsg( self, "_self_destruction", 1, des );
    hb_itemRelease( des );
  }
  else if( hb_pcount() == 1 && ISPOINTER(1) )
  {
    PHB_ITEM ptr = hb_itemPutPtr( NULL, (void *) hb_itemGetPtr( hb_param(1, HB_IT_POINTER ) ) );
    hb_objSendMsg( self, "_pointer", 1, ptr );
    hb_itemRelease( ptr );
    PHB_ITEM des = hb_itemPutL( NULL, false );
    hb_objSendMsg( self, "_self_destruction", 1, des );
    hb_itemRelease( des );
  }

  hb_itemReturn( self );
}

HB_FUNC_STATIC( QTESTEVENTLIST_NEWFROMOBJECT )
{
  HB_FUNC_EXEC( QTESTEVENTLIST_NEWFROM );
}

HB_FUNC_STATIC( QTESTEVENTLIST_NEWFROMPOINTER )
{
  HB_FUNC_EXEC( QTESTEVENTLIST_NEWFROM );
}

HB_FUNC_STATIC( QTESTEVENTLIST_SELFDESTRUCTION )
{
  hb_retl( (bool) hb_itemGetL( hb_objSendMsg( hb_stackSelfItem(), "SELF_DESTRUCTION", 0 ) ) );
}

HB_FUNC_STATIC( QTESTEVENTLIST_SETSELFDESTRUCTION )
{
  PHB_ITEM self = hb_stackSelfItem();

  if( hb_pcount() == 1 && ISLOG(1) )
  {
    PHB_ITEM des = hb_itemPutL( NULL, hb_parl(1) );
    hb_objSendMsg( self, "_self_destruction", 1, des );
    hb_itemRelease( des );
  }

  hb_itemReturn( self );
}

#pragma ENDDUMP


tests/QtWebSockets/websocketserver.prg: fix

/*

  Qt5xHb Project - Test Program

  Copyright (C) 2018 Marcos Antonio Gambeta

  E-mail:
  marcosgambeta AT outlook DOT com

  Website:
  https://github.com/marcosgambeta/Qt5xHb

*/

#include "qt5xhb.ch"

PROCEDURE Main ()

   LOCAL oApp
   LOCAL oWebSocketServer

   oApp := QCoreApplication():new()

   oWebSocketServer := QWebSocketServer():new("WebSocketServer", QWebSocketServer_NonSecureMode)

   IF oWebSocketServer:listen(QHostAddress():new("127.0.0.1"), 1234)
      ? "servidor ativo na porta 1234"
   ELSE
      ? "servidor inativo"
      WAIT
      oWebSocketServer:delete()
      oApp:delete()
      QUIT
   ENDIF

   oWebSocketServer:onNewConnection( {||newConnection(oWebSocketServer)} )
   oWebSocketServer:onClosed( {||oApp:quit()} )

   oApp:exec()

   oWebSocketServer:delete()

   oApp:delete()

RETURN

STATIC FUNCTION newConnection (oWebSocketServer)

   LOCAL oSocket

   ? "iniciando nova conexao"

   oSocket := oWebSocketServer:nextPendingConnection()

   oSocket:onDestroyed( {|oSender|qout(oSender:pointer),qout("socket destruido"),oSender:disconnectAll(.T.)} )
   oSocket:onTextMessageReceived( {|oSender, cText|qout(oSender:pointer),qout("textMessageReceived="+cText),oSender:sendTextMessage(cText)} )
   oSocket:onDisconnected( {|oSender|qout(oSender:pointer),qout("socket desconectado"),oSender:delete()} )

   ? "finalizando nova conexao"

RETURN NIL

/*

  Qt5xHb Project - Test Program

  Copyright (C) 2018 Marcos Antonio Gambeta

  E-mail:
  marcosgambeta AT outlook DOT com

  Website:
  https://github.com/marcosgambeta/Qt5xHb

*/

#include "qt5xhb.ch"

PROCEDURE Main ()

   LOCAL oApp
   LOCAL oWebSocketServer

   oApp := QCoreApplication():new()

   oWebSocketServer := QWebSocketServer():new("WebSocketServer", QWebSocketServer_NonSecureMode)

   IF oWebSocketServer:listen(QHostAddress():new("127.0.0.1"), 1234)
      ? "servidor ativo na porta 1234"
   ELSE
      ? "servidor inativo"
      WAIT
      oWebSocketServer:delete()
      oApp:delete()
      QUIT
   ENDIF

   oWebSocketServer:onNewConnection( {||newConnection(oWebSocketServer)} )
   oWebSocketServer:onClosed( {||oApp:quit()} )

   oApp:exec()

   oWebSocketServer:delete()

   oSocket:delete()

   oApp:delete()

RETURN

STATIC FUNCTION newConnection (oWebSocketServer)

   LOCAL oSocket

   ? "iniciando nova conexao"

   oSocket := oWebSocketServer:nextPendingConnection()

   oSocket:onDestroyed( {|oSender|qout(oSender:pointer),qout("socket destruido"),oSender:disconnectAll(.T.)} )
   oSocket:onTextMessageReceived( {|oSender, cText|qout(oSender:pointer),qout("textMessageReceived="+cText),oSender:sendTextMessage(cText)} )
   oSocket:onDisconnected( {|oSender|qout(oSender:pointer),qout("socket desconectado"),oSender:delete()} )

   ? "finalizando nova conexao"

RETURN NIL


QtScriptTools: data for code generation updated

Modified:
codegen/QtScriptTools/QScriptEngineDebugger.prg