Permalink
Browse files

Getting ready to improve native function resolution and definition.

  • Loading branch information...
Aaron Leung
Aaron Leung committed Aug 31, 2012
1 parent ec64161 commit d74cdbb2c0de72495a7b6b79bfe9445e5758e50e
Showing with 39 additions and 32 deletions.
  1. +8 −32 context.hpp
  2. +2 −0 document.hpp
  3. +2 −0 error.hpp
  4. +2 −0 eval_apply.hpp
  5. +16 −0 functions.cpp
  6. +5 −0 functions.hpp
  7. +2 −0 node_factory.hpp
  8. +2 −0 sass_interface.h
View
@@ -1,47 +1,23 @@
#define SASS_CONTEXT
-#ifndef SASS_ENVIRONMENT
+//#ifndef SASS_ENVIRONMENT
#include "environment.hpp"
-#endif
+//#endif
#include <utility>
+
+#ifndef SASS_NODE_FACTORY
#include "node_factory.hpp"
+#endif
+
+#ifndef SASS_FUNCTIONS
#include "functions.hpp"
+#endif
namespace Sass {
using std::pair;
using std::map;
- // struct Environment {
- // map<Token, Node> current_frame;
- // Environment* parent;
- // Environment* global;
-
- // Environment()
- // : current_frame(map<Token, Node>()), parent(0), global(0)
- // { }
-
- // void link(Environment& env)
- // {
- // parent = &env;
- // global = parent->global ? parent->global : parent;
- // }
-
- // bool query(const Token& key) const
- // {
- // if (current_frame.count(key)) return true;
- // else if (parent) return parent->query(key);
- // else return false;
- // }
-
- // Node& operator[](const Token& key)
- // {
- // if (current_frame.count(key)) return current_frame[key];
- // else if (parent) return (*parent)[key];
- // else return current_frame[key];
- // }
- // };
-
struct Context {
Environment global_env;
map<string, Function> function_env;
View
@@ -1,3 +1,5 @@
+#define SASS_DOCUMENT
+
#include <map>
#ifndef SASS_PRELEXER
View
@@ -1,3 +1,5 @@
+#define SASS_ERROR
+
namespace Sass {
struct Error {
View
@@ -1,3 +1,5 @@
+#define SASS_EVAL_APPLY
+
#include <map>
#ifndef SASS_NODE
View
@@ -1,14 +1,25 @@
#ifndef SASS_PRELEXER
#include "prelexer.hpp"
#endif
+
#include "node_factory.hpp"
#include "functions.hpp"
+#include "context.hpp"
#include "error.hpp"
+
#include <iostream>
#include <cmath>
+
using std::cerr; using std::endl;
namespace Sass {
+
+ Function::Function(const char* signature, Primitive ip, Node_Factory& new_Node)
+ {
+ //Document sig_doc(Document::make_from_source_chars(
+ }
+
+
namespace Functions {
static void throw_eval_error(string message, string path, size_t line)
@@ -19,6 +30,11 @@ namespace Sass {
throw Error(Error::evaluation, path, line, message);
}
+ extern const char foo_sig[] = "foo($x, $y, $z: hey hey)";
+ Node foo(const Node parameters, Environment& bindings, Node_Factory& new_Node) {
+ return Node();
+ }
+
// RGB Functions ///////////////////////////////////////////////////////
Function_Descriptor rgb_descriptor =
View
@@ -1,3 +1,5 @@
+#define SASS_FUNCTIONS
+
#include <cstring>
#include <map>
@@ -26,6 +28,7 @@ namespace Sass {
Function()
{ /* TO DO: set up the generic callback here */ }
+ // for user-defined functions
Function(Node def)
: name(def[0].to_string()),
parameters(def[1]),
@@ -42,6 +45,8 @@ namespace Sass {
primitive(0),
overloaded(overloaded)
{ }
+
+ Function(const char* signature, Primitive ip, Node_Factory& new_Node);
Function(Function_Descriptor d, Primitive ip, Node_Factory& new_Node)
: name(d[0]),
View
@@ -1,3 +1,5 @@
+#define SASS_NODE_FACTORY
+
#include <vector>
#ifndef SASS_NODE
View
@@ -1,3 +1,5 @@
+#define SASS_INTERFACE
+
#ifdef __cplusplus
extern "C" {
#endif

0 comments on commit d74cdbb

Please sign in to comment.