Created
November 24, 2009 16:20
-
-
Save willb/241988 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'spqr/spqr' | |
| require 'spqr/app' | |
| require 'examples/codegen/EchoAgent' | |
| app = SPQR::App.new(:loglevel => :debug) | |
| app.register Examples::Codegen::EchoAgent | |
| app.main |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <schema package="examples.codegen"> | |
| <class name="EchoAgent"> | |
| <method name="echo" desc="returns its argument"> | |
| <arg name="arg" dir="IO" type="lstr"/> | |
| </method> | |
| </class> | |
| </schema> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module Examples | |
| module Codegen | |
| class EchoAgent | |
| include SPQR::Manageable | |
| # Find method (NB: you must implement this) | |
| def EchoAgent.find_by_id(objid) | |
| EchoAgent.new | |
| end | |
| # Find-all method (NB: you must implement this) | |
| def EchoAgent.find_all | |
| [EchoAgent.new] | |
| end | |
| ### Schema method declarations | |
| # echo returns its argument | |
| # * arg (lstr/IO) | |
| # | |
| def echo(args) | |
| # Print values of in/out parameters | |
| log.debug "arg => #{args["arg"]}" # | |
| # Assign values to in/out parameters | |
| args["arg"] = args["arg"] | |
| end | |
| spqr_expose :echo do |args| | |
| args.declare :arg, :lstr, :inout, {} | |
| end | |
| end | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module Examples | |
| module Codegen | |
| class EchoAgent | |
| include SPQR::Manageable | |
| # Find method (NB: you must implement this) | |
| def EchoAgent.find_by_id(objid) | |
| EchoAgent.new | |
| end | |
| # Find-all method (NB: you must implement this) | |
| def EchoAgent.find_all | |
| [EchoAgent.new] | |
| end | |
| ### Schema method declarations | |
| # echo returns its argument | |
| # * arg (lstr/IO) | |
| # | |
| def echo(args) | |
| # Print values of in/out parameters | |
| log.debug "arg => #{args["arg"]}" # | |
| # Assign values to in/out parameters | |
| args["arg"] = args["arg"] | |
| end | |
| spqr_expose :echo do |args| | |
| args.declare :arg, :lstr, :inout, {} | |
| end | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment