diff options
author | Dennis Kasprzyk <onestone@compiz-fusion.org> | 2009-03-15 15:39:29 +0100 |
---|---|---|
committer | Dennis kasprzyk <onestone@compiz-fusion.org> | 2009-03-15 15:39:29 +0100 |
commit | cb423b48a53ae10fd401d32a28c3e365a70b3b7e (patch) | |
tree | f1ac13a320700de284475a915d226c9f9d1a4d3c | |
parent | 3bb2c969c1c5549e9750832fe94152d80a2b54e4 (diff) | |
download | zcomp-cb423b48a53ae10fd401d32a28c3e365a70b3b7e.tar.gz zcomp-cb423b48a53ae10fd401d32a28c3e365a70b3b7e.tar.bz2 |
Initialize options without CompMetadata.
-rw-r--r-- | cmake/CompizBcop.cmake | 34 | ||||
-rw-r--r-- | xslt/bcop.xslt | 1174 |
2 files changed, 966 insertions, 242 deletions
diff --git a/cmake/CompizBcop.cmake b/cmake/CompizBcop.cmake index a818f61..0d00a95 100644 --- a/cmake/CompizBcop.cmake +++ b/cmake/CompizBcop.cmake @@ -18,30 +18,24 @@ endfunction () # prepare bcop build function (compiz_add_bcop_targets _plugin _file _sources) -# add_custom_command ( -# OUTPUT ${CMAKE_BINARY_DIR}/generated/${_plugin}_options.h -# COMMAND ${XSLTPROC_EXECUTABLE} -# --stringparam "header" "true" ${COMPIZ_BCOP_XSLT} -# ${_file} > ${CMAKE_BINARY_DIR}/generated/${_plugin}_options.h -# DEPENDS ${_file} -# ) -# add_custom_command ( -# OUTPUT ${CMAKE_BINARY_DIR}/generated/${_plugin}_options.cpp -# COMMAND ${XSLTPROC_EXECUTABLE} -# --stringparam "source" "true" ${COMPIZ_BCOP_XSLT} -# ${_file} > ${CMAKE_BINARY_DIR}/generated/${_plugin}_options.cpp -# DEPENDS ${_file} -# ${CMAKE_BINARY_DIR}/generated/${_plugin}_options.h -# ) -# set (${_sources} "${CMAKE_BINARY_DIR}/generated/${_plugin}_options.h;${CMAKE_BINARY_DIR}/generated/${_plugin}_options.cpp" PARENT_SCOPE) - add_custom_command ( OUTPUT ${CMAKE_BINARY_DIR}/generated/${_plugin}_options.h COMMAND ${XSLTPROC_EXECUTABLE} - ${COMPIZ_BCOP_XSLT} - ${_file} > ${CMAKE_BINARY_DIR}/generated/${_plugin}_options.h + -o ${CMAKE_BINARY_DIR}/generated/${_plugin}_options.h + --stringparam "file" "header" ${COMPIZ_BCOP_XSLT} + ${_file} + DEPENDS ${_file} + ) + add_custom_command ( + OUTPUT ${CMAKE_BINARY_DIR}/generated/${_plugin}_options.cpp + COMMAND ${XSLTPROC_EXECUTABLE} + -o ${CMAKE_BINARY_DIR}/generated/${_plugin}_options.cpp + --stringparam "file" "source" ${COMPIZ_BCOP_XSLT} + ${_file} > ${CMAKE_BINARY_DIR}/generated/${_plugin}_options.cpp DEPENDS ${_file} + ${CMAKE_BINARY_DIR}/generated/${_plugin}_options.h ) - set (${_sources} "${CMAKE_BINARY_DIR}/generated/${_plugin}_options.h" PARENT_SCOPE) + set (${_sources} "${CMAKE_BINARY_DIR}/generated/${_plugin}_options.h;${CMAKE_BINARY_DIR}/generated/${_plugin}_options.cpp" PARENT_SCOPE) + endfunction ()
\ No newline at end of file diff --git a/xslt/bcop.xslt b/xslt/bcop.xslt index 19b1c30..1f2c395 100644 --- a/xslt/bcop.xslt +++ b/xslt/bcop.xslt @@ -1,8 +1,8 @@ <!-- Compiz option code generator - Copyright : (C) 2008 by Dennis Kasprzyk - E-mail : onestone@compiz-fusion.org + Copyright : (C) 2009 by Dennis Kasprzyk + E-mail : onestone@compiz.org This program is free software; you can redistribute it and/or @@ -18,155 +18,62 @@ <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="text"/> -<!-- String conversion helper functions --> +<!-- external parameters that could be passed to this document --> - <xsl:template name="print"> - <xsl:param name="text"/> - <xsl:value-of select="translate($text,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')"/> - </xsl:template> - - <xsl:template name="PRINT"> - <xsl:param name="text"/> - <xsl:value-of select="translate($text,'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/> - </xsl:template> - - <xsl:template name="Print"> - <xsl:param name="text"/> - <xsl:call-template name="PRINT"> - <xsl:with-param name="text"> - <xsl:value-of select="substring($text,1,1)"/> - </xsl:with-param> - </xsl:call-template> - <xsl:call-template name="print"> - <xsl:with-param name="text"> - <xsl:value-of select="substring($text,2)"/> - </xsl:with-param> - </xsl:call-template> - </xsl:template> - - <xsl:template name="PrintCamel"> - <xsl:param name="text"/> - <xsl:variable name="textconv"> - <xsl:value-of select="translate($text,' +-/\','_____')"/> - </xsl:variable> - <xsl:if test="string-length($textconv)"> - <xsl:if test="contains($textconv,'_')"> - <xsl:call-template name="Print"> - <xsl:with-param name="text"> - <xsl:value-of select="substring-before($textconv,'_')"/> - </xsl:with-param> - </xsl:call-template> - <xsl:call-template name="PrintCamel"> - <xsl:with-param name="text"> - <xsl:value-of select="substring-after($textconv,'_')"/> - </xsl:with-param> - </xsl:call-template> - </xsl:if> - <xsl:if test="not(contains($textconv,'_'))"> - <xsl:call-template name="Print"> - <xsl:with-param name="text"> - <xsl:value-of select="$textconv"/> - </xsl:with-param> - </xsl:call-template> - </xsl:if> - </xsl:if> - </xsl:template> + <xsl:param name="file">header</xsl:param> - <xsl:template name="saveCName"> - <xsl:param name="text"/> - <xsl:variable name="textFirst"> - <xsl:value-of select="translate(substring($text,1,1),'0123456789 +-','zottffssen___')"/> - </xsl:variable> - <xsl:value-of select="concat($textFirst,substring($text,2))"/> +<!-- *** main block *** --> + + <xsl:template match="/compiz"> + <xsl:if test="plugin[@useBcop = 'true']"> + <xsl:choose> + <xsl:when test="$file = 'source'"> + <xsl:call-template name="sfile"/> + </xsl:when> + <xsl:otherwise> + <xsl:call-template name="hfile"/> + </xsl:otherwise> + </xsl:choose> + </xsl:if> </xsl:template> -<!-- Plugin name variables --> - - <xsl:variable name="pName"> - <xsl:value-of select="/compiz/plugin[@useBcop = 'true']/@name"/> - </xsl:variable> - - <xsl:variable name="pCName"> - <xsl:call-template name="saveCName"> - <xsl:with-param name="text"> - <xsl:value-of select="$pName"/> - </xsl:with-param> - </xsl:call-template> - </xsl:variable> - - <xsl:variable name="plugin"> - <xsl:call-template name="print"> - <xsl:with-param name="text"> - <xsl:value-of select="$pCName"/> - </xsl:with-param> - </xsl:call-template> - </xsl:variable> - - <xsl:variable name="Plugin"> - <xsl:call-template name="Print"> - <xsl:with-param name="text"> - <xsl:value-of select="$pCName"/> - </xsl:with-param> - </xsl:call-template> - </xsl:variable> +<!-- *** header file generation *** --> - <xsl:variable name="PLUGIN"> - <xsl:call-template name="PRINT"> - <xsl:with-param name="text"> - <xsl:value-of select="$pCName"/> - </xsl:with-param> - </xsl:call-template> - </xsl:variable> + <xsl:template name="hfile"> + <xsl:call-template name="license"/> + <xsl:text>#ifndef _</xsl:text> + <xsl:value-of select="$PLUGIN"/> + <xsl:text>_OPTIONS_H +#define _</xsl:text> + <xsl:value-of select="$PLUGIN"/> + <xsl:text>_OPTIONS_H -<!-- global helper functions --> +#include <core/core.h> - <xsl:template name="license"> -<xsl:text>/* - * This file is autogenerated with bcop: - * The Compiz option code generator - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - */ +</xsl:text> + <xsl:call-template name="printClass"/> + <xsl:call-template name="printFunctions"/> + <xsl:text> +#endif </xsl:text> </xsl:template> - <xsl:template name="printOptionsEnumName"> - <xsl:value-of select="$Plugin"/> - <xsl:text>Options::</xsl:text> - <xsl:call-template name="PrintCamel"> - <xsl:with-param name="text"> - <xsl:value-of select="@name"/> - </xsl:with-param> - </xsl:call-template> - </xsl:template> +<!-- *** cpp source file generation *** --> - <xsl:template name="printOptionsEnumNamePure"> - <xsl:call-template name="PrintCamel"> - <xsl:with-param name="text"> - <xsl:value-of select="@name"/> - </xsl:with-param> - </xsl:call-template> - </xsl:template> + <xsl:template name="sfile"> + <xsl:call-template name="license"/> + <xsl:text> +#include <core/core.h> - <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:call-template name="hfile"/> - </xsl:if> +#include "</xsl:text> + <xsl:value-of select="$plugin"/> + <xsl:text>_options.h" + +</xsl:text> + <xsl:call-template name="printConstructor"/> + <xsl:call-template name="printDestructor"/> + <xsl:call-template name="printBaseSetGet"/> </xsl:template> <!-- print get/set functions --> @@ -386,9 +293,7 @@ inline void </xsl:when> </xsl:choose> - <xsl:text> - -inline void + <xsl:text>inline void </xsl:text> <xsl:value-of select="$Plugin"/> <xsl:text>Options::optionSet</xsl:text> @@ -408,43 +313,486 @@ inline void <!-- initialze option functions generation --> - <xsl:template name="printOptionsInfo"> - <xsl:text>static const CompMetadata::OptionInfo </xsl:text> - <xsl:value-of select="$plugin"/> - <xsl:text>OptionsOptionInfo[] = { + <xsl:template name="initBoolValue"> + <xsl:param name="value"/> + <xsl:value-of select="$value"/> + <xsl:text>.set(</xsl:text> + <xsl:choose> + <xsl:when test="./text()"> + <xsl:call-template name="print"> + <xsl:with-param name="text"> + <xsl:value-of select="./text()"/> + </xsl:with-param> + </xsl:call-template> + </xsl:when> + <xsl:otherwise> + <xsl:text>false</xsl:text> + </xsl:otherwise> + </xsl:choose> + <xsl:text>); </xsl:text> - <xsl:for-each select="/compiz/plugin[@name=$pName]/descendant-or-self::option"> - <xsl:call-template name="initOption"/> + </xsl:template> + + <xsl:template name="initIntValue"> + <xsl:param name="value"/> + <xsl:value-of select="$value"/> + <xsl:text>.set((int) </xsl:text> + <xsl:choose> + <xsl:when test="./text()"> + <xsl:value-of select="./text()"/> + </xsl:when> + <xsl:otherwise> + <xsl:text>0</xsl:text> + </xsl:otherwise> + </xsl:choose> + <xsl:text>); +</xsl:text> + </xsl:template> + + <xsl:template name="initFloatValue"> + <xsl:param name="value"/> + <xsl:value-of select="$value"/> + <xsl:text>.set((float) </xsl:text> + <xsl:choose> + <xsl:when test="./text()"> + <xsl:value-of select="./text()"/> + </xsl:when> + <xsl:otherwise> + <xsl:text>0.0</xsl:text> + </xsl:otherwise> + </xsl:choose> + <xsl:text>); +</xsl:text> + </xsl:template> + + <xsl:template name="initStringValue"> + <xsl:param name="value"/> + <xsl:value-of select="$value"/> + <xsl:text>.set(CompString ("</xsl:text> + <xsl:choose> + <xsl:when test="./text()"> + <xsl:value-of select="./text()"/> + </xsl:when> + <xsl:otherwise> + <xsl:text></xsl:text> + </xsl:otherwise> + </xsl:choose> + <xsl:text>")); +</xsl:text> + </xsl:template> + + <xsl:template name="initMatchValue"> + <xsl:param name="value"/> + <xsl:value-of select="$value"/> + <xsl:text>.set(CompMatch ("</xsl:text> + <xsl:choose> + <xsl:when test="./text()"> + <xsl:value-of select="./text()"/> + </xsl:when> + <xsl:otherwise> + <xsl:text></xsl:text> + </xsl:otherwise> + </xsl:choose> + <xsl:text>")); +</xsl:text> + <xsl:value-of select="$value"/> + <xsl:text>.update (); +</xsl:text> + </xsl:template> + + <xsl:template name="initColorValue"> + <xsl:param name="value"/> + <xsl:text> color[0] = </xsl:text> + <xsl:choose> + <xsl:when test="./red/text()"> + <xsl:text>MAX (0, MIN (0xffff, </xsl:text> + <xsl:value-of select="./red/text()"/> + <xsl:text>)); +</xsl:text> + </xsl:when> + <xsl:otherwise> + <xsl:text>0; +</xsl:text> + </xsl:otherwise> + </xsl:choose> + <xsl:text> color[1] = </xsl:text> + <xsl:choose> + <xsl:when test="./green/text()"> + <xsl:text>MAX (0, MIN (0xffff, </xsl:text> + <xsl:value-of select="./green/text()"/> + <xsl:text>)); +</xsl:text> + </xsl:when> + <xsl:otherwise> + <xsl:text>0; +</xsl:text> + </xsl:otherwise> + </xsl:choose> + <xsl:text> color[2] = </xsl:text> + <xsl:choose> + <xsl:when test="./default/blue/text()"> + <xsl:text>MAX (0, MIN (0xffff, </xsl:text> + <xsl:value-of select="./blue/text()"/> + <xsl:text>)); +</xsl:text> + </xsl:when> + <xsl:otherwise> + <xsl:text>0; +</xsl:text> + </xsl:otherwise> + </xsl:choose> + <xsl:text> color[3] = </xsl:text> + <xsl:choose> + <xsl:when test="./default/alpha/text()"> + <xsl:text>MAX (0, MIN (0xffff, </xsl:text> + <xsl:value-of select="./alpha/text()"/> + <xsl:text>)); +</xsl:text> + </xsl:when> + <xsl:otherwise> + <xsl:text>0xffff; +</xsl:text> + </xsl:otherwise> + </xsl:choose> + <xsl:value-of select="$value"/> + <xsl:text>.set(color); +</xsl:text> + </xsl:template> + + <xsl:template name="initActionValue"> + <xsl:param name="value"/> + <xsl:value-of select="$value"/> + <xsl:text>.set(CompAction ()); +</xsl:text> + <xsl:value-of select="$value"/> + <xsl:text>.action ().setState (state); +</xsl:text> + </xsl:template> + + <xsl:template name="initKeyValue"> + <xsl:param name="value"/> + <xsl:text> action = CompAction (); +</xsl:text> + <xsl:text> action.setState (state | CompAction::StateInitKey); +</xsl:text> + <xsl:if test="./text() and ./text() != 'disabled'"> + <xsl:text> action.keyFromString ("</xsl:text> + <xsl:value-of select="./text()"/> + <xsl:text>"); +</xsl:text> + </xsl:if> + + <xsl:value-of select="$value"/> + <xsl:text>.set (action); +</xsl:text> + </xsl:template> + + <xsl:template name="initButtonValue"> + <xsl:param name="value"/> + <xsl:text> action = CompAction (); +</xsl:text> + <xsl:text> action.setState (state | CompAction::StateInitButton); +</xsl:text> + <xsl:if test="./text() and ./text() != 'disabled'"> + <xsl:text> action.buttonFromString ("</xsl:text> + <xsl:value-of select="./text()"/> + <xsl:text>"); +</xsl:text> + </xsl:if> + + <xsl:value-of select="$value"/> + <xsl:text>.set (action); +</xsl:text> + </xsl:template> + + <xsl:template name="initEdgeValue"> + <xsl:param name="value"/> + <xsl:text> action = CompAction (); +</xsl:text> + <xsl:text> action.setState (state | CompAction::StateInitEdge); +</xsl:text> + <xsl:text> edge = 0; +</xsl:text> + + <xsl:for-each select="./edge"> + <xsl:choose> + <xsl:when test="@name = 'Left'"> + <xsl:text> edge |= 1; +</xsl:text> + </xsl:when> + <xsl:when test="@name = 'Right'"> + <xsl:text> edge |= (1 << 1); +</xsl:text> + </xsl:when> + <xsl:when test="@name = 'Top'"> + <xsl:text> edge |= (1 << 2); +</xsl:text> + </xsl:when> + <xsl:when test="@name = 'Bottom'"> + <xsl:text> edge |= (1 << 3); +</xsl:text> + </xsl:when> + <xsl:when test="@name = 'TopLeft'"> + <xsl:text> edge |= (1 << 4); +</xsl:text> + </xsl:when> + <xsl:when test="@name = 'TopRight'"> + <xsl:text> edge |= (1 << 5); +</xsl:text> + </xsl:when> + <xsl:when test="@name = 'BottomLeft'"> + <xsl:text> edge |= (1 << 6); +</xsl:text> + </xsl:when> + <xsl:when test="@name = 'BottomRight'"> + <xsl:text> edge |= (1 << 7); +</xsl:text> + </xsl:when> + </xsl:choose> </xsl:for-each> - <xsl:text>}; + <xsl:text> action.setEdgeMask (edge); +</xsl:text> + + <xsl:value-of select="$value"/> + <xsl:text>.set (action); </xsl:text> </xsl:template> - <xsl:template name="initOption"> - <xsl:text> { "</xsl:text> - <xsl:value-of select="@name"/> - <xsl:text>", "</xsl:text> - <xsl:value-of select="@type"/> - <xsl:text>", </xsl:text> + <xsl:template name="initBellValue"> + <xsl:param name="value"/> + <xsl:text> action = CompAction (); +</xsl:text> + <xsl:text> action.setState (state | CompAction::StateInitButton); +</xsl:text> + <xsl:if test="./text() and ./text() = 'true'"> + <xsl:text> action.setBell (true); +</xsl:text> + </xsl:if> + + <xsl:value-of select="$value"/> + <xsl:text>.set (action); +</xsl:text> + </xsl:template> + + <xsl:template name="initListValue"> + <xsl:param name="value"/> + <xsl:value-of select="$value"/> + <xsl:text>.list ().clear (); + list.clear (); +</xsl:text> + <xsl:for-each select="./value"> + <xsl:choose> + <xsl:when test="../../type/text() = 'bool'"> + <xsl:call-template name="initBoolValue"> + <xsl:with-param name="value"> + <xsl:text> value</xsl:text> + </xsl:with-param> + </xsl:call-template> + </xsl:when> + <xsl:when test="../../type/text() = 'float'"> + <xsl:call-template name="initFloatValue"> + <xsl:with-param name="value"> + <xsl:text> value</xsl:text> + </xsl:with-param> + </xsl:call-template> + </xsl:when> + <xsl:when test="../../type/text() = 'int'"> + <xsl:call-template name="initIntValue"> + <xsl:with-param name="value"> + <xsl:text> value</xsl:text> + </xsl:with-param> + </xsl:call-template> + </xsl:when> + <xsl:when test="../../type/text() = 'string'"> + <xsl:call-template name="initStringValue"> + <xsl:with-param name="value"> + <xsl:text> value</xsl:text> + </xsl:with-param> + </xsl:call-template> + </xsl:when> + <xsl:when test="../../type/text() = 'match'"> + <xsl:call-template name="initMatchValue"> + <xsl:with-param name="value"> + <xsl:text> value</xsl:text> + </xsl:with-param> + </xsl:call-template> + </xsl:when> + <xsl:when test="../../type/text() = 'action'"> + <xsl:call-template name="initActionValue"> + <xsl:with-param name="value"> + <xsl:text> value</xsl:text> + </xsl:with-param> + </xsl:call-template> + </xsl:when> + <xsl:when test="../../type/text() = 'key'"> + <xsl:call-template name="initKeyValue"> + <xsl:with-param name="value"> + <xsl:text> value</xsl:text> + </xsl:with-param> + </xsl:call-template> + </xsl:when> + <xsl:when test="../../type/text() = 'button'"> + <xsl:call-template name="initButtonValue"> + <xsl:with-param name="value"> + <xsl:text> value</xsl:text> + </xsl:with-param> + </xsl:call-template> + </xsl:when> + <xsl:when test="../../type/text() = 'edge'"> + <xsl:call-template name="initEdgeValue"> + <xsl:with-param name="value"> + <xsl:text> value</xsl:text> + </xsl:with-param> + </xsl:call-template> + </xsl:when> + <xsl:when test="../../type/text() = 'bell'"> + <xsl:call-template name="initBellValue"> + <xsl:with-param name="value"> + <xsl:text> value</xsl:text> + </xsl:with-param> + </xsl:call-template> + </xsl:when> + </xsl:choose> + <xsl:text> list.push_back (value); +</xsl:text> + </xsl:for-each> + + <xsl:value-of select="$value"/> + <xsl:text>.set (</xsl:text> <xsl:choose> - <xsl:when test="(@type = 'int' or @type = 'float') and (./min/text() and ./max/text())"> - <xsl:text>"<min></xsl:text> + <xsl:when test="../type/text() = 'bool'"> + <xsl:text>CompOption::TypeBool</xsl:text> + </xsl:when> + <xsl:when test="../type/text() = 'int'"> + <xsl:text>CompOption::TypeInt</xsl:text> + </xsl:when> + <xsl:when test="../type/text() = 'float'"> + <xsl:text>CompOption::TypeFloat</xsl:text> + </xsl:when> + <xsl:when test="../type/text() = 'string'"> + <xsl:text>CompOption::TypeString</xsl:text> + </xsl:when> + <xsl:when test="../type/text() = 'color'"> + <xsl:text>CompOption::TypeColor</xsl:text> + </xsl:when> + <xsl:when test="../type/text() = 'action'"> + <xsl:text>CompOption::TypeAction</xsl:text> + </xsl:when> + <xsl:when test="../type/text() = 'key'"> + <xsl:text>CompOption::TypeKey</xsl:text> + </xsl:when> + <xsl:when test="../type/text() = 'button'"> + <xsl:text>CompOption::TypeButton</xsl:text> + </xsl:when> + <xsl:when test="../type/text() = 'edge'"> + <xsl:text>CompOption::TypeEdge</xsl:text> + </xsl:when> + <xsl:when test="../type/text() = 'bell'"> + <xsl:text>CompOption::TypeBell</xsl:text> + </xsl:when> + <xsl:when test="../type/text() = 'match'"> + <xsl:text>CompOption::TypeMatch</xsl:text> + </xsl:when> + </xsl:choose> + <xsl:text>, list); +</xsl:text> + + </xsl:template> + + <xsl:template name="initActionState"> + <xsl:choose> + <xsl:when test="./passive_grab/text() = 'false'"> + <xsl:text> state = 0; +</xsl:text> + </xsl:when> + <xsl:otherwise> + <xsl:text> state = CompAction::StateAutoGrab; +</xsl:text> + </xsl:otherwise> + </xsl:choose> + <xsl:if test="@type = 'edge' and ./nodelay/text() = 'true'"> + <xsl:text> state |= CompAction::StateNoEdgeDelay; +</xsl:text> + </xsl:if> + <xsl:if test="./allowed[@key = 'true']"> + <xsl:text> state |= CompAction::StateInitKey; +</xsl:text> + </xsl:if> + <xsl:if test="./allowed[@button = 'true']"> + <xsl:text> state |= CompAction::StateInitButton; +</xsl:text> + </xsl:if> + <xsl:if test="./allowed[@bell = 'true']"> + <xsl:text> state |= CompAction::StateInitBell; +</xsl:text> + </xsl:if> + <xsl:if test="./allowed[@edge = 'true']"> + <xsl:text> state |= CompAction::StateInitEdge; +</xsl:text> + </xsl:if> + <xsl:if test="./allowed[@edgednd = 'true']"> + <xsl:text> state |= CompAction::StateInitEdgeDnd; +</xsl:text> + </xsl:if> + </xsl:template> + + <xsl:template name="initIntRestriction"> + <xsl:param name="value"/> + <xsl:value-of select="$value"/> + <xsl:text>.rest ().set (</xsl:text> + <xsl:choose> + <xsl:when test="./min/text()"> <xsl:value-of select="./min/text()"/> - <xsl:text></min><max></xsl:text> + </xsl:when> + <xsl:otherwise> + <xsl:text>MINSHORT</xsl:text> + </xsl:otherwise> + </xsl:choose> + <xsl:text>, </xsl:text> + <xsl:choose> + <xsl:when test="./max/text()"> <xsl:value-of select="./max/text()"/> - <xsl:text></max>", </xsl:text> </xsl:when> - <xsl:when test="@type = 'list' and ./type/text()"> - <xsl:text>"<type></xsl:text> - <xsl:value-of select="./type/text()"/> - <xsl:text></type>", </xsl:text> + <xsl:otherwise> + <xsl:text>MAXSHORT</xsl:text> + </xsl:otherwise> + </xsl:choose> + <xsl:text>); +</xsl:text> + </xsl:template> + + <xsl:template name="initFloatRestriction"> + <xsl:param name="value"/> + <xsl:value-of select="$value"/> + <xsl:text>.rest ().set (</xsl:text> + <xsl:choose> + <xsl:when test="./min/text()"> + <xsl:value-of select="./min/text()"/> </xsl:when> <xsl:otherwise> - <xsl:text>0, </xsl:text> + <xsl:text>MINSHORT</xsl:text> </xsl:otherwise> </xsl:choose> - <xsl:text>0, 0 }, + <xsl:text>, </xsl:text> + <xsl:choose> + <xsl:when test="./max/text()"> + <xsl:value-of select="./max/text()"/> + </xsl:when> + <xsl:otherwise> + <xsl:text>MAXSHORT</xsl:text> + </xsl:otherwise> + </xsl:choose> + <xsl:text>, </xsl:text> + <xsl:choose> + <xsl:when test="./precision/text()"> + <xsl:value-of select="./precision/text()"/> + </xsl:when> + <xsl:otherwise> + <xsl:text>0.1f</xsl:text> + </xsl:otherwise> + </xsl:choose> + <xsl:text>); </xsl:text> </xsl:template> @@ -504,26 +852,7 @@ inline void </xsl:text> </xsl:template> -<!-- *** header file generation *** --> - - <xsl:template name="hfile"> - <xsl:call-template name="license"/> - <xsl:text>#ifndef _</xsl:text> - <xsl:value-of select="$PLUGIN"/> - <xsl:text>_OPTIONS_H -#define _</xsl:text> - <xsl:value-of select="$PLUGIN"/> - <xsl:text>_OPTIONS_H -#include <core/core.h> - -</xsl:text> - <xsl:call-template name="printClass"/> - <xsl:text> - -#endif -</xsl:text> - </xsl:template> <!-- enum for options --> @@ -614,7 +943,7 @@ inline void </xsl:text> <xsl:value-of select="$Plugin"/> - <xsl:text>Options (CompMetadata *); + <xsl:text>Options (); virtual ~</xsl:text> <xsl:value-of select="$Plugin"/> <xsl:text>Options (); @@ -724,11 +1053,46 @@ inline void </xsl:text> - <xsl:call-template name="printOptionsInfo"/> + </xsl:template> + + <xsl:template name="printGetFunctionDef"> + <xsl:text>optionGet</xsl:text> + <xsl:call-template name="printOptionName"/> + <xsl:text> ()</xsl:text> + </xsl:template> + + <!-- compiz set/getOption(s) function generation --> + + <xsl:template name="printBaseSetGet"> + <xsl:text> +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:template> + + <!-- constructor/destructor function generation --> + + <xsl:template name="printConstructor"> <xsl:value-of select="$Plugin"/> <xsl:text>Options::</xsl:text> <xsl:value-of select="$Plugin"/> - <xsl:text>Options (CompMetadata *metadata) : + <xsl:text>Options () : mOptions (</xsl:text> <xsl:value-of select="$Plugin"/> <xsl:text>Options::OptionNum), @@ -736,24 +1100,271 @@ inline void <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:if test="/compiz/plugin[@name=$pName]/descendant-or-self::option[@type = 'action'] or + /compiz/plugin[@name=$pName]/descendant-or-self::option[@type = 'key'] or + /compiz/plugin[@name=$pName]/descendant-or-self::option[@type = 'button'] or + /compiz/plugin[@name=$pName]/descendant-or-self::option[@type = 'edge'] or + /compiz/plugin[@name=$pName]/descendant-or-self::option[@type = 'bell'] or + /compiz/plugin[@name=$pName]/descendant-or-self::option[@type = 'list']/type/text() = 'action' or + /compiz/plugin[@name=$pName]/descendant-or-self::option[@type = 'list']/type/text() = 'key' or + /compiz/plugin[@name=$pName]/descendant-or-self::option[@type = 'list']/type/text() = 'button' or + /compiz/plugin[@name=$pName]/descendant-or-self::option[@type = 'list']/type/text() = 'edge' or + /compiz/plugin[@name=$pName]/descendant-or-self::option[@type = 'list']/type/text() = 'bell'"> + <xsl:text> unsigned int state; + CompAction action; +</xsl:text> + </xsl:if> + <xsl:if test="/compiz/plugin[@name=$pName]/descendant-or-self::option[@type = 'edge'] or + /compiz/plugin[@name=$pName]/descendant-or-self::option[@type = 'list']/type/text() = 'edge'"> + <xsl:text> unsigned int edge; +</xsl:text> + </xsl:if> +<xsl:if test="/compiz/plugin[@name=$pName]/descendant-or-self::option[@type = 'color'] or + /compiz/plugin[@name=$pName]/descendant-or-self::option[@type = 'list']/type/text() = 'color'"> + <xsl:text> unsigned short color[4]; +</xsl:text> + </xsl:if> + <xsl:if test="/compiz/plugin[@name=$pName]/descendant-or-self::option[@type = 'list']"> + <xsl:text> CompOption::Value::Vector list; + CompOption::Value value; +</xsl:text> + </xsl:if> + <xsl:for-each select="/compiz/plugin[@name=$pName]/descendant-or-self::option"> + <xsl:text> + // </xsl:text> + <xsl:value-of select="@name"/> + <xsl:text> +</xsl:text> + <xsl:variable name="opt"> + <xsl:text> mOptions[</xsl:text> + <xsl:call-template name="printOptionsEnumName"/> + <xsl:text>]</xsl:text> + </xsl:variable> + <xsl:choose> + <xsl:when test="@type='bool'"> + <xsl:for-each select="./default[1]"> + <xsl:call-template name="initBoolValue"> + <xsl:with-param name="value"> + <xsl:value-of select="$opt"/> + <xsl:text>.value()</xsl:text> + </xsl:with-param> + </xsl:call-template> + </xsl:for-each> + </xsl:when> + <xsl:when test="@type='float'"> + <xsl:call-template name="initFloatRestriction"> + <xsl:with-param name="value"> + <xsl:value-of select="$opt"/> + </xsl:with-param> + </xsl:call-template> + <xsl:for-each select="./default[1]"> + <xsl:call-template name="initFloatValue"> + <xsl:with-param name="value"> + <xsl:value-of select="$opt"/> + <xsl:text>.value()</xsl:text> + </xsl:with-param> + </xsl:call-template> + </xsl:for-each> + </xsl:when> + <xsl:when test="@type='int'"> + <xsl:call-template name="initIntRestriction"> + <xsl:with-param name="value"> + <xsl:value-of select="$opt"/> + </xsl:with-param> + </xsl:call-template> + <xsl:for-each select="./default[1]"> + <xsl:call-template name="initIntValue"> + <xsl:with-param name="value"> + <xsl:value-of select="$opt"/> + <xsl:text>.value()</xsl:text> + </xsl:with-param> + </xsl:call-template> + </xsl:for-each> + </xsl:when> + <xsl:when test="@type='string'"> + <xsl:for-each select="./default[1]"> + <xsl:call-template name="initStringValue"> + <xsl:with-param name="value"> + <xsl:value-of select="$opt"/> + <xsl:text>.value()</xsl:text> + </xsl:with-param> + </xsl:call-template> + </xsl:for-each> + </xsl:when> + <xsl:when test="@type='match'"> + <xsl:for-each select="./default[1]"> + <xsl:call-template name="initMatchValue"> + <xsl:with-param name="value"> + <xsl:value-of select="$opt"/> + <xsl:text>.value()</xsl:text> + </xsl:with-param> + </xsl:call-template> + </xsl:for-each> + </xsl:when> + <xsl:when test="@type='color'"> + <xsl:for-each select="./default[1]"> + <xsl:call-template name="initColorValue"> + <xsl:with-param name="value"> + <xsl:value-of select="$opt"/> + <xsl:text>.value()</xsl:text> + </xsl:with-param> + </xsl:call-template> + </xsl:for-each> + </xsl:when> + <xsl:when test="@type='action'"> + <xsl:call-template name="initActionState"/> + </xsl:when> + <xsl:when test="@type='key'"> + <xsl:call-template name="initActionState"/> + <xsl:for-each select="./default[1]"> + <xsl:call-template name="initKeyValue"> + <xsl:with-param name="value"> + <xsl:value-of select="$opt"/> + <xsl:text>.value()</xsl:text> + </xsl:with-param> + </xsl:call-template> + </xsl:for-each> + <xsl:if test="not (./passive_grab/text() = 'false')"> + <xsl:text> screen->addAction (&</xsl:text> + <xsl:text>mOptions[</xsl:text> + <xsl:call-template name="printOptionsEnumName"/> + <xsl:text>].value ().action ()); +</xsl:text> + </xsl:if> + </xsl:when> + <xsl:when test="@type='button'"> + <xsl:call-template name="initActionState"/> + <xsl:for-each select="./default[1]"> + <xsl:call-template name="initButtonValue"> + <xsl:with-param name="value"> + <xsl:value-of select="$opt"/> + <xsl:text>.value()</xsl:text> + </xsl:with-param> + </xsl:call-template> + </xsl:for-each> + <xsl:if test="not (./passive_grab/text() = 'false')"> + <xsl:text> screen->addAction (&</xsl:text> + <xsl:text>mOptions[</xsl:text> + <xsl:call-template name="printOptionsEnumName"/> + <xsl:text>].value ().action ()); +</xsl:text> + </xsl:if> + </xsl:when> + <xsl:when test="@type='edge'"> + <xsl:call-template name="initActionState"/> + <xsl:for-each select="./default[1]"> + <xsl:call-template name="initEdgeValue"> + <xsl:with-param name="value"> + <xsl:value-of select="$opt"/> + <xsl:text>.value()</xsl:text> + </xsl:with-param> + </xsl:call-template> + </xsl:for-each> + <xsl:if test="not (./passive_grab/text() = 'false')"> + <xsl:text> screen->addAction (&</xsl:text> + <xsl:text>mOptions[</xsl:text> + <xsl:call-template name="printOptionsEnumName"/> + <xsl:text>].value ().action ()); +</xsl:text> + </xsl:if> + </xsl:when> + <xsl:when test="@type='bell'"> + <xsl:call-template name="initActionState"/> + <xsl:for-each select="./default[1]"> + <xsl:call-template name="initBellValue"> + <xsl:with-param name="value"> + <xsl:value-of select="$opt"/> + <xsl:text>.value()</xsl:text> + </xsl:with-param> + </xsl:call-template> + </xsl:for-each> + <xsl:if test="not (./passive_grab/text() = 'false')"> + <xsl:text> screen->addAction (&</xsl:text> + <xsl:text>mOptions[</xsl:text> + <xsl:call-template name="printOptionsEnumName"/> + <xsl:text>].value ().action ()); +</xsl:text> + </xsl:if> + </xsl:when> + <xsl:when test="@type='list'"> + <xsl:if test="not (./default[1])"> + <xsl:value-of select="$opt"/> + <xsl:text>.set (</xsl:text> + <xsl:choose> + <xsl:when test="./type/text() = 'bool'"> + <xsl:text>CompOption::TypeBool</xsl:text> + </xsl:when> + <xsl:when test="./type/text() = 'int'"> + <xsl:text>CompOption::TypeInt</xsl:text> + </xsl:when> + <xsl:when test="./type/text() = 'float'"> + <xsl:text>CompOption::TypeFloat</xsl:text> + </xsl:when> + <xsl:when test="./type/text() = 'string'"> + <xsl:text>CompOption::TypeString</xsl:text> + </xsl:when> + <xsl:when test="./type/text() = 'color'"> + <xsl:text>CompOption::TypeColor</xsl:text> + </xsl:when> + <xsl:when test="./type/text() = 'action'"> + <xsl:text>CompOption::TypeAction</xsl:text> + </xsl:when> + <xsl:when test="./type/text() = 'key'"> + <xsl:text>CompOption::TypeKey</xsl:text> + </xsl:when> + <xsl:when test="./type/text() = 'button'"> + <xsl:text>CompOption::TypeButton</xsl:text> + </xsl:when> + <xsl:when test="./type/text() = 'edge'"> + <xsl:text>CompOption::TypeEdge</xsl:text> + </xsl:when> + <xsl:when test="./type/text() = 'bell'"> + <xsl:text>CompOption::TypeBell</xsl:text> + </xsl:when> + <xsl:when test="./type/text() = 'match'"> + <xsl:text>CompOption::TypeMatch</xsl:text> + </xsl:when> + </xsl:choose> + <xsl:text>, CompOption::Value::Vector (0)); +</xsl:text> + </xsl:if> + <xsl:choose> + <xsl:when test="./type/text () = 'int'"> + <xsl:call-template name="initIntRestriction"> + <xsl:with-param name="value"> + <xsl:value-of select="$opt"/> + </xsl:with-param> + </xsl:call-template> + </xsl:when> + <xsl:when test="./type/text () = 'float'"> + <xsl:call-template name="initFloatRestriction"> + <xsl:with-param name="value"> + <xsl:value-of select="$opt"/> + </xsl:with-param> + </xsl:call-template> + </xsl:when> + <xsl:when test="./type/text () = 'action' or ./type/text () = 'key' or ./type/text () = 'button' or ./type/text () = 'edge' or ./type/text () = 'bell'"> + <xsl:call-template name="initActionState"/> + </xsl:when> + </xsl:choose> + <xsl:for-each select="./default[1]"> + <xsl:call-template name="initListValue"> + <xsl:with-param name="value"> + <xsl:value-of select="$opt"/> + <xsl:text>.value()</xsl:text> + </xsl:with-param> + </xsl:call-template> + </xsl:for-each> + </xsl:when> + </xsl:choose> + </xsl:for-each> + + <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:text> + m</xsl:text> <xsl:call-template name="printOptionName"/> <xsl:text>Mask = 0; foreach (CompOption::Value &val, mOptions[</xsl:text> @@ -769,6 +1380,9 @@ inline void } </xsl:text> + </xsl:template> + + <xsl:template name="printDestructor"> <xsl:value-of select="$Plugin"/> <xsl:text>Options::~</xsl:text> <xsl:value-of select="$Plugin"/> @@ -776,34 +1390,150 @@ inline void { } -CompOption::Vector & </xsl:text> - <xsl:value-of select="$Plugin"/> - <xsl:text>Options::getOptions () -{ - return mOptions; -} + </xsl:template> -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> -} + <!-- String conversion helper functions --> + + <xsl:template name="print"> + <xsl:param name="text"/> + <xsl:value-of select="translate($text,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')"/> + </xsl:template> + + <xsl:template name="PRINT"> + <xsl:param name="text"/> + <xsl:value-of select="translate($text,'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/> + </xsl:template> + + <xsl:template name="Print"> + <xsl:param name="text"/> + <xsl:call-template name="PRINT"> + <xsl:with-param name="text"> + <xsl:value-of select="substring($text,1,1)"/> + </xsl:with-param> + </xsl:call-template> + <xsl:call-template name="print"> + <xsl:with-param name="text"> + <xsl:value-of select="substring($text,2)"/> + </xsl:with-param> + </xsl:call-template> + </xsl:template> + + <xsl:template name="PrintCamel"> + <xsl:param name="text"/> + <xsl:variable name="textconv"> + <xsl:value-of select="translate($text,' +-/\','_____')"/> + </xsl:variable> + <xsl:if test="string-length($textconv)"> + <xsl:if test="contains($textconv,'_')"> + <xsl:call-template name="Print"> + <xsl:with-param name="text"> + <xsl:value-of select="substring-before($textconv,'_')"/> + </xsl:with-param> + </xsl:call-template> + <xsl:call-template name="PrintCamel"> + <xsl:with-param name="text"> + <xsl:value-of select="substring-after($textconv,'_')"/> + </xsl:with-param> + </xsl:call-template> + </xsl:if> + <xsl:if test="not(contains($textconv,'_'))"> + <xsl:call-template name="Print"> + <xsl:with-param name="text"> + <xsl:value-of select="$textconv"/> + </xsl:with-param> + </xsl:call-template> + </xsl:if> + </xsl:if> + </xsl:template> + + <xsl:template name="saveCName"> + <xsl:param name="text"/> + <xsl:variable name="textFirst"> + <xsl:value-of select="translate(substring($text,1,1),'0123456789 +-','zottffssen___')"/> + </xsl:variable> + <xsl:value-of select="concat($textFirst,substring($text,2))"/> + </xsl:template> + +<!-- Plugin name variables --> + + <xsl:variable name="pName"> + <xsl:value-of select="/compiz/plugin[@useBcop = 'true']/@name"/> + </xsl:variable> + + <xsl:variable name="pCName"> + <xsl:call-template name="saveCName"> + <xsl:with-param name="text"> + <xsl:value-of select="$pName"/> + </xsl:with-param> + </xsl:call-template> + </xsl:variable> + + <xsl:variable name="plugin"> + <xsl:call-template name="print"> + <xsl:with-param name="text"> + <xsl:value-of select="$pCName"/> + </xsl:with-param> + </xsl:call-template> + </xsl:variable> + + <xsl:variable name="Plugin"> + <xsl:call-template name="Print"> + <xsl:with-param name="text"> + <xsl:value-of select="$pCName"/> + </xsl:with-param> + </xsl:call-template> + </xsl:variable> + + <xsl:variable name="PLUGIN"> + <xsl:call-template name="PRINT"> + <xsl:with-param name="text"> + <xsl:value-of select="$pCName"/> + </xsl:with-param> + </xsl:call-template> + </xsl:variable> + + <!-- global helper functions --> + + <xsl:template name="license"> +<xsl:text>/* + * This file is autogenerated with bcop: + * The Compiz option code generator + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ -</xsl:text><xsl:text> </xsl:text> + </xsl:template> + + <xsl:template name="printOptionsEnumName"> + <xsl:value-of select="$Plugin"/> + <xsl:text>Options::</xsl:text> + <xsl:call-template name="PrintCamel"> + <xsl:with-param name="text"> + <xsl:value-of select="@name"/> + </xsl:with-param> + </xsl:call-template> + </xsl:template> - <xsl:call-template name="printFunctions"/> + <xsl:template name="printOptionsEnumNamePure"> + <xsl:call-template name="PrintCamel"> + <xsl:with-param name="text"> + <xsl:value-of select="@name"/> + </xsl:with-param> + </xsl:call-template> </xsl:template> - <xsl:template name="printGetFunctionDef"> - <xsl:text>optionGet</xsl:text> - <xsl:call-template name="printOptionName"/> - <xsl:text> ()</xsl:text> + <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> </xsl:stylesheet> |