xquery/XQuery__SmallScriptFunctionLibrary.st
author Patrik Svestka <patrik.svestka@gmail.com>
Wed, 14 Nov 2018 13:13:37 +0100
changeset 306 fb9d45df523b
parent 296 ea3dbc023c80
permissions -rw-r--r--
Issue #239: Fix all Smalltak/X source files to be in unicode (UTF8 without BOM) and prefixed by "{ Encoding: utf8 }" when any unicode character is present - All source *.st files are now Unicode UTF8 without BOM Files are in two groups (fileOut works this way in Smalltalk/X): - containing a unicode character have "{ Encoding: utf8 }" at the header - ASCII only are without the header

"{ Package: 'stx:goodies/xmlsuite/xquery' }"

"{ NameSpace: XQuery }"

FunctionLibrary subclass:#SmallScriptFunctionLibrary
	instanceVariableNames:'interpreter'
	classVariableNames:''
	poolDictionaries:''
	category:'XQuery-Libraries'
!


!SmallScriptFunctionLibrary class methodsFor:'function library API'!

namespaceURI
    "Superclass XQuery::FunctionLibrary class says that I am responsible to implement this method"

    ^'http://smalltalk.felk.cvut.cz/ns/smallscript-library'

    "Created: / 01-12-2008 / 10:20:37 / Jan Vrany <vranyj1@fel.cvut.cz>"
! !

!SmallScriptFunctionLibrary methodsFor:'function library API'!

defaultPrefix
    "Superclass XQuery::FunctionLibrary says that I am responsible to implement this method"

    ^'smallscript'

    "Created: / 01-12-2008 / 10:20:37 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

functionLocalNames
    "Superclass XQuery::FunctionLibrary says that I am responsible to implement this method"

    ^#(
        'div'
    )

    "Created: / 01-12-2008 / 10:20:37 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

performPrimitive:function withArguments:parameters 
    |args f|

    args := parameters collect:[:param | param asInteger ].
    f := interpreter compileFunction:(self 
                        perform:(self class smalltalkize:function localName) asSymbol).
    ^ XQuerySequence 
        withNumber:(interpreter evaluateFunction:f withArguments:args)

    "Created: / 20-01-2009 / 09:35:17 / Jan Vrany <vranyj1@fel.cvut.cz>"
! !

!SmallScriptFunctionLibrary methodsFor:'initialization'!

initialize

    interpreter := SmallScript::Interpreter new

    "Created: / 01-12-2008 / 11:29:58 / Jan Vrany <vranyj1@fel.cvut.cz>"
! !

!SmallScriptFunctionLibrary methodsFor:'smalltscript:*'!

div

    ^'function div ( a , b ) {
return a / b;
}'

    "Created: / 01-12-2008 / 10:22:18 / Jan Vrany <vranyj1@fel.cvut.cz>"
! !

!SmallScriptFunctionLibrary class methodsFor:'documentation'!

version
    ^'$Id$'
!

version_SVN
    ^ '$Id$'
! !