codegen/QtWebEngine: updated

codegen/QtWebEngine: updated

Modified:
codegen/QtWebEngine/QQuickWebEngineProfile.prg

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

$project=Qt5xHb
$module=QtWebEngine

$header

#include "hbclass.ch"

$addRequests

$beginClassFrom=QObject

$addMethods

$addSignals

$endClass

$destructor

#pragma BEGINDUMP

$includes=5,6,0

#if (QT_VERSION >= QT_VERSION_CHECK(5,6,0))
#include <QtWebEngine/QWebEngineCookieStore>
#endif
#if (QT_VERSION >= QT_VERSION_CHECK(5,6,0))
#include <QtWebEngine/QWebEngineUrlSchemeHandler>
#endif

$prototype=QQuickWebEngineProfile(QObject *parent = Q_NULLPTR)
$constructor=5,6,0|new|QObject *=Q_NULLPTR

$prototype=QQuickWebEngineProfile(QQuickWebEngineProfilePrivate *, QObject *parent = Q_NULLPTR) [private]

$prototype=~QQuickWebEngineProfile()
$deleteMethod=5,6,0

%%
%% Q_PROPERTY(QString storageName READ storageName WRITE setStorageName NOTIFY storageNameChanged FINAL)
%%

$prototype=QString storageName() const
$method=5,6,0|QString|storageName|

$prototype=void setStorageName(const QString &name)
$method=5,6,0|void|setStorageName|const QString &

%%
%% Q_PROPERTY(bool offTheRecord READ isOffTheRecord WRITE setOffTheRecord NOTIFY offTheRecordChanged FINAL)
%%

$prototype=bool isOffTheRecord() const
$method=5,6,0|bool|isOffTheRecord|

$prototype=void setOffTheRecord(bool offTheRecord)
$method=5,6,0|void|setOffTheRecord|bool

%%
%% Q_PROPERTY(QString persistentStoragePath READ persistentStoragePath WRITE setPersistentStoragePath NOTIFY persistentStoragePathChanged FINAL)
%%

$prototype=QString persistentStoragePath() const
$method=5,6,0|QString|persistentStoragePath|

$prototype=void setPersistentStoragePath(const QString &path)
$method=5,6,0|void|setPersistentStoragePath|const QString &

%%
%% Q_PROPERTY(QString cachePath READ cachePath WRITE setCachePath NOTIFY cachePathChanged FINAL)
%%

$prototype=QString cachePath() const
$method=5,6,0|QString|cachePath|

$prototype=void setCachePath(const QString &path)
$method=5,6,0|void|setCachePath|const QString &

%%
%% Q_PROPERTY(QString httpUserAgent READ httpUserAgent WRITE setHttpUserAgent NOTIFY httpUserAgentChanged FINAL)
%%

$prototype=QString httpUserAgent() const
$method=5,6,0|QString|httpUserAgent|

$prototype=void setHttpUserAgent(const QString &userAgent)
$method=5,6,0|void|setHttpUserAgent|const QString &

%%
%% Q_PROPERTY(HttpCacheType httpCacheType READ httpCacheType WRITE setHttpCacheType NOTIFY httpCacheTypeChanged FINAL)
%%

$prototype=HttpCacheType httpCacheType() const
$method=5,6,0|QQuickWebEngineProfile::HttpCacheType|httpCacheType|

$prototype=void setHttpCacheType(QQuickWebEngineProfile::HttpCacheType)
$method=5,6,0|void|setHttpCacheType|QQuickWebEngineProfile::HttpCacheType

%%
%% Q_PROPERTY(QString httpAcceptLanguage READ httpAcceptLanguage WRITE setHttpAcceptLanguage NOTIFY httpAcceptLanguageChanged FINAL REVISION 1)
%%

$prototype=QString httpAcceptLanguage() const
$method=5,6,0|QString|httpAcceptLanguage|

$prototype=void setHttpAcceptLanguage(const QString &httpAcceptLanguage)
$method=5,6,0|void|setHttpAcceptLanguage|const QString &

%%
%% Q_PROPERTY(PersistentCookiesPolicy persistentCookiesPolicy READ persistentCookiesPolicy WRITE setPersistentCookiesPolicy NOTIFY persistentCookiesPolicyChanged FINAL)
%%

$prototype=PersistentCookiesPolicy persistentCookiesPolicy() const
$method=5,6,0|QQuickWebEngineProfile::PersistentCookiesPolicy|persistentCookiesPolicy|

$prototype=void setPersistentCookiesPolicy(QQuickWebEngineProfile::PersistentCookiesPolicy)
$method=5,6,0|void|setPersistentCookiesPolicy|QQuickWebEngineProfile::PersistentCookiesPolicy

%%
%% Q_PROPERTY(int httpCacheMaximumSize READ httpCacheMaximumSize WRITE setHttpCacheMaximumSize NOTIFY httpCacheMaximumSizeChanged FINAL)
%%

$prototype=int httpCacheMaximumSize() const
$method=5,6,0|int|httpCacheMaximumSize|

$prototype=void setHttpCacheMaximumSize(int maxSize)
$method=5,6,0|void|setHttpCacheMaximumSize|int

%%
%% Q_PROPERTY(QStringList spellCheckLanguages READ spellCheckLanguages WRITE setSpellCheckLanguages NOTIFY spellCheckLanguagesChanged FINAL REVISION 3)
%%

$prototype=QStringList spellCheckLanguages() const
$method=5,8,0|QStringList|spellCheckLanguages|

$prototype=void setSpellCheckLanguages(const QStringList &languages)
%% TODO: verificar se entrou na versao 5,8,0
$method=5,8,0|void|setSpellCheckLanguages|const QStringList &

%%
%% Q_PROPERTY(bool spellCheckEnabled READ isSpellCheckEnabled WRITE setSpellCheckEnabled NOTIFY spellCheckEnabledChanged FINAL REVISION 3)
%%

%% TODO: confirmar versao do Qt

$prototype=bool isSpellCheckEnabled() const
$method=5,8,0|bool|isSpellCheckEnabled|

$prototype=void setSpellCheckEnabled(bool enabled)
$method=5,8,0|void|setSpellCheckEnabled|bool

%%
%% Q_PROPERTY(QQmlListProperty<QQuickWebEngineScript> userScripts READ userScripts FINAL REVISION 4)
%%

$prototype=QQmlListProperty<QQuickWebEngineScript> userScripts()
%% TODO: implementar
%% $method=5,9,0|QQmlListProperty<QQuickWebEngineScript>|userScripts|

%%
%%
%%

$prototype=QWebEngineCookieStore *cookieStore() const
$method=5,6,0|QWebEngineCookieStore *|cookieStore|

$prototype=void setRequestInterceptor(QWebEngineUrlRequestInterceptor *interceptor)
$method=5,6,0|void|setRequestInterceptor|QWebEngineUrlRequestInterceptor *

$prototype=const QWebEngineUrlSchemeHandler *urlSchemeHandler(const QByteArray &) const
$method=5,6,0|const QWebEngineUrlSchemeHandler *|urlSchemeHandler|const QByteArray &

$prototype=void installUrlSchemeHandler(const QByteArray &scheme, QWebEngineUrlSchemeHandler *)
$method=5,6,0|void|installUrlSchemeHandler|const QByteArray &,QWebEngineUrlSchemeHandler *

$prototype=void removeUrlScheme(const QByteArray &scheme)
$method=5,6,0|void|removeUrlScheme|const QByteArray &

$prototype=void removeUrlSchemeHandler(QWebEngineUrlSchemeHandler *)
$method=5,6,0|void|removeUrlSchemeHandler|QWebEngineUrlSchemeHandler *

$prototype=void removeAllUrlSchemeHandlers()
$method=5,6,0|void|removeAllUrlSchemeHandlers|

$prototype=Q_REVISION(2) Q_INVOKABLE void clearHttpCache()
$method=5,7,0|void|clearHttpCache|

$prototype=static QQuickWebEngineProfile *defaultProfile()
$staticMethod=5,6,0|QQuickWebEngineProfile *|defaultProfile|

$prototype=void destroyedUrlSchemeHandler(QWebEngineUrlSchemeHandler *obj) (slot) [private]

$prototype=QQuickWebEngineSettings *settings() const [private]

$beginSignals
$signal=|cachePathChanged()
%% $signal=|downloadFinished(QQuickWebEngineDownloadItem*)
%% $signal=|downloadRequested(QQuickWebEngineDownloadItem*)
$signal=|httpAcceptLanguageChanged()
$signal=|httpCacheMaximumSizeChanged()
$signal=|httpCacheTypeChanged()
$signal=|httpUserAgentChanged()
$signal=|offTheRecordChanged()
$signal=|persistentCookiesPolicyChanged()
$signal=|persistentStoragePathChanged()
$signal=|spellCheckEnabledChanged()
$signal=|spellCheckLanguagesChanged()
$signal=|storageNameChanged()
$endSignals

#pragma ENDDUMP

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

$project=Qt5xHb
$module=QtWebEngine

$header

#include "hbclass.ch"

$addRequests

$beginClassFrom=QObject

$addMethods

$addSignals

$endClass

$destructor

#pragma BEGINDUMP

$includes=5,6,0

#if (QT_VERSION >= QT_VERSION_CHECK(5,6,0))
#include <QWebEngineCookieStore>
#endif
#if (QT_VERSION >= QT_VERSION_CHECK(5,6,0))
#include <QWebEngineUrlSchemeHandler>
#endif

$prototype=QQuickWebEngineProfile(QObject *parent = Q_NULLPTR)
$constructor=5,6,0|new|QObject *=Q_NULLPTR

$prototype=QQuickWebEngineProfile(QQuickWebEngineProfilePrivate *, QObject *parent = Q_NULLPTR) [private]

$prototype=~QQuickWebEngineProfile()
$deleteMethod=5,6,0

%%
%% Q_PROPERTY(QString storageName READ storageName WRITE setStorageName NOTIFY storageNameChanged FINAL)
%%

$prototype=QString storageName() const
$method=5,6,0|QString|storageName|

$prototype=void setStorageName(const QString &name)
$method=5,6,0|void|setStorageName|const QString &

%%
%% Q_PROPERTY(bool offTheRecord READ isOffTheRecord WRITE setOffTheRecord NOTIFY offTheRecordChanged FINAL)
%%

$prototype=bool isOffTheRecord() const
$method=5,6,0|bool|isOffTheRecord|

$prototype=void setOffTheRecord(bool offTheRecord)
$method=5,6,0|void|setOffTheRecord|bool

%%
%% Q_PROPERTY(QString persistentStoragePath READ persistentStoragePath WRITE setPersistentStoragePath NOTIFY persistentStoragePathChanged FINAL)
%%

$prototype=QString persistentStoragePath() const
$method=5,6,0|QString|persistentStoragePath|

$prototype=void setPersistentStoragePath(const QString &path)
$method=5,6,0|void|setPersistentStoragePath|const QString &

%%
%% Q_PROPERTY(QString cachePath READ cachePath WRITE setCachePath NOTIFY cachePathChanged FINAL)
%%

$prototype=QString cachePath() const
$method=5,6,0|QString|cachePath|

$prototype=void setCachePath(const QString &path)
$method=5,6,0|void|setCachePath|const QString &

%%
%% Q_PROPERTY(QString httpUserAgent READ httpUserAgent WRITE setHttpUserAgent NOTIFY httpUserAgentChanged FINAL)
%%

$prototype=QString httpUserAgent() const
$method=5,6,0|QString|httpUserAgent|

$prototype=void setHttpUserAgent(const QString &userAgent)
$method=5,6,0|void|setHttpUserAgent|const QString &

%%
%% Q_PROPERTY(HttpCacheType httpCacheType READ httpCacheType WRITE setHttpCacheType NOTIFY httpCacheTypeChanged FINAL)
%%

$prototype=HttpCacheType httpCacheType() const
$method=5,6,0|QQuickWebEngineProfile::HttpCacheType|httpCacheType|

$prototype=void setHttpCacheType(QQuickWebEngineProfile::HttpCacheType)
$method=5,6,0|void|setHttpCacheType|QQuickWebEngineProfile::HttpCacheType

%%
%% Q_PROPERTY(QString httpAcceptLanguage READ httpAcceptLanguage WRITE setHttpAcceptLanguage NOTIFY httpAcceptLanguageChanged FINAL REVISION 1)
%%

$prototype=QString httpAcceptLanguage() const
$method=5,6,0|QString|httpAcceptLanguage|

$prototype=void setHttpAcceptLanguage(const QString &httpAcceptLanguage)
$method=5,6,0|void|setHttpAcceptLanguage|const QString &

%%
%% Q_PROPERTY(PersistentCookiesPolicy persistentCookiesPolicy READ persistentCookiesPolicy WRITE setPersistentCookiesPolicy NOTIFY persistentCookiesPolicyChanged FINAL)
%%

$prototype=PersistentCookiesPolicy persistentCookiesPolicy() const
$method=5,6,0|QQuickWebEngineProfile::PersistentCookiesPolicy|persistentCookiesPolicy|

$prototype=void setPersistentCookiesPolicy(QQuickWebEngineProfile::PersistentCookiesPolicy)
$method=5,6,0|void|setPersistentCookiesPolicy|QQuickWebEngineProfile::PersistentCookiesPolicy

%%
%% Q_PROPERTY(int httpCacheMaximumSize READ httpCacheMaximumSize WRITE setHttpCacheMaximumSize NOTIFY httpCacheMaximumSizeChanged FINAL)
%%

$prototype=int httpCacheMaximumSize() const
$method=5,6,0|int|httpCacheMaximumSize|

$prototype=void setHttpCacheMaximumSize(int maxSize)
$method=5,6,0|void|setHttpCacheMaximumSize|int

%%
%% Q_PROPERTY(QStringList spellCheckLanguages READ spellCheckLanguages WRITE setSpellCheckLanguages NOTIFY spellCheckLanguagesChanged FINAL REVISION 3)
%%

$prototype=QStringList spellCheckLanguages() const
$method=5,8,0|QStringList|spellCheckLanguages|

$prototype=void setSpellCheckLanguages(const QStringList &languages)
%% TODO: verificar se entrou na versao 5,8,0
$method=5,8,0|void|setSpellCheckLanguages|const QStringList &

%%
%% Q_PROPERTY(bool spellCheckEnabled READ isSpellCheckEnabled WRITE setSpellCheckEnabled NOTIFY spellCheckEnabledChanged FINAL REVISION 3)
%%

%% TODO: confirmar versao do Qt

$prototype=bool isSpellCheckEnabled() const
$method=5,8,0|bool|isSpellCheckEnabled|

$prototype=void setSpellCheckEnabled(bool enabled)
$method=5,8,0|void|setSpellCheckEnabled|bool

%%
%% Q_PROPERTY(QQmlListProperty<QQuickWebEngineScript> userScripts READ userScripts FINAL REVISION 4)
%%

$prototype=QQmlListProperty<QQuickWebEngineScript> userScripts()
%% TODO: implementar
%% $method=5,9,0|QQmlListProperty<QQuickWebEngineScript>|userScripts|

%%
%%
%%

$prototype=QWebEngineCookieStore *cookieStore() const
$method=5,6,0|QWebEngineCookieStore *|cookieStore|

$prototype=void setRequestInterceptor(QWebEngineUrlRequestInterceptor *interceptor)
$method=5,6,0|void|setRequestInterceptor|QWebEngineUrlRequestInterceptor *

$prototype=const QWebEngineUrlSchemeHandler *urlSchemeHandler(const QByteArray &) const
$method=5,6,0|const QWebEngineUrlSchemeHandler *|urlSchemeHandler|const QByteArray &

$prototype=void installUrlSchemeHandler(const QByteArray &scheme, QWebEngineUrlSchemeHandler *)
$method=5,6,0|void|installUrlSchemeHandler|const QByteArray &,QWebEngineUrlSchemeHandler *

$prototype=void removeUrlScheme(const QByteArray &scheme)
$method=5,6,0|void|removeUrlScheme|const QByteArray &

$prototype=void removeUrlSchemeHandler(QWebEngineUrlSchemeHandler *)
$method=5,6,0|void|removeUrlSchemeHandler|QWebEngineUrlSchemeHandler *

$prototype=void removeAllUrlSchemeHandlers()
$method=5,6,0|void|removeAllUrlSchemeHandlers|

$prototype=Q_REVISION(2) Q_INVOKABLE void clearHttpCache()
$method=5,7,0|void|clearHttpCache|

$prototype=static QQuickWebEngineProfile *defaultProfile()
$staticMethod=5,6,0|QQuickWebEngineProfile *|defaultProfile|

$prototype=void destroyedUrlSchemeHandler(QWebEngineUrlSchemeHandler *obj) (slot) [private]

$prototype=QQuickWebEngineSettings *settings() const [private]

$beginSignals
$signal=|cachePathChanged()
%% $signal=|downloadFinished(QQuickWebEngineDownloadItem*)
%% $signal=|downloadRequested(QQuickWebEngineDownloadItem*)
$signal=|httpAcceptLanguageChanged()
$signal=|httpCacheMaximumSizeChanged()
$signal=|httpCacheTypeChanged()
$signal=|httpUserAgentChanged()
$signal=|offTheRecordChanged()
$signal=|persistentCookiesPolicyChanged()
$signal=|persistentStoragePathChanged()
$signal=|spellCheckEnabledChanged()
$signal=|spellCheckLanguagesChanged()
$signal=|storageNameChanged()
$endSignals

#pragma ENDDUMP


use primes instead of underscores

use primes instead of underscores

-- See: http://en.wikipedia.org/wiki/Normalisation_by_evaluation
--
import "../src/LangPrelude.prg" (listM,Monad,compose,const)

monad listM

-- abstract syntax -------------------------------------------------------------

data Ty :: *0 ~> *0 where
   Bool :: Ty Bool
   Arr :: Ty a -> Ty b -> Ty (a -> b)

data Var :: *0 ~> *0 ~> *0 where
   ZVar :: Var (h,t) t
   SVar :: Var h t -> Var (h,s) t

data Exp :: *0 ~> *0 ~> *0 where
   Var :: Var g t -> Exp g t
   Lam :: Ty a -> Exp (g,a) b -> Exp g (a -> b)
   App :: Exp g (s -> t) -> Exp g s -> Exp g t
   If :: Exp g Bool -> Exp g t -> Exp g t -> Exp g t
   ETrue :: Exp g Bool
   EFalse :: Exp g Bool

-- smart constructors ----------------------------------------------------------
lamE :: Ty s -> (Exp (g,s) s -> Exp (g,s) t) -> Exp g (s -> t)
lamE s f = Lam s (f (Var ZVar))

ifE :: Exp g Bool -> Exp g t -> Exp g t -> Exp g t
ifE t ETrue EFalse = t
ifE t e e' = if eqE e e' then e else If t e e'

-- boring equality tests -------------------------------------------------------
eqB :: BoxExp t -> BoxExp s -> Bool
eqB (Box e) (Box e') = eqE e e'

eqE :: Exp g t -> Exp h s -> Bool
eqE (Var x) (Var y) = eqV x y
eqE (Lam s e) (Lam s' e') = eqT s s' && eqE e e'
eqE (App e1 e2) (App e1' e2') = eqE e1 e1' && eqE e2 e2'
eqE (If e1 e2 e3) (If e1' e2' e3') = eqE e1 e1' && (eqE e2 e2' && eqE e3 e3')
eqE ETrue ETrue = True
eqE EFalse EFalse = True
eqE _ _ = False

eqT :: Ty t -> Ty s -> Bool
eqT (Arr s t) (Arr s' t') = eqT s s' && eqT t t'
eqT Bool Bool = True
eqT _ _ = False

eqV :: Var g t -> Var h s -> Bool
eqV (SVar x) (SVar y) = eqV x y
eqV ZVar ZVar = True
eqV _ _ = False

-- evaluation ------------------------------------------------------------------
var :: Var g t -> g -> t
var ZVar     (_,t) = t
var (SVar x) (h,s) = var x h

exp :: Exp g t -> g -> t
exp (Var x)    g = var x g
exp (Lam _ e)  g = \a -> exp e (g,a)
exp (App e e') g = exp e g (exp e' g)
exp ETrue      g = True
exp EFalse     g = False
exp (If c t e) g = if exp c g then exp t g else exp e g

-- type inference --------------------------------------------------------------

data TyEnv :: *0 ~> *0 where
   Cons :: Ty t -> TyEnv h -> TyEnv (h,t)
   Nil :: TyEnv g

infer :: TyEnv g -> Exp g t -> Ty t
infer g (Var x)         = inferVar g x
infer g (Lam t e)       = Arr t (infer (Cons t g) e)
infer g (App e e')      = case infer g e of Arr _ t -> t
infer g (ETrue)         = Bool
infer g (EFalse)        = Bool
infer g (If _ e _)      = infer g e

inferVar :: TyEnv g -> Var g t -> Ty t
inferVar (Cons t h) (SVar x) = inferVar h x
inferVar (Cons t h) (ZVar)   = t

-- tree monad ------------------------------------------------------------------

data Tree a = Val a | Choice (Tree a) (Tree a)
-- doesn't yet force trees to be fully balanced:
--      Val :: a -> Tree a Z
--      Choice :: Tree a n -> Tree a n -> Tree a (S n)

treeM = Monad Val bind error
  where bind (Val a) f = f a
        bind (Choice l r) f = Choice (bind l f) (bind r f)

tmap f x = do a <- x; return (f a)
  where monad treeM

flatten t = fl t []
 where
   fl (Val a)      k = a:k
   fl (Choice l r) k = fl l (fl r k)

-- quote & friends -------------------------------------------------------------

-- for values --------------------------
enumV           :: Ty t -> Tree t
questionsV      :: Ty t -> [t -> Bool]

enumV Bool      = Choice (Val True) (Val False)
enumV (Arr s t) = mkEnum (questionsV s) (enumV t)
 where
   monad treeM
   mkEnum [] t = tmap const t
   mkEnum (q:qs) es = do
                   f1 <- mkEnum qs es
                   f2 <- mkEnum qs es
                   return (\d -> if q d then f1 d else f2 d)

questionsV Bool         = return (\x -> x)
questionsV (Arr s t)    = do
                          d <- flatten (enumV s)
                          q <- questionsV t
                          return (\f -> q (f d))

-- for expressions ---------------------
enumE           :: Ty t -> Tree (Exp g t)
questionsE      :: Ty t -> [Exp g t -> Exp g Bool]

enumE Bool      = Choice (Val ETrue) (Val EFalse)
enumE (Arr s t) = tmap (lamE s) (mkEnumE (questionsE s) (enumE t))
 where
   monad treeM
   mkEnumE [] t = tmap const t
   mkEnumE (q:qs) es = do
                        f1 <- mkEnumE qs es
                        f2 <- mkEnumE qs es
                        return (\d -> ifE (q d) (f1 d) (f2 d))

questionsE Bool         = return (\x -> x)
questionsE (Arr s t)    = do
                          d <- flatten (enumE s)
                          q <- questionsE t
                          return (\f -> q (App f d))

-- should be
--      find (List (Exp g Bool) n) -> Tree (Exp g a) n -> Exp g a
find :: [Exp g Bool] -> Tree (Exp g a) -> Exp g a
find []         (Val a)         = a
find (b:bs)     (Choice l r)    = ifE b (find bs l) (find bs r)
find _          _               = error "bad arguments to find"

quote :: Ty t -> t -> Exp g t
quote Bool      t = case t of True -> ETrue; False -> EFalse
quote (Arr s t) f = lamE s (\e -> find (do q <- questionsE s; return (q e))
                                        (tmap (quote t . f) (enumV s)))

-- normalization (by evaluation) -----------------------------------------------
data BoxExp t = Box (forall g. Exp g t)

normalize :: Ty t -> BoxExp t -> BoxExp t
normalize s (Box e) = Box (quote s (exp e ()))

-- examples --------------------------------------------------------------------
b2b = Arr Bool Bool
b22b = Arr b2b b2b
zero = Var ZVar
one = Var (SVar ZVar)
once   = Box (Lam b2b (Lam Bool (App one zero)))
twice  = Box (Lam b2b (Lam Bool (App one (App one zero))))
thrice = Box (Lam b2b (Lam Bool (App one (App one (App one zero)))))

test = [ eqB (nf b22b thrice) (nf b22b once)
       , eqB (nf b22b twice)  (nf b22b once)]
  where nf = normalize

-- See: http://en.wikipedia.org/wiki/Normalisation_by_evaluation
--
import "../src/LangPrelude.prg" (listM,Monad,compose,const)

monad listM

-- abstract syntax -------------------------------------------------------------

data Ty :: *0 ~> *0 where
   Bool :: Ty Bool
   Arr :: Ty a -> Ty b -> Ty (a -> b)

data Var :: *0 ~> *0 ~> *0 where
   ZVar :: Var (h,t) t
   SVar :: Var h t -> Var (h,s) t

data Exp :: *0 ~> *0 ~> *0 where
   Var :: Var g t -> Exp g t
   Lam :: Ty a -> Exp (g,a) b -> Exp g (a -> b)
   App :: Exp g (s -> t) -> Exp g s -> Exp g t
   If :: Exp g Bool -> Exp g t -> Exp g t -> Exp g t
   ETrue :: Exp g Bool
   EFalse :: Exp g Bool

-- smart constructors ----------------------------------------------------------
lamE :: Ty s -> (Exp (g,s) s -> Exp (g,s) t) -> Exp g (s -> t)
lamE s f = Lam s (f (Var ZVar))

ifE :: Exp g Bool -> Exp g t -> Exp g t -> Exp g t
ifE t ETrue EFalse = t
ifE t e e' = if eqE e e' then e else If t e e'

-- boring equality tests -------------------------------------------------------
eqB :: BoxExp t -> BoxExp s -> Bool
eqB (Box e) (Box e_) = eqE e e_

eqE :: Exp g t -> Exp h s -> Bool
eqE (Var x) (Var y) = eqV x y
eqE (Lam s e) (Lam s_ e_) = eqT s s_ && eqE e e_
eqE (App e1 e2) (App e1_ e2_) = eqE e1 e1_ && eqE e2 e2_
eqE (If e1 e2 e3) (If e1_ e2_ e3_) = eqE e1 e1_ && (eqE e2 e2_ && eqE e3 e3_)
eqE ETrue ETrue = True
eqE EFalse EFalse = True
eqE _ _ = False

eqT :: Ty t -> Ty s -> Bool
eqT (Arr s t) (Arr s_ t_) = eqT s s_ && eqT t t_
eqT Bool Bool = True
eqT _ _ = False

eqV :: Var g t -> Var h s -> Bool
eqV (SVar x) (SVar y) = eqV x y
eqV ZVar ZVar = True
eqV _ _ = False

-- evaluation ------------------------------------------------------------------
var :: Var g t -> g -> t
var ZVar     (_,t) = t
var (SVar x) (h,s) = var x h

exp :: Exp g t -> g -> t
exp (Var x)    g = var x g
exp (Lam _ e)  g = \a -> exp e (g,a)
exp (App e e') g = exp e g (exp e' g)
exp ETrue      g = True
exp EFalse     g = False
exp (If c t e) g = if exp c g then exp t g else exp e g

-- type inference --------------------------------------------------------------

data TyEnv :: *0 ~> *0 where
   Cons :: Ty t -> TyEnv h -> TyEnv (h,t)
   Nil :: TyEnv g

infer :: TyEnv g -> Exp g t -> Ty t
infer g (Var x)         = inferVar g x
infer g (Lam t e)       = Arr t (infer (Cons t g) e)
infer g (App e e')      = case infer g e of Arr _ t -> t
infer g (ETrue)         = Bool
infer g (EFalse)        = Bool
infer g (If _ e _)      = infer g e

inferVar :: TyEnv g -> Var g t -> Ty t
inferVar (Cons t h) (SVar x) = inferVar h x
inferVar (Cons t h) (ZVar)   = t

-- tree monad ------------------------------------------------------------------

data Tree a = Val a | Choice (Tree a) (Tree a)
-- doesn't yet force trees to be fully balanced:
--      Val :: a -> Tree a Z
--      Choice :: Tree a n -> Tree a n -> Tree a (S n)

treeM = Monad Val bind error
  where bind (Val a) f = f a
        bind (Choice l r) f = Choice (bind l f) (bind r f)

tmap f x = do a <- x; return (f a)
  where monad treeM

flatten t = flatten_ t []
 where
   flatten_ (Val a)      k = a:k
   flatten_ (Choice l r) k = flatten_ l (flatten_ r k)

-- quote & friends -------------------------------------------------------------

-- for values --------------------------
enumV           :: Ty t -> Tree t
questionsV      :: Ty t -> [t -> Bool]

enumV Bool      = Choice (Val True) (Val False)
enumV (Arr s t) = mkEnum (questionsV s) (enumV t)
 where
   monad treeM
   mkEnum [] t = tmap const t
   mkEnum (q:qs) es = do
                   f1 <- mkEnum qs es
                   f2 <- mkEnum qs es
                   return (\d -> if q d then f1 d else f2 d)

questionsV Bool         = return (\x -> x)
questionsV (Arr s t)    = do
                          d <- flatten (enumV s)
                          q <- questionsV t
                          return (\f -> q (f d))

-- for expressions ---------------------
enumE           :: Ty t -> Tree (Exp g t)
questionsE      :: Ty t -> [Exp g t -> Exp g Bool]

enumE Bool      = Choice (Val ETrue) (Val EFalse)
enumE (Arr s t) = tmap (lamE s) (mkEnumE (questionsE s) (enumE t))
 where
   monad treeM
   mkEnumE [] t = tmap const t
   mkEnumE (q:qs) es = do
                        f1 <- mkEnumE qs es
                        f2 <- mkEnumE qs es
                        return (\d -> ifE (q d) (f1 d) (f2 d))

questionsE Bool         = return (\x -> x)
questionsE (Arr s t)    = do
                          d <- flatten (enumE s)
                          q <- questionsE t
                          return (\f -> q (App f d))

-- should be
--      find (List (Exp g Bool) n) -> Tree (Exp g a) n -> Exp g a
find :: [Exp g Bool] -> Tree (Exp g a) -> Exp g a
find []         (Val a)         = a
find (b:bs)     (Choice l r)    = ifE b (find bs l) (find bs r)
find _          _               = error "bad arguments to find"

quote :: Ty t -> t -> Exp g t
quote Bool      t = case t of True -> ETrue; False -> EFalse
quote (Arr s t) f = lamE s (\e -> find (do q <- questionsE s; return (q e))
                                        (tmap (quote t . f) (enumV s)))

-- normalization (by evaluation) -----------------------------------------------
data BoxExp t = Box (forall g. Exp g t)

normalize :: Ty t -> BoxExp t -> BoxExp t
normalize s (Box e) = Box (quote s (exp e ()))

-- examples --------------------------------------------------------------------
b2b = Arr Bool Bool
b22b = Arr b2b b2b
zero = Var ZVar
one = Var (SVar ZVar)
once   = Box (Lam b2b (Lam Bool (App one zero)))
twice  = Box (Lam b2b (Lam Bool (App one (App one zero))))
thrice = Box (Lam b2b (Lam Bool (App one (App one (App one zero)))))

test = [ eqB (nf b22b thrice) (nf b22b once)
       , eqB (nf b22b twice)  (nf b22b once)]
  where nf = normalize


this is fixed in trunk

this is fixed in trunk

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

{-
data TreeF :: * ~> Dir ~> *1 where
  Unit :: TreeF f Ver
  Ni :: TreeF f Hor
  Fork :: f ~> TreeF f Hor ~> TreeF f Hor
 deriving syntax (tr) List(Ni, Fork) Unit(Unit)

--kind Id d k = Id k

kind Fix t f = In (f (Fix t f))

type Tree = Fix TreeF
-}

kind T r a = Nix | F r a r

kind Fix f a = X (f (Fix f a) a)

type Tree a = Fix T a

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

{-
data TreeF :: * ~> Dir ~> *1 where
  Unit :: TreeF f Ver
  Ni :: TreeF f Hor
  Fork :: f ~> TreeF f Hor ~> TreeF f Hor
 deriving syntax (tr) List(Ni, Fork) Unit(Unit)

--kind Id d k = Id k

kind Fix t f = In (f (Fix t f))

type Tree = Fix TreeF
-}

kind T r a = Nix | F r a r

kind Fix f a = X (f (Fix f a) a)
---               ^
------------------+
--- here is the bug!

type Tree a = Fix T a

{- Triggers omega bug:

omega.exe: RankN.hs:(1704,1)-(1708,23): Non-exhaustive patterns in function matchKind

>>> http://code.google.com/p/omega/source/browse/trunk/src/RankN.hs#1704

-}


QtUiTools: dead code deletion

QtUiTools: dead code deletion

/*

  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"

#ifndef QT5XHB_NO_REQUESTS
REQUEST QACTION
REQUEST QACTIONGROUP
REQUEST QLAYOUT
REQUEST QWIDGET
REQUEST QDIR
#endif

CLASS QUiLoader INHERIT QObject

   DATA class_flags INIT 1
   DATA self_destruction INIT .F.

   METHOD new
   METHOD delete
   METHOD addPluginPath
   METHOD availableLayouts
   METHOD availableWidgets
   METHOD clearPluginPaths
   METHOD createAction
   METHOD createActionGroup
   METHOD createLayout
   METHOD createWidget
   METHOD isLanguageChangeEnabled
   METHOD load
   METHOD pluginPaths
   METHOD setLanguageChangeEnabled
   METHOD setWorkingDirectory
   METHOD workingDirectory

   DESTRUCTOR destroyObject

END CLASS

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

#pragma BEGINDUMP

#include <Qt>

#ifndef __XHARBOUR__
#include <QUiLoader>
#endif

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

#ifdef __XHARBOUR__
#include <QUiLoader>
#endif

#include <QStringList>
#include <QDir>

/*
QUiLoader ( QObject * parent = 0 )
*/
HB_FUNC_STATIC( QUILOADER_NEW )
{
  QObject * par1 = ISNIL(1)? 0 : (QObject *) _qt5xhb_itemGetPtr(1);
  QUiLoader * o = new QUiLoader ( par1 );
  _qt5xhb_storePointerAndFlag( o, false );
}

HB_FUNC_STATIC( QUILOADER_DELETE )
{
  QUiLoader * obj = (QUiLoader *) 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 addPluginPath ( const QString & path )
*/
HB_FUNC_STATIC( QUILOADER_ADDPLUGINPATH )
{
  QUiLoader * obj = (QUiLoader *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QString par1 = QLatin1String( hb_parc(1) );
    obj->addPluginPath ( par1 );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
QStringList availableLayouts () const
*/
HB_FUNC_STATIC( QUILOADER_AVAILABLELAYOUTS )
{
  QUiLoader * obj = (QUiLoader *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QStringList strl = obj->availableLayouts (  );
    _qt5xhb_convert_qstringlist_to_array ( strl );
  }
}

/*
QStringList availableWidgets () const
*/
HB_FUNC_STATIC( QUILOADER_AVAILABLEWIDGETS )
{
  QUiLoader * obj = (QUiLoader *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QStringList strl = obj->availableWidgets (  );
    _qt5xhb_convert_qstringlist_to_array ( strl );
  }
}

/*
void clearPluginPaths ()
*/
HB_FUNC_STATIC( QUILOADER_CLEARPLUGINPATHS )
{
  QUiLoader * obj = (QUiLoader *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    obj->clearPluginPaths (  );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
virtual QAction * createAction ( QObject * parent = 0, const QString & name = QString() )
*/
HB_FUNC_STATIC( QUILOADER_CREATEACTION )
{
  QUiLoader * obj = (QUiLoader *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QObject * par1 = ISNIL(1)? 0 : (QObject *) _qt5xhb_itemGetPtr(1);
    QString par2 = ISNIL(2)? QString() : QLatin1String( hb_parc(2) );
    QAction * ptr = obj->createAction ( par1, par2 );
    _qt5xhb_createReturnClass ( ptr, "QACTION" );
  }
}

/*
virtual QActionGroup * createActionGroup ( QObject * parent = 0, const QString & name = QString() )
*/
HB_FUNC_STATIC( QUILOADER_CREATEACTIONGROUP )
{
  QUiLoader * obj = (QUiLoader *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QObject * par1 = ISNIL(1)? 0 : (QObject *) _qt5xhb_itemGetPtr(1);
    QString par2 = ISNIL(2)? QString() : QLatin1String( hb_parc(2) );
    QActionGroup * ptr = obj->createActionGroup ( par1, par2 );
    _qt5xhb_createReturnClass ( ptr, "QACTIONGROUP" );
  }
}

/*
virtual QLayout * createLayout ( const QString & className, QObject * parent = 0, const QString & name = QString() )
*/
HB_FUNC_STATIC( QUILOADER_CREATELAYOUT )
{
  QUiLoader * obj = (QUiLoader *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QString par1 = QLatin1String( hb_parc(1) );
    QObject * par2 = ISNIL(2)? 0 : (QObject *) _qt5xhb_itemGetPtr(2);
    QString par3 = ISNIL(3)? QString() : QLatin1String( hb_parc(3) );
    QLayout * ptr = obj->createLayout ( par1, par2, par3 );
    _qt5xhb_createReturnClass ( ptr, "QLAYOUT" );
  }
}

/*
virtual QWidget * createWidget ( const QString & className, QWidget * parent = 0, const QString & name = QString() )
*/
HB_FUNC_STATIC( QUILOADER_CREATEWIDGET )
{
  QUiLoader * obj = (QUiLoader *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QString par1 = QLatin1String( hb_parc(1) );
    QWidget * par2 = ISNIL(2)? 0 : (QWidget *) _qt5xhb_itemGetPtr(2);
    QString par3 = ISNIL(3)? QString() : QLatin1String( hb_parc(3) );
    QWidget * ptr = obj->createWidget ( par1, par2, par3 );
    _qt5xhb_createReturnQWidgetClass ( ptr, "QWIDGET" );
  }
}

/*
bool isLanguageChangeEnabled () const
*/
HB_FUNC_STATIC( QUILOADER_ISLANGUAGECHANGEENABLED )
{
  QUiLoader * obj = (QUiLoader *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    hb_retl( obj->isLanguageChangeEnabled (  ) );
  }
}

/*
QWidget * load ( QIODevice * device, QWidget * parentWidget = 0 )
*/
HB_FUNC_STATIC( QUILOADER_LOAD )
{
  QUiLoader * obj = (QUiLoader *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QIODevice * par1 = (QIODevice *) _qt5xhb_itemGetPtr(1);
    QWidget * par2 = ISNIL(2)? 0 : (QWidget *) _qt5xhb_itemGetPtr(2);
    QWidget * ptr = obj->load ( par1, par2 );
    _qt5xhb_createReturnQWidgetClass ( ptr, "QWIDGET" );
  }
}

/*
QStringList pluginPaths () const
*/
HB_FUNC_STATIC( QUILOADER_PLUGINPATHS )
{
  QUiLoader * obj = (QUiLoader *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QStringList strl = obj->pluginPaths (  );
    _qt5xhb_convert_qstringlist_to_array ( strl );
  }
}

/*
void setLanguageChangeEnabled ( bool enabled )
*/
HB_FUNC_STATIC( QUILOADER_SETLANGUAGECHANGEENABLED )
{
  QUiLoader * obj = (QUiLoader *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    obj->setLanguageChangeEnabled ( (bool) hb_parl(1) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setWorkingDirectory ( const QDir & dir )
*/
HB_FUNC_STATIC( QUILOADER_SETWORKINGDIRECTORY )
{
  QUiLoader * obj = (QUiLoader *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QDir * par1 = (QDir *) _qt5xhb_itemGetPtr(1);
    obj->setWorkingDirectory ( *par1 );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
QDir workingDirectory () const
*/
HB_FUNC_STATIC( QUILOADER_WORKINGDIRECTORY )
{
  QUiLoader * obj = (QUiLoader *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QDir * ptr = new QDir( obj->workingDirectory (  ) );
    _qt5xhb_createReturnClass ( ptr, "QDIR", true );
  }
}

#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 QACTIONGROUP
REQUEST QLAYOUT
REQUEST QWIDGET
REQUEST QDIR
#endif

CLASS QUiLoader INHERIT QObject

   //DATA class_id INIT Class_Id_QUiLoader
   DATA class_flags INIT 1
   DATA self_destruction INIT .F.

   METHOD new
   METHOD delete
   METHOD addPluginPath
   METHOD availableLayouts
   METHOD availableWidgets
   METHOD clearPluginPaths
   METHOD createAction
   METHOD createActionGroup
   METHOD createLayout
   METHOD createWidget
   METHOD isLanguageChangeEnabled
   METHOD load
   METHOD pluginPaths
   METHOD setLanguageChangeEnabled
   METHOD setWorkingDirectory
   METHOD workingDirectory

   DESTRUCTOR destroyObject

END CLASS

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

#pragma BEGINDUMP

#include <Qt>

#ifndef __XHARBOUR__
#include <QUiLoader>
#endif

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

#ifdef __XHARBOUR__
#include <QUiLoader>
#endif

#include <QStringList>
#include <QDir>

/*
QUiLoader ( QObject * parent = 0 )
*/
HB_FUNC_STATIC( QUILOADER_NEW )
{
  QObject * par1 = ISNIL(1)? 0 : (QObject *) _qt5xhb_itemGetPtr(1);
  QUiLoader * o = new QUiLoader ( par1 );
  _qt5xhb_storePointerAndFlag( o, false );
}

HB_FUNC_STATIC( QUILOADER_DELETE )
{
  QUiLoader * obj = (QUiLoader *) 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 addPluginPath ( const QString & path )
*/
HB_FUNC_STATIC( QUILOADER_ADDPLUGINPATH )
{
  QUiLoader * obj = (QUiLoader *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QString par1 = QLatin1String( hb_parc(1) );
    obj->addPluginPath ( par1 );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
QStringList availableLayouts () const
*/
HB_FUNC_STATIC( QUILOADER_AVAILABLELAYOUTS )
{
  QUiLoader * obj = (QUiLoader *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QStringList strl = obj->availableLayouts (  );
    _qt5xhb_convert_qstringlist_to_array ( strl );
  }
}

/*
QStringList availableWidgets () const
*/
HB_FUNC_STATIC( QUILOADER_AVAILABLEWIDGETS )
{
  QUiLoader * obj = (QUiLoader *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QStringList strl = obj->availableWidgets (  );
    _qt5xhb_convert_qstringlist_to_array ( strl );
  }
}

/*
void clearPluginPaths ()
*/
HB_FUNC_STATIC( QUILOADER_CLEARPLUGINPATHS )
{
  QUiLoader * obj = (QUiLoader *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    obj->clearPluginPaths (  );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
virtual QAction * createAction ( QObject * parent = 0, const QString & name = QString() )
*/
HB_FUNC_STATIC( QUILOADER_CREATEACTION )
{
  QUiLoader * obj = (QUiLoader *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QObject * par1 = ISNIL(1)? 0 : (QObject *) _qt5xhb_itemGetPtr(1);
    QString par2 = ISNIL(2)? QString() : QLatin1String( hb_parc(2) );
    QAction * ptr = obj->createAction ( par1, par2 );
    _qt5xhb_createReturnClass ( ptr, "QACTION" );
  }
}

/*
virtual QActionGroup * createActionGroup ( QObject * parent = 0, const QString & name = QString() )
*/
HB_FUNC_STATIC( QUILOADER_CREATEACTIONGROUP )
{
  QUiLoader * obj = (QUiLoader *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QObject * par1 = ISNIL(1)? 0 : (QObject *) _qt5xhb_itemGetPtr(1);
    QString par2 = ISNIL(2)? QString() : QLatin1String( hb_parc(2) );
    QActionGroup * ptr = obj->createActionGroup ( par1, par2 );
    _qt5xhb_createReturnClass ( ptr, "QACTIONGROUP" );
  }
}

/*
virtual QLayout * createLayout ( const QString & className, QObject * parent = 0, const QString & name = QString() )
*/
HB_FUNC_STATIC( QUILOADER_CREATELAYOUT )
{
  QUiLoader * obj = (QUiLoader *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QString par1 = QLatin1String( hb_parc(1) );
    QObject * par2 = ISNIL(2)? 0 : (QObject *) _qt5xhb_itemGetPtr(2);
    QString par3 = ISNIL(3)? QString() : QLatin1String( hb_parc(3) );
    QLayout * ptr = obj->createLayout ( par1, par2, par3 );
    _qt5xhb_createReturnClass ( ptr, "QLAYOUT" );
  }
}

/*
virtual QWidget * createWidget ( const QString & className, QWidget * parent = 0, const QString & name = QString() )
*/
HB_FUNC_STATIC( QUILOADER_CREATEWIDGET )
{
  QUiLoader * obj = (QUiLoader *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QString par1 = QLatin1String( hb_parc(1) );
    QWidget * par2 = ISNIL(2)? 0 : (QWidget *) _qt5xhb_itemGetPtr(2);
    QString par3 = ISNIL(3)? QString() : QLatin1String( hb_parc(3) );
    QWidget * ptr = obj->createWidget ( par1, par2, par3 );
    _qt5xhb_createReturnQWidgetClass ( ptr, "QWIDGET" );
  }
}

/*
bool isLanguageChangeEnabled () const
*/
HB_FUNC_STATIC( QUILOADER_ISLANGUAGECHANGEENABLED )
{
  QUiLoader * obj = (QUiLoader *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    hb_retl( obj->isLanguageChangeEnabled (  ) );
  }
}

/*
QWidget * load ( QIODevice * device, QWidget * parentWidget = 0 )
*/
HB_FUNC_STATIC( QUILOADER_LOAD )
{
  QUiLoader * obj = (QUiLoader *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QIODevice * par1 = (QIODevice *) _qt5xhb_itemGetPtr(1);
    QWidget * par2 = ISNIL(2)? 0 : (QWidget *) _qt5xhb_itemGetPtr(2);
    QWidget * ptr = obj->load ( par1, par2 );
    _qt5xhb_createReturnQWidgetClass ( ptr, "QWIDGET" );
  }
}

/*
QStringList pluginPaths () const
*/
HB_FUNC_STATIC( QUILOADER_PLUGINPATHS )
{
  QUiLoader * obj = (QUiLoader *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QStringList strl = obj->pluginPaths (  );
    _qt5xhb_convert_qstringlist_to_array ( strl );
  }
}

/*
void setLanguageChangeEnabled ( bool enabled )
*/
HB_FUNC_STATIC( QUILOADER_SETLANGUAGECHANGEENABLED )
{
  QUiLoader * obj = (QUiLoader *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    obj->setLanguageChangeEnabled ( (bool) hb_parl(1) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setWorkingDirectory ( const QDir & dir )
*/
HB_FUNC_STATIC( QUILOADER_SETWORKINGDIRECTORY )
{
  QUiLoader * obj = (QUiLoader *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QDir * par1 = (QDir *) _qt5xhb_itemGetPtr(1);
    obj->setWorkingDirectory ( *par1 );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
QDir workingDirectory () const
*/
HB_FUNC_STATIC( QUILOADER_WORKINGDIRECTORY )
{
  QUiLoader * obj = (QUiLoader *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QDir * ptr = new QDir( obj->workingDirectory (  ) );
    _qt5xhb_createReturnClass ( ptr, "QDIR", true );
  }
}

#pragma ENDDUMP


[Runtime] X# 2.6 for 3rd party

[Runtime] X# 2.6 for 3rd party

USING System
USING System.Collections.Generic
USING System.Linq
USING System.Text

FUNCTION Start() AS VOID STRICT
    TRY
    LOCAL bin1 AS BINARY
    LOCAL bin2 AS BINARY
    bin1 := "Robert"
    bin2 := "Rober"
    ? bin1 == bin2
    ? bin1 > bin2
    ? bin1 >= bin2
    ? bin1 < bin2
    ? bin1 <= bin2
    bin2 := "Robert"
    ? bin1 > bin2
    ? bin1 >= bin2
    ? bin1 < bin2
    ? bin1 <= bin2
    CATCH e as Exception
        ? e:ToString()
    END TRY
    WAIT
	RETURN

USING System
USING System.Collections.Generic
USING System.Linq
USING System.Text

FUNCTION Start() AS VOID STRICT
    TRY
    LOCAL bin1 AS BINARY
    LOCAL bin2 AS BINARY
    LOCAL strtest  IS TEST
    strtest.l1 := TRUE
    bin1 := "Robert"
    bin2 := "Rober"
    ? bin1 == bin2
    ? bin1 > bin2
    ? bin1 >= bin2
    ? bin1 < bin2
    ? bin1 <= bin2
    bin2 := "Robert"
    ? bin1 > bin2
    ? bin1 >= bin2
    ? bin1 < bin2
    ? bin1 <= bin2
    CATCH e as Exception
        ? e:ToString()
    END TRY
    WAIT
	RETURN

VOSTRUCT TEST
    MEMBER l1 as LOGIC


add a clue-stick

add a clue-stick

import "../tests/OneHi.prg" (plus, plusZ, plusS)

data Thrist :: (l ~> l ~> *) ~> l ~> l ~> * where
  Nil :: Thrist k a a
  Cons :: k a b -> Thrist k b c -> Thrist k a c
 deriving List(t)

data At :: * ~> Nat ~> Nat ~> * where
  HoldChar :: Char -> At Char n (S n)

thristLen :: Thrist (At Char) here {plus len here} -> Nat' len
thristLen Nil = 0v
  where theorem plusZ

move :: Nat' offs -> Nat' len -> Thrist (At Char) here {plus len here} -> Thrist (At Char) offs {plus len offs}
move _ 0v Nil = Nil
move offs (1+len)v (Cons (HoldChar c) as) = Cons (HoldChar c) $ move (1+offs)v len as
  where theorem plusS

import "../tests/OneHi.prg" (plus, plusS)

data Thrist :: (l ~> l ~> *) ~> l ~> l ~> * where
  Nil :: Thrist k a a
  Cons :: k a b -> Thrist k b c -> Thrist k a c
 deriving List(t)

data At :: * ~> Nat ~> Nat ~> * where
  HoldChar :: Char -> At Char n (S n)

thristLen :: Thrist (At Char) here {plus len here} -> Nat' len
thristLen Nil = 0v

move :: Nat' offs -> Nat' len -> Thrist (At Char) here {plus len here} -> Thrist (At Char) offs {plus len offs}
move _ 0v Nil = Nil
move offs (1+len)v (Cons (HoldChar c) as) = Cons (HoldChar c) $ move (1+offs)v len as
  where theorem plusS


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

$addSignals

$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"

$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


[VOEditors] Fix for https://github.com/X-Sharp/XSharpPublic/issues/458, now the PARTIAL, INTERNAL, PROTECTED and PRIVATE modifiers are being retained for generated classes/methods

#using System.Collections.Generic
#using System.Collections.Generic
#using System.Collections

USING Xide

BEGIN NAMESPACE Xide

CLASS AbstractEditor
	EXPORT aLines AS List<LineObject>
	PROTECT nStart,nEnd AS INT
	PROTECT oCaretPos AS System.Drawing.Point
	PROTECT oBuffer AS EditorBuffer
	CONSTRUCTOR(_oBuffer AS EditorBuffer)
		SELF:oBuffer := _oBuffer
		SELF:oBuffer:FullParse()
		SELF:aLines := SELF:oBuffer:aLines
	RETURN

	METHOD BeginCode() AS VOID
		SELF:nStart := 0
		SELF:nEnd := 0
		IF SELF:oBuffer != NULL
			SELF:oBuffer:BeginAction()
		END IF
	RETURN

	METHOD EndCode() AS VOID
		IF SELF:oBuffer != NULL
			SELF:oBuffer:EndAction()
		END IF
	RETURN

	METHOD ModifiedLine(nLine AS INT) AS VOID
		IF SELF:nStart == 0 .or. SELF:nStart > nLine
			SELF:nStart := nLine
		ENDIF
		IF SELF:nEnd == 0 .or. SELF:nEnd < nLine
			SELF:nEnd := nLine
		ENDIF
	RETURN

	METHOD CheckCreatedCode() AS VOID
		IF SELF:nStart != 0
			SELF:oBuffer:LinesModified(0,0,0)
		ENDIF
		SELF:nStart := 0
		SELF:nEnd := 0
	RETURN

	METHOD AddLine(cLine AS STRING) AS VOID
		SELF:oBuffer:AddLine(cLine)
	RETURN

	METHOD InsertLine(cLine AS STRING , nLine AS INT) AS VOID
		SELF:oBuffer:InsertLine(nLine , cLine)
	RETURN

	METHOD ReplaceLine(cLine AS STRING , nLine AS INT) AS VOID
		SELF:oBuffer:ChangeLine(nLine , cLine)
	RETURN

	METHOD RemoveLine(nLine AS INT) AS VOID
		SELF:oBuffer:DeleteLine(nLine)
	RETURN

	METHOD DeleteAllLines() AS VOID
		SELF:oBuffer:DeleteAllLines()
	RETURN

END CLASS

PARTIAL CLASS CodeGenerator
	PROTECT aLines AS List<LineObject>
	PROTECT nStart,nEnd AS INT
	PROTECT oCaretPos AS System.Drawing.Point
	PROTECT oEditor , oBaseEditor , oDesEditor AS AbstractEditor

	CONSTRUCTOR(oBuffer AS EditorBuffer)
		SELF:aLines := oBuffer:aLines
		SELF:oBaseEditor := AbstractEditor{oBuffer}
	RETURN

	METHOD BeginCode() AS LOGIC
		SELF:oDesEditor := SELF:oBaseEditor
		SELF:oEditor := SELF:oBaseEditor
		SELF:oEditor:BeginCode()
	RETURN FALSE

	METHOD EndCode() AS VOID
		SELF:oEditor:EndCode()
	RETURN

METHOD ModifiedLine(nLine AS INT) AS VOID
	SELF:oEditor:ModifiedLine(nLine)
RETURN

METHOD CheckCreatedCode() AS VOID
	SELF:oEditor:CheckCreatedCode()
RETURN
METHOD GetLine(nLine AS INT) AS LineObject
	RETURN SELF:aLines[nLine - 1]

METHOD EntityExists(eType AS EntityType,cName AS STRING,cClass AS STRING) AS LOGIC
LOCAL nDummy AS INT
SELF:FindEntity(eType,cName,cClass,nDummy)
RETURN nDummy!=0

METHOD EntityExistsAnywhere(eType AS EntityType , cName AS STRING , cClass AS STRING) AS LOGIC
RETURN FALSE

METHOD FindEntity(eType AS EntityType,cName AS STRING,cClass AS STRING,nLine REF Int32) AS LOGIC
LOCAL oLine AS LineObject
LOCAL oEntity AS EntityObject
cName := cName:ToUpper():Trim()
cClass := cClass:ToUpper():Trim()
FOR nLine:=1 UPTO SELF:aLines:Count
	oLine:=SELF:GetLine(nLine)
	IF oLine:lEntity
		oEntity:=oLine:oEntity
		IF oEntity:eType == eType .and. oEntity:cTypedClassName:ToUpper() == cClass
			IF eType == EntityType._Constructor .or. oEntity:cName:ToUpper() == cName
				RETURN FALSE
			ENDIF
		END IF
	END IF
NEXT
nLine:=0
RETURN FALSE

METHOD DeleteEntity(eType AS EntityType,cName AS STRING,cClass AS STRING) AS LOGIC
	LOCAL nLine AS INT
RETURN SELF:DeleteEntity(eType , cName ,cClass , nLine)

METHOD DeleteEntity(eType AS EntityType,cName AS STRING,cClass AS STRING,nLine REF Int32) AS LOGIC
LOCAL oLine AS LineObject
LOCAL lExit AS LOGIC
LOCAL nOldLine AS INT
LOCAL cLine AS STRING
nOldLine := nLine
SELF:FindEntity(eType,cName,cClass,nLine)
IF nLine == 0
	nLine := nOldLine
	RETURN FALSE
ENDIF

DO WHILE nLine!=0
	SELF:RemoveWEDLine(nLine)
	SELF:ModifiedLine(nLine)
	IF nLine<=SELF:aLines:Count
		oLine:=SELF:GetLine(nLine)
		IF oLine:lEntity .or. lExit .or. oLine:IsEndClass
			EXIT
		END IF
		cLine := oLine:LineText:ToUpper()
		IF cLine:Contains("##USER##") .or. cLine:Contains("{{%UC%}}") .or. cLine:Contains("USER CODE STARTS")
			lExit := TRUE
		END IF
	ELSE
		EXIT
	END IF
END DO
SELF:CheckCreatedCode()
RETURN FALSE

METHOD AddInclude(cInclude AS STRING) AS VOID
	LOCAL oLine AS LineObject
	LOCAL nLine AS INT
	LOCAL n AS INT

	nLine := 1

	FOR n := 1 UPTO SELF:aLines:Count
		oLine := SELF:aLines[n - 1]
		DO CASE
		CASE oLine:lEntity
			nLine := n - 1
			EXIT
		CASE oLine:IsInclude .and. oLine:cArgument:ToUpper() == cInclude:ToUpper()
			RETURN
		END CASE
	NEXT
	IF nLine <= 0
		nLine := 1
	ENDIF

	SELF:AddWEDLine("#include " + e"\"" + cInclude + e"\"" , nLine)
	SELF:ModifiedLine(nLine)
RETURN

METHOD RemoveInclude(cInclude AS STRING) AS VOID
	FOR LOCAL nLine := 1 UPTO SELF:aLines:Count
		LOCAL oLine AS LineObject
		oLine := SELF:aLines[nLine - 1]
		DO CASE
		CASE oLine:lEntity
			RETURN
		CASE oLine:IsInclude .and. oLine:cArgument:ToUpper() == cInclude:ToUpper()
			SELF:RemoveWEDLine(nLine)
			SELF:ModifiedLine(nLine)
			RETURN
		END CASE
	NEXT
RETURN

METHOD AddLine(cLine AS STRING) AS VOID
	SELF:oEditor:AddLine(cLine)
	SELF:ModifiedLine(SELF:aLines:Count)
RETURN
METHOD InsertLine(nLine AS INT , cLine AS STRING) AS VOID
	SELF:oEditor:InsertLine(cLine , nLine)
	SELF:ModifiedLine(SELF:aLines:Count)
RETURN

METHOD AddWEDLine(cLine AS STRING,nLine REF Int32) AS LineObject
LOCAL oLine AS LineObject
IF nLine<=SELF:aLines:Count .and. nLine!=0
	SELF:oEditor:InsertLine(cLine , nLine)
	SELF:ModifiedLine(nLine)
ELSE
	SELF:oEditor:AddLine(cLine)
	nLine:=SELF:aLines:Count
	SELF:ModifiedLine(nLine)
END IF
oLine := SELF:GetLine(nLine)
nLine++
RETURN oLine
METHOD ReplaceWEDLine(cLine AS STRING,nLine AS Int32) AS LineObject
	SELF:oEditor:ReplaceLine(cLine , nLine)
	SELF:ModifiedLine(nLine)
RETURN SELF:GetLine(nLine)
METHOD RemoveWEDLine(nLine AS Int32) AS VOID
	SELF:oEditor:RemoveLine(nLine)
RETURN
METHOD Clear() AS VOID
	SELF:oEditor:DeleteAllLines()
RETURN

	STATIC PROTECT cUser := "// {{%UC%}} User code starts here (DO NOT remove this line)  " AS STRING
	STATIC PROTECT cTagU := "" AS STRING

	METHOD GetEntity(eType AS EntityType , cName AS STRING , cClass AS STRING) AS EntityObject
		LOCAL nLine AS INT
		nLine := SELF:FindEntity(eType , cName , cClass)
		IF nLine != 0
			RETURN SELF:GetLine(nLine):oEntity
		END IF
	RETURN NULL

	METHOD FindEntity(eType AS EntityType , cName AS STRING , cClass AS STRING) AS INT
		LOCAL nLine AS INT
		SELF:FindEntity(eType , cName , cClass , nLine)
	RETURN nLine

	METHOD WriteEntity(eType AS EntityType , cName AS STRING , cClass AS STRING , eOptions AS EntityOptions , aEntity AS List<STRING>) AS INT
		LOCAL oLine AS LineObject
		LOCAL nLine AS INT
		LOCAL nTemp AS INT
		LOCAL nFirst AS INT
		LOCAL lIsUser AS LOGIC
		LOCAL lRemoveFields AS LOGIC
		LOCAL n AS INT

		LOCAL cTab , ceTab AS STRING
		cTab := e"\t"
		ceTab := e"\t"

		IF aEntity:Count == 0
			RETURN 0
		END IF

		cClass := cClass:ToUpper()
		nLine := SELF:FindEntity(eType , cName , cClass)

		IF nLine == 0
			IF eType == EntityType._Class
				nLine := SELF:aLines:Count + 1
			ELSEIF eType == EntityType._Constructor
				nLine := SELF:FindEntity(EntityType._Class , cClass , cClass)
				IF nLine == 0
					RETURN 0
				END IF
				DO WHILE TRUE
					nLine ++
					IF nLine > SELF:aLines:Count
						EXIT
					END IF
					oLine := SELF:GetLine(nLine)
					IF oLine:lEntity .or. oLine:IsEndClass
						EXIT
					END IF
				END DO
			ELSE
				nLine := SELF:FindEntity(EntityType._Class , cClass , cClass)
				IF nLine == 0
					RETURN 0
				END IF
				DO WHILE TRUE
					nLine ++
					IF nLine > SELF:aLines:Count
						EXIT
					END IF
					oLine := SELF:GetLine(nLine)
					IF oLine:IsEndClass
						EXIT
					END IF
					IF oLine:lEntity .and. oLine:oEntity:cTypedClassName:ToUpper() != cClass
						EXIT
					END IF
				END DO
			END IF
			nFirst := nLine
		ELSE
			nFirst := nLine
			IF (eOptions & EntityOptions.NotOverwrite) == EntityOptions.NotOverwrite
				RETURN nFirst
			END IF
			oLine := SELF:GetLine(nLine)
			LOCAL oDeclarationLine AS LineObject
			oDeclarationLine := oLine

			DO WHILE oLine:lOutAmpersand .and. (oLine:LineText:Contains("[") .or. oLine:LineText:Contains("]"))
				nLine ++
				oLine := SELF:GetLine(nLine)
			END DO

			IF (eOptions & EntityOptions.ClearOldFields) == EntityOptions.ClearOldFields
				lRemoveFields := FALSE
				nTemp := nLine
				nTemp ++
				DO WHILE nTemp <= SELF:aLines:Count
					oLine := SELF:GetLine(nTemp)
					IF oLine:lEntity
						EXIT
					END IF
					IF oLine:IsDesignerUserStart
						lRemoveFields := TRUE
						EXIT
					ENDIF
					nTemp ++
				END DO
			ELSE
				lRemoveFields := TRUE
			END IF

			IF lRemoveFields
				nTemp := nLine
				nTemp ++
				DO WHILE nTemp <= SELF:aLines:Count
					oLine := SELF:GetLine(nTemp)
					IF oLine:lEntity .or. oLine:IsEndClass
						EXIT
					END IF
					lIsUser := oLine:IsDesignerUserStart
					SELF:RemoveWEDLine(nTemp)
					IF lIsUser
						EXIT
					ENDIF
				END DO
			END IF

			IF SELF:GetLine(nLine):LineText:ToUpper() == aEntity[0]:ToUpper() .or. (eOptions & EntityOptions.KeepFirstLine) == EntityOptions.KeepFirstLine
				nLine ++
			ELSE
				LOCAL cDeclarationLine AS STRING
				cDeclarationLine := aEntity[0]
				IF oDeclarationLine:oEntity != NULL
					IF _AND(oDeclarationLine:oEntity:eModifiers , EntityModifiers._Protected) == EntityModifiers._Protected
						cDeclarationLine := "PROTECTED " + cDeclarationLine
					ENDIF
					IF _AND(oDeclarationLine:oEntity:eModifiers , EntityModifiers._Private) == EntityModifiers._Private
						cDeclarationLine := "PRIVATE " + cDeclarationLine
					ENDIF
					IF _AND(oDeclarationLine:oEntity:eModifiers , EntityModifiers._Partial) == EntityModifiers._Partial
						cDeclarationLine := "PARTIAL " + cDeclarationLine
					ENDIF
					IF _AND(oDeclarationLine:oEntity:eModifiers , EntityModifiers._Internal) == EntityModifiers._Internal
						cDeclarationLine := "INTERNAL " + cDeclarationLine
					ENDIF
				END IF
				SELF:ReplaceWEDLine(cDeclarationLine , nLine)
				nLine ++
			END IF
			n := 1
		END IF

		DO WHILE n < aEntity:Count
			oLine := SELF:AddWEDLine(aEntity[n] , nLine)
			n ++
		END DO
		IF (eOptions & EntityOptions.AddUser) == EntityOptions.AddUser
			IF eType == EntityType._Class
				oLine := SELF:AddWEDLine(ceTab + cUser + cTagU , nLine)
			ELSE
				oLine := SELF:AddWEDLine(cTab + cUser + cTagU , nLine)
			END IF
		END IF

		IF eType != EntityType._Class
			IF nLine <= SELF:aLines:Count
				oLine := SELF:GetLine(nLine)
				IF oLine:LineText:Trim() != ""
					oLine := SELF:AddWEDLine("" , nLine)
				END IF
			END IF
		END IF

		SELF:CheckCreatedCode()
	RETURN nFirst

	METHOD WriteEndClass(cClass AS STRING) AS VOID
		LOCAL oLine AS LineObject
		LOCAL lFound AS LOGIC
		LOCAL nLine AS INT
		LOCAL n AS INT

		cClass := cClass:ToUpper()
		FOR n := 1 UPTO SELF:aLines:Count
			oLine := SELF:GetLine(n)
			IF lFound
				IF oLine:IsEndClass
					RETURN
				END IF
				IF oLine:lEntity .and. oLine:oEntity:cTypedClassName:ToUpper() != cClass
					EXIT
				END IF
				nLine := n + 1
			ELSE
				IF oLine:lEntity .and. oLine:oEntity:cTypedClassName:ToUpper() == cClass
					lFound := TRUE
					nLine := n + 1
				END IF
			END IF
		NEXT

		IF nLine != 0
			SELF:AddWEDLine("END CLASS" , nLine)
		END IF

	RETURN

	METHOD DeleteLine(nLine AS INT) AS VOID
		SELF:RemoveWEDLine(nLine)
		SELF:ModifiedLine(nLine)
	RETURN

	METHOD DeleteDefines(aDefines AS List<STRING>) AS VOID
		LOCAL oLine AS LineObject
		LOCAL nLine AS INT
		nLine := 1
		DO WHILE nLine <= SELF:aLines:Count
			LOCAL lDeleted := FALSE AS LOGIC
			oLine := SELF:aLines[nLine - 1]
			IF oLine:eType == LineType.Define .and. .not. String.IsNullOrEmpty(oLine:cArgument)
				FOREACH cDefine AS STRING IN aDefines
					IF cDefine:ToUpper() == oLine:cArgument:ToUpper()
						SELF:DeleteLine(nLine)
						lDeleted := TRUE
						EXIT
					END IF
				NEXT
			ELSEIF oLine:oEntity != NULL .and. oLine:oEntity:eType == EntityType._Define
				FOREACH cDefine AS STRING IN aDefines
					IF cDefine:ToUpper() == oLine:oEntity:cName:ToUpper()
						SELF:DeleteLine(nLine)
						lDeleted := TRUE
						EXIT
					END IF
				NEXT
			END IF
			IF .not. lDeleted
				nLine ++
			END IF
		END DO

		SELF:CheckCreatedCode()

	RETURN

	METHOD AddDefine(cDefine AS STRING , cValue AS STRING) AS VOID
		SELF:AddDefine(cDefine , cValue , TRUE)
	RETURN

	METHOD AddDefine(cDefine AS STRING , cValue AS STRING , lAdd AS LOGIC) AS VOID
		LOCAL cLine AS STRING
		cLine := String.Format("#define {0} {1}" , cDefine , cValue)
//		cLine := String.Format("DEFINE {0} := {1}" , cDefine , cValue)
		IF lAdd
			SELF:AddLine(cLine)
		ELSE
			SELF:InsertLine(1 , cLine)
		END IF
	RETURN

	METHOD AddDefines(aDefines AS List<STRING> , aDefineValues AS List<STRING>) AS VOID
		SELF:AddDefines(aDefines , aDefineValues , TRUE)
	RETURN

	METHOD AddDefines(aDefines AS List<STRING> , aDefineValues AS List<STRING> , lAdd AS LOGIC) AS VOID
		FOR LOCAL n := 0 AS INT UPTO aDefines:Count - 1
			SELF:AddDefine(aDefines[n] , aDefineValues[n] , lAdd)
		NEXT
	RETURN

	METHOD RemoveDefines(cWindowName as STRING) AS VOID
		LOCAL oLine AS LineObject
		LOCAL nLine AS INT
		nLine := 1
		cWindowName := cWindowName:ToUpper()+"_"
		DO WHILE nLine <= SELF:aLines:Count
			LOCAL lDeleted := FALSE AS LOGIC
			oLine := SELF:aLines[nLine - 1]
			IF oLine:eType == LineType.Define .and. .not. String.IsNullOrEmpty(oLine:cArgument)
				IF oLine:cArgument:ToUpper():StartsWith(cWindowName)
					SELF:DeleteLine(nLine)
					lDeleted := TRUE
				END IF
			ELSEIF oLine:oEntity != NULL .and. oLine:oEntity:eType == EntityType._Define
				IF oLine:oEntity:cName:ToUpper():StartsWith(cWindowName)
					SELF:DeleteLine(nLine)
					lDeleted := TRUE
				END IF
			END IF
			IF .not. lDeleted
				nLine ++
			END IF
		END DO
		SELF:CheckCreatedCode()
		RETURN

	METHOD AddXSharpDefines(aDefines AS List<STRING> , aDefineValues AS List<STRING>) AS VOID
		SELF:AddXSharpDefines(aDefines, aDefineValues, FALSE)

	METHOD AddXSharpDefines(aDefines AS List<STRING> , aDefineValues AS List<STRING>, lStatic AS LOGIC) AS VOID
		LOCAL cLine AS STRING
		LOCAL nLine AS INT
		FOR LOCAL n := 1 AS INT UPTO SELF:aLines:Count
			LOCAL oLine AS LineObject
			oLine := SELF:aLines[n-1]
			nLine := n
			DO CASE
			CASE oLine:oEntity != NULL
				EXIT
//			CASE oLine:IsRegionIn .and. oLine:cArgument:ToUpper() == "DEFINES"
			// grr, I am not setting cArgument for regions
			CASE oLine:IsRegionIn .and. oLine:LineText:ToUpper():Contains("DEFINES")
				nLine ++
				EXIT
			END CASE
		NEXT
		LOCAL cMask AS STRING
		cMask := "DEFINE {0} := {1}"
		IF lStatic
			cMask := "STATIC "+cMask
		ENDIF
		FOR LOCAL n := 0 AS INT UPTO aDefines:Count - 1
			cLine := String.Format(cMask , aDefines[n] , aDefineValues[n])
			SELF:InsertLine(nLine , cLine)
			nLine ++
		NEXT
	RETURN

END CLASS

[Flags];
ENUM EntityOptions
	MEMBER None := 0
	MEMBER AddUser := 1
	MEMBER NotOverwrite := 2
	MEMBER ClearOldFields := 4
	MEMBER KeepFirstLine := 8
END ENUM

END NAMESPACE

#using System.Collections.Generic
#using System.Collections.Generic
#using System.Collections

USING Xide

BEGIN NAMESPACE Xide

CLASS AbstractEditor
	EXPORT aLines AS List<LineObject>
	PROTECT nStart,nEnd AS INT
	PROTECT oCaretPos AS System.Drawing.Point
	PROTECT oBuffer AS EditorBuffer
	CONSTRUCTOR(_oBuffer AS EditorBuffer)
		SELF:oBuffer := _oBuffer
		SELF:oBuffer:FullParse()
		SELF:aLines := SELF:oBuffer:aLines
	RETURN

	METHOD BeginCode() AS VOID
		SELF:nStart := 0
		SELF:nEnd := 0
		IF SELF:oBuffer != NULL
			SELF:oBuffer:BeginAction()
		END IF
	RETURN

	METHOD EndCode() AS VOID
		IF SELF:oBuffer != NULL
			SELF:oBuffer:EndAction()
		END IF
	RETURN

	METHOD ModifiedLine(nLine AS INT) AS VOID
		IF SELF:nStart == 0 .or. SELF:nStart > nLine
			SELF:nStart := nLine
		ENDIF
		IF SELF:nEnd == 0 .or. SELF:nEnd < nLine
			SELF:nEnd := nLine
		ENDIF
	RETURN

	METHOD CheckCreatedCode() AS VOID
		IF SELF:nStart != 0
			SELF:oBuffer:LinesModified(0,0,0)
		ENDIF
		SELF:nStart := 0
		SELF:nEnd := 0
	RETURN

	METHOD AddLine(cLine AS STRING) AS VOID
		SELF:oBuffer:AddLine(cLine)
	RETURN

	METHOD InsertLine(cLine AS STRING , nLine AS INT) AS VOID
		SELF:oBuffer:InsertLine(nLine , cLine)
	RETURN

	METHOD ReplaceLine(cLine AS STRING , nLine AS INT) AS VOID
		SELF:oBuffer:ChangeLine(nLine , cLine)
	RETURN

	METHOD RemoveLine(nLine AS INT) AS VOID
		SELF:oBuffer:DeleteLine(nLine)
	RETURN

	METHOD DeleteAllLines() AS VOID
		SELF:oBuffer:DeleteAllLines()
	RETURN

END CLASS

PARTIAL CLASS CodeGenerator
	PROTECT aLines AS List<LineObject>
	PROTECT nStart,nEnd AS INT
	PROTECT oCaretPos AS System.Drawing.Point
	PROTECT oEditor , oBaseEditor , oDesEditor AS AbstractEditor

	CONSTRUCTOR(oBuffer AS EditorBuffer)
		SELF:aLines := oBuffer:aLines
		SELF:oBaseEditor := AbstractEditor{oBuffer}
	RETURN

	METHOD BeginCode() AS LOGIC
		SELF:oDesEditor := SELF:oBaseEditor
		SELF:oEditor := SELF:oBaseEditor
		SELF:oEditor:BeginCode()
	RETURN FALSE

	METHOD EndCode() AS VOID
		SELF:oEditor:EndCode()
	RETURN

METHOD ModifiedLine(nLine AS INT) AS VOID
	SELF:oEditor:ModifiedLine(nLine)
RETURN

METHOD CheckCreatedCode() AS VOID
	SELF:oEditor:CheckCreatedCode()
RETURN
METHOD GetLine(nLine AS INT) AS LineObject
	RETURN SELF:aLines[nLine - 1]

METHOD EntityExists(eType AS EntityType,cName AS STRING,cClass AS STRING) AS LOGIC
LOCAL nDummy AS INT
SELF:FindEntity(eType,cName,cClass,nDummy)
RETURN nDummy!=0

METHOD EntityExistsAnywhere(eType AS EntityType , cName AS STRING , cClass AS STRING) AS LOGIC
RETURN FALSE

METHOD FindEntity(eType AS EntityType,cName AS STRING,cClass AS STRING,nLine REF Int32) AS LOGIC
LOCAL oLine AS LineObject
LOCAL oEntity AS EntityObject
cName := cName:ToUpper():Trim()
cClass := cClass:ToUpper():Trim()
FOR nLine:=1 UPTO SELF:aLines:Count
	oLine:=SELF:GetLine(nLine)
	IF oLine:lEntity
		oEntity:=oLine:oEntity
		IF oEntity:eType == eType .and. oEntity:cTypedClassName:ToUpper() == cClass
			IF eType == EntityType._Constructor .or. oEntity:cName:ToUpper() == cName
				RETURN FALSE
			ENDIF
		END IF
	END IF
NEXT
nLine:=0
RETURN FALSE

METHOD DeleteEntity(eType AS EntityType,cName AS STRING,cClass AS STRING) AS LOGIC
	LOCAL nLine AS INT
RETURN SELF:DeleteEntity(eType , cName ,cClass , nLine)

METHOD DeleteEntity(eType AS EntityType,cName AS STRING,cClass AS STRING,nLine REF Int32) AS LOGIC
LOCAL oLine AS LineObject
LOCAL lExit AS LOGIC
LOCAL nOldLine AS INT
LOCAL cLine AS STRING
nOldLine := nLine
SELF:FindEntity(eType,cName,cClass,nLine)
IF nLine == 0
	nLine := nOldLine
	RETURN FALSE
ENDIF

DO WHILE nLine!=0
	SELF:RemoveWEDLine(nLine)
	SELF:ModifiedLine(nLine)
	IF nLine<=SELF:aLines:Count
		oLine:=SELF:GetLine(nLine)
		IF oLine:lEntity .or. lExit .or. oLine:IsEndClass
			EXIT
		END IF
		cLine := oLine:LineText:ToUpper()
		IF cLine:Contains("##USER##") .or. cLine:Contains("{{%UC%}}") .or. cLine:Contains("USER CODE STARTS")
			lExit := TRUE
		END IF
	ELSE
		EXIT
	END IF
END DO
SELF:CheckCreatedCode()
RETURN FALSE

METHOD AddInclude(cInclude AS STRING) AS VOID
	LOCAL oLine AS LineObject
	LOCAL nLine AS INT
	LOCAL n AS INT

	nLine := 1

	FOR n := 1 UPTO SELF:aLines:Count
		oLine := SELF:aLines[n - 1]
		DO CASE
		CASE oLine:lEntity
			nLine := n - 1
			EXIT
		CASE oLine:IsInclude .and. oLine:cArgument:ToUpper() == cInclude:ToUpper()
			RETURN
		END CASE
	NEXT
	IF nLine <= 0
		nLine := 1
	ENDIF

	SELF:AddWEDLine("#include " + e"\"" + cInclude + e"\"" , nLine)
	SELF:ModifiedLine(nLine)
RETURN

METHOD RemoveInclude(cInclude AS STRING) AS VOID
	FOR LOCAL nLine := 1 UPTO SELF:aLines:Count
		LOCAL oLine AS LineObject
		oLine := SELF:aLines[nLine - 1]
		DO CASE
		CASE oLine:lEntity
			RETURN
		CASE oLine:IsInclude .and. oLine:cArgument:ToUpper() == cInclude:ToUpper()
			SELF:RemoveWEDLine(nLine)
			SELF:ModifiedLine(nLine)
			RETURN
		END CASE
	NEXT
RETURN

METHOD AddLine(cLine AS STRING) AS VOID
	SELF:oEditor:AddLine(cLine)
	SELF:ModifiedLine(SELF:aLines:Count)
RETURN
METHOD InsertLine(nLine AS INT , cLine AS STRING) AS VOID
	SELF:oEditor:InsertLine(cLine , nLine)
	SELF:ModifiedLine(SELF:aLines:Count)
RETURN

METHOD AddWEDLine(cLine AS STRING,nLine REF Int32) AS LineObject
LOCAL oLine AS LineObject
IF nLine<=SELF:aLines:Count .and. nLine!=0
	SELF:oEditor:InsertLine(cLine , nLine)
	SELF:ModifiedLine(nLine)
ELSE
	SELF:oEditor:AddLine(cLine)
	nLine:=SELF:aLines:Count
	SELF:ModifiedLine(nLine)
END IF
oLine := SELF:GetLine(nLine)
nLine++
RETURN oLine
METHOD ReplaceWEDLine(cLine AS STRING,nLine AS Int32) AS LineObject
	SELF:oEditor:ReplaceLine(cLine , nLine)
	SELF:ModifiedLine(nLine)
RETURN SELF:GetLine(nLine)
METHOD RemoveWEDLine(nLine AS Int32) AS VOID
	SELF:oEditor:RemoveLine(nLine)
RETURN
METHOD Clear() AS VOID
	SELF:oEditor:DeleteAllLines()
RETURN

	STATIC PROTECT cUser := "// {{%UC%}} User code starts here (DO NOT remove this line)  " AS STRING
	STATIC PROTECT cTagU := "" AS STRING

	METHOD GetEntity(eType AS EntityType , cName AS STRING , cClass AS STRING) AS EntityObject
		LOCAL nLine AS INT
		nLine := SELF:FindEntity(eType , cName , cClass)
		IF nLine != 0
			RETURN SELF:GetLine(nLine):oEntity
		END IF
	RETURN NULL

	METHOD FindEntity(eType AS EntityType , cName AS STRING , cClass AS STRING) AS INT
		LOCAL nLine AS INT
		SELF:FindEntity(eType , cName , cClass , nLine)
	RETURN nLine

	METHOD WriteEntity(eType AS EntityType , cName AS STRING , cClass AS STRING , eOptions AS EntityOptions , aEntity AS List<STRING>) AS INT
		LOCAL oLine AS LineObject
		LOCAL nLine AS INT
		LOCAL nTemp AS INT
		LOCAL nFirst AS INT
		LOCAL lIsUser AS LOGIC
		LOCAL lRemoveFields AS LOGIC
		LOCAL n AS INT

		LOCAL cTab , ceTab AS STRING
		cTab := e"\t"
		ceTab := e"\t"

		IF aEntity:Count == 0
			RETURN 0
		END IF

		cClass := cClass:ToUpper()
		nLine := SELF:FindEntity(eType , cName , cClass)

		IF nLine == 0
			IF eType == EntityType._Class
				nLine := SELF:aLines:Count + 1
			ELSEIF eType == EntityType._Constructor
				nLine := SELF:FindEntity(EntityType._Class , cClass , cClass)
				IF nLine == 0
					RETURN 0
				END IF
				DO WHILE TRUE
					nLine ++
					IF nLine > SELF:aLines:Count
						EXIT
					END IF
					oLine := SELF:GetLine(nLine)
					IF oLine:lEntity .or. oLine:IsEndClass
						EXIT
					END IF
				END DO
			ELSE
				nLine := SELF:FindEntity(EntityType._Class , cClass , cClass)
				IF nLine == 0
					RETURN 0
				END IF
				DO WHILE TRUE
					nLine ++
					IF nLine > SELF:aLines:Count
						EXIT
					END IF
					oLine := SELF:GetLine(nLine)
					IF oLine:IsEndClass
						EXIT
					END IF
					IF oLine:lEntity .and. oLine:oEntity:cTypedClassName:ToUpper() != cClass
						EXIT
					END IF
				END DO
			END IF
			nFirst := nLine
		ELSE
			nFirst := nLine
			IF (eOptions & EntityOptions.NotOverwrite) == EntityOptions.NotOverwrite
				RETURN nFirst
			END IF
			oLine := SELF:GetLine(nLine)

			DO WHILE oLine:lOutAmpersand .and. (oLine:LineText:Contains("[") .or. oLine:LineText:Contains("]"))
				nLine ++
				oLine := SELF:GetLine(nLine)
			END DO

			IF (eOptions & EntityOptions.ClearOldFields) == EntityOptions.ClearOldFields
				lRemoveFields := FALSE
				nTemp := nLine
				nTemp ++
				DO WHILE nTemp <= SELF:aLines:Count
					oLine := SELF:GetLine(nTemp)
					IF oLine:lEntity
						EXIT
					END IF
					IF oLine:IsDesignerUserStart
						lRemoveFields := TRUE
						EXIT
					ENDIF
					nTemp ++
				END DO
			ELSE
				lRemoveFields := TRUE
			END IF

			IF lRemoveFields
				nTemp := nLine
				nTemp ++
				DO WHILE nTemp <= SELF:aLines:Count
					oLine := SELF:GetLine(nTemp)
					IF oLine:lEntity .or. oLine:IsEndClass
						EXIT
					END IF
					lIsUser := oLine:IsDesignerUserStart
					SELF:RemoveWEDLine(nTemp)
					IF lIsUser
						EXIT
					ENDIF
				END DO
			END IF

			IF SELF:GetLine(nLine):LineText:ToUpper() == aEntity[0]:ToUpper() .or. (eOptions & EntityOptions.KeepFirstLine) == EntityOptions.KeepFirstLine
				nLine ++
			ELSE
				SELF:ReplaceWEDLine(aEntity[0] , nLine)
				nLine ++
			END IF
			n := 1
		END IF

		DO WHILE n < aEntity:Count
			oLine := SELF:AddWEDLine(aEntity[n] , nLine)
			n ++
		END DO
		IF (eOptions & EntityOptions.AddUser) == EntityOptions.AddUser
			IF eType == EntityType._Class
				oLine := SELF:AddWEDLine(ceTab + cUser + cTagU , nLine)
			ELSE
				oLine := SELF:AddWEDLine(cTab + cUser + cTagU , nLine)
			END IF
		END IF

		IF eType != EntityType._Class
			IF nLine <= SELF:aLines:Count
				oLine := SELF:GetLine(nLine)
				IF oLine:LineText:Trim() != ""
					oLine := SELF:AddWEDLine("" , nLine)
				END IF
			END IF
		END IF

		SELF:CheckCreatedCode()
	RETURN nFirst

	METHOD WriteEndClass(cClass AS STRING) AS VOID
		LOCAL oLine AS LineObject
		LOCAL lFound AS LOGIC
		LOCAL nLine AS INT
		LOCAL n AS INT

		cClass := cClass:ToUpper()
		FOR n := 1 UPTO SELF:aLines:Count
			oLine := SELF:GetLine(n)
			IF lFound
				IF oLine:IsEndClass
					RETURN
				END IF
				IF oLine:lEntity .and. oLine:oEntity:cTypedClassName:ToUpper() != cClass
					EXIT
				END IF
				nLine := n + 1
			ELSE
				IF oLine:lEntity .and. oLine:oEntity:cTypedClassName:ToUpper() == cClass
					lFound := TRUE
					nLine := n + 1
				END IF
			END IF
		NEXT

		IF nLine != 0
			SELF:AddWEDLine("END CLASS" , nLine)
		END IF

	RETURN

	METHOD DeleteLine(nLine AS INT) AS VOID
		SELF:RemoveWEDLine(nLine)
		SELF:ModifiedLine(nLine)
	RETURN

	METHOD DeleteDefines(aDefines AS List<STRING>) AS VOID
		LOCAL oLine AS LineObject
		LOCAL nLine AS INT
		nLine := 1
		DO WHILE nLine <= SELF:aLines:Count
			LOCAL lDeleted := FALSE AS LOGIC
			oLine := SELF:aLines[nLine - 1]
			IF oLine:eType == LineType.Define .and. .not. String.IsNullOrEmpty(oLine:cArgument)
				FOREACH cDefine AS STRING IN aDefines
					IF cDefine:ToUpper() == oLine:cArgument:ToUpper()
						SELF:DeleteLine(nLine)
						lDeleted := TRUE
						EXIT
					END IF
				NEXT
			ELSEIF oLine:oEntity != NULL .and. oLine:oEntity:eType == EntityType._Define
				FOREACH cDefine AS STRING IN aDefines
					IF cDefine:ToUpper() == oLine:oEntity:cName:ToUpper()
						SELF:DeleteLine(nLine)
						lDeleted := TRUE
						EXIT
					END IF
				NEXT
			END IF
			IF .not. lDeleted
				nLine ++
			END IF
		END DO

		SELF:CheckCreatedCode()

	RETURN

	METHOD AddDefine(cDefine AS STRING , cValue AS STRING) AS VOID
		SELF:AddDefine(cDefine , cValue , TRUE)
	RETURN

	METHOD AddDefine(cDefine AS STRING , cValue AS STRING , lAdd AS LOGIC) AS VOID
		LOCAL cLine AS STRING
		cLine := String.Format("#define {0} {1}" , cDefine , cValue)
//		cLine := String.Format("DEFINE {0} := {1}" , cDefine , cValue)
		IF lAdd
			SELF:AddLine(cLine)
		ELSE
			SELF:InsertLine(1 , cLine)
		END IF
	RETURN

	METHOD AddDefines(aDefines AS List<STRING> , aDefineValues AS List<STRING>) AS VOID
		SELF:AddDefines(aDefines , aDefineValues , TRUE)
	RETURN

	METHOD AddDefines(aDefines AS List<STRING> , aDefineValues AS List<STRING> , lAdd AS LOGIC) AS VOID
		FOR LOCAL n := 0 AS INT UPTO aDefines:Count - 1
			SELF:AddDefine(aDefines[n] , aDefineValues[n] , lAdd)
		NEXT
	RETURN

	METHOD RemoveDefines(cWindowName as STRING) AS VOID
		LOCAL oLine AS LineObject
		LOCAL nLine AS INT
		nLine := 1
		cWindowName := cWindowName:ToUpper()+"_"
		DO WHILE nLine <= SELF:aLines:Count
			LOCAL lDeleted := FALSE AS LOGIC
			oLine := SELF:aLines[nLine - 1]
			IF oLine:eType == LineType.Define .and. .not. String.IsNullOrEmpty(oLine:cArgument)
				IF oLine:cArgument:ToUpper():StartsWith(cWindowName)
					SELF:DeleteLine(nLine)
					lDeleted := TRUE
				END IF
			ELSEIF oLine:oEntity != NULL .and. oLine:oEntity:eType == EntityType._Define
				IF oLine:oEntity:cName:ToUpper():StartsWith(cWindowName)
					SELF:DeleteLine(nLine)
					lDeleted := TRUE
				END IF
			END IF
			IF .not. lDeleted
				nLine ++
			END IF
		END DO
		SELF:CheckCreatedCode()
		RETURN

	METHOD AddXSharpDefines(aDefines AS List<STRING> , aDefineValues AS List<STRING>) AS VOID
		SELF:AddXSharpDefines(aDefines, aDefineValues, FALSE)

	METHOD AddXSharpDefines(aDefines AS List<STRING> , aDefineValues AS List<STRING>, lStatic AS LOGIC) AS VOID
		LOCAL cLine AS STRING
		LOCAL nLine AS INT
		FOR LOCAL n := 1 AS INT UPTO SELF:aLines:Count
			LOCAL oLine AS LineObject
			oLine := SELF:aLines[n-1]
			nLine := n
			DO CASE
			CASE oLine:oEntity != NULL
				EXIT
//			CASE oLine:IsRegionIn .and. oLine:cArgument:ToUpper() == "DEFINES"
			// grr, I am not setting cArgument for regions
			CASE oLine:IsRegionIn .and. oLine:LineText:ToUpper():Contains("DEFINES")
				nLine ++
				EXIT
			END CASE
		NEXT
		LOCAL cMask AS STRING
		cMask := "DEFINE {0} := {1}"
		IF lStatic
			cMask := "STATIC "+cMask
		ENDIF
		FOR LOCAL n := 0 AS INT UPTO aDefines:Count - 1
			cLine := String.Format(cMask , aDefines[n] , aDefineValues[n])
			SELF:InsertLine(nLine , cLine)
			nLine ++
		NEXT
	RETURN

END CLASS

[Flags];
ENUM EntityOptions
	MEMBER None := 0
	MEMBER AddUser := 1
	MEMBER NotOverwrite := 2
	MEMBER ClearOldFields := 4
	MEMBER KeepFirstLine := 8
END ENUM

END NAMESPACE


codegen/QtGui/QIconEnginePluginV2.prg: fixed