Paula Script
Loading...
Searching...
No Matches
args.h
Go to the documentation of this file.
1#pragma once
2#include "defs.h"
3#include "array.h"
4#include "tree.h"
5#include "stack.h"
6
7using namespace paula::core;
8
9namespace paula
10{
11 namespace core
12 {
13 class Engine;
14 }
18 class Var
19 {
20 public:
25 INT type() const;
30 INT size() const;
36 bool match(INT tag) const;
42 bool getInt(INT& out) const;
48 bool getDouble(DOUBLE& out) const;
54 bool getBool(bool& out) const;
60 bool getOp(char& out) const;
66 bool getChars(char*&out) const;
71 bool isSubtree() const;
72
73 friend class Args;
74 friend class core::Tree;
75 friend class core::TreeIterator;
76 friend class core::Stack;
77 friend class core::StackIterator;
78 friend class core::Engine;
79 private:
80 const INT* ptr; // pointer to a data tag in a tree. volatile, as data can change
81 Var(const INT*_ptr);
82 Var();
83 };
87 class Args
88 {
89 public:
94 INT count();
99 void returnInt(INT value);
104 void returnBool(bool value);
116 Var get(INT dataIndex);
117
118 void print();
119
120 friend class Engine;
121
122 private:
123 Args();
124 Args(Engine*_engine, INT* _stackBase);
125
126 Engine*engine;
127 INT*stackBase;
128
129 static INT emptyData;
130
131 friend class Var;
132 friend class core::Engine;
133
134 };
135
136 /*
137 class ArgDef
138 {
139 public:
140 ArgDef(INT size);
141
142 bool match(Tree&);
143 bool match(TreeIterator&);
144
145 Array<INT>types;
146
147 private:
148
149 ArgDef() = delete;
150 };
151 */
152}
Access callback arguments (e.g. value of "a" in "f(a)"). Set return value of the callback function,...
Definition args.h:88
friend class Engine
Definition args.h:120
bool hasReturnValue()
Check if a return value is set.
Var get(INT dataIndex)
Get argument value, eg. get(2) to value of c if the call is "f(a, b, c)".
INT count()
Get number of arguments, eg. 3 for "f(a, b, c)".
friend class core::Engine
Definition args.h:132
void print()
void returnInt(INT value)
Set return value, returned by a callback.
void returnBool(bool value)
Set return value, returned by a callback.
void returnData(Var x)
Access Paula script variable data.
Definition args.h:19
friend class core::StackIterator
Definition args.h:77
bool getOp(char &out) const
Write variable's operation character (eg. '+' or '<') to reference, if variable is of correct type.
bool getBool(bool &out) const
Write variable's boolean value to reference, if variable is of correct type.
INT size() const
Get node size.
INT type() const
Get variable type, eg. NODE_INTEGER. See node_types.h.
bool getDouble(DOUBLE &out) const
Write variable's double (64-bit floating point) value to reference, if variable is of correct type.
friend class core::TreeIterator
Definition args.h:75
bool match(INT tag) const
Compare node (variable) type.
friend class core::Stack
Definition args.h:76
friend class core::Engine
Definition args.h:78
bool getChars(char *&out) const
Write variable's text value (char*) to reference, if variable is of correct type.
friend class core::Tree
Definition args.h:74
bool getInt(INT &out) const
Write variable's integer (32 bits) value to reference, if variable is of correct type.
bool isSubtree() const
Check if a variable is a subtree.
Definition args.h:12
Definition paula.h:7