func.go 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*
  2. * Brawler
  3. *
  4. * Copyright 2019 Matthias Ladkau. All rights reserved.
  5. *
  6. * This Source Code Form is subject to the terms of the MIT
  7. * License, If a copy of the MIT License was not distributed with this
  8. * file, You can obtain one at https://opensource.org/licenses/MIT.
  9. */
  10. /*
  11. Package rumble contains all definitions which external code should use to
  12. integrate with Brawler.
  13. */
  14. package rumble
  15. /*
  16. Function is a function in Rumble.
  17. */
  18. type Function interface {
  19. /*
  20. Name returns the name of the function. A function should be camelCase
  21. and should only contain alphanumerical characters.
  22. */
  23. Name() string
  24. /*
  25. Validate is called to validate the number of arguments, check the
  26. environment and to execute any initialisation code which might be
  27. necessary for the function.
  28. */
  29. Validate(argsNum int, runtime Runtime) RuntimeError
  30. /*
  31. Execute executes the rumble function. This function might be called
  32. by several threads concurrently.
  33. */
  34. Execute(argsVal []interface{}, vars Variables, runtime Runtime) (interface{}, RuntimeError)
  35. }