diff options
author | Dennis Kasprzyk <onestone@compiz-fusion.org> | 2008-12-24 12:10:17 +0100 |
---|---|---|
committer | Dennis Kasprzyk <onestone@compiz-fusion.org> | 2008-12-24 12:10:17 +0100 |
commit | a887aee6014a19fdf99bd72cb92730e4e2e2716d (patch) | |
tree | 7d0707085454a106f3b202b2a99200abd6cb6ce1 | |
parent | 40aec5975dda0a1d3eb4d5483636f4f4b12f11f9 (diff) | |
download | bcop-compiz++.tar.gz bcop-compiz++.tar.bz2 |
Initial compiz++ work.compiz++
-rw-r--r-- | src/bcop.xslt | 1532 |
1 files changed, 317 insertions, 1215 deletions
diff --git a/src/bcop.xslt b/src/bcop.xslt index 8f169d6..19b1c30 100644 --- a/src/bcop.xslt +++ b/src/bcop.xslt @@ -1,8 +1,8 @@ <!-- Compiz option code generator - Copyright : (C) 2007 by Dennis Kasprzyk - E-mail : onestone@beryl-project.org + Copyright : (C) 2008 by Dennis Kasprzyk + E-mail : onestone@compiz-fusion.org This program is free software; you can redistribute it and/or @@ -118,14 +118,6 @@ </xsl:call-template> </xsl:variable> -<!-- external parameters that could be passed to this document --> - - <xsl:param name="header">false</xsl:param> - <xsl:param name="source">false</xsl:param> - <xsl:param name="filename"><xsl:value-of select="$pName"/><xsl:text>_options.h</xsl:text></xsl:param> - <xsl:param name="metaname"><xsl:value-of select="$pName"/></xsl:param> - - <!-- global helper functions --> <xsl:template name="license"> @@ -145,8 +137,7 @@ <xsl:template name="printOptionsEnumName"> <xsl:value-of select="$Plugin"/> - <xsl:call-template name="screenOrDisplay"/> - <xsl:text>Option</xsl:text> + <xsl:text>Options::</xsl:text> <xsl:call-template name="PrintCamel"> <xsl:with-param name="text"> <xsl:value-of select="@name"/> @@ -154,7 +145,7 @@ </xsl:call-template> </xsl:template> - <xsl:template name="printOptionName"> + <xsl:template name="printOptionsEnumNamePure"> <xsl:call-template name="PrintCamel"> <xsl:with-param name="text"> <xsl:value-of select="@name"/> @@ -162,173 +153,19 @@ </xsl:call-template> </xsl:template> - <xsl:template name="screenOrDisplay"> - <xsl:if test="ancestor::display"> - <xsl:text>Display</xsl:text> - </xsl:if> - <xsl:if test="ancestor::screen"> - <xsl:text>Screen</xsl:text> - </xsl:if> - </xsl:template> - - <xsl:template name="baseType"> - <xsl:if test="ancestor::display"> - <xsl:text>CompDisplay *d</xsl:text> - </xsl:if> - <xsl:if test="ancestor::screen"> - <xsl:text>CompScreen *s</xsl:text> - </xsl:if> + <xsl:template name="printOptionName"> + <xsl:call-template name="PrintCamel"> + <xsl:with-param name="text"> + <xsl:value-of select="@name"/> + </xsl:with-param> + </xsl:call-template> </xsl:template> <!-- *** main block *** --> <xsl:template match="/compiz"> <xsl:if test="plugin[@useBcop = 'true']"> - <xsl:if test="$header = 'true'"> - <xsl:call-template name="hfile"/> - </xsl:if> - <xsl:if test="$source = 'true'"> - <xsl:call-template name="cfile"/> - </xsl:if> - </xsl:if> - </xsl:template> - -<!-- *** c source file generation *** --> - - <xsl:template name="cfile"> - <xsl:call-template name="license"/> - <xsl:text>#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include <compiz-core.h> - -</xsl:text> - <xsl:text>#include "</xsl:text> - <xsl:value-of select="$filename"/> - <xsl:text>" - -static int </xsl:text> - <xsl:value-of select="$Plugin"/> - <xsl:text>OptionsDisplayPrivateIndex; - -static CompMetadata </xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>OptionsMetadata; - -static CompPluginVTable *</xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>PluginVTable = NULL; -CompPluginVTable </xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>OptionsVTable; - -#define </xsl:text> - <xsl:value-of select="$PLUGIN"/> - <xsl:text>_OPTIONS_DISPLAY(d) PLUGIN_DISPLAY(d, </xsl:text> - <xsl:value-of select="$Plugin"/> - <xsl:text>Options, o) -#define </xsl:text> - <xsl:value-of select="$PLUGIN"/> - <xsl:text>_OPTIONS_SCREEN(s) PLUGIN_SCREEN(s, </xsl:text> - <xsl:value-of select="$Plugin"/> - <xsl:text>Options, o) - -typedef struct _</xsl:text> - <xsl:value-of select="$Plugin"/> - <xsl:text>OptionsDisplay -{ - int screenPrivateIndex; - -</xsl:text> - <xsl:if test="plugin[@name=$pName]/display/descendant-or-self::option"> - <xsl:text> CompOption opt[</xsl:text> - <xsl:value-of select="$Plugin"/> - <xsl:text>DisplayOptionNum]; - </xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>DisplayOptionChangeNotifyProc notify[</xsl:text> - <xsl:value-of select="$Plugin"/> - <xsl:text>DisplayOptionNum]; -</xsl:text> - <xsl:for-each select="plugin[@name=$pName]/display/descendant-or-self::option[@type = 'list' and ./desc/value and ./type/text() = 'int']"> - <xsl:text> unsigned int </xsl:text> - <xsl:value-of select="@name"/> - <xsl:text>; -</xsl:text> - </xsl:for-each> - </xsl:if> - <xsl:text>} </xsl:text> - <xsl:value-of select="$Plugin"/> - <xsl:text>OptionsDisplay; - -typedef struct _</xsl:text> - <xsl:value-of select="$Plugin"/> - <xsl:text>OptionsScreen -{ -</xsl:text> - <xsl:if test="plugin[@name=$pName]/screen/descendant-or-self::option"> - <xsl:text> CompOption opt[</xsl:text> - <xsl:value-of select="$Plugin"/> - <xsl:text>ScreenOptionNum]; - </xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>ScreenOptionChangeNotifyProc notify[</xsl:text> - <xsl:value-of select="$Plugin"/> - <xsl:text>ScreenOptionNum]; -</xsl:text> - <xsl:for-each select="plugin[@name=$pName]/screen/descendant-or-self::option[@type = 'list' and ./desc/value and ./type/text() = 'int']"> - <xsl:text> unsigned int </xsl:text> - <xsl:value-of select="@name"/> - <xsl:text>; -</xsl:text> - </xsl:for-each> - </xsl:if> - <xsl:text>} </xsl:text> - <xsl:value-of select="$Plugin"/> - <xsl:text>OptionsScreen; - -</xsl:text> - <xsl:call-template name="printFunctions"/> - <xsl:if test="/compiz/plugin[@name=$pName]/display/descendant-or-self::option"> - <xsl:call-template name="initDisplayOptions"/> - <xsl:call-template name="setDisplayOptions"/> - <xsl:call-template name="getDisplayOptions"/> - </xsl:if> - <xsl:if test="/compiz/plugin[@name=$pName]/screen/descendant-or-self::option"> - <xsl:call-template name="initScreenOptions"/> - <xsl:call-template name="setScreenOptions"/> - <xsl:call-template name="getScreenOptions"/> - </xsl:if> - <xsl:call-template name="initFiniScreen"/> - <xsl:call-template name="initFiniDisplay"/> - <xsl:call-template name="initFini"/> - <xsl:call-template name="initFiniObject"/> - <xsl:call-template name="getSetObject"/> - <xsl:call-template name="getVTable"/> - </xsl:template> - -<!-- helper functions --> - - <xsl:template name="initPrivate"> - <xsl:value-of select="$PLUGIN"/> - <xsl:text>_OPTIONS_</xsl:text> - <xsl:if test="ancestor::display"> - <xsl:text>DISPLAY(d); -</xsl:text> - </xsl:if> - <xsl:if test="ancestor::screen"> - <xsl:text>SCREEN(s); -</xsl:text> - </xsl:if> - </xsl:template> - - <xsl:template name="privateName"> - <xsl:if test="ancestor::display"> - <xsl:text>od</xsl:text> - </xsl:if> - <xsl:if test="ancestor::screen"> - <xsl:text>os</xsl:text> + <xsl:call-template name="hfile"/> </xsl:if> </xsl:template> @@ -338,335 +175,245 @@ typedef struct _</xsl:text> <xsl:for-each select="/compiz/plugin[@name=$pName]/descendant-or-self::option"> <xsl:choose> <xsl:when test="@type='int'"> - <xsl:text>int </xsl:text> + <xsl:text>inline int +</xsl:text> + <xsl:value-of select="$Plugin"/> + <xsl:text>Options::</xsl:text> <xsl:call-template name="printGetFunctionDef"/> <xsl:text> { - </xsl:text> - <xsl:call-template name="initPrivate"/> - <xsl:text> return </xsl:text> - <xsl:call-template name="privateName"/> - <xsl:text>->opt[</xsl:text> + return mOptions[</xsl:text> <xsl:call-template name="printOptionsEnumName"/> - <xsl:text>].value.i; + <xsl:text>].value ().i (); } </xsl:text> </xsl:when> <xsl:when test="@type='float'"> - <xsl:text>float </xsl:text> + <xsl:text>inline float +</xsl:text> + <xsl:value-of select="$Plugin"/> + <xsl:text>Options::</xsl:text> <xsl:call-template name="printGetFunctionDef"/> <xsl:text> { - </xsl:text> - <xsl:call-template name="initPrivate"/> - <xsl:text> return </xsl:text> - <xsl:call-template name="privateName"/> - <xsl:text>->opt[</xsl:text> + return mOptions[</xsl:text> <xsl:call-template name="printOptionsEnumName"/> - <xsl:text>].value.f; + <xsl:text>].value ().f (); } </xsl:text> </xsl:when> - <xsl:when test="@type='bool'"> - <xsl:text>Bool </xsl:text> + <xsl:when test="@type='bool'"> + <xsl:text>inline bool +</xsl:text> + <xsl:value-of select="$Plugin"/> + <xsl:text>Options::</xsl:text> <xsl:call-template name="printGetFunctionDef"/> <xsl:text> { - </xsl:text> - <xsl:call-template name="initPrivate"/> - <xsl:text> return </xsl:text> - <xsl:call-template name="privateName"/> - <xsl:text>->opt[</xsl:text> + return mOptions[</xsl:text> <xsl:call-template name="printOptionsEnumName"/> - <xsl:text>].value.b; + <xsl:text>].value ().b (); } </xsl:text> </xsl:when> - <xsl:when test="@type='string'"> - <xsl:text>char * </xsl:text> + <xsl:when test="@type='string'"> + <xsl:text>inline CompString +</xsl:text> + <xsl:value-of select="$Plugin"/> + <xsl:text>Options::</xsl:text> <xsl:call-template name="printGetFunctionDef"/> <xsl:text> { - </xsl:text> - <xsl:call-template name="initPrivate"/> - <xsl:text> return </xsl:text> - <xsl:call-template name="privateName"/> - <xsl:text>->opt[</xsl:text> + return mOptions[</xsl:text> <xsl:call-template name="printOptionsEnumName"/> - <xsl:text>].value.s; + <xsl:text>].value ().s (); } </xsl:text> </xsl:when> - <xsl:when test="@type='match'"> - <xsl:text>CompMatch * </xsl:text> + <xsl:when test="@type='match'"> + <xsl:text>inline CompMatch & +</xsl:text> + <xsl:value-of select="$Plugin"/> + <xsl:text>Options::</xsl:text> <xsl:call-template name="printGetFunctionDef"/> <xsl:text> { - </xsl:text> - <xsl:call-template name="initPrivate"/> - <xsl:text> return &</xsl:text> - <xsl:call-template name="privateName"/> - <xsl:text>->opt[</xsl:text> + return mOptions[</xsl:text> <xsl:call-template name="printOptionsEnumName"/> - <xsl:text>].value.match; + <xsl:text>].value ().match (); } </xsl:text> </xsl:when> <xsl:when test="@type='color'"> - <xsl:text>unsigned short * </xsl:text> + <xsl:text>inline unsigned short * +</xsl:text> + <xsl:value-of select="$Plugin"/> + <xsl:text>Options::</xsl:text> <xsl:call-template name="printGetFunctionDef"/> <xsl:text> { - </xsl:text> - <xsl:call-template name="initPrivate"/> - <xsl:text> return </xsl:text> - <xsl:call-template name="privateName"/> - <xsl:text>->opt[</xsl:text> + return mOptions[</xsl:text> <xsl:call-template name="printOptionsEnumName"/> - <xsl:text>].value.c; + <xsl:text>].value ().c (); } -unsigned short </xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>Get</xsl:text> +inline unsigned short +</xsl:text> + <xsl:value-of select="$Plugin"/> + <xsl:text>Options::optionGet</xsl:text> <xsl:call-template name="printOptionName"/> - <xsl:text>Red (</xsl:text> - <xsl:call-template name="baseType"/> - <xsl:text>) + <xsl:text>Red () { - </xsl:text> - <xsl:call-template name="initPrivate"/> - <xsl:text> return </xsl:text> - <xsl:call-template name="privateName"/> - <xsl:text>->opt[</xsl:text> + return mOptions[</xsl:text> <xsl:call-template name="printOptionsEnumName"/> - <xsl:text>].value.c[0]; + <xsl:text>].value ().c ()[0]; } -unsigned short </xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>Get</xsl:text> +inline unsigned short +</xsl:text> + <xsl:value-of select="$Plugin"/> + <xsl:text>Options::optionGet</xsl:text> <xsl:call-template name="printOptionName"/> - <xsl:text>Green (</xsl:text> - <xsl:call-template name="baseType"/> - <xsl:text>) + <xsl:text>Green () { - </xsl:text> - <xsl:call-template name="initPrivate"/> - <xsl:text> return </xsl:text> - <xsl:call-template name="privateName"/> - <xsl:text>->opt[</xsl:text> + return mOptions[</xsl:text> <xsl:call-template name="printOptionsEnumName"/> - <xsl:text>].value.c[1]; + <xsl:text>].value ().c ()[1]; } -unsigned short </xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>Get</xsl:text> + +inline unsigned short +</xsl:text> + <xsl:value-of select="$Plugin"/> + <xsl:text>Options::optionGet</xsl:text> <xsl:call-template name="printOptionName"/> - <xsl:text>Blue (</xsl:text> - <xsl:call-template name="baseType"/> - <xsl:text>) + <xsl:text>Blue () { - </xsl:text> - <xsl:call-template name="initPrivate"/> - <xsl:text> return </xsl:text> - <xsl:call-template name="privateName"/> - <xsl:text>->opt[</xsl:text> + return mOptions[</xsl:text> <xsl:call-template name="printOptionsEnumName"/> - <xsl:text>].value.c[2]; + <xsl:text>].value ().c ()[2]; } -unsigned short </xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>Get</xsl:text> + +inline unsigned short +</xsl:text> + <xsl:value-of select="$Plugin"/> + <xsl:text>Options::optionGet</xsl:text> <xsl:call-template name="printOptionName"/> - <xsl:text>Alpha (</xsl:text> - <xsl:call-template name="baseType"/> - <xsl:text>) + <xsl:text>Alpha () { - </xsl:text> - <xsl:call-template name="initPrivate"/> - <xsl:text> return </xsl:text> - <xsl:call-template name="privateName"/> - <xsl:text>->opt[</xsl:text> + return mOptions[</xsl:text> <xsl:call-template name="printOptionsEnumName"/> - <xsl:text>].value.c[3]; + <xsl:text>].value ().c ()[3]; } + </xsl:text> </xsl:when> - <xsl:when test="@type='action' or @type='key' or @type='button' or @type='edge' or @type='bell'"> - <xsl:text>CompAction * </xsl:text> + <xsl:when test="@type='action' or @type='key' or @type='button' or @type='edge' or @type='bell'"> + <xsl:text>inline CompAction & +</xsl:text> + <xsl:value-of select="$Plugin"/> + <xsl:text>Options::</xsl:text> <xsl:call-template name="printGetFunctionDef"/> <xsl:text> { - </xsl:text> - <xsl:call-template name="initPrivate"/> - <xsl:text> return &</xsl:text> - <xsl:call-template name="privateName"/> - <xsl:text>->opt[</xsl:text> + return mOptions[</xsl:text> <xsl:call-template name="printOptionsEnumName"/> - <xsl:text>].value.action; + <xsl:text>].value ().action (); } -void </xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>Set</xsl:text> +inline void +</xsl:text> + <xsl:value-of select="$Plugin"/> + <xsl:text>Options::optionSet</xsl:text> <xsl:call-template name="printOptionName"/> - <xsl:text>Initiate (</xsl:text> - <xsl:call-template name="baseType"/> - <xsl:text>, CompActionCallBackProc init) + <xsl:text>Initiate (CompAction::CallBack init) { - </xsl:text> - <xsl:call-template name="initPrivate"/> - <xsl:text> </xsl:text> - <xsl:call-template name="privateName"/> - <xsl:text>->opt[</xsl:text> + mOptions[</xsl:text> <xsl:call-template name="printOptionsEnumName"/> - <xsl:text>].value.action.initiate = init; + <xsl:text>].value ().action ().setInitiate (init); } -void </xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>Set</xsl:text> +inline void +</xsl:text> + <xsl:value-of select="$Plugin"/> + <xsl:text>Options::optionSet</xsl:text> <xsl:call-template name="printOptionName"/> - <xsl:text>Terminate (</xsl:text> - <xsl:call-template name="baseType"/> - <xsl:text>, CompActionCallBackProc term) + <xsl:text>Terminate (CompAction::CallBack term) { - </xsl:text> - <xsl:call-template name="initPrivate"/> - <xsl:text> </xsl:text> - <xsl:call-template name="privateName"/> - <xsl:text>->opt[</xsl:text> + mOptions[</xsl:text> <xsl:call-template name="printOptionsEnumName"/> - <xsl:text>].value.action.terminate = term; + <xsl:text>].value ().action ().setTerminate (term); } </xsl:text> </xsl:when> - <xsl:when test="@type='list'"> - <xsl:text>CompListValue * </xsl:text> + <xsl:when test="@type='list'"> + <xsl:text>inline CompOption::Value::Vector & +</xsl:text> + <xsl:value-of select="$Plugin"/> + <xsl:text>Options::</xsl:text> <xsl:call-template name="printGetFunctionDef"/> <xsl:text> { - </xsl:text> - <xsl:call-template name="initPrivate"/> - <xsl:text> return &</xsl:text> - <xsl:call-template name="privateName"/> - <xsl:text>->opt[</xsl:text> + return mOptions[</xsl:text> <xsl:call-template name="printOptionsEnumName"/> - <xsl:text>].value.list; + <xsl:text>].value ().list (); } </xsl:text> <xsl:if test="./type[text() = 'int']/../desc/value"> - <xsl:text>unsigned int </xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>Get</xsl:text> + <xsl:text>inline unsigned int +</xsl:text> + <xsl:value-of select="$Plugin"/> + <xsl:text>Options::optionGet</xsl:text> <xsl:call-template name="printOptionName"/> - <xsl:text>Mask (</xsl:text> - <xsl:call-template name="baseType"/> - <xsl:text>) + <xsl:text>Mask () { - </xsl:text> - <xsl:call-template name="initPrivate"/> - <xsl:text> return </xsl:text> - <xsl:call-template name="privateName"/> - <xsl:text>-></xsl:text> - <xsl:value-of select="@name"/> - <xsl:text>; + return m</xsl:text> + <xsl:call-template name="printOptionName"/> + <xsl:text>Mask; } </xsl:text> </xsl:if> </xsl:when> </xsl:choose> - <xsl:text>CompOption * </xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>Get</xsl:text> - <xsl:call-template name="printOptionName"/> - <xsl:text>Option (</xsl:text> - <xsl:call-template name="baseType"/> - <xsl:text>) -{ - </xsl:text> - <xsl:call-template name="initPrivate"/> - <xsl:text> return &</xsl:text> - <xsl:call-template name="privateName"/> - <xsl:text>->opt[</xsl:text> - <xsl:call-template name="printOptionsEnumName"/> - <xsl:text>]; -} - -void </xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>Set</xsl:text> - <xsl:call-template name="printOptionName"/> - <xsl:text>Notify (</xsl:text> - <xsl:call-template name="baseType"/> - <xsl:text>, </xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:call-template name="screenOrDisplay"/> - <xsl:text>OptionChangeNotifyProc notify) -{ - </xsl:text> - <xsl:call-template name="initPrivate"/> - <xsl:text> </xsl:text> - <xsl:call-template name="privateName"/> - <xsl:text>->notify[</xsl:text> - <xsl:call-template name="printOptionsEnumName"/> - <xsl:text>] = notify; -} -</xsl:text> - </xsl:for-each> - <xsl:if test="/compiz/plugin[@name=$pName]/display/descendant-or-self::option"> - <xsl:text>CompOption * </xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>GetDisplayOption (CompDisplay *d, </xsl:text> - <xsl:value-of select="$Plugin"/> - <xsl:text>DisplayOptions num) -{ - </xsl:text> - <xsl:value-of select="$PLUGIN"/> - <xsl:text>_OPTIONS_DISPLAY(d); - return &od->opt[num]; -} + <xsl:text> +inline void </xsl:text> - </xsl:if> - <xsl:if test="/compiz/plugin[@name=$pName]/screen/descendant-or-self::option"> - <xsl:text>CompOption * </xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>GetScreenOption (CompScreen *s, </xsl:text> + <xsl:value-of select="$Plugin"/> + <xsl:text>Options::optionSet</xsl:text> + <xsl:call-template name="printOptionName"/> + <xsl:text>Notify (</xsl:text> <xsl:value-of select="$Plugin"/> - <xsl:text>ScreenOptions num) + <xsl:text>Options::ChangeNotify notify) { - </xsl:text> - <xsl:value-of select="$PLUGIN"/> - <xsl:text>_OPTIONS_SCREEN(s); - return &os->opt[num]; + mNotify[</xsl:text> + <xsl:call-template name="printOptionsEnumName"/> + <xsl:text>] = notify; } </xsl:text> - </xsl:if> + </xsl:for-each> </xsl:template> <!-- initialze option functions generation --> - <xsl:template name="initDisplayOptions"> - <xsl:text>static const CompMetadataOptionInfo </xsl:text> + <xsl:template name="printOptionsInfo"> + <xsl:text>static const CompMetadata::OptionInfo </xsl:text> <xsl:value-of select="$plugin"/> - <xsl:text>OptionsDisplayOptionInfo[] = { + <xsl:text>OptionsOptionInfo[] = { </xsl:text> - <xsl:for-each select="/compiz/plugin[@name=$pName]/display/descendant-or-self::option"> + <xsl:for-each select="/compiz/plugin[@name=$pName]/descendant-or-self::option"> <xsl:call-template name="initOption"/> </xsl:for-each> <xsl:text>}; @@ -674,18 +421,6 @@ void </xsl:text> </xsl:text> </xsl:template> - <xsl:template name="initScreenOptions"> - <xsl:text>static const CompMetadataOptionInfo </xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>OptionsScreenOptionInfo[] = { -</xsl:text> - <xsl:for-each select="/compiz/plugin[@name=$pName]/screen/descendant-or-self::option"> - <xsl:call-template name="initOption"/> - </xsl:for-each> - <xsl:text>}; - -</xsl:text> - </xsl:template> <xsl:template name="initOption"> <xsl:text> { "</xsl:text> <xsl:value-of select="@name"/> @@ -713,672 +448,62 @@ void </xsl:text> </xsl:text> </xsl:template> -<!-- get option functions generation --> - - <xsl:template name="getDisplayOptions"> - <xsl:text>static CompOption * </xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>OptionsGetDisplayOptions (CompPlugin *plugin, CompDisplay *d, int *count) -{ - </xsl:text> - <xsl:value-of select="$PLUGIN"/> - <xsl:text>_OPTIONS_DISPLAY(d); - *count = </xsl:text> - <xsl:value-of select="$Plugin"/> - <xsl:text>DisplayOptionNum; - return od->opt; -} - -</xsl:text> - </xsl:template> - - <xsl:template name="getScreenOptions"> - <xsl:text>static CompOption * </xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>OptionsGetScreenOptions (CompPlugin *plugin, CompScreen *s, int *count) -{ - </xsl:text> - <xsl:value-of select="$PLUGIN"/> - <xsl:text>_OPTIONS_SCREEN(s); - *count = </xsl:text> - <xsl:value-of select="$Plugin"/> - <xsl:text>ScreenOptionNum; - return os->opt; -} - -</xsl:text> - </xsl:template> <!-- set option function generation --> - <xsl:template name="setDisplayOptions"> - <xsl:text>static Bool </xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>OptionsSetDisplayOption (CompPlugin *plugin, CompDisplay *d, const char *name, CompOptionValue *value) -{ - </xsl:text> - <xsl:value-of select="$PLUGIN"/> - <xsl:text>_OPTIONS_DISPLAY(d); - CompOption *o; - int index; + <xsl:template name="setOptions"> + <xsl:text> CompOption *o; + unsigned int index; - o = compFindOption (od->opt, </xsl:text> - <xsl:value-of select="$Plugin"/> - <xsl:text>DisplayOptionNum, name, &index); + o = CompOption::findOption (mOptions, name, &index); if (!o) - return FALSE; + return false; switch (index) { </xsl:text> - <xsl:for-each select="/compiz/plugin[@name=$pName]/display/descendant-or-self::option"> - <xsl:call-template name="setOption"/> - </xsl:for-each> - <xsl:text> default: - break; - } - return FALSE; -} - -</xsl:text> - </xsl:template> - - <xsl:template name="setScreenOptions"> - <xsl:text>static Bool </xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>OptionsSetScreenOption (CompPlugin *plugin, CompScreen *s, const char *name, CompOptionValue *value) -{ - </xsl:text> - <xsl:value-of select="$PLUGIN"/> - <xsl:text>_OPTIONS_SCREEN(s); - CompOption *o; - int index; - - o = compFindOption (os->opt, </xsl:text> - <xsl:value-of select="$Plugin"/> - <xsl:text>ScreenOptionNum, name, &index); - - if (!o) - return FALSE; - - switch (index) - { -</xsl:text> - <xsl:for-each select="/compiz/plugin[@name=$pName]/screen/descendant-or-self::option"> + <xsl:for-each select="/compiz/plugin[@name=$pName]/descendant-or-self::option"> <xsl:call-template name="setOption"/> </xsl:for-each> - <xsl:text> default: - break; + <xsl:text> default: + break; } - return FALSE; -} - + return false; </xsl:text> </xsl:template> <xsl:template name="setOption"> - <xsl:text> case </xsl:text> + <xsl:text> case </xsl:text> <xsl:call-template name="printOptionsEnumName"/> <xsl:text>: - if (</xsl:text> - <xsl:choose> - <xsl:when test="ancestor::display"> - <xsl:text>compSetDisplayOption (d, o, value))</xsl:text> - </xsl:when> - <xsl:when test="ancestor::screen"> - <xsl:text>compSetScreenOption (s, o, value))</xsl:text> - </xsl:when> - <xsl:otherwise> - <xsl:text>compSetOption (o, value))</xsl:text> - </xsl:otherwise> - </xsl:choose> - <xsl:text> - { + if (o->set (value)) + { </xsl:text> <xsl:if test="@type = 'list' and ./desc/value and ./type/text() = 'int'"> - <xsl:text> int i; - </xsl:text> - <xsl:call-template name="privateName"/> - <xsl:text>-></xsl:text> - <xsl:value-of select="@name"/> - <xsl:text> = 0; - for (i = 0; i < o->value.list.nValue; i++) - </xsl:text> - <xsl:call-template name="privateName"/> - <xsl:text>-></xsl:text> - <xsl:value-of select="@name"/> - <xsl:text> |= (1 << o->value.list.value[i].i); + <xsl:text> m</xsl:text> + <xsl:call-template name="printOptionName"/> + <xsl:text>Mask = 0; + foreach (CompOption::Value &val, o->value ().list ()) + m</xsl:text> + <xsl:call-template name="printOptionName"/> + <xsl:text>Mask |= (1 << val.i ()); </xsl:text> </xsl:if> - <xsl:text> if (</xsl:text> - <xsl:call-template name="privateName"/> - <xsl:text>->notify[</xsl:text> + <xsl:text> if (!mNotify[</xsl:text> <xsl:call-template name="printOptionsEnumName"/> - <xsl:text>]) - (*</xsl:text> - <xsl:call-template name="privateName"/> - <xsl:text>->notify[</xsl:text> + <xsl:text>].empty ()) + mNotify[</xsl:text> <xsl:call-template name="printOptionsEnumName"/> - <xsl:text>]) (</xsl:text> - <xsl:if test="ancestor::display"> - <xsl:text>d</xsl:text> - </xsl:if> - <xsl:if test="ancestor::screen"> - <xsl:text>s</xsl:text> - </xsl:if> - <xsl:text>, o, </xsl:text> + <xsl:text>] (o, </xsl:text> <xsl:call-template name="printOptionsEnumName"/> <xsl:text>); - return TRUE; - } - break; -</xsl:text> - </xsl:template> - - -<!-- init/fini screen --> - - <xsl:template name="initFiniScreen"> - <xsl:text>static Bool </xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>OptionsInitScreen (CompPlugin *p, CompScreen *s) -{ - </xsl:text> - <xsl:value-of select="$Plugin"/> - <xsl:text>OptionsScreen *os; - </xsl:text> - <xsl:if test="/compiz/plugin[@name=$pName]/screen/descendant-or-self::option[@type = 'list']/desc/value and - /compiz/plugin[@name=$pName]/screen/descendant-or-self::option[@type = 'list']/type/text() = 'int'"> - <xsl:text>CompOption *o; - int i; - </xsl:text> - </xsl:if> - <xsl:text> - </xsl:text> - <xsl:value-of select="$PLUGIN"/> - <xsl:text>_OPTIONS_DISPLAY (s->display); - - os = calloc (1, sizeof(</xsl:text> - <xsl:value-of select="$Plugin"/> - <xsl:text>OptionsScreen)); - if (!os) - return FALSE; - - s->base.privates[od->screenPrivateIndex].ptr = os; - - </xsl:text> - <xsl:if test="/compiz/plugin[@name=$pName]/screen/descendant-or-self::option"> - <xsl:text>if (!compInitScreenOptionsFromMetadata (s, &</xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>OptionsMetadata, </xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>OptionsScreenOptionInfo, os->opt, </xsl:text> - <xsl:value-of select="$Plugin"/> - <xsl:text>ScreenOptionNum)) - { - free (os); - return FALSE; - } -</xsl:text> - </xsl:if> - <xsl:for-each select="/compiz/plugin[@name=$pName]/screen/descendant-or-self::option"> - <xsl:if test="@type = 'list' and ./desc/value and ./type/text() = 'int'"> - <xsl:text> o = &os->opt[</xsl:text> - <xsl:call-template name="printOptionsEnumName"/> - <xsl:text>]; - </xsl:text> - <xsl:call-template name="privateName"/> - <xsl:text>-></xsl:text> - <xsl:value-of select="@name"/> - <xsl:text> = 0; - for (i = 0; i < o->value.list.nValue; i++) - </xsl:text> - <xsl:call-template name="privateName"/> - <xsl:text>-></xsl:text> - <xsl:value-of select="@name"/> - <xsl:text> |= (1 << o->value.list.value[i].i); - -</xsl:text> - </xsl:if> - - </xsl:for-each> - - <xsl:text> - return TRUE; -} - -static void </xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>OptionsFiniScreen (CompPlugin *p, CompScreen *s) -{ - </xsl:text> - <xsl:value-of select="$PLUGIN"/> - <xsl:text>_OPTIONS_SCREEN (s); - -</xsl:text> - <xsl:if test="/compiz/plugin[@name=$pName]/screen/descendant-or-self::option"> - <xsl:text> - compFiniScreenOptions (s, os->opt, </xsl:text> - <xsl:value-of select="$Plugin"/> - <xsl:text>ScreenOptionNum); - -</xsl:text> - </xsl:if> - <xsl:text> free (os); -} - -</xsl:text> - </xsl:template> - -<!-- init/fini display --> - - <xsl:template name="initFiniDisplay"> - <xsl:text>static Bool </xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>OptionsInitDisplay (CompPlugin *p, CompDisplay *d) -{ - </xsl:text> - <xsl:value-of select="$Plugin"/> - <xsl:text>OptionsDisplay *od; - </xsl:text> - <xsl:if test="/compiz/plugin[@name=$pName]/display/descendant-or-self::option[@type = 'list']/desc/value and - /compiz/plugin[@name=$pName]/display/descendant-or-self::option[@type = 'list']/type/text() = 'int'"> - <xsl:text>CompOption *o; - int i; - </xsl:text> - </xsl:if> - <xsl:text> - </xsl:text> - <xsl:text> - od = calloc (1, sizeof(</xsl:text> - <xsl:value-of select="$Plugin"/> - <xsl:text>OptionsDisplay)); - if (!od) - return FALSE; - - od->screenPrivateIndex = allocateScreenPrivateIndex(d); - if (od->screenPrivateIndex < 0) - { - free(od); - return FALSE; - } - - d->base.privates[</xsl:text> - <xsl:value-of select="$Plugin"/> - <xsl:text>OptionsDisplayPrivateIndex].ptr = od; - - </xsl:text> - <xsl:if test="/compiz/plugin[@name=$pName]/display/descendant-or-self::option"> - <xsl:text>if (!compInitDisplayOptionsFromMetadata (d, &</xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>OptionsMetadata, </xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>OptionsDisplayOptionInfo, od->opt, </xsl:text> - <xsl:value-of select="$Plugin"/> - <xsl:text>DisplayOptionNum)) - { - free (od); - return FALSE; - } -</xsl:text> - </xsl:if> - <xsl:for-each select="/compiz/plugin[@name=$pName]/display/descendant-or-self::option"> - <xsl:if test="@type = 'list' and ./desc/value and ./type/text() = 'int'"> - <xsl:text> o = &od->opt[</xsl:text> - <xsl:call-template name="printOptionsEnumName"/> - <xsl:text>]; - </xsl:text> - <xsl:call-template name="privateName"/> - <xsl:text>-></xsl:text> - <xsl:value-of select="@name"/> - <xsl:text> = 0; - for (i = 0; i < o->value.list.nValue; i++) - </xsl:text> - <xsl:call-template name="privateName"/> - <xsl:text>-></xsl:text> - <xsl:value-of select="@name"/> - <xsl:text> |= (1 << o->value.list.value[i].i); - -</xsl:text> - </xsl:if> - - </xsl:for-each> - <xsl:text> - return TRUE; -} - -static void </xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>OptionsFiniDisplay (CompPlugin *p, CompDisplay *d) -{ - </xsl:text> - <xsl:value-of select="$PLUGIN"/> - <xsl:text>_OPTIONS_DISPLAY (d); - - freeScreenPrivateIndex(d, od->screenPrivateIndex); -</xsl:text> - <xsl:if test="/compiz/plugin[@name=$pName]/display/descendant-or-self::option"> - <xsl:text> - compFiniDisplayOptions (d, od->opt, </xsl:text> - <xsl:value-of select="$Plugin"/> - <xsl:text>DisplayOptionNum); - -</xsl:text> - </xsl:if> - <xsl:text> free (od); -} - -</xsl:text> - </xsl:template> - -<!-- init/fini plugin --> - - <xsl:template name="initFini"> - <xsl:text>static Bool </xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>OptionsInit (CompPlugin *p) -{ - </xsl:text> - <xsl:value-of select="$Plugin"/> - <xsl:text>OptionsDisplayPrivateIndex = allocateDisplayPrivateIndex(); - if (</xsl:text> - <xsl:value-of select="$Plugin"/> - <xsl:text>OptionsDisplayPrivateIndex < 0) - return FALSE; - - if (!compInitPluginMetadataFromInfo (&</xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>OptionsMetadata, "</xsl:text> - <xsl:value-of select="$pName"/> - <xsl:text>",</xsl:text> - <xsl:choose> - <xsl:when test="/compiz/plugin[@name=$pName]/display/descendant-or-self::option"> - <xsl:value-of select="$plugin"/> - <xsl:text>OptionsDisplayOptionInfo, </xsl:text> - <xsl:value-of select="$Plugin"/> - <xsl:text>DisplayOptionNum, </xsl:text> - </xsl:when> - <xsl:otherwise> - <xsl:text>0, 0, </xsl:text> - </xsl:otherwise> - </xsl:choose> - <xsl:choose> - <xsl:when test="/compiz/plugin[@name=$pName]/screen/descendant-or-self::option"> - <xsl:value-of select="$plugin"/> - <xsl:text>OptionsScreenOptionInfo, </xsl:text> - <xsl:value-of select="$Plugin"/> - <xsl:text>ScreenOptionNum</xsl:text> - </xsl:when> - <xsl:otherwise> - <xsl:text>0, 0</xsl:text> - </xsl:otherwise> - </xsl:choose> -<xsl:text>)) - return FALSE; - - compAddMetadataFromFile (&</xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>OptionsMetadata, "</xsl:text> - <xsl:value-of select="$metaname"/> - <xsl:text>"); - if (</xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>PluginVTable && </xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>PluginVTable->init) - return </xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>PluginVTable->init (p); - return TRUE; -} - -static void </xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>OptionsFini (CompPlugin *p) -{ - if (</xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>PluginVTable && </xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>PluginVTable->fini) - </xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>PluginVTable->fini (p); - - if (</xsl:text> - <xsl:value-of select="$Plugin"/> - <xsl:text>OptionsDisplayPrivateIndex >= 0) - freeDisplayPrivateIndex (</xsl:text> - <xsl:value-of select="$Plugin"/> - <xsl:text>OptionsDisplayPrivateIndex); - - compFiniMetadata (&</xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>OptionsMetadata); -} - + return true; + } + break; </xsl:text> </xsl:template> -<!-- init/fini object plugin --> - - <xsl:template name="initFiniObject"> - <xsl:text>static CompBool </xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>OptionsInitObject (CompPlugin *p, CompObject *o) -{ - static InitPluginObjectProc dispTab[] = { - (InitPluginObjectProc) 0, - (InitPluginObjectProc) </xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>OptionsInitDisplay, - (InitPluginObjectProc) </xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>OptionsInitScreen - }; - - RETURN_DISPATCH (o, dispTab, ARRAY_SIZE (dispTab), TRUE, (p, o)); -} - -static void </xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>OptionsFiniObject (CompPlugin *p, CompObject *o) -{ - static FiniPluginObjectProc dispTab[] = { - (FiniPluginObjectProc) 0, - (FiniPluginObjectProc) </xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>OptionsFiniDisplay, - (FiniPluginObjectProc) </xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>OptionsFiniScreen - }; - - DISPATCH (o, dispTab, ARRAY_SIZE (dispTab), (p, o)); -} - -static CompBool </xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>OptionsInitObjectWrapper (CompPlugin *p, CompObject *o) -{ - CompBool rv = TRUE; - rv = </xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>OptionsInitObject (p, o); - if (</xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>PluginVTable->initObject) - rv &= </xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>PluginVTable->initObject (p, o); - return rv; -} - -static void </xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>OptionsFiniObjectWrapper (CompPlugin *p, CompObject *o) -{ - if (</xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>PluginVTable->finiObject) - </xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>PluginVTable->finiObject (p, o); - </xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>OptionsFiniObject (p, o); -} - -</xsl:text> - </xsl:template> - -<!-- get/set object options --> - - <xsl:template name="getSetObject"> - <xsl:text>static CompOption * </xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>OptionsGetObjectOptions (CompPlugin *p, CompObject *o, int *count) -{ - static GetPluginObjectOptionsProc dispTab[] = { - (GetPluginObjectOptionsProc) 0, - </xsl:text> - <xsl:if test="/compiz/plugin[@name=$pName]/display/descendant-or-self::option"> - <xsl:text> (GetPluginObjectOptionsProc) </xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>OptionsGetDisplayOptions, - </xsl:text> - </xsl:if> - <xsl:if test="not(/compiz/plugin[@name=$pName]/display/descendant-or-self::option)"> - <xsl:text> (GetPluginObjectOptionsProc) 0, - </xsl:text> - </xsl:if> - <xsl:if test="/compiz/plugin[@name=$pName]/screen/descendant-or-self::option"> - <xsl:text> (GetPluginObjectOptionsProc) </xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>OptionsGetScreenOptions - </xsl:text> - </xsl:if> - <xsl:text>}; - - *count = 0; - RETURN_DISPATCH (o, dispTab, ARRAY_SIZE (dispTab), - NULL, (p, o, count)); -} - -static CompBool </xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>OptionsSetObjectOption (CompPlugin *p, CompObject *o, const char *name, CompOptionValue *value) -{ - static SetPluginObjectOptionProc dispTab[] = { - (SetPluginObjectOptionProc) 0, - </xsl:text> - <xsl:if test="/compiz/plugin[@name=$pName]/display/descendant-or-self::option"> - <xsl:text> (SetPluginObjectOptionProc) </xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>OptionsSetDisplayOption, - </xsl:text> - </xsl:if> - <xsl:if test="not(/compiz/plugin[@name=$pName]/display/descendant-or-self::option)"> - <xsl:text> (SetPluginObjectOptionProc) 0, - </xsl:text> - </xsl:if> - <xsl:if test="/compiz/plugin[@name=$pName]/screen/descendant-or-self::option"> - <xsl:text> (SetPluginObjectOptionProc) </xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>OptionsSetScreenOption - </xsl:text> - </xsl:if> - <xsl:text>}; - - RETURN_DISPATCH (o, dispTab, ARRAY_SIZE (dispTab), FALSE, - (p, o, name, value)); -} - -</xsl:text> - </xsl:template> - -<!-- vtable generation --> - - <xsl:template name="getVTable"> - <xsl:text>static CompMetadata * -</xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>OptionsGetMetadata (CompPlugin *plugin) -{ - return &</xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>OptionsMetadata; -} - -</xsl:text> - <xsl:text>CompPluginVTable *getCompPluginInfo20070830 (void) -{ - if (!</xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>PluginVTable) - { - </xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>PluginVTable = </xsl:text> - <xsl:text>getCompPluginInfo (); - memcpy(&</xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>OptionsVTable, </xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>PluginVTable, sizeof(CompPluginVTable)); - </xsl:text> - - <xsl:value-of select="$plugin"/> - <xsl:text>OptionsVTable.getMetadata = </xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>OptionsGetMetadata; - </xsl:text> - - <xsl:value-of select="$plugin"/> - <xsl:text>OptionsVTable.init = </xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>OptionsInit; - </xsl:text> - - <xsl:value-of select="$plugin"/> - <xsl:text>OptionsVTable.fini = </xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>OptionsFini; - </xsl:text> - - <xsl:value-of select="$plugin"/> - <xsl:text>OptionsVTable.initObject = </xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>OptionsInitObjectWrapper; - </xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>OptionsVTable.finiObject = </xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>OptionsFiniObjectWrapper; - </xsl:text> - - <xsl:value-of select="$plugin"/> - <xsl:text>OptionsVTable.getObjectOptions = </xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>OptionsGetObjectOptions; - </xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>OptionsVTable.setObjectOption = </xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>OptionsSetObjectOption; - </xsl:text> - <xsl:text> - } - return &</xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>OptionsVTable; -} - -</xsl:text> - </xsl:template> - - <!-- *** header file generation *** --> <xsl:template name="hfile"> @@ -1390,134 +515,44 @@ static CompBool </xsl:text> <xsl:value-of select="$PLUGIN"/> <xsl:text>_OPTIONS_H -#include <compiz-common.h> - -COMPIZ_BEGIN_DECLS - -CompPluginVTable * getCompPluginInfo (void); +#include <core/core.h> </xsl:text> - <xsl:call-template name="printDisplayOptionsEnum"/> - <xsl:call-template name="printScreenOptionsEnum"/> - <xsl:call-template name="printOptionEnums"/> - <xsl:call-template name="printOptionMasks"/> - <xsl:call-template name="printFunctionDefinitions"/> - <xsl:text>#ifndef GENERIC_PRIVATE_DEFINES -#define GENERIC_PRIVATE_DEFINES - -#define GET_PLUGIN_CORE(object, plugin) \ - ((plugin##Core *) (object)->base.privates[plugin##CorePrivateIndex].ptr) -#define PLUGIN_CORE(object, plugin, prefix) \ - plugin##Core * prefix##c = GET_PLUGIN_CORE (object, plugin) - -#define GET_PLUGIN_DISPLAY(object, plugin) \ - ((plugin##Display *) \ - (object)->base.privates[plugin##DisplayPrivateIndex].ptr) -#define PLUGIN_DISPLAY(object, plugin, prefix) \ - plugin##Display * prefix##d = GET_PLUGIN_DISPLAY (object, plugin) - -#define GET_PLUGIN_SCREEN(object, parent, plugin) \ - ((plugin##Screen *) \ - (object)->base.privates[(parent)->screenPrivateIndex].ptr) -#define PLUGIN_SCREEN(object, plugin, prefix) \ - plugin##Screen * prefix##s = \ - GET_PLUGIN_SCREEN (object, \ - GET_PLUGIN_DISPLAY ((object)->display, plugin), plugin) - -#define GET_PLUGIN_WINDOW(object, parent, plugin) \ - ((plugin##Window *) \ - (object)->base.privates[(parent)->windowPrivateIndex].ptr) -#define PLUGIN_WINDOW(object, plugin, prefix) \ - plugin##Window * prefix##w = \ - GET_PLUGIN_WINDOW (object, \ - GET_PLUGIN_SCREEN ((object)->screen, \ - GET_PLUGIN_DISPLAY ((object)->screen->display, plugin), plugin), plugin) - -#endif - -COMPIZ_END_DECLS + <xsl:call-template name="printClass"/> + <xsl:text> #endif </xsl:text> </xsl:template> -<!-- enums for screen/display options --> +<!-- enum for options --> - <xsl:template name="printDisplayOptionsEnum"> -<xsl:text>typedef enum -{ + <xsl:template name="printOptionsEnum"> +<xsl:text>enum Options { </xsl:text> - <xsl:for-each select="/compiz/plugin[@name=$pName]/display/descendant-or-self::option"> - <xsl:text> </xsl:text> - <xsl:call-template name="printOptionsEnumName"/> + <xsl:for-each select="/compiz/plugin[@name=$pName]/descendant-or-self::option"> + <xsl:text> </xsl:text> + <xsl:call-template name="printOptionsEnumNamePure"/> <xsl:text>, </xsl:text> </xsl:for-each> - <xsl:text> </xsl:text> - <xsl:value-of select="$Plugin"/> - <xsl:text>DisplayOptionNum -</xsl:text> -<xsl:text>} </xsl:text> - <xsl:value-of select="$Plugin"/> -<xsl:text>DisplayOptions; - -typedef void (*</xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>DisplayOptionChangeNotifyProc) (CompDisplay *display, CompOption *opt, </xsl:text> - <xsl:value-of select="$Plugin"/> - <xsl:text>DisplayOptions num); - -CompOption *</xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>GetDisplayOption (CompDisplay *d, </xsl:text> - <xsl:value-of select="$Plugin"/> - <xsl:text>DisplayOptions num); + <xsl:text> OptionNum + }; </xsl:text> </xsl:template> - - <xsl:template name="printScreenOptionsEnum"> -<xsl:text>typedef enum -{ -</xsl:text> - <xsl:for-each select="/compiz/plugin[@name=$pName]/screen/descendant-or-self::option"> - <xsl:text> </xsl:text> - <xsl:call-template name="printOptionsEnumName"/> - <xsl:text>, -</xsl:text> - </xsl:for-each> - <xsl:text> </xsl:text> - <xsl:value-of select="$Plugin"/> - <xsl:text>ScreenOptionNum -</xsl:text> -<xsl:text>} </xsl:text> - <xsl:value-of select="$Plugin"/> -<xsl:text>ScreenOptions; -typedef void (*</xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>ScreenOptionChangeNotifyProc) (CompScreen *screen, CompOption *opt, </xsl:text> - <xsl:value-of select="$Plugin"/> - <xsl:text>ScreenOptions num); - -CompOption *</xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>GetScreenOption (CompScreen *s, </xsl:text> - <xsl:value-of select="$Plugin"/> - <xsl:text>ScreenOptions num); - -</xsl:text> - </xsl:template> <!-- generate enums/masks for restricted string options --> <xsl:template name="printOptionEnums"> <xsl:for-each select="/compiz/plugin[@name=$pName]/descendant-or-self::option[(@type = 'int' or (@type = 'list' and ./type/text() = 'int')) and ./desc/value]"> - <xsl:text>typedef enum -{ + <xsl:text> enum </xsl:text> + <xsl:call-template name="printOptionName"/> + <xsl:text> { </xsl:text> <xsl:for-each select="desc/*[(name() = 'name' and not(@xml:lang)) or name() = '_name']"> - <xsl:text> </xsl:text> + <xsl:text> </xsl:text> <xsl:call-template name="PrintCamel"> <xsl:with-param name="text"> <xsl:value-of select="../../@name"/> @@ -1533,10 +568,7 @@ CompOption *</xsl:text> <xsl:text>, </xsl:text> </xsl:for-each> - <xsl:text>} </xsl:text> - <xsl:value-of select="$Plugin"/> - <xsl:call-template name="printOptionName"/> - <xsl:text>Enum; + <xsl:text> }; </xsl:text> </xsl:for-each> @@ -1545,7 +577,7 @@ CompOption *</xsl:text> <xsl:template name="printOptionMasks"> <xsl:for-each select="/compiz/plugin[@name=$pName]/descendant-or-self::option[@type = 'list' and ./desc/value and ./type/text() = 'int']"> <xsl:for-each select="desc/*[(name() = 'name' and not(@xml:lang)) or name() = '_name']"> - <xsl:text>#define </xsl:text> + <xsl:text> #define </xsl:text> <xsl:call-template name="PrintCamel"> <xsl:with-param name="text"> <xsl:value-of select="../../@name"/> @@ -1569,139 +601,209 @@ CompOption *</xsl:text> <!-- generate get/set function definitions --> - <xsl:template name="printFunctionDefinitions"> + <xsl:template name="printClass"> + <xsl:text>class </xsl:text> + <xsl:value-of select="$Plugin"/> + <xsl:text>Options { + public: + </xsl:text> + <xsl:call-template name="printOptionsEnum"/> + <xsl:call-template name="printOptionEnums"/> + <xsl:call-template name="printOptionMasks"/> + <xsl:text> typedef boost::function <void (CompOption *opt, Options num)> ChangeNotify; + + </xsl:text> + <xsl:value-of select="$Plugin"/> + <xsl:text>Options (CompMetadata *); + virtual ~</xsl:text> + <xsl:value-of select="$Plugin"/> + <xsl:text>Options (); + + virtual CompOption::Vector & getOptions (); + virtual bool setOption (const char *name, CompOption::Value &value); + +</xsl:text> <xsl:for-each select="/compiz/plugin[@name=$pName]/descendant-or-self::option"> <xsl:choose> <xsl:when test="@type='int'"> - <xsl:text>int </xsl:text> + <xsl:text> int </xsl:text> <xsl:call-template name="printGetFunctionDef"/> <xsl:text>; </xsl:text> </xsl:when> <xsl:when test="@type='float'"> - <xsl:text>float </xsl:text> + <xsl:text> float </xsl:text> <xsl:call-template name="printGetFunctionDef"/> <xsl:text>; </xsl:text> </xsl:when> <xsl:when test="@type='bool'"> - <xsl:text>Bool </xsl:text> + <xsl:text> bool </xsl:text> <xsl:call-template name="printGetFunctionDef"/> <xsl:text>; </xsl:text> </xsl:when> <xsl:when test="@type='string'"> - <xsl:text>char * </xsl:text> + <xsl:text> CompString </xsl:text> <xsl:call-template name="printGetFunctionDef"/> <xsl:text>; </xsl:text> </xsl:when> <xsl:when test="@type='match'"> - <xsl:text>CompMatch * </xsl:text> + <xsl:text> CompMatch & </xsl:text> <xsl:call-template name="printGetFunctionDef"/> <xsl:text>; </xsl:text> </xsl:when> <xsl:when test="@type='color'"> - <xsl:text>unsigned short * </xsl:text> + <xsl:text> unsigned short * </xsl:text> <xsl:call-template name="printGetFunctionDef"/> <xsl:text>; -unsigned short </xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>Get</xsl:text> + unsigned short optionGet</xsl:text> <xsl:call-template name="printOptionName"/> - <xsl:text>Red (</xsl:text> - <xsl:call-template name="baseType"/> - <xsl:text>); -unsigned short </xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>Get</xsl:text> + <xsl:text>Red (); + unsigned short optionGet</xsl:text> <xsl:call-template name="printOptionName"/> - <xsl:text>Green (</xsl:text> - <xsl:call-template name="baseType"/> - <xsl:text>); -unsigned short </xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>Get</xsl:text> + <xsl:text>Green (); + unsigned short optionGet</xsl:text> <xsl:call-template name="printOptionName"/> - <xsl:text>Blue (</xsl:text> - <xsl:call-template name="baseType"/> - <xsl:text>); -unsigned short </xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>Get</xsl:text> + <xsl:text>Blue (); + unsigned short optionGet</xsl:text> <xsl:call-template name="printOptionName"/> - <xsl:text>Alpha (</xsl:text> - <xsl:call-template name="baseType"/> - <xsl:text>); + <xsl:text>Alpha (); </xsl:text> </xsl:when> <xsl:when test="@type='action' or @type='key' or @type='button' or @type='edge' or @type='bell'"> - <xsl:text>CompAction * </xsl:text> + <xsl:text> CompAction & </xsl:text> <xsl:call-template name="printGetFunctionDef"/> <xsl:text>; -void </xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>Set</xsl:text> + void </xsl:text> + <xsl:text>optionSet</xsl:text> <xsl:call-template name="printOptionName"/> - <xsl:text>Initiate (</xsl:text> - <xsl:call-template name="baseType"/> - <xsl:text>, CompActionCallBackProc init); -void </xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>Set</xsl:text> + <xsl:text>Initiate (CompAction::CallBack init); + void </xsl:text> + <xsl:text>optionSet</xsl:text> <xsl:call-template name="printOptionName"/> - <xsl:text>Terminate (</xsl:text> - <xsl:call-template name="baseType"/> - <xsl:text>, CompActionCallBackProc term); + <xsl:text>Terminate (CompAction::CallBack term); </xsl:text> </xsl:when> <xsl:when test="@type='list'"> - <xsl:text>CompListValue * </xsl:text> + <xsl:text> CompOption::Value::Vector & </xsl:text> <xsl:call-template name="printGetFunctionDef"/> <xsl:text>; </xsl:text> <xsl:if test="./type[text() = 'int']/../desc/value"> - <xsl:text>unsigned int </xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>Get</xsl:text> + <xsl:text> unsigned int optionGet</xsl:text> <xsl:call-template name="printOptionName"/> - <xsl:text>Mask (</xsl:text> - <xsl:call-template name="baseType"/> - <xsl:text>); + <xsl:text>Mask (); </xsl:text> </xsl:if> </xsl:when> </xsl:choose> - <xsl:text>CompOption * </xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>Get</xsl:text> - <xsl:call-template name="printOptionName"/> - <xsl:text>Option (</xsl:text> - <xsl:call-template name="baseType"/> - <xsl:text>); -void </xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>Set</xsl:text> + <xsl:text> void optionSet</xsl:text> <xsl:call-template name="printOptionName"/> - <xsl:text>Notify (</xsl:text> - <xsl:call-template name="baseType"/> - <xsl:text>, </xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:call-template name="screenOrDisplay"/> - <xsl:text>OptionChangeNotifyProc notify); + <xsl:text>Notify (ChangeNotify notify); + +</xsl:text> + </xsl:for-each> + <xsl:text> + protected: + CompOption::Vector mOptions; + private: + std::vector<ChangeNotify> mNotify; +</xsl:text> + <xsl:for-each select="plugin[@name=$pName]/descendant-or-self::option[@type = 'list' and ./desc/value and ./type/text() = 'int']"> + <xsl:text> unsigned int m</xsl:text> + <xsl:call-template name="printOptionName"/> + <xsl:text>Mask; </xsl:text> </xsl:for-each> + <xsl:text> +}; + + +</xsl:text> + <xsl:call-template name="printOptionsInfo"/> + <xsl:value-of select="$Plugin"/> + <xsl:text>Options::</xsl:text> + <xsl:value-of select="$Plugin"/> + <xsl:text>Options (CompMetadata *metadata) : + mOptions (</xsl:text> + <xsl:value-of select="$Plugin"/> + <xsl:text>Options::OptionNum), + mNotify (</xsl:text> + <xsl:value-of select="$Plugin"/> + <xsl:text>Options::OptionNum) +{ + metadata->addFromOptionInfo (</xsl:text> + <xsl:value-of select="$plugin"/> + <xsl:text>OptionsOptionInfo, </xsl:text> + <xsl:value-of select="$Plugin"/> + <xsl:text>Options::OptionNum); + metadata->addFromFile ("</xsl:text> + <xsl:value-of select="$plugin"/> + <xsl:text>"); + metadata->initOptions (</xsl:text> + <xsl:value-of select="$plugin"/> + <xsl:text>OptionsOptionInfo, </xsl:text> + <xsl:value-of select="$Plugin"/> + <xsl:text>Options::OptionNum, mOptions); + +</xsl:text> + <xsl:for-each select="/compiz/plugin[@name=$pName]/descendant-or-self::option"> + <xsl:if test="@type = 'list' and ./desc/value and ./type/text() = 'int'"> + <xsl:text> m</xsl:text> + <xsl:call-template name="printOptionName"/> + <xsl:text>Mask = 0; + foreach (CompOption::Value &val, mOptions[</xsl:text> + <xsl:call-template name="printOptionsEnumName"/> + <xsl:text>].value ().list ()) + m</xsl:text> + <xsl:call-template name="printOptionName"/> + <xsl:text>Mask |= (1 << val.i ()); +</xsl:text> + </xsl:if> + </xsl:for-each> + <xsl:text> +} + +</xsl:text> + <xsl:value-of select="$Plugin"/> + <xsl:text>Options::~</xsl:text> + <xsl:value-of select="$Plugin"/> + <xsl:text>Options () +{ +} + +CompOption::Vector & +</xsl:text> + <xsl:value-of select="$Plugin"/> + <xsl:text>Options::getOptions () +{ + return mOptions; +} + +bool +</xsl:text> + <xsl:value-of select="$Plugin"/> + <xsl:text>Options::setOption (const char *name, CompOption::Value &value) +{ +</xsl:text> + <xsl:call-template name="setOptions"/> + <xsl:text> +} + +</xsl:text><xsl:text> +</xsl:text> + + <xsl:call-template name="printFunctions"/> </xsl:template> <xsl:template name="printGetFunctionDef"> - <xsl:value-of select="$plugin"/> - <xsl:text>Get</xsl:text> + <xsl:text>optionGet</xsl:text> <xsl:call-template name="printOptionName"/> - <xsl:text> (</xsl:text> - <xsl:call-template name="baseType"/> - <xsl:text>)</xsl:text> + <xsl:text> ()</xsl:text> </xsl:template> </xsl:stylesheet> |