judicious use of syntax extensions

judicious use of syntax extensions

data Termination :: *1 where
   Total:: Termination
   Partial:: Termination

lub:: Termination ~> Termination ~> Termination
{lub Total x} = x
{lub Partial x} = Partial

data Stage :: *1 where
  Succ :: Stage ~> Stage
  Inf :: Stage
 deriving syntax(s) Tick(Succ)

data Typ :: *1 where
  Arr:: Typ ~> Termination ~> Typ ~> Typ
  Li :: Stage ~> Typ ~> Typ
  I:: Typ
  P:: Typ ~> Typ ~> Typ
 deriving syntax(ty) Pair(P)

mean:: Typ ~> *0
{mean I} = Int
{mean (Arr a n b)} = {mean a} -> {mean b}
{mean (Li n a)} = [{mean a}]
{mean (P x y)} = ({mean x},{mean y})

data Prim:: Typ ~> *0 where
  Add :: Prim (Arr I Total (Arr I Total I))
  Sub :: Prim (Arr I Total (Arr I Total I))
  Mul :: Prim (Arr I Total (Arr I Total I))
  Div :: Prim (Arr I Total (Arr I Partial I))

data DBindex:: Tag ~> Typ ~> Row Tag Typ ~> *0 where
  DBz :: DBindex a t (RCons a t r)
  DBs :: DBindex a t g -> DBindex a t (RCons c b g)
 deriving Nat(d)

data Exp:: Typ ~> Row Tag Typ ~> Termination ~> *0 where
  Var:: Label a -> DBindex a t g -> Exp t g Total
  Shift:: Exp t g m -> Exp t (RCons a b g) m
  Const:: Int -> Exp I g Total
  Oper:: Prim t -> Exp t g Total
  Pair:: Exp x g m -> Exp y g n -> Exp (P x y) g {lub m n}
  App:: Exp (Arr x m b) g n -> Exp x g p -> Exp b g {lub m {lub n p}}
  Cons:: Exp a g n -> Exp (Li s a) g m -> Exp (Li (Succ s) a) g {lub m n}
  Nil:: Exp (Li (Succ s) a) g Total
  Abs:: Exp rng (RCons a dom g) n -> Exp (Arr dom n rng) g Total
  Fix:: Exp b
            (RCons body (Li (Succ s) a)
            (RCons f (Arr (Li s a) n b) env))
            Total ->
        Exp (Arr (Li Inf a) Total b) env Total
  PFix:: Exp b
            (RCons body a
            (RCons f (Arr a n b) env))
            m ->
        Exp (Arr a Partial b) env Total
  Case:: Exp (Li (Succ s) a) env p ->
         Exp t env n ->
         Exp t (RCons xs (Li s a)(RCons x a env)) m ->
         Exp t env {lub {lub p n} m}

length = Fix
   (Case (Var `x 0d)
                    (Const 0)
                    (App (App (Oper Add) (Const 1))
                         (App (Var `f 3d) (Var `ys 0d)))
               )

eval :: Exp t env Total -> Rec env -> {mean t}

data Termination :: *1 where
   Total:: Termination
   Partial:: Termination

lub:: Termination ~> Termination ~> Termination
{lub Total x} = x
{lub Partial x} = Partial

data Stage :: *1 where
  Succ :: Stage ~> Stage
  Inf :: Stage

data Typ :: *1 where
  Arr:: Typ ~> Termination ~> Typ ~> Typ
  Li :: Stage ~> Typ ~> Typ
  I:: Typ
  P:: Typ ~> Typ ~> Typ

mean:: Typ ~> *0
{mean I} = Int
{mean (Arr a n b)} = {mean a} -> {mean b}
{mean (Li n a)} = [{mean a}]
{mean (P x y)} = ({mean x},{mean y})

data Prim:: Typ ~> *0 where
  Add :: Prim (Arr I Total (Arr I Total I))
  Sub :: Prim (Arr I Total (Arr I Total I))
  Mul :: Prim (Arr I Total (Arr I Total I))
  Div :: Prim (Arr I Total (Arr I Partial I))

data DBindex:: Tag ~> Typ ~> Row Tag Typ ~> *0 where
  DBz :: DBindex a t (RCons a t r)
  DBs :: DBindex a t g -> DBindex a t (RCons c b g)
 deriving Nat(d)

data Exp:: Typ ~> Row Tag Typ ~> Termination ~> *0 where
  Var:: Label a -> DBindex a t g -> Exp t g Total
  Shift:: Exp t g m -> Exp t (RCons a b g) m
  Const:: Int -> Exp I g Total
  Oper:: Prim t -> Exp t g Total
  Pair:: Exp x g m -> Exp y g n -> Exp (P x y) g {lub m n}
  App:: Exp (Arr x m b) g n -> Exp x g p -> Exp b g {lub m {lub n p}}
  Cons:: Exp a g n -> Exp (Li s a) g m -> Exp (Li (Succ s) a) g {lub m n}
  Nil:: Exp (Li (Succ s) a) g Total
  Abs:: Exp rng (RCons a dom g) n -> Exp (Arr dom n rng) g Total
  Fix:: Exp b
            (RCons body (Li (Succ s) a)
            (RCons f (Arr (Li s a) n b) env))
            Total ->
        Exp (Arr (Li Inf a) Total b) env Total
  PFix:: Exp b
            (RCons body a
            (RCons f (Arr a n b) env))
            m ->
        Exp (Arr a Partial b) env Total
  Case:: Exp (Li (Succ s) a) env p ->
         Exp t env n ->
         Exp t (RCons xs (Li s a)(RCons x a env)) m ->
         Exp t env {lub {lub p n} m}

length = Fix
   (Case (Var `x 0d)
                    (Const 0)
                    (App (App (Oper Add) (Const 1))
                         (App (Var `f 3d) (Var `ys 0d)))
               )

eval :: Exp t env Total -> Rec env -> {mean t}


codegen/Qt3DCore: updated

codegen/Qt3DCore: updated

Modified:
codegen/Qt3DCore/QTransform.prg

%%
%% Qt5xHb - Bindings libraries for Harbour/xHarbour and Qt Framework 5
%%
%% Copyright (C) 2020 Marcos Antonio Gambeta <marcosgambeta AT outlook DOT com>
%%

$project=Qt5xHb
$module=Qt3DCore

$header

#include "hbclass.ch"

$addRequests

$beginClassFrom=QComponent

$addMethods

$addSignals

$endClass

$destructor

#pragma BEGINDUMP

$includes

$prototype=explicit QTransform(QNode *parent = nullptr)
$constructor=|new|QNode *=nullptr

$prototype=explicit QTransform(QTransformPrivate &dd, QNode *parent = nullptr) [protected]

$prototype=~QTransform()
$deleteMethod

%%
%% Q_PROPERTY(QMatrix4x4 matrix READ matrix WRITE setMatrix NOTIFY matrixChanged)
%%

$prototype=QMatrix4x4 matrix() const
$method=|QMatrix4x4|matrix|

$prototype=void setMatrix(const QMatrix4x4 &matrix)
$slotMethod=|void|setMatrix|const QMatrix4x4 &

%%
%% Q_PROPERTY(float scale READ scale WRITE setScale NOTIFY scaleChanged)
%%

$prototype=float scale() const
$method=|float|scale|

$prototype=void setScale(float scale)
$slotMethod=|void|setScale|float

%%
%% Q_PROPERTY(QVector3D scale3D READ scale3D WRITE setScale3D NOTIFY scale3DChanged)
%%

$prototype=QVector3D scale3D() const
$method=|QVector3D|scale3D|

$prototype=void setScale3D(const QVector3D &scale)
$slotMethod=|void|setScale3D|const QVector3D &

%%
%% Q_PROPERTY(QQuaternion rotation READ rotation WRITE setRotation NOTIFY rotationChanged)
%%

$prototype=QQuaternion rotation() const
$method=|QQuaternion|rotation|

$prototype=void setRotation(const QQuaternion &rotation)
$slotMethod=|void|setRotation|const QQuaternion &

%%
%% Q_PROPERTY(QVector3D translation READ translation WRITE setTranslation NOTIFY translationChanged)
%%

$prototype=QVector3D translation() const
$method=|QVector3D|translation|

$prototype=void setTranslation(const QVector3D &translation)
$slotMethod=|void|setTranslation|const QVector3D &

%%
%% Q_PROPERTY(float rotationX READ rotationX WRITE setRotationX NOTIFY rotationXChanged)
%%

$prototype=float rotationX() const
$method=|float|rotationX|

$prototype=void setRotationX(float rotationX)
$slotMethod=|void|setRotationX|float

%%
%% Q_PROPERTY(float rotationY READ rotationY WRITE setRotationY NOTIFY rotationYChanged)
%%

$prototype=float rotationY() const
$method=|float|rotationY|

$prototype=void setRotationY(float rotationY)
$slotMethod=|void|setRotationY|float

%%
%% Q_PROPERTY(float rotationZ READ rotationZ WRITE setRotationZ NOTIFY rotationZChanged)
%%

$prototype=float rotationZ() const
$method=|float|rotationZ|

$prototype=void setRotationZ(float rotationZ)
$slotMethod=|void|setRotationZ|float

%%
%%
%%

$prototype=Q_INVOKABLE static QQuaternion fromAxisAndAngle(const QVector3D &axis, float angle)
$staticMethod=|QQuaternion|fromAxisAndAngle,fromAxisAndAngle1|const QVector3D &,float

$prototype=Q_INVOKABLE static QQuaternion fromAxisAndAngle(float x, float y, float z, float angle)
$staticMethod=|QQuaternion|fromAxisAndAngle,fromAxisAndAngle2|float,float,float,float

/*
[1]Q_INVOKABLE static QQuaternion fromAxisAndAngle(const QVector3D &axis, float angle)
[2]Q_INVOKABLE static QQuaternion fromAxisAndAngle(float x, float y, float z, float angle)
*/

HB_FUNC_STATIC( QTRANSFORM_FROMAXISANDANGLE )
{
%% TODO: implementar
}

$prototype=Q_INVOKABLE static QQuaternion fromAxesAndAngles(const QVector3D &axis1, float angle1, const QVector3D &axis2, float angle2)
$staticMethod=|QQuaternion|fromAxesAndAngles,fromAxesAndAngles1|const QVector3D &,float,const QVector3D &,float

$prototype=Q_INVOKABLE static QQuaternion fromAxesAndAngles(const QVector3D &axis1, float angle1, const QVector3D &axis2, float angle2, const QVector3D &axis3, float angle3)
$staticMethod=|QQuaternion|fromAxesAndAngles,fromAxesAndAngles2|const QVector3D &,float,const QVector3D &,float,const QVector3D &,float

/*
[1]Q_INVOKABLE static QQuaternion fromAxesAndAngles(const QVector3D &axis1, float angle1, const QVector3D &axis2, float angle2)
[2]Q_INVOKABLE static QQuaternion fromAxesAndAngles(const QVector3D &axis1, float angle1, const QVector3D &axis2, float angle2, const QVector3D &axis3, float angle3)
*/

HB_FUNC_STATIC( QTRANSFORM_FROMAXESANDANGLES )
{
%% TODO: implementar
}

$prototype=Q_INVOKABLE static QQuaternion fromEulerAngles(const QVector3D &eulerAngles)
$staticMethod=|QQuaternion|fromEulerAngles,fromEulerAngles1|const QVector3D &

$prototype=Q_INVOKABLE static QQuaternion fromEulerAngles(float pitch, float yaw, float roll)
$staticMethod=|QQuaternion|fromEulerAngles,fromEulerAngles2|float,float,float

/*
[1]Q_INVOKABLE static QQuaternion fromEulerAngles(const QVector3D &eulerAngles)
[2]Q_INVOKABLE static QQuaternion fromEulerAngles(float pitch, float yaw, float roll)
*/

HB_FUNC_STATIC( QTRANSFORM_FROMEULERANGLES )
{
%% TODO: implementar
}

$prototype=Q_INVOKABLE static QMatrix4x4 rotateAround(const QVector3D &point, float angle, const QVector3D &axis)
$staticMethod=|QMatrix4x4|rotateAround|const QVector3D &,float,const QVector3D &

$prototype=QNodeCreatedChangeBasePtr createNodeCreationChange() const Q_DECL_OVERRIDE [private]

$beginSignals
$signal=|scaleChanged(float)
$signal=|scale3DChanged(QVector3D)
$signal=|rotationChanged(QQuaternion)
$signal=|translationChanged(QVector3D)
$signal=|matrixChanged()
$signal=|rotationXChanged(float)
$signal=|rotationYChanged(float)
$signal=|rotationZChanged(float)
$endSignals

#pragma ENDDUMP

%%
%% Qt5xHb - Bindings libraries for Harbour/xHarbour and Qt Framework 5
%%
%% Copyright (C) 2020 Marcos Antonio Gambeta <marcosgambeta AT outlook DOT com>
%%

$project=Qt5xHb
$module=Qt3DCore

$header

#include "hbclass.ch"

$addRequests

$beginClassFrom=QComponent

$addMethods

$addSignals

$endClass

$destructor

#pragma BEGINDUMP

$includes

$prototype=explicit QTransform(QNode *parent = nullptr)
$constructor=|new|QNode *=nullptr

$prototype=explicit QTransform(QTransformPrivate &dd, QNode *parent = nullptr) [protected]

$prototype=~QTransform()
$deleteMethod

%%
%% Q_PROPERTY(QMatrix4x4 matrix READ matrix WRITE setMatrix NOTIFY matrixChanged)
%%

$prototype=QMatrix4x4 matrix() const
$method=|QMatrix4x4|matrix|

$prototype=void setMatrix(const QMatrix4x4 &matrix)
$slotMethod=|void|setMatrix|const QMatrix4x4 &

%%
%% Q_PROPERTY(float scale READ scale WRITE setScale NOTIFY scaleChanged)
%%

$prototype=float scale() const
$method=|float|scale|

$prototype=void setScale(float scale)
$slotMethod=|void|setScale|float

%%
%% Q_PROPERTY(QVector3D scale3D READ scale3D WRITE setScale3D NOTIFY scale3DChanged)
%%

$prototype=QVector3D scale3D() const
$method=|QVector3D|scale3D|

$prototype=void setScale3D(const QVector3D &scale)
$slotMethod=|void|setScale3D|const QVector3D &

%%
%% Q_PROPERTY(QQuaternion rotation READ rotation WRITE setRotation NOTIFY rotationChanged)
%%

$prototype=QQuaternion rotation() const
$method=|QQuaternion|rotation|

$prototype=void setRotation(const QQuaternion &rotation)
$slotMethod=|void|setRotation|const QQuaternion &

%%
%% Q_PROPERTY(QVector3D translation READ translation WRITE setTranslation NOTIFY translationChanged)
%%

$prototype=QVector3D translation() const
$method=|QVector3D|translation|

$prototype=void setTranslation(const QVector3D &translation)
$slotMethod=|void|setTranslation|const QVector3D &

%%
%% Q_PROPERTY(float rotationX READ rotationX WRITE setRotationX NOTIFY rotationXChanged)
%%

$prototype=float rotationX() const
$method=|float|rotationX|

$prototype=void setRotationX(float rotationX)
$slotMethod=|void|setRotationX|float

%%
%% Q_PROPERTY(float rotationY READ rotationY WRITE setRotationY NOTIFY rotationYChanged)
%%

$prototype=float rotationY() const
$method=|float|rotationY|

$prototype=void setRotationY(float rotationY)
$slotMethod=|void|setRotationY|float

%%
%% Q_PROPERTY(float rotationZ READ rotationZ WRITE setRotationZ NOTIFY rotationZChanged)
%%

$prototype=float rotationZ() const
$method=|float|rotationZ|

$prototype=void setRotationZ(float rotationZ)
$slotMethod=|void|setRotationZ|float

%%
%%
%%

$prototype=Q_INVOKABLE static QQuaternion fromAxisAndAngle(const QVector3D &axis, float angle)
$staticMethod=|QQuaternion|fromAxisAndAngle,fromAxisAndAngle1|const QVector3D &,float

$prototype=Q_INVOKABLE static QQuaternion fromAxisAndAngle(float x, float y, float z, float angle)
$staticMethod=|QQuaternion|fromAxisAndAngle,fromAxisAndAngle2|float,float,float,float

//[1]Q_INVOKABLE static QQuaternion fromAxisAndAngle(const QVector3D &axis, float angle)
//[2]Q_INVOKABLE static QQuaternion fromAxisAndAngle(float x, float y, float z, float angle)

HB_FUNC_STATIC( QTRANSFORM_FROMAXISANDANGLE )
{
%% TODO: implementar
}

$prototype=Q_INVOKABLE static QQuaternion fromAxesAndAngles(const QVector3D &axis1, float angle1, const QVector3D &axis2, float angle2)
$staticMethod=|QQuaternion|fromAxesAndAngles,fromAxesAndAngles1|const QVector3D &,float,const QVector3D &,float

$prototype=Q_INVOKABLE static QQuaternion fromAxesAndAngles(const QVector3D &axis1, float angle1, const QVector3D &axis2, float angle2, const QVector3D &axis3, float angle3)
$staticMethod=|QQuaternion|fromAxesAndAngles,fromAxesAndAngles2|const QVector3D &,float,const QVector3D &,float,const QVector3D &,float

//[1]Q_INVOKABLE static QQuaternion fromAxesAndAngles(const QVector3D &axis1, float angle1, const QVector3D &axis2, float angle2)
//[2]Q_INVOKABLE static QQuaternion fromAxesAndAngles(const QVector3D &axis1, float angle1, const QVector3D &axis2, float angle2, const QVector3D &axis3, float angle3)

HB_FUNC_STATIC( QTRANSFORM_FROMAXESANDANGLES )
{
%% TODO: implementar
}

$prototype=Q_INVOKABLE static QQuaternion fromEulerAngles(const QVector3D &eulerAngles)
$staticMethod=|QQuaternion|fromEulerAngles,fromEulerAngles1|const QVector3D &

$prototype=Q_INVOKABLE static QQuaternion fromEulerAngles(float pitch, float yaw, float roll)
$staticMethod=|QQuaternion|fromEulerAngles,fromEulerAngles2|float,float,float

//[1]Q_INVOKABLE static QQuaternion fromEulerAngles(const QVector3D &eulerAngles)
//[2]Q_INVOKABLE static QQuaternion fromEulerAngles(float pitch, float yaw, float roll)

HB_FUNC_STATIC( QTRANSFORM_FROMEULERANGLES )
{
%% TODO: implementar
}

$prototype=Q_INVOKABLE static QMatrix4x4 rotateAround(const QVector3D &point, float angle, const QVector3D &axis)
$staticMethod=|QMatrix4x4|rotateAround|const QVector3D &,float,const QVector3D &

$prototype=QNodeCreatedChangeBasePtr createNodeCreationChange() const Q_DECL_OVERRIDE [private]

$beginSignals
$signal=|scaleChanged(float)
$signal=|scale3DChanged(QVector3D)
$signal=|rotationChanged(QQuaternion)
$signal=|translationChanged(QVector3D)
$signal=|matrixChanged()
$signal=|rotationXChanged(float)
$signal=|rotationYChanged(float)
$signal=|rotationZChanged(float)
$endSignals

#pragma ENDDUMP


[Runtime] Implemented W2String()

[Runtime] Implemented W2String()

//
// 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.Threading
USING System.Security.Permissions

///
/// Remove leading and trailing spacesincluding double-byte spacesfrom a string.
///
/// <param name="cMBString">The string to trim</param>
/// <returns>A trimmed string, with leading and trailing spaces removed.</returns>
/// <remarks>This function is the same as AllTrim() since .Net has unicode strings</remarks>
FUNCTION MBAllTrim(cMBString AS STRING) AS STRING
	RETURN AllTrim(cMBString)

///
/// Return the position of the first occurrence of a substring within a stringboth the substring and the string can contain double-byte characters.
///
/// <param name="cSearch">The substring to search for.</param>
/// <param name="cTarget">The string in which to search.  (To start at a specific offset, use MBAt3().)</param>
/// <returns>The position of the first occurrence of cMBSearch within cMBTarget.  If cMBSearch is not found, MBAt() returns zero.</returns>
/// <remarks>This function is the same as At() since .Net has unicode strings</remarks>
FUNCTION MBAt(cSearch AS STRING,cTarget AS STRING) AS DWORD
	RETURN At( cSearch, cTarget )

///
/// Return the position of the first occurrence of a substring within a stringboth the substring and the string can contain double-byte characters.
///
/// <param name="cSearch">The substring for which to search.</param>
/// <param name="cTarget">The string in which to search.  (To start at a specific offset, use MBAt3().)</param>
/// <returns>The position of the first occurrence of cMBSearch within cMBTarget.  If cMBSearch is not found, MBAt2() returns zero.</returns>
/// <remarks>This function is the same as At2 since .Net has unicode strings</remarks>
FUNCTION MBAt2(cSearch AS STRING,cTarget AS STRING) AS DWORD
	RETURN At2( cSearch, cTarget )

///
/// Return the position of the first occurrence of a substring within a string, starting at a specific positionboth the substring and the string can contain double-byte characters.
///
/// <param name="cSearch">The substring to search for.</param>
/// <param name="cTarget">The string in which to search.</param>
/// <param name="wOffset">The position in the string at which to start searching.  A value of zero corresponds to the first character.</param>
/// <returns>The position of the first occurrence of cMBSearch within cMBTarget.  If cMBSearch is not found, MBAt3() returns zero.</returns>
/// <remarks>This function is the same as At3 since .Net has unicode strings</remarks>
FUNCTION MBAt3(cSearch AS STRING,cTarget AS STRING,wOffset AS DWORD) AS DWORD
	RETURN At3( cSearch, cTarget, wOffset )

///
/// Return the position of the first occurrence of a sub string within a string, without regard for caseboth the substring and the string can contain double-byte characters.
///
/// <param name="cSearch">The substring to search for.</param>
/// <param name="cTarget">The string in which to search.</param>
/// <returns>The position of the first occurrence of cMBSearch within cMBTarget.  If cMBSearch is not found, MBAtC() returns zero.</returns>
/// <remarks>This function is the same as AtC since .Net has unicode strings</remarks>
FUNCTION MBAtC(cSearch AS STRING,cTarget AS STRING) AS DWORD
	RETURN AtC(cSearch, cTarget)

///
/// Return the position of the first occurrence of a substring within a string, without regard for caseboth the substring and the string can contain double-byte characters.
///
/// <param name="cSearch">The substring to search for.</param>
/// <param name="cTarget">The string in which to search.</param>
/// <returns>The position of the first occurrence of cMBSearch within cMBTarget.  If cMBSearch is not found, MBAtC2() returns zero.</returns>
/// <remarks>This function is the same as AtC2 since .Net has unicode strings</remarks>
FUNCTION MBAtC2(cSearch AS STRING,cTarget AS STRING) AS DWORD
	RETURN AtC2(cSearch, cTarget)

///
/// Return the line number of the first occurrence of a substring within a multiple line stringboth the substring and the string can contain double-byte characters.
///
/// <param name="cSearch">The substring to search for.</param>
/// <param name="cTarget">The string in which to search.</param>
/// <returns>The position of the first occurrence of cMBSearch within cMBTarget.  If cMBSearch is not found, MBAtLine() returns zero.</returns>
/// <remarks>This function is the same as AtLine() since .Net has unicode strings</remarks>
FUNCTION MBAtLine(cSearch AS STRING,cTarget AS STRING) AS LONGINT
	RETURN (LONG) AtLine(cSearch, cTarget)

///
/// Return the line number of the first occurrence of a substring within a multiple line stringboth the substring and the string can contain double-byte characters.
///
/// <param name="cSearch">The substring to search for.</param>
/// <param name="cTarget">The string in which to search.</param>
/// <returns>The position of the first occurrence of cMBSearch within cMBTarget.  If cMBSearch is not found, MBAtLine() returns zero.</returns>
/// <remarks>This function is the same as AtLine2() since .Net has unicode strings</remarks>
FUNCTION MBAtLine2(cSearch AS STRING,cTarget AS STRING) AS DWORD
	RETURN AtLine2(cSearch, cTarget)

///
/// Return a substring beginning with the first character of a string containing double-byte characters.
///
/// <param name="c">The string from which to extract characters. </param>
/// <param name="wLen">The number of characters to extract.</param>
/// <returns>The leftmost wCount characters of cMBString  each character counts as one character.  If wCount is zero, MBLeft() returns a NULL_STRING.  If wCount is larger than the length of the string, MBLeft() returns the entire string.</returns>
/// <remarks>This function is the same as Left() since .Net has unicode strings</remarks>
FUNCTION MBLEFT(c AS STRING,wLen AS DWORD) AS STRING
	RETURN Left(c, wLen)

///
/// Return the length of a string containing double-byte characters.
///
/// <param name="cMBString">The string to measure.  Each character counts as one .</param>
/// <returns>The length of cMBString in which each character counts as one.</returns>
/// <remarks>This function is the same as SLen() since .Net has unicode strings</remarks>
FUNCTION MBLEN(cMBString AS STRING) AS DWORD
	RETURN SLen(cMBString)

///
/// Remove leading spacesincluding double-byte spacesfrom a string.
///
/// <param name="cMBString"></param>
/// <returns>cMBString with the leading spaces removed.  If cMBString is a NULL_STRING or all spaces, MBLTrim() returns a NULL_STRING.</returns>
/// <remarks>This function is the same as LTrim() since .Net has unicode strings</remarks>
FUNCTION MBLTrim(cMBString AS STRING) AS STRING
	RETURN LTrim(cMBString)

///
/// Return the position of the last occurrence of a substring within a stringboth the substring and the string can contain double-byte characters.
///
/// <param name="cSearch">The substring for which to search.</param>
/// <param name="cTarget">The string in which to search.  (To start at a specific offset, use MBRAt3().)</param>
/// <returns>The position of cMBSearch within cMBTarget.  If cMBSearch is not found, MBRAt() returns zero.</returns>
/// <remarks>This function is the same as Rat() since .Net has unicode strings</remarks>
FUNCTION MBRat(cSearch AS STRING,cTarget AS STRING) AS LONGINT
	RETURN (LONG) RAt(cSearch, cTarget)

///
/// Return the position of the last occurrence of a substring within a stringboth the substring and the string can contain double-byte characters.
///
/// <param name="cSearch">The substring for which to search.</param>
/// <param name="cTarget">The string in which to search.  (To start at a specific offset, use MBRAt3().)</param>
/// <returns>The position of cMBSearch within cMBTarget.  If cMBSearch is not found, MBRAt() returns zero.</returns>
/// <remarks>This function is the same as Rat2() since .Net has unicode strings</remarks>
FUNCTION MBRat2(cSearch AS STRING,cTarget AS STRING) AS DWORD
	RETURN RAt2(cSearch, cTarget)

///
/// Return the position of the last occurrence of a substring within a string, starting at a specific positionboth the substring and the string can contain double-byte characters.
///
/// <param name="cSearch">The substring for which to search.</param>
/// <param name="cTarget">The string in which to search.  (To start at a specific offset, use MBRAt3().)</param>
/// <param name="wOffset">The position in the string at which to start searching.  A value of zero specifies the first character.</param>
/// <returns>The position of cMBSearch within cMBTarget.  If cMBSearch is not found, MBRAt() returns zero.</returns>
/// <remarks>This function is the same as Rat3() since .Net has unicode strings</remarks>
FUNCTION MBRat3(cSearch AS STRING,cTarget AS STRING,wOffset AS DWORD) AS DWORD
	RETURN RAt3(cSearch, cTarget, wOffSet)

///
/// Return a substring beginning with the last character of a string containing double-byte characters.
///
/// <param name="cMbString">The string from which to extract characters.</param>
/// <param name="wLen">The number of characters to extract. </param>
/// <returns>The rightmost wCount characters of cMBString.  If wCount is zero, MBRight() returns a NULL_STRING.  If wCount is larger than the length of the string, MBRight() returns cMBString.</returns>
/// <remarks>This function is the same as Right() since .Net has unicode strings</remarks>
FUNCTION MBRight(cMbString AS STRING,wLen AS DWORD) AS STRING
	RETURN Right(cMbString, wLen)

///
/// Remove trailing spacesincluding double-byte spacesfrom a string.
///
/// <param name="cMbString">The string to trim.</param>
/// <returns>cMBString with the trailing spaces removed.  If cMBString is a NULL_STRING or all spaces, MBRTrim() returns a NULL_STRING.</returns>
/// <remarks>This function is the same as RTrim() since .Net has unicode strings</remarks>
FUNCTION MBRTrim(cMbString AS STRING) AS STRING
	RETURN RTrim(cMbString)

///
/// Return the length of a strongly typed string containing double-byte characters.
///
/// <param name="cMbString">The string to count.</param>
/// <returns>The length of cMBString in which character counts as one.  If the string is a NULL_STRING, MBSLen() returns zero.</returns>
/// <remarks>This function is the same as Slen() since .Net has unicode strings</remarks>
FUNCTION MBSLen(cMbString AS STRING) AS DWORD
	RETURN SLen(cMbString)

///
/// Insert a string into another string, optionally deleting a specified number of characters from the original stringboth strings can contain double-byte characters.
///
/// <param name="cMBTarget">The string into which characters are inserted and deleted. </param>
/// <param name="wStart">The position in cMBTarget where the insertion/deletion occurs.</param>
/// <param name="wDel">The number of characters to delete.</param>
/// <param name="cIns">The string to insert.</param>
/// <returns>cMBTarget with the specified characters deleted and cMBInsert inserted.</returns>
/// <remarks>This function is the same as Stuff() since .Net has unicode strings</remarks>
FUNCTION MBStuff(cMBTarget AS STRING,wStart AS DWORD,wDel AS DWORD,cIns AS STRING) AS STRING
	RETURN Stuff(cMBTarget, wStart, wDel, cIns)

///
/// Extract a substring from a string, using strong typing and only two argumentsboth the substring and the string can contain double-byte characters.
///
/// <param name="cMbString">The string from which to extract a substring.</param>
/// <param name="wStart">The starting position relative to the leftmost character in cMBTarget. </param>
/// <returns>MBSubstr2() is a typed version of MBSubstr().</returns>
/// <remarks>This function is the same as Substr2() since .Net has unicode strings</remarks>
FUNCTION MBSubstr2(cMbString AS STRING,wStart AS DWORD) AS STRING
	RETURN SubStr2(cMbString, wStart)

///
/// Extract a substring from a string, using strong typing and three required argumentsboth the substring and the string can contain double-byte characters.
///
/// <param name="cMbString">The string from which to extract a substring.</param>
/// <param name="wStart">The starting position relative to the leftmost character in cMBTarget. </param>
/// <param name="wLen">The number of characters to extract  double-byte characters count as one character.  If wCount is greater than the number of characters from wStart to the end of cMBTarget, the extra is ignored.</param>
/// <returns>The substring.  If the substring is not present, or if you specify wStart as zero, MBSubstr3() returns a NULL_STRING.</returns>
/// <remarks>This function is the same as Substr3() since .Net has unicode strings</remarks>
FUNCTION MBSubstr3(cMbString AS STRING,wStart AS DWORD,wLen AS DWORD) AS STRING
	RETURN SubStr3(cMbString, wStart, wLen)

///
/// Remove trailing spacesincluding double-byte spacesfrom a string.
///
/// <param name="cMBString">The string to trim.</param>
/// <returns>cMBString with the trailing spaces removed.  If cMBString is a NULL_STRING or all spaces, MBTrim() returns a NULL_STRING.</returns>
/// <remarks>This function is the same as Trim() since .Net has unicode strings</remarks>
FUNCTION MBTrim(cMBString AS STRING) AS STRING
	RETURN Trim(cMBString)

///
/// Gets the locale ID that the runtime uses for comparing strings when running in Windows collation mode (SetCollation(#Windows)).
///
/// <returns>Locale ID: System.Globalization.CultureInfo.CurrentCulture:LCID
/// </returns>
FUNCTION GetAppLocaleID() AS DWORD
	LOCAL oCI AS CultureInfo
	oCI := CultureInfo.CurrentCulture
	RETURN (DWORD) oCI:LCID

///
/// Sets the locale that the runtime uses for comparing strings when running in Windows collation mode (SetCollation(#Windows)).
///
/// <param name="dwLocaleId"></param>
/// <returns>Previous Locale ID: System.Globalization.CultureInfo.CurrentCulture:LCID
/// </returns>
[SecurityPermissionAttribute(SecurityAction.Demand, ControlThread := TRUE)];
FUNCTION SetAppLocaleID(dwLocaleId AS DWORD) AS DWORD
	VAR ci := CultureInfo{ (INT) dwLocaleID}
	Thread.CurrentThread:CurrentCulture	  := ci
	Thread.CurrentThread:CurrentUICulture := ci
	RETURN dwLocaleID

/// This function is not implemented yet
///
/// <param name="pFunc"></param>
/// <returns>
/// </returns>
FUNCTION SetClipCompFunc(pFunc AS OBJECT) AS IntPtr
	THROW NotImplementedException{}
	RETURN IntPtr.Zero

/// This function is not implemented yet
///
///
/// <param name="n"></param>
/// <returns>
/// </returns>
FUNCTION SetWinCompFlags(n AS OBJECT) AS LONG
	THROW NotImplementedException{}
	RETURN 0

/// This function is not implemented yet
///
///
/// <param name="pFunc"></param>
/// <returns>
/// </returns>
FUNCTION SetWinCompFunc(pFunc AS OBJECT) AS IntPtr
	THROW NotImplementedException{}
	RETURN IntPtr.Zero

/// <exclude />
[Obsolete];
FUNCTION NationInit(dwInst AS DWORD) AS INT
	RETURN 0

/// <exclude />
[Obsolete];
FUNCTION NationExit() AS INT
	RETURN 0

/// This function is not implemented yet
//
// Identify a character set by its nation driver.
//
/// <returns>
/// </returns>
FUNCTION NVersion() AS STRING
	THROW NotImplementedException{}
	RETURN String.Empty

/// <exclude />
FUNCTION MAKELANGID( p AS WORD, s AS WORD ) AS WORD
	RETURN (WORD) ( ( s << 10 ) | p )

/// <exclude />
FUNCTION MAKELCID( lgid AS WORD, srtid AS WORD ) AS DWORD
	RETURN (DWORD) ( ( ( (DWORD)(srtid) ) << 16) | ( (INT)(DWORD) lgid ) )

/// <exclude />
FUNCTION IsBiDi() AS LOGIC
   RETURN System.Windows.Forms.SystemInformation.MidEastEnabled

/// <exclude />
_DLL FUNCTION String2W( sz AS STRING ) AS IntPtr PASCAL:OLEAUT32.SysAllocString

/// <exclude />
FUNCTION W2String(p AS IntPtr) AS STRING
	LOCAL IMPLIED cRet := System.Text.StringBuilder{}
	LOCAL nIndex AS INT
	LOCAL pChar AS WORD PTR
	nIndex := 1
	pChar := (WORD PTR)p
	DO WHILE pChar[nIndex] != 0
		cRet:Append(Convert.ToChar(pChar[nIndex]))
		nIndex ++
	END DO
RETURN cRet:ToString()

/// <exclude />
FUNCTION GetNatDllHandle() AS IntPtr STRICT
  LOCAL t AS Type
   LOCAL m AS System.Reflection.Module
   t := typeof( XSharp.Error )
   m := t:Module
   RETURN System.Runtime.InteropServices.Marshal.GetHINSTANCE( m )

//
// 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.Threading
USING System.Security.Permissions

///
/// Remove leading and trailing spaces — including double-byte spaces — from a string.
///
/// <param name="cMBString">The string to trim</param>
/// <returns>A trimmed string, with leading and trailing spaces removed.</returns>
/// <remarks>This function is the same as AllTrim() since .Net has unicode strings</remarks>
FUNCTION MBAllTrim(cMBString AS STRING) AS STRING
	RETURN Alltrim(cMBString)

///
/// Return the position of the first occurrence of a substring within a string — both the substring and the string can contain double-byte characters.
///
/// <param name="cSearch">The substring to search for.</param>
/// <param name="cTarget">The string in which to search.  (To start at a specific offset, use MBAt3().)</param>
/// <returns>The position of the first occurrence of cMBSearch within cMBTarget.  If cMBSearch is not found, MBAt() returns zero.</returns>
/// <remarks>This function is the same as At() since .Net has unicode strings</remarks>
FUNCTION MBAt(cSearch AS STRING,cTarget AS STRING) AS DWORD
	RETURN At( cSearch, cTarget )

///
/// Return the position of the first occurrence of a substring within a string — both the substring and the string can contain double-byte characters.
///
/// <param name="cSearch">The substring for which to search.</param>
/// <param name="cTarget">The string in which to search.  (To start at a specific offset, use MBAt3().)</param>
/// <returns>The position of the first occurrence of cMBSearch within cMBTarget.  If cMBSearch is not found, MBAt2() returns zero.</returns>
/// <remarks>This function is the same as At2 since .Net has unicode strings</remarks>
FUNCTION MBAt2(cSearch AS STRING,cTarget AS STRING) AS DWORD
	RETURN At2( cSearch, cTarget )

///
/// Return the position of the first occurrence of a substring within a string, starting at a specific position — both the substring and the string can contain double-byte characters.
///
/// <param name="cSearch">The substring to search for.</param>
/// <param name="cTarget">The string in which to search.</param>
/// <param name="wOffset">The position in the string at which to start searching.  A value of zero corresponds to the first character.</param>
/// <returns>The position of the first occurrence of cMBSearch within cMBTarget.  If cMBSearch is not found, MBAt3() returns zero.</returns>
/// <remarks>This function is the same as At3 since .Net has unicode strings</remarks>
FUNCTION MBAt3(cSearch AS STRING,cTarget AS STRING,wOffset AS DWORD) AS DWORD
	RETURN At3( cSearch, cTarget, wOffset )

///
/// Return the position of the first occurrence of a sub string within a string, without regard for case — both the substring and the string can contain double-byte characters.
///
/// <param name="cSearch">The substring to search for.</param>
/// <param name="cTarget">The string in which to search.</param>
/// <returns>The position of the first occurrence of cMBSearch within cMBTarget.  If cMBSearch is not found, MBAtC() returns zero.</returns>
/// <remarks>This function is the same as AtC since .Net has unicode strings</remarks>
FUNCTION MBAtC(cSearch AS STRING,cTarget AS STRING) AS DWORD
	RETURN AtC(cSearch, cTarget)

///
/// Return the position of the first occurrence of a substring within a string, without regard for case — both the substring and the string can contain double-byte characters.
///
/// <param name="cSearch">The substring to search for.</param>
/// <param name="cTarget">The string in which to search.</param>
/// <returns>The position of the first occurrence of cMBSearch within cMBTarget.  If cMBSearch is not found, MBAtC2() returns zero.</returns>
/// <remarks>This function is the same as AtC2 since .Net has unicode strings</remarks>
FUNCTION MBAtC2(cSearch AS STRING,cTarget AS STRING) AS DWORD
	RETURN AtC2(cSearch, cTarget)

///
/// Return the line number of the first occurrence of a substring within a multiple line string — both the substring and the string can contain double-byte characters.
///
/// <param name="cSearch">The substring to search for.</param>
/// <param name="cTarget">The string in which to search.</param>
/// <returns>The position of the first occurrence of cMBSearch within cMBTarget.  If cMBSearch is not found, MBAtLine() returns zero.</returns>
/// <remarks>This function is the same as AtLine() since .Net has unicode strings</remarks>
FUNCTION MBAtLine(cSearch AS STRING,cTarget AS STRING) AS LONGINT
	RETURN (LONG) AtLine(cSearch, cTarget)

///
/// Return the line number of the first occurrence of a substring within a multiple line string — both the substring and the string can contain double-byte characters.
///
/// <param name="cSearch">The substring to search for.</param>
/// <param name="cTarget">The string in which to search.</param>
/// <returns>The position of the first occurrence of cMBSearch within cMBTarget.  If cMBSearch is not found, MBAtLine() returns zero.</returns>
/// <remarks>This function is the same as AtLine2() since .Net has unicode strings</remarks>
FUNCTION MBAtLine2(cSearch AS STRING,cTarget AS STRING) AS DWORD
	RETURN AtLine2(cSearch, cTarget)

///
/// Return a substring beginning with the first character of a string containing double-byte characters.
///
/// <param name="c">The string from which to extract characters. </param>
/// <param name="wLen">The number of characters to extract.</param>
/// <returns>The leftmost wCount characters of cMBString — each character counts as one character.  If wCount is zero, MBLeft() returns a NULL_STRING.  If wCount is larger than the length of the string, MBLeft() returns the entire string.</returns>
/// <remarks>This function is the same as Left() since .Net has unicode strings</remarks>
FUNCTION MBLEFT(c AS STRING,wLen AS DWORD) AS STRING
	RETURN Left(c, wLen)

///
/// Return the length of a string containing double-byte characters.
///
/// <param name="cMBString">The string to measure.  Each character counts as one .</param>
/// <returns>The length of cMBString in which each character counts as one.</returns>
/// <remarks>This function is the same as SLen() since .Net has unicode strings</remarks>
FUNCTION MBLEN(cMBString AS STRING) AS DWORD
	RETURN SLen(cMBString)

///
/// Remove leading spaces — including double-byte spaces — from a string.
///
/// <param name="cMBString"></param>
/// <returns>cMBString with the leading spaces removed.  If cMBString is a NULL_STRING or all spaces, MBLTrim() returns a NULL_STRING.</returns>
/// <remarks>This function is the same as LTrim() since .Net has unicode strings</remarks>
FUNCTION MBLTrim(cMBString AS STRING) AS STRING
	RETURN LTrim(cMBString)

///
/// Return the position of the last occurrence of a substring within a string — both the substring and the string can contain double-byte characters.
///
/// <param name="cSearch">The substring for which to search.</param>
/// <param name="cTarget">The string in which to search.  (To start at a specific offset, use MBRAt3().)</param>
/// <returns>The position of cMBSearch within cMBTarget.  If cMBSearch is not found, MBRAt() returns zero.</returns>
/// <remarks>This function is the same as Rat() since .Net has unicode strings</remarks>
FUNCTION MBRat(cSearch AS STRING,cTarget AS STRING) AS LONGINT
	RETURN (LONG) Rat(cSearch, cTarget)

///
/// Return the position of the last occurrence of a substring within a string — both the substring and the string can contain double-byte characters.
///
/// <param name="cSearch">The substring for which to search.</param>
/// <param name="cTarget">The string in which to search.  (To start at a specific offset, use MBRAt3().)</param>
/// <returns>The position of cMBSearch within cMBTarget.  If cMBSearch is not found, MBRAt() returns zero.</returns>
/// <remarks>This function is the same as Rat2() since .Net has unicode strings</remarks>
FUNCTION MBRat2(cSearch AS STRING,cTarget AS STRING) AS DWORD
	RETURN Rat2(cSearch, cTarget)

///
/// Return the position of the last occurrence of a substring within a string, starting at a specific position — both the substring and the string can contain double-byte characters.
///
/// <param name="cSearch">The substring for which to search.</param>
/// <param name="cTarget">The string in which to search.  (To start at a specific offset, use MBRAt3().)</param>
/// <param name="wOffset">The position in the string at which to start searching.  A value of zero specifies the first character.</param>
/// <returns>The position of cMBSearch within cMBTarget.  If cMBSearch is not found, MBRAt() returns zero.</returns>
/// <remarks>This function is the same as Rat3() since .Net has unicode strings</remarks>
FUNCTION MBRat3(cSearch AS STRING,cTarget AS STRING,wOffset AS DWORD) AS DWORD
	RETURN Rat3(cSearch, cTarget, wOffSet)

///
/// Return a substring beginning with the last character of a string containing double-byte characters.
///
/// <param name="cMbString">The string from which to extract characters.</param>
/// <param name="wLen">The number of characters to extract. </param>
/// <returns>The rightmost wCount characters of cMBString.  If wCount is zero, MBRight() returns a NULL_STRING.  If wCount is larger than the length of the string, MBRight() returns cMBString.</returns>
/// <remarks>This function is the same as Right() since .Net has unicode strings</remarks>
FUNCTION MBRight(cMbString AS STRING,wLen AS DWORD) AS STRING
	RETURN Right(cMbString, wLen)

///
/// Remove trailing spaces — including double-byte spaces — from a string.
///
/// <param name="cMbString">The string to trim.</param>
/// <returns>cMBString with the trailing spaces removed.  If cMBString is a NULL_STRING or all spaces, MBRTrim() returns a NULL_STRING.</returns>
/// <remarks>This function is the same as RTrim() since .Net has unicode strings</remarks>
FUNCTION MBRTrim(cMbString AS STRING) AS STRING
	RETURN RTrim(cMbString)

///
/// Return the length of a strongly typed string containing double-byte characters.
///
/// <param name="cMbString">The string to count.</param>
/// <returns>The length of cMBString in which character counts as one.  If the string is a NULL_STRING, MBSLen() returns zero.</returns>
/// <remarks>This function is the same as Slen() since .Net has unicode strings</remarks>
FUNCTION MBSLen(cMbString AS STRING) AS DWORD
	RETURN SLen(cMbString)

///
/// Insert a string into another string, optionally deleting a specified number of characters from the original string — both strings can contain double-byte characters.
///
/// <param name="cMBTarget">The string into which characters are inserted and deleted. </param>
/// <param name="wStart">The position in cMBTarget where the insertion/deletion occurs.</param>
/// <param name="wDel">The number of characters to delete.</param>
/// <param name="cIns">The string to insert.</param>
/// <returns>cMBTarget with the specified characters deleted and cMBInsert inserted.</returns>
/// <remarks>This function is the same as Stuff() since .Net has unicode strings</remarks>
FUNCTION MBStuff(cMBTarget AS STRING,wStart AS DWORD,wDel AS DWORD,cIns AS STRING) AS STRING
	RETURN Stuff(cMBTarget, wStart, wDel, cIns)

///
/// Extract a substring from a string, using strong typing and only two arguments — both the substring and the string can contain double-byte characters.
///
/// <param name="cMbString">The string from which to extract a substring.</param>
/// <param name="wStart">The starting position relative to the leftmost character in cMBTarget. </param>
/// <returns>MBSubstr2() is a typed version of MBSubstr().</returns>
/// <remarks>This function is the same as Substr2() since .Net has unicode strings</remarks>
FUNCTION MBSubstr2(cMbString AS STRING,wStart AS DWORD) AS STRING
	RETURN Substr2(cMbString, wStart)

///
/// Extract a substring from a string, using strong typing and three required arguments — both the substring and the string can contain double-byte characters.
///
/// <param name="cMbString">The string from which to extract a substring.</param>
/// <param name="wStart">The starting position relative to the leftmost character in cMBTarget. </param>
/// <param name="wLen">The number of characters to extract — double-byte characters count as one character.  If wCount is greater than the number of characters from wStart to the end of cMBTarget, the extra is ignored.</param>
/// <returns>The substring.  If the substring is not present, or if you specify wStart as zero, MBSubstr3() returns a NULL_STRING.</returns>
/// <remarks>This function is the same as Substr3() since .Net has unicode strings</remarks>
FUNCTION MBSubstr3(cMbString AS STRING,wStart AS DWORD,wLen AS DWORD) AS STRING
	RETURN Substr3(cMbString, wStart, wLen)

///
/// Remove trailing spaces — including double-byte spaces — from a string.
///
/// <param name="cMBString">The string to trim.</param>
/// <returns>cMBString with the trailing spaces removed.  If cMBString is a NULL_STRING or all spaces, MBTrim() returns a NULL_STRING.</returns>
/// <remarks>This function is the same as Trim() since .Net has unicode strings</remarks>
FUNCTION MBTrim(cMBString AS STRING) AS STRING
	RETURN Trim(cMBString)

///
/// Gets the locale ID that the runtime uses for comparing strings when running in Windows collation mode (SetCollation(#Windows)).
///
/// <returns>Locale ID: System.Globalization.CultureInfo.CurrentCulture:LCID
/// </returns>
FUNCTION GetAppLocaleID() AS DWORD
	LOCAL oCI AS CultureInfo
	oCI := CultureInfo.CurrentCulture
	RETURN (DWORD) oCI:LCID

///
/// Sets the locale that the runtime uses for comparing strings when running in Windows collation mode (SetCollation(#Windows)).
///
/// <param name="dwLocaleId"></param>
/// <returns>Previous Locale ID: System.Globalization.CultureInfo.CurrentCulture:LCID
/// </returns>
[SecurityPermissionAttribute(SecurityAction.Demand, ControlThread := TRUE)];
FUNCTION SetAppLocaleID(dwLocaleId AS DWORD) AS DWORD
	VAR ci := CultureInfo{ (INT) dwLocaleID}
	Thread.CurrentThread:CurrentCulture	  := ci
	Thread.CurrentThread:CurrentUICulture := ci
	RETURN dwLocaleID

/// This function is not implemented yet
///
/// <param name="pFunc"></param>
/// <returns>
/// </returns>
FUNCTION SetClipCompFunc(pFunc AS OBJECT) AS IntPtr
	THROW NotImplementedException{}
	RETURN IntPtr.Zero

/// This function is not implemented yet
///
///
/// <param name="n"></param>
/// <returns>
/// </returns>
FUNCTION SetWinCompFlags(n AS OBJECT) AS LONG
	THROW NotImplementedException{}
	RETURN 0

/// This function is not implemented yet
///
///
/// <param name="pFunc"></param>
/// <returns>
/// </returns>
FUNCTION SetWinCompFunc(pFunc AS OBJECT) AS IntPtr
	THROW NotImplementedException{}
	RETURN IntPtr.Zero

/// <exclude />
[Obsolete];
FUNCTION NationInit(dwInst AS DWORD) AS INT
	RETURN 0

/// <exclude />
[Obsolete];
FUNCTION NationExit() AS INT
	RETURN 0

/// This function is not implemented yet
//
// Identify a character set by its nation driver.
//
/// <returns>
/// </returns>
FUNCTION NVersion() AS STRING
	THROW NotImplementedException{}
	RETURN String.Empty

/// <exclude />
FUNCTION MAKELANGID( p AS WORD, s AS WORD ) AS WORD
	RETURN (WORD) ( ( s << 10 ) | p )

/// <exclude />
FUNCTION MAKELCID( lgid AS WORD, srtid AS WORD ) AS DWORD
	RETURN (DWORD) ( ( ( (DWORD)(srtid) ) << 16) | ( (INT)(DWORD) lgid ) )

/// <exclude />
FUNCTION IsBiDi() AS LOGIC
   RETURN System.Windows.Forms.SystemInformation.MidEastEnabled

/// <exclude />
_DLL FUNCTION String2W( sz AS STRING ) AS IntPtr PASCAL:OLEAUT32.SysAllocString

/// <exclude />
FUNCTION GetNatDllHandle() AS IntPtr STRICT
  LOCAL t AS Type
   LOCAL m AS System.Reflection.Module
   t := typeof( XSharp.Error )
   m := t:Module
   RETURN System.Runtime.InteropServices.Marshal.GetHINSTANCE( m )


codegen/QtScriptTools: updated

codegen/QtScriptTools: updated

Modified:
codegen/QtScriptTools/QScriptEngineDebugger.prg

%%
%% Qt5xHb - Bindings libraries for Harbour/xHarbour and Qt Framework 5
%%
%% Copyright (C) 2018 Marcos Antonio Gambeta <marcosgambeta AT outlook DOT com>
%%

$header

#include "hbclass.ch"

$addRequests

$beginClassFrom=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

$endClass

$destructor

#pragma BEGINDUMP

$includes

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

$prototype=QScriptEngineDebugger(QObject * parent = 0)
$constructor=|new|QObject *=0

$deleteMethod

$prototype=QAction * action(DebuggerAction action) const
$method=|QAction *|action|QScriptEngineDebugger::DebuggerAction

$prototype=void attachTo(QScriptEngine * engine)
$method=|void|attachTo|QScriptEngine *

$prototype=bool autoShowStandardWindow() const
$method=|bool|autoShowStandardWindow|

$prototype=QMenu * createStandardMenu(QWidget * parent = 0)
$method=|QMenu *|createStandardMenu|QWidget *=0

$prototype=QToolBar * createStandardToolBar(QWidget * parent = 0)
$method=|QToolBar *|createStandardToolBar|QWidget *=0

$prototype=void detach()
$method=|void|detach|

$prototype=void setAutoShowStandardWindow(bool autoShow)
$method=|void|setAutoShowStandardWindow|bool

$prototype=QMainWindow * standardWindow() const
$method=|QMainWindow *|standardWindow|

$prototype=DebuggerState state() const
$method=|QScriptEngineDebugger::DebuggerState|state|

$prototype=QWidget * widget(DebuggerWidget widget) const
$method=|QWidget *|widget|QScriptEngineDebugger::DebuggerWidget

$beginSignals
$signal=|evaluationResumed()
$signal=|evaluationSuspended()
$endSignals

#pragma ENDDUMP

%%
%% Qt5xHb - Bindings libraries for Harbour/xHarbour and Qt Framework 5
%%
%% Copyright (C) 2018 Marcos Antonio Gambeta <marcosgambeta AT outlook DOT com>
%%

$header

#include "hbclass.ch"

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

$beginClassFrom=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

$endClass

$destructor

#pragma BEGINDUMP

$includes

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

$prototype=QScriptEngineDebugger(QObject * parent = 0)
$constructor=|new|QObject *=0

$deleteMethod

$prototype=QAction * action(DebuggerAction action) const
$method=|QAction *|action|QScriptEngineDebugger::DebuggerAction

$prototype=void attachTo(QScriptEngine * engine)
$method=|void|attachTo|QScriptEngine *

$prototype=bool autoShowStandardWindow() const
$method=|bool|autoShowStandardWindow|

$prototype=QMenu * createStandardMenu(QWidget * parent = 0)
$method=|QMenu *|createStandardMenu|QWidget *=0

$prototype=QToolBar * createStandardToolBar(QWidget * parent = 0)
$method=|QToolBar *|createStandardToolBar|QWidget *=0

$prototype=void detach()
$method=|void|detach|

$prototype=void setAutoShowStandardWindow(bool autoShow)
$method=|void|setAutoShowStandardWindow|bool

$prototype=QMainWindow * standardWindow() const
$method=|QMainWindow *|standardWindow|

$prototype=DebuggerState state() const
$method=|QScriptEngineDebugger::DebuggerState|state|

$prototype=QWidget * widget(DebuggerWidget widget) const
$method=|QWidget *|widget|QScriptEngineDebugger::DebuggerWidget

$beginSignals
$signal=|evaluationResumed()
$signal=|evaluationSuspended()
$endSignals

#pragma ENDDUMP


Add missing Methods : Index must be updated before DBF file write

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

BEGIN NAMESPACE XSharp.RDD
	/// <summary>DBFNTX RDD. For DBF/DBT/NTX.</summary>
	CLASS DBFNTX INHERIT DBFDBT

		INTERNAL _ntxList AS NtxOrderList

		CONSTRUCTOR()
			SUPER()
			SELF:_ntxList := NtxOrderList{SELF}
			SELF:_oIndex := NtxOrder{SELF}
			RETURN

		PROPERTY SysName AS STRING GET TYPEOF(DbfNtx):ToString()

		#REGION Order Support
		VIRTUAL METHOD OrderCreate(orderInfo AS DBORDERCREATEINFO ) AS LOGIC
			RETURN SELF:_ntxList:Create(orderInfo)

		VIRTUAL METHOD OrderDestroy(orderInfo AS DBORDERINFO ) AS LOGIC
			RETURN SUPER:OrderDestroy(orderInfo)

		VIRTUAL METHOD OrderListAdd( orderInfo AS DbOrderInfo, fullPath AS STRING) AS LOGIC
			//
			BEGIN LOCK SELF
				//
				SELF:GoCold()
				RETURN SELF:_ntxList:Add(orderInfo, fullPath)
			END LOCK

		VIRTUAL METHOD OrderListDelete(orderInfo AS DbOrderInfo) AS LOGIC
			//
			BEGIN LOCK SELF
				//
				SELF:GoCold()
				RETURN SELF:_ntxList:CloseAll()
			END LOCK

		VIRTUAL METHOD OrderListFocus(orderInfo AS DbOrderInfo) AS LOGIC
			//
			BEGIN LOCK SELF
				//
				SELF:GoCold()
				RETURN SELF:_ntxList:SetFocus(orderInfo)
			END LOCK

		VIRTUAL METHOD OrderListRebuild() AS LOGIC
			//
			BEGIN LOCK SELF
				//
				SELF:GoCold()
				RETURN SELF:_ntxList:Rebuild()
			END LOCK

			#endregion

		#region Pack, Zap
		METHOD Pack() AS LOGIC
			LOCAL isOk AS LOGIC
			//
			isOk := SUPER:Pack()
			IF (isOk)
				//
				isOk := SELF:OrderListRebuild()
			ENDIF
			RETURN isOk

		PUBLIC METHOD Zap() AS LOGIC
			LOCAL isOk AS LOGIC
			//
			isOk := SUPER:Zap()
			IF (isOk)
				isOk := SELF:OrderListRebuild()
			ENDIF
			RETURN isOk

			#endregion

		#REGION Open, Close, Create

		PUBLIC OVERRIDE METHOD Close() AS LOGIC
			LOCAL orderInfo AS DbOrderInfo
			//
			orderInfo := DbOrderInfo{}
			orderInfo:AllTags := TRUE
			SELF:OrderListDelete(orderInfo)
			RETURN SUPER:Close()

		PUBLIC OVERRIDE METHOD Create( openInfo AS DBOPENINFO ) AS LOGIC
			LOCAL isOk AS LOGIC
			//
			isOk := SUPER:Create(openInfo)
			IF ( XSharp.RuntimeState.Ansi .AND. isOk)
				VAR sig := SELF:_Header:Version
				// Set bit to Force Ansi Signature
				sig := sig |4
				// Should we also set the CodePage ??
				//SELF:_Header:DbfCodePage := DbfCodePage.CP_DBF_WIN_ANSI
				SELF:_Header:Version := sig
			ENDIF
			RETURN isOk

		#ENDREGION

		#REGION Move

		PUBLIC METHOD Seek(seekInfo AS DBSEEKINFO ) AS LOGIC
			LOCAL isOk AS LOGIC
			LOCAL ntxIndex AS NtxOrder
			//
			isOk := FALSE
			BEGIN LOCK SELF
				ntxIndex := SELF:_ntxList:CurrentOrder
				IF (ntxIndex != NULL)
					isOk := ntxIndex:Seek(seekInfo)
				ENDIF
				IF ( !isOk )
					SELF:_DbfError(SubCodes.ERDD_DATATYPE, GenCode.EG_NOORDER )
				ENDIF
			END LOCK
			RETURN isOk

		PUBLIC METHOD GoBottom() AS LOGIC
			BEGIN LOCK SELF
				IF SELF:_ntxList:CurrentOrder != NULL
					RETURN SELF:_ntxList:CurrentOrder:GoBottom()
				ELSE
					RETURN SUPER:GoBottom()
				ENDIF
			END LOCK

		PUBLIC METHOD GoTo(record AS INT ) AS LOGIC
			RETURN SUPER:GoTo(record)

		PUBLIC METHOD GoTop() AS LOGIC
			BEGIN LOCK SELF
				IF SELF:_ntxList:CurrentOrder != NULL
					RETURN SELF:_ntxList:CurrentOrder:GoTop()
				ELSE
					RETURN SUPER:GoTop()
				ENDIF
			END LOCK

		PUBLIC METHOD SkipRaw( move AS LONG ) AS LOGIC
			BEGIN LOCK SELF
				IF SELF:_ntxList:CurrentOrder != NULL
					RETURN SELF:_ntxList:CurrentOrder:SkipRaw(move)
				ELSE
					RETURN SUPER:SkipRaw(move)
				ENDIF
			END LOCK

		#ENDREGION

		#REGION GoCold, GoHot, Flush
		PUBLIC OVERRIDE METHOD GoCold() AS LOGIC
			LOCAL isOk AS LOGIC
			//
			isOk := TRUE
			BEGIN LOCK SELF
				IF ( !SELF:IsHot )
					RETURN isOk
				ENDIF
				isOk := SELF:_ntxList:GoCold()
				IF (!isOk)
					RETURN isOk
				ENDIF
				RETURN SUPER:GoCold()
			END LOCK

		PUBLIC OVERRIDE METHOD GoHot() AS LOGIC
			LOCAL isOk AS LOGIC
			//
			isOk := TRUE
			BEGIN LOCK SELF
				isOk := SUPER:GoHot()
				IF (!isOk)
					RETURN isOk
				ENDIF
				RETURN SELF:_ntxList:GoHot()
			END LOCK

		PUBLIC OVERRIDE METHOD Flush() AS LOGIC
			LOCAL isOk AS LOGIC
			//
			isOk := TRUE
			BEGIN LOCK SELF
				isOk := SUPER:Flush()
				RETURN SELF:_ntxList:Flush()
			END LOCK

		#ENDREGION

	END CLASS

END NAMESPACE

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

BEGIN NAMESPACE XSharp.RDD
	/// <summary>DBFNTX RDD. For DBF/DBT/NTX.</summary>
	CLASS DBFNTX INHERIT DBFDBT

		INTERNAL _ntxList AS NtxOrderList

		CONSTRUCTOR()
			SUPER()
			SELF:_ntxList := NtxOrderList{SELF}
			SELF:_oIndex := NtxOrder{SELF}
			RETURN

		PROPERTY SysName AS STRING GET TYPEOF(DbfNtx):ToString()

			#REGION Order Support
		VIRTUAL METHOD OrderCreate(orderInfo AS DBORDERCREATEINFO ) AS LOGIC
			RETURN SELF:_ntxList:Create(orderInfo)

		VIRTUAL METHOD OrderDestroy(orderInfo AS DBORDERINFO ) AS LOGIC
			RETURN SUPER:OrderDestroy(orderInfo)

		VIRTUAL METHOD OrderListAdd( orderInfo AS DbOrderInfo, fullPath AS STRING) AS LOGIC
			//
			BEGIN LOCK SELF
				//
				SELF:GoCold()
				RETURN SELF:_ntxList:Add(orderInfo, fullPath)
			END LOCK

		VIRTUAL METHOD OrderListDelete(orderInfo AS DbOrderInfo) AS LOGIC
			//
			BEGIN LOCK SELF
				//
				SELF:GoCold()
				RETURN SELF:_ntxList:CloseAll()
			END LOCK

		VIRTUAL METHOD OrderListFocus(orderInfo AS DbOrderInfo) AS LOGIC
			//
			BEGIN LOCK SELF
				//
				SELF:GoCold()
				RETURN SELF:_ntxList:SetFocus(orderInfo)
			END LOCK

		VIRTUAL METHOD OrderListRebuild() AS LOGIC
			//
			BEGIN LOCK SELF
				//
				SELF:GoCold()
				RETURN SELF:_ntxList:Rebuild()
			END LOCK

			#endregion

		#region Pack, Zap
		METHOD Pack() AS LOGIC
			LOCAL isOk AS LOGIC
			//
			isOk := SUPER:Pack()
			IF (isOk)
				//
				isOk := SELF:OrderListRebuild()
			ENDIF
			RETURN isOk

		PUBLIC METHOD Zap() AS LOGIC
			LOCAL isOk AS LOGIC
			//
			isOk := SUPER:Zap()
			IF (isOk)
				isOk := SELF:OrderListRebuild()
			ENDIF
			RETURN isOk

			#endregion

		#REGION Open, Close, Create

		PUBLIC OVERRIDE METHOD Close() AS LOGIC
			LOCAL orderInfo AS DbOrderInfo
			//
			orderInfo := DbOrderInfo{}
			orderInfo:AllTags := TRUE
			SELF:OrderListDelete(orderInfo)
			RETURN SUPER:Close()

		PUBLIC OVERRIDE METHOD Create( openInfo AS DBOPENINFO ) AS LOGIC
			LOCAL isOk AS LOGIC
			//
			isOk := SUPER:Create(openInfo)
			IF ( XSharp.RuntimeState.Ansi .AND. isOk)
				VAR sig := SELF:_Header:Version
				// Set bit to Force Ansi Signature
				sig := sig |4
				// Should we also set the CodePage ??
				//SELF:_Header:DbfCodePage := DbfCodePage.CP_DBF_WIN_ANSI
				SELF:_Header:Version := sig
			ENDIF
			RETURN isOk

		#ENDREGION

		#REGION Move

		PUBLIC METHOD Seek(seekInfo AS DBSEEKINFO ) AS LOGIC
			LOCAL isOk AS LOGIC
			LOCAL ntxIndex AS NtxOrder
			//
			isOk := FALSE
			BEGIN LOCK SELF
				ntxIndex := SELF:_ntxList:CurrentOrder
				IF (ntxIndex != NULL)
					isOk := ntxIndex:Seek(seekInfo)
				ENDIF
				IF ( !isOk )
					SELF:_DbfError(SubCodes.ERDD_DATATYPE, GenCode.EG_NOORDER )
				ENDIF
			END LOCK
			RETURN isOk

		PUBLIC METHOD GoBottom() AS LOGIC
			BEGIN LOCK SELF
				IF SELF:_ntxList:CurrentOrder != NULL
					RETURN SELF:_ntxList:CurrentOrder:GoBottom()
				ELSE
					RETURN SUPER:GoBottom()
				ENDIF
			END LOCK

		PUBLIC METHOD GoTo(record AS INT ) AS LOGIC
			RETURN SUPER:GoTo(record)

		PUBLIC METHOD GoTop() AS LOGIC
			BEGIN LOCK SELF
				IF SELF:_ntxList:CurrentOrder != NULL
					RETURN SELF:_ntxList:CurrentOrder:GoTop()
				ELSE
					RETURN SUPER:GoTop()
				ENDIF
			END LOCK

		PUBLIC METHOD SkipRaw( move AS LONG ) AS LOGIC
			BEGIN LOCK SELF
				IF SELF:_ntxList:CurrentOrder != NULL
					RETURN SELF:_ntxList:CurrentOrder:SkipRaw(move)
				ELSE
					RETURN SUPER:SkipRaw(move)
				ENDIF
			END LOCK

			#ENDREGION

	END CLASS

END NAMESPACE


put some lipstick on it

put some lipstick on it

-- 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 'outout cards', so
--          - (output) cards   <-->  lines
--          - space between stacked cards <--> output cards
--          - lines disappear
--          -                (regular) cards appear

--import "../tests/NatList.prg"
import "../tests/Nat.prg"

-- list kind
--kind List = Ni | Co

-- define the Tree kind, a rose tree
-- note: Ni may only appear in Fork second position (TODO: use GADT!)

kind Tree = Unit | Ni | Fork Tree Tree deriving syntax (tr) List(Ni, Fork) Unit(Unit)

-- make it singleton

data Tree' :: Tree ~> * where
  In :: Tree' ()tr
  Fork :: Tree' head -> Tree' tail -> Tree' [head; tail]tr
  Done :: Tree' []tr

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

prop Subtree :: Tree ~> Tree ~> * 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 ~> Tree ~> * where
  Empty :: Corolla tr => Tree' tr -> Stack tr ()tr
  SubDone :: Stack ()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
  -- [perhaps, note: there may be other cards stacked on this one]
  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 {substitute out' at out}

-- it remains to define corollas

prop Corolla :: Tree ~> * 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   |
-- | [o] |  --->   \ /
-- | [|] |          o
--    |             |

--cyclops :: Stack [()tr]tr [[]tr, ()tr]tr
--cyclops = Subdivision SubDone (Exclude NodeDone)

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

-- Counting Units in a tree

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

-- 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 ~> Tree ~> * where
  Finger :: Pointers 1t ()tr ()tr
  Finished :: Pointers 0t []tr []tr
  ThisWay :: Pointers 1t head' head -> Pointers 0t tail' tail -> Pointers 1t [head'; tail']tr [head; tail]tr
  ElseWhere :: Pointers 1t tail' tail -> Pointers 1t [[]tr; tail']tr [head; tail]tr

-- substitute WHAT    WHERE   IN
substitute :: Tree ~> Tree ~> Tree ~> Tree
{substitute what ()tr ()tr} = what
{substitute what []tr []tr} = []tr
{substitute what [head'; tail']tr [head; tail]tr} = [{substitute what head' head}; {substitute what tail' tail}]tr

-- 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 'outout cards', so
--          - (output) cards   <-->  lines
--          - space between stacked cards <--> output cards
--          - lines disappear
--          -                (regular) cards appear

--import "../tests/NatList.prg"
import "../tests/Nat.prg"

-- list kind
--kind List = Ni | Co

-- define the Tree kind, a rose tree
-- note: Ni may only appear in Fork second position (TODO: use GADT!)

kind Tree = Unit | Ni | Fork Tree Tree deriving syntax (tr) List(Ni, Fork) Unit(Unit)

-- make it singleton

data Tree' :: Tree ~> * where
  In :: Tree' ()tr
  Fork :: Tree' head -> Tree' tail -> Tree' [head; tail]tr
  Done :: Tree' []tr

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

prop Subtree :: Tree ~> Tree ~> * 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 ~> Tree ~> * where
  Empty :: Corolla tr => Tree' tr -> Stack tr ()tr
  SubDone :: Stack ()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
  -- [perhaps, note: there may be other cards stacked on this one]
  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 {substitute out' at out}

-- it remains to define corollas

prop Corolla :: Tree ~> * 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)

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

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

--cyclops :: Stack [()tr]tr [[]tr, ()tr]tr
--cyclops = Subdivision SubDone (Exclude NodeDone)

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

-- Counting Units in a tree

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

-- 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 ~> Tree ~> * where
  Finger :: Pointers 1t ()tr ()tr
  Finished :: Pointers 0t []tr []tr
  ThisWay :: Pointers 1t head' head -> Pointers 0t tail' tail -> Pointers 1t [head'; tail']tr [head; tail]tr
  ElseWhere :: Pointers 1t tail' tail -> Pointers 1t [[]tr; tail']tr [head; tail]tr

-- substitute WHAT    WHERE   IN
substitute :: Tree ~> Tree ~> Tree ~> Tree
{substitute what ()tr ()tr} = what
{substitute what []tr []tr} = []tr
{substitute what [head'; tail']tr [head; tail]tr} = [{substitute what head' head}; {substitute what tail' tail}]tr


add the usage parameter and implement Enc for grabbing the enclosing lambda

-- see also http://cs.ioc.ee/~james/papers/Relative_Monads.pdf
-- "Monads Need Not Be Endofunctors"
-- which references Fiore, Plotkin and Turi's work
-- Hamana also has much to say (http://www.cs.gunma-u.ac.jp/~hamana/)
--

-- TODO:
--  o add another parameter (VAR | FUN | NORMAL)
--  o Arg is VAR
--  o Up is VAR -> VAR
--  o Enc is VAR -> FUN
--  o introduce constructor Enc, signifying the function value enclosing the corresponding variable
--    so we can write fak as Lm `fak $ If 0tm == 0 then 1 else App (Enc 0tm) (0tm - 1)

import "Inventory.prg"

kind Usage = VAR | NORMAL

data Tm :: Usage ~> Inventory Tag ~> * where
  -- lambda
  Lm :: Label t -> Tm u [inv; t]i -> Tm NORMAL inv
  -- argument access
  Arg :: Tm VAR [ups; t]i
  Up :: Tm VAR [ups; t]i -> Tm VAR [ups; t, t']i
  -- the lambda introducing the argument
  Enc :: Tm VAR inv -> Tm NORMAL inv
  -- application
  App :: Tm u inv -> Tm v inv -> Tm NORMAL inv
  -- recursive let
  Let :: Label t -> Tm u [inv; t]i ->  Tm v [inv; t]i -> Tm NORMAL inv
 deriving syntax (tm) Nat(Arg, Up) LeftPair(App) Item(Enc)

-- (closed) identity function
--
identity :: Tm NORMAL []i
identity = Lm `a 0tm

-- ($) = \f . \a . f a
--
dollar :: Tm NORMAL []i
dollar = Lm `f (Lm `a (1tm, 0tm)tm)

-- bottom = \n . bottom n
bottom = Lm `n ((0tm), 0tm)tm

-- let a = a in a
leta :: Tm NORMAL []i
leta = Let `a 0tm 0tm

-- see also http://cs.ioc.ee/~james/papers/Relative_Monads.pdf
-- "Monads Need Not Be Endofunctors"
-- which references Fiore, Plotkin and Turi's work
-- Hamana also has much to say (http://www.cs.gunma-u.ac.jp/~hamana/)
--

-- TODO:
--  o add another parameter (VAR | FUN | NORMAL)
--  o Arg is VAR
--  o Up is VAR -> VAR
--  o Enc is VAR -> FUN
--  o introduce constructor Enc, signifying the function value enclosing the corresponding variable
--    so we can write fak as Lm `fak $ If 0tm == 0 then 1 else App (Enc 0tm) (0tm - 1)

import "Inventory.prg"

data Tm :: Inventory Tag ~> * where
  -- lambda
  Lm :: Label t -> Tm [inv; t]i -> Tm inv
  -- argument access
  Arg :: Tm [ups; t]i
  Up :: Tm [ups; t]i -> Tm [ups; t, t']i
  -- application
  App :: Tm inv -> Tm inv -> Tm inv
  -- recursive let
  Let :: Label t -> Tm [inv; t]i ->  Tm [inv; t]i -> Tm inv
 deriving syntax (tm) Nat(Arg, Up) LeftPair(App)

-- identity function
--
identity :: Tm []i
identity = Lm `a 0tm

-- ($) = \f . \a . f a
--
dollar :: Tm []i
dollar = Lm `f (Lm `a (1tm, 0tm)tm)

-- let a = a in a
leta :: Tm []i
leta = Let `a 0tm 0tm


QtWebEngineWidgets: data for code generation updated

Modified:
codegen/QtWebEngineWidgets/QWebEnginePage.prg

%%
%% Qt5xHb - Bindings libraries for Harbour/xHarbour and Qt Framework 5
%%
%% Copyright (C) 2018 Marcos Antonio Gambeta <marcosgambeta AT outlook DOT com>
%%

$header

#include "hbclass.ch"

#ifndef QT5XHB_NO_REQUESTS
REQUEST QWEBENGINEHISTORY
REQUEST QWIDGET
REQUEST QACTION
REQUEST QMENU
REQUEST QURL
REQUEST QWEBENGINESETTINGS
#endif

CLASS QWebEnginePage INHERIT QObject

   METHOD new
   METHOD delete
   METHOD history
   METHOD view
   METHOD setView
   METHOD hasSelection
   METHOD selectedText
   METHOD action
   METHOD triggerAction
   METHOD event
%%   METHOD findText
   METHOD createStandardContextMenu
   METHOD setFeaturePermission
   METHOD load
   METHOD setHtml
   METHOD setContent
%%   METHOD toHtml
%%   METHOD toPlainText
   METHOD title
   METHOD url
   METHOD setUrl
   METHOD requestedUrl
   METHOD iconUrl
   METHOD zoomFactor
   METHOD setZoomFactor
   METHOD runJavaScript
   METHOD settings

   METHOD onLoadStarted
   METHOD onLoadProgress
   METHOD onLoadFinished
   METHOD onLinkHovered
   METHOD onSelectionChanged
   METHOD onGeometryChangeRequested
   METHOD onWindowCloseRequested
   METHOD onFeaturePermissionRequested
   METHOD onFeaturePermissionRequestCanceled
   METHOD onAuthenticationRequired
   METHOD onProxyAuthenticationRequired
   METHOD onTitleChanged
   METHOD onUrlChanged
   METHOD onIconUrlChanged

   DESTRUCTOR destroyObject

END CLASS

$destructor

#pragma BEGINDUMP

$includes=5,4,0

#include <QAction>
#include <QMenu>

$prototype=explicit QWebEnginePage(QObject *parent = 0)
$constructor=5,4,0|new|QObject *=0

$deleteMethod=5,4,0

$prototype=QWebEngineHistory *history() const
$method=5,4,0|QWebEngineHistory *|history|

$prototype=QWidget *view() const
$method=5,4,0|QWidget *|view|

$prototype=void setView(QWidget *view)
$method=5,4,0|void|setView|QWidget *

$prototype=bool hasSelection() const
$method=5,4,0|bool|hasSelection|

$prototype=QString selectedText() const
$method=5,4,0|QString|selectedText|

$prototype=QAction *action(WebAction action) const
$method=5,4,0|QAction *|action|QWebEnginePage::WebAction

$prototype=virtual void triggerAction(WebAction action, bool checked = false)
$virtualMethod=5,4,0|void|triggerAction|QWebEnginePage::WebAction,bool=false

$prototype=virtual bool event(QEvent*)
$virtualMethod=5,4,0|bool|event|QEvent *

$prototype=void findText(const QString &subString, FindFlags options = 0, const QWebEngineCallback<bool> &resultCallback = QWebEngineCallback<bool>())
%% TODO: implementar
%% $method=5,4,0|void|findText|const QString &,QWebEnginePage::FindFlags=0,const QWebEngineCallback<bool> &=QWebEngineCallback<bool>()

$prototype=QMenu *createStandardContextMenu()
$method=5,4,0|QMenu *|createStandardContextMenu|

$prototype=void setFeaturePermission(const QUrl &securityOrigin, Feature feature, PermissionPolicy policy)
$method=5,4,0|void|setFeaturePermission|const QUrl &,QWebEnginePage::Feature,QWebEnginePage::PermissionPolicy

$prototype=void load(const QUrl &url)
$method=5,4,0|void|load|const QUrl &

$prototype=void setHtml(const QString &html, const QUrl &baseUrl = QUrl())
$method=5,4,0|void|setHtml|const QString &,const QUrl &=QUrl()

$prototype=void setContent(const QByteArray &data, const QString &mimeType = QString(), const QUrl &baseUrl = QUrl())
$method=5,4,0|void|setContent|const QByteArray &,const QString &=QString(),const QUrl &=QUrl()

$prototype=void toHtml(const QWebEngineCallback<const QString &> &resultCallback) const
%% TODO: implementar
%% $method=5,4,0|void|toHtml|const QWebEngineCallback<const QString &> &

$prototype=void toPlainText(const QWebEngineCallback<const QString &> &resultCallback) const
%% TODO: implementar
%% $method=5,4,0|void|toPlainText|const QWebEngineCallback<const QString &> &

$prototype=QString title() const
$method=5,4,0|QString|title|

$prototype=QUrl url() const
$method=5,4,0|QUrl|url|

$prototype=void setUrl(const QUrl &url)
$method=5,4,0|void|setUrl|const QUrl &

$prototype=QUrl requestedUrl() const
$method=5,4,0|QUrl|requestedUrl|

$prototype=QUrl iconUrl() const
$method=5,4,0|QUrl|iconUrl|

$prototype=qreal zoomFactor() const
$method=5,4,0|qreal|zoomFactor|

$prototype=void setZoomFactor(qreal factor)
$method=5,4,0|void|setZoomFactor|qreal

$prototype=void runJavaScript(const QString& scriptSource)
$internalMethod=5,4,0|void|runJavaScript,runJavaScript1|const QString &

$prototype=void runJavaScript(const QString& scriptSource, const QWebEngineCallback<const QVariant &> &resultCallback)
%% TODO: implementar
%% $internalMethod=5,4,0|void|runJavaScript,runJavaScript2|const QString &,const QWebEngineCallback<const QVariant &> &

//[1]void runJavaScript(const QString& scriptSource)
//[2]void runJavaScript(const QString& scriptSource, const QWebEngineCallback<const QVariant &> &resultCallback)

HB_FUNC( QWEBENGINEPAGE_RUNJAVASCRIPT )
{
  if( ISNUMPAR(1) && ISCHAR(1) )
  {
    QWebEnginePage_runJavaScript1();
  }
%%  else if( ISNUMPAR(2) && ISCHAR(1) && ISARRAY(2) )
%%  {
%%    QWebEnginePage_runJavaScript2();
%%  }
  else
  {
    hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
  }
}

$prototype=QWebEngineSettings *settings() const
$method=5,4,0|QWebEngineSettings *|settings|

#pragma ENDDUMP

%%
%% Qt5xHb - Bindings libraries for Harbour/xHarbour and Qt Framework 5
%%
%% Copyright (C) 2018 Marcos Antonio Gambeta <marcosgambeta AT outlook DOT com>
%%

$header

#include "hbclass.ch"

#ifndef QT5XHB_NO_REQUESTS
REQUEST QWEBENGINEHISTORY
REQUEST QWIDGET
REQUEST QACTION
REQUEST QMENU
REQUEST QURL
REQUEST QWEBENGINESETTINGS
#endif

CLASS QWebEnginePage INHERIT QObject

   METHOD new
   METHOD delete
   METHOD history
   METHOD view
   METHOD setView
   METHOD hasSelection
   METHOD selectedText
   METHOD action
   METHOD triggerAction
   METHOD event
%%   METHOD findText
   METHOD createStandardContextMenu
   METHOD setFeaturePermission
   METHOD load
   METHOD setHtml
   METHOD setContent
%%   METHOD toHtml
%%   METHOD toPlainText
   METHOD title
   METHOD url
   METHOD setUrl
   METHOD requestedUrl
   METHOD iconUrl
   METHOD zoomFactor
   METHOD setZoomFactor
   METHOD runJavaScript
   METHOD settings

   METHOD onLoadStarted
   METHOD onLoadProgress
   METHOD onLoadFinished
   METHOD onLinkHovered
   METHOD onSelectionChanged
   METHOD onGeometryChangeRequested
   METHOD onWindowCloseRequested
   METHOD onFeaturePermissionRequested
   METHOD onFeaturePermissionRequestCanceled
   METHOD onAuthenticationRequired
   METHOD onProxyAuthenticationRequired
   METHOD onTitleChanged
   METHOD onUrlChanged
   METHOD onIconUrlChanged

   DESTRUCTOR destroyObject

END CLASS

$destructor

#pragma BEGINDUMP

$includes=5,4,0

#include <QAction>

$prototype=explicit QWebEnginePage(QObject *parent = 0)
$constructor=5,4,0|new|QObject *=0

$deleteMethod=5,4,0

$prototype=QWebEngineHistory *history() const
$method=5,4,0|QWebEngineHistory *|history|

$prototype=QWidget *view() const
$method=5,4,0|QWidget *|view|

$prototype=void setView(QWidget *view)
$method=5,4,0|void|setView|QWidget *

$prototype=bool hasSelection() const
$method=5,4,0|bool|hasSelection|

$prototype=QString selectedText() const
$method=5,4,0|QString|selectedText|

$prototype=QAction *action(WebAction action) const
$method=5,4,0|QAction *|action|QWebEnginePage::WebAction

$prototype=virtual void triggerAction(WebAction action, bool checked = false)
$virtualMethod=5,4,0|void|triggerAction|QWebEnginePage::WebAction,bool=false

$prototype=virtual bool event(QEvent*)
$virtualMethod=5,4,0|bool|event|QEvent *

$prototype=void findText(const QString &subString, FindFlags options = 0, const QWebEngineCallback<bool> &resultCallback = QWebEngineCallback<bool>())
%% TODO: implementar
%% $method=5,4,0|void|findText|const QString &,QWebEnginePage::FindFlags=0,const QWebEngineCallback<bool> &=QWebEngineCallback<bool>()

$prototype=QMenu *createStandardContextMenu()
$method=5,4,0|QMenu *|createStandardContextMenu|

$prototype=void setFeaturePermission(const QUrl &securityOrigin, Feature feature, PermissionPolicy policy)
$method=5,4,0|void|setFeaturePermission|const QUrl &,QWebEnginePage::Feature,QWebEnginePage::PermissionPolicy

$prototype=void load(const QUrl &url)
$method=5,4,0|void|load|const QUrl &

$prototype=void setHtml(const QString &html, const QUrl &baseUrl = QUrl())
$method=5,4,0|void|setHtml|const QString &,const QUrl &=QUrl()

$prototype=void setContent(const QByteArray &data, const QString &mimeType = QString(), const QUrl &baseUrl = QUrl())
$method=5,4,0|void|setContent|const QByteArray &,const QString &=QString(),const QUrl &=QUrl()

$prototype=void toHtml(const QWebEngineCallback<const QString &> &resultCallback) const
%% TODO: implementar
%% $method=5,4,0|void|toHtml|const QWebEngineCallback<const QString &> &

$prototype=void toPlainText(const QWebEngineCallback<const QString &> &resultCallback) const
%% TODO: implementar
%% $method=5,4,0|void|toPlainText|const QWebEngineCallback<const QString &> &

$prototype=QString title() const
$method=5,4,0|QString|title|

$prototype=QUrl url() const
$method=5,4,0|QUrl|url|

$prototype=void setUrl(const QUrl &url)
$method=5,4,0|void|setUrl|const QUrl &

$prototype=QUrl requestedUrl() const
$method=5,4,0|QUrl|requestedUrl|

$prototype=QUrl iconUrl() const
$method=5,4,0|QUrl|iconUrl|

$prototype=qreal zoomFactor() const
$method=5,4,0|qreal|zoomFactor|

$prototype=void setZoomFactor(qreal factor)
$method=5,4,0|void|setZoomFactor|qreal

$prototype=void runJavaScript(const QString& scriptSource)
$internalMethod=5,4,0|void|runJavaScript,runJavaScript1|const QString &

$prototype=void runJavaScript(const QString& scriptSource, const QWebEngineCallback<const QVariant &> &resultCallback)
%% TODO: implementar
%% $internalMethod=5,4,0|void|runJavaScript,runJavaScript2|const QString &,const QWebEngineCallback<const QVariant &> &

//[1]void runJavaScript(const QString& scriptSource)
//[2]void runJavaScript(const QString& scriptSource, const QWebEngineCallback<const QVariant &> &resultCallback)

HB_FUNC( QWEBENGINEPAGE_RUNJAVASCRIPT )
{
  if( ISNUMPAR(1) && ISCHAR(1) )
  {
    QWebEnginePage_runJavaScript1();
  }
%%  else if( ISNUMPAR(2) && ISCHAR(1) && ISARRAY(2) )
%%  {
%%    QWebEnginePage_runJavaScript2();
%%  }
  else
  {
    hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
  }
}

$prototype=QWebEngineSettings *settings() const
$method=5,4,0|QWebEngineSettings *|settings|

#pragma ENDDUMP