Update functions to use the clone interface.

Change-Id: I6b4d6be5b1d963bc7d97851432e40844d3619d8d
This commit is contained in:
Felix Raimundo
2016-03-24 16:54:53 +01:00
parent f5f5399e92
commit 4707459a19
8 changed files with 46 additions and 4 deletions

View File

@@ -1,6 +1,19 @@
extern "C" {
#include <stdlib.h>
}
#include <poincare/function.h>
#include "layout/function_layout.h"
Function::Function(Expression * arg, char* function_name, bool clone_operands) {
m_arg = (Expression *)malloc(sizeof(Expression));
m_function_name = function_name;
if (clone_operands) {
m_arg = arg->clone();
} else {
m_arg = arg;
}
}
Function::~Function() {
delete m_arg;
}
@@ -8,3 +21,15 @@ Function::~Function() {
ExpressionLayout * Function::createLayout(ExpressionLayout * parent) {
return new FunctionLayout(parent, m_function_name, m_arg);
}
Expression * Function::operand(int i) {
if (i==0) {
return m_arg;
} else {
return nullptr;
}
}
int Function::numberOfOperands() {
return 1;
}