This patch adds a 'include' directive to comp. It inserts the include
file near the beginning of the generated C file. For instance:
include "myheader.h"
will create a C file like this:
/* Autogenerated by /home/les/Documents/src/emc2-dev/bin/comp on Fri Jul
17 10:11:27 2009 -- do not edit */
#include "rtapi.h"
#ifdef RTAPI
#include "rtapi_app.h"
#endif
#include "rtapi_string.h"
#include "rtapi_errno.h"
#include "hal.h"
static int comp_id;
#include "myheader.h"
...
This is useful for using your own typedefs when declaring variables. e.g.
include "myheader.h"
variable mytype myvariable
Les
>From eae7bffa5703b0c45f1a010d8f2aa8534ff0b086 Mon Sep 17 00:00:00 2001
From: Les Newell <[email protected]>
Date: Fri, 17 Jul 2009 10:12:54 +0100
Subject: [PATCH] Added 'include' options. This adds a #include to the beginning of the C
file. For instance:
include "myheader.h"
will output
#include "myheader.h"
near the beginning of the header file
---
src/hal/utils/comp.g | 11 +++++++++--
1 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/src/hal/utils/comp.g b/src/hal/utils/comp.g
index 5eb6889..e714c26 100644
--- a/src/hal/utils/comp.g
+++ b/src/hal/utils/comp.g
@@ -52,6 +52,7 @@ parser Hal:
| "description" String ";" {{ description(String) }}
| "license" String ";" {{ license(String) }}
| "author" String ";" {{ author(String) }}
+ | "include" String ";" {{ include(String) }}
| "modparam" NAME {{ NAME1=NAME; }} NAME OptSAssign OptString ";" {{ modparam(NAME1, NAME, OptSAssign, OptString) }}
rule String: TSTRING {{ return eval(TSTRING) }}
@@ -120,10 +121,10 @@ deprecated = ['s32', 'u32']
def initialize():
global functions, params, pins, options, comp_name, names, docs, variables
- global modparams
+ global modparams, includes
functions = []; params = []; pins = []; options = {}; variables = []
- modparams = []; docs = []
+ modparams = []; docs = []; includes = [];
comp_name = None
names = {}
@@ -214,6 +215,9 @@ def modparam(type, name, default, doc):
names[name] = None
modparams.append((type, name, default, doc))
+def include(value):
+ includes.append((value))
+
def removeprefix(s,p):
if s.startswith(p): return s[len(p):]
return s
@@ -240,6 +244,9 @@ def prologue(f):
static int comp_id;
"""
+ for name in includes:
+ print >>f, "#include \"%s\"" % name
+
names = {}
def q(s):
--
1.5.4.3
------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge
This is your chance to win up to $100,000 in prizes! For a limited time,
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Emc-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-developers