#ifndef __CDLCORE_HXX
# define __CDLCORE_HXX
-//{{{ Banner
+//{{{ Banner
//==========================================================================
//
//
//==========================================================================
//####COPYRIGHTBEGIN####
-//
+//
// ----------------------------------------------------------------------------
// Copyright (C) 2002 Bart Veer
// Copyright (C) 1999, 2000, 2001 Red Hat, Inc.
//
// This file is part of the eCos host tools.
//
-// This program is free software; you can redistribute it and/or modify it
-// under the terms of the GNU General Public License as published by the Free
-// Software Foundation; either version 2 of the License, or (at your option)
+// This program is free software; you can redistribute it and/or modify it
+// under the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 of the License, or (at your option)
// any later version.
-//
-// This program is distributed in the hope that it will be useful, but WITHOUT
-// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+//
+// This program is distributed in the hope that it will be useful, but WITHOUT
+// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
// more details.
-//
+//
// You should have received a copy of the GNU General Public License along with
-// this program; if not, write to the Free Software Foundation, Inc.,
+// this program; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
// ----------------------------------------------------------------------------
-//
+//
//####COPYRIGHTEND####
//==========================================================================
-//#####DESCRIPTIONBEGIN####
+//#####DESCRIPTIONBEGIN####
//
// Author(s): bartv
// Contributors: bartv
//==========================================================================
//}}}
-//{{{ Platform dependencies
+//{{{ Platform dependencies
// ----------------------------------------------------------------------------
// Visual C++ has the delightful feature that the source browser will generate
#endif
//}}}
-//{{{ nested #include's
+//{{{ nested #include's
// ----------------------------------------------------------------------------
// The libcdl API is defined using parts of the standard C++ library,
//}}}
-//{{{ Primitive types, constants:, enums, etc.
+//{{{ Primitive types, constants:, enums, etc.
// ----------------------------------------------------------------------------
// The CDL languages are defined in terms of arbitrary precision
// for enums? Arrays? Bitfields? Structures? Unions? C++ classes?
// How about other programming languages such as Ada or Java?
//
-// Any attempt to implement a grand union of all data types in CDL
+// Any attempt to implement a grand union of all data types in CDL
// is doomed to failure and should not be attempted. Treating
// everything as a string instead has proven successful in a number
// of languages, including Tcl and Perl.
CdlValueSource_Wizard = 2,
CdlValueSource_User = 3,
CdlValueSource_Current = 4
-};
+};
// ----------------------------------------------------------------------------
// Update support.
CdlUpdate_Created = 0x0008, // The destination has just been created
CdlUpdate_Destroyed = 0x0010, // The destination is being destroyed
CdlUpdate_ValueChange = 0x0020, // The destination's value has changed.
- // This gets applied to nodes as well
+ // This gets applied to nodes as well
CdlUpdate_ActiveChange = 0x0040 // The node has become active or inactive
};
CdlBoolWidget_CustomDialog = 1, // There is a valid custom dialog property
CdlBoolWidget_CheckButton = 2, // For simple booleans
CdlBoolWidget_Radio = 3, // For several mutual exclusive options,
- // the data structure will provide a string identifier
+ // the data structure will provide a string identifier
};
enum CdlValueWidget {
CdlValueWidget_EntryBox = 3, // Fallback
CdlValueWidget_MultilineString = 4, // For complicated strings
CdlValueWidget_DecimalRange = 5, // e.g. 1 to 16
- // Could be implemented as scale, radio buttons, entry, pull-down menu,
- // combo box, ... depending on GUI conventions and number of entries
+ // Could be implemented as scale, radio buttons, entry, pull-down menu,
+ // combo box, ... depending on GUI conventions and number of entries
CdlValueWidget_HexRange = 6, // e.g. 0x01 to 0x10
CdlValueWidget_OctalRange = 7, // e.g. 01 to 020
CdlValueWidget_DoubleRange = 8, // e.g. 0.1 to 0.2
CdlValueWidget_NumericSet = 9, // e.g. 1 2 4 8 16
- // The exact nature of the numbers is irrelevant, they will only
- // get displayed, not edited
- // Could be implemented as radio buttons, entry widget, pull-down menu,
- // combo box, ... depending on GUI conventions and number of entries
- // Each entry can have its own representation
+ // The exact nature of the numbers is irrelevant, they will only
+ // get displayed, not edited
+ // Could be implemented as radio buttons, entry widget, pull-down menu,
+ // combo box, ... depending on GUI conventions and number of entries
+ // Each entry can have its own representation
CdlValueWidget_StringSet = 10 // e.g. "ram", "rom"
// More to be added, e.g. for compiler flag handling
};
//}}}
-//{{{ Exception classes
+//{{{ Exception classes
// ----------------------------------------------------------------------------
// Some parts of the library make use of C++ exception handling. A number
public:
CdlStringException(std::string message_arg) {
- message = message_arg;
+ message = message_arg;
}
CdlStringException(const CdlStringException& original) {
- message = original.message;
+ message = original.message;
}
CdlStringException& operator=(const CdlStringException& original) {
- message = original.message;
- return *this;
+ message = original.message;
+ return *this;
}
~CdlStringException() {
- message = "";
+ message = "";
}
const std::string& get_message() const {
- return message;
+ return message;
}
private:
std::string message;
friend class CdlTest;
public:
CdlInputOutputException(std::string message_arg) :
- CdlStringException(message_arg) {
+ CdlStringException(message_arg) {
}
CdlInputOutputException(const CdlInputOutputException& original) :
- CdlStringException(original) {
+ CdlStringException(original) {
}
CdlInputOutputException& operator=(const CdlInputOutputException& original) {
- (void) CdlStringException::operator=(original);
- return *this;
+ (void) CdlStringException::operator=(original);
+ return *this;
}
};
friend class CdlTest;
public:
CdlParseException(std::string message_arg) :
- CdlStringException(message_arg) {
+ CdlStringException(message_arg) {
}
CdlParseException(const CdlParseException& original) :
- CdlStringException(original) {
+ CdlStringException(original) {
}
CdlParseException& operator=(const CdlParseException& original) {
- (void) CdlStringException::operator=(original);
- return *this;
+ (void) CdlStringException::operator=(original);
+ return *this;
}
};
friend class CdlTest;
public:
CdlEvalException(std::string message_arg) :
- CdlStringException(message_arg) {
+ CdlStringException(message_arg) {
}
CdlEvalException(const CdlEvalException& original) :
- CdlStringException(original) {
+ CdlStringException(original) {
}
CdlEvalException& operator=(const CdlEvalException& original) {
- (void) CdlStringException::operator=(original);
- return *this;
+ (void) CdlStringException::operator=(original);
+ return *this;
}
};
//}}}
-//{{{ Forward declarations of the body classes
+//{{{ Forward declarations of the body classes
// ----------------------------------------------------------------------------
// This section provides forward declarations of the main classes in
// Base classes. CDL entities such as options and components derive
// from one or more of these, using virtual inheritance.
-//
+//
// The lowest-level class is CdlNodeBody.
//
// 1) a node usually lives in a hierarchy, below a toplevel
typedef const CdlTransactionBody* CdlConstTransaction;
//}}}
-//{{{ Miscellaneous types etc.
+//{{{ Miscellaneous types etc.
// ----------------------------------------------------------------------------
// This section is used for data types, function prototypes, etc. which could
CdlInterpreterCommandEntry() : name(""), command(0) {}
CdlInterpreterCommandEntry(const char *name_arg, CdlInterpreterCommand command_arg)
- : name(name_arg), command(command_arg)
+ : name(name_arg), command(command_arg)
{
}
CdlInterpreterCommandEntry(std::string name_arg, CdlInterpreterCommand command_arg)
- : name(name_arg), command(command_arg)
+ : name(name_arg), command(command_arg)
{
}
~CdlInterpreterCommandEntry()
{
- name = "";
- command = 0;
+ name = "";
+ command = 0;
}
};
};
//}}}
-//{{{ Memory leak detection
+//{{{ Memory leak detection
// ----------------------------------------------------------------------------
// Provide some macros that are useful for detecting memory leaks. Basically
#define CYGDBG_MEMLEAK_CONSTRUCTOR() this->memleak_counter++;
#define CYGDBG_MEMLEAK_DESTRUCTOR() this->memleak_counter--;
#define CYGDBG_MEMLEAK_CHECKTHIS() if (this->memleak_counter < 0) { return false; }
-
+
#else
#define CYGDBG_MEMLEAK_CONSTRUCTOR()
//}}}
-//{{{ Cdl class
+//{{{ Cdl class
// ---------------------------------------------------------------------------
// The sole purpose of this class is to provide some utility functions with
// implements namespaces.
class Cdl {
-
+
public:
static bool is_valid_value_flavor(CdlValueFlavor);
static bool is_valid_value_source(CdlValueSource);
-
+
static bool is_valid_cdl_name(const std::string&);
static bool is_valid_c_preprocessor_symbol(const std::string&);
-
+
static bool string_to_integer(std::string, cdl_int&);
static bool string_to_double(std::string, double&);
static bool string_to_bool(std::string, bool&);
static void integer_to_double(cdl_int, double&);
static double integer_to_double(cdl_int);
static bool double_to_integer(double, cdl_int&);
-
+
static bool string_to_flavor(std::string, CdlValueFlavor&);
static bool flavor_to_string(CdlValueFlavor, std::string&);
static bool string_to_source(std::string, CdlValueSource&);
static bool source_to_string(CdlValueSource, std::string&);
-
+
static std::string get_library_version();
static void set_interactive(bool = true);
static bool is_interactive();
static bool truth() { return true; }
static bool falsehood() { return false; }
-
+
// return values are -1,0,1 just like strcmp(). The most recent
// version is the smallest.
static int compare_versions(std::string, std::string);
// Also provide an STL-friendly comparison class
class version_cmp {
public:
- bool operator()(const std::string& v1, const std::string& v2) const {
- return Cdl::compare_versions(v1,v2) < 0;
- }
+ bool operator()(const std::string& v1, const std::string& v2) const {
+ return Cdl::compare_versions(v1,v2) < 0;
+ }
};
// Split a version string into major, minor and release numbers.
static void split_version_string(const std::string&, std::string& /* major */,
- std::string& /* minor */, std::string& /* release */);
-
+ std::string& /* minor */, std::string& /* release */);
+
// It is occasionally useful to take a full CDL name such as CYGPKG_KERNEL
// and turn it into a short form, i.e. kernel.
static std::string get_short_form(const std::string&);
-
+
private:
static bool interactive;
};
//}}}
-//{{{ CdlInterpreter class
+//{{{ CdlInterpreter class
// ----------------------------------------------------------------------------
// libcdl requires access to a Tcl interpreter. For now the standard
public:
CYGDBG_DECLARE_MEMLEAK_COUNTER();
-
+
// This is how a top-level (i.e. per-toplevel) interpreter
// should get created.
static CdlInterpreter make(Tcl_Interp* = 0);
// Create a slave interpreter for reading in the data in e.g. a
// cdl_package
CdlInterpreter create_slave(CdlLoadable, bool /* safe */ = true);
-
+
// Make the interpreter safe, a one-way operation.
void make_safe();
-
+
// The destructor is public.
virtual ~CdlInterpreterBody();
std::vector<CdlInterpreterCommandEntry>* push_commands(std::vector<CdlInterpreterCommandEntry>&);
void pop_commands(std::vector<CdlInterpreterCommandEntry>*);
std::vector<CdlInterpreterCommandEntry>* get_pushed_commands() const;
-
+
// Similarly, allow variables to be set, unset and queried
void set_variable(std::string, std::string);
void unset_variable(std::string);
std::string get_variable(std::string);
-
+
// FIXME: add support for variable traces. These are needed
// for cdl_value and similar utilities.
-
+
// Provide hooks into the AssocData() facilities associated with
// Tcl interpreters. This makes it possible to store arbitrary
// data with an interpreter, e.g. to keep track of current state.
// And support for evaluating an entire file
int eval_file(std::string);
int eval_file(std::string, std::string&);
-
+
// For use by commands implemented in C++, a way of setting the result
void set_result(std::string);
// Was the result set by the Tcl interpreter or by libcdl?
bool result_set_by_cdl();
-
+
// A utility to quote data that is going to end up in a TCL script.
static std::string quote(std::string);
// Add some data to a comment, allowing for newlines if necessary
static std::string extend_comment(const std::string&, int, int = 0);
-
+
// Write some data to a savefile, throwing an exception on error
void write_data(Tcl_Channel, std::string);
// exceptions may get thrown.
class DiagSupport {
public:
- DiagSupport(CdlInterpreter interp_arg, CdlDiagnosticFnPtr error_fn_arg, CdlDiagnosticFnPtr warn_fn_arg) {
- interp = interp_arg;
- saved_error_fn = interp->push_error_fn_ptr(error_fn_arg);
- saved_warn_fn = interp->push_warning_fn_ptr(warn_fn_arg);
- }
- ~DiagSupport() {
- interp->pop_error_fn_ptr(saved_error_fn);
- interp->pop_warning_fn_ptr(saved_warn_fn);
- }
+ DiagSupport(CdlInterpreter interp_arg, CdlDiagnosticFnPtr error_fn_arg, CdlDiagnosticFnPtr warn_fn_arg) {
+ interp = interp_arg;
+ saved_error_fn = interp->push_error_fn_ptr(error_fn_arg);
+ saved_warn_fn = interp->push_warning_fn_ptr(warn_fn_arg);
+ }
+ ~DiagSupport() {
+ interp->pop_error_fn_ptr(saved_error_fn);
+ interp->pop_warning_fn_ptr(saved_warn_fn);
+ }
private:
- DiagSupport();
+ DiagSupport();
- CdlInterpreter interp;
- CdlDiagnosticFnPtr saved_error_fn;
- CdlDiagnosticFnPtr saved_warn_fn;
+ CdlInterpreter interp;
+ CdlDiagnosticFnPtr saved_error_fn;
+ CdlDiagnosticFnPtr saved_warn_fn;
};
class ContextSupport {
public:
- ContextSupport(CdlInterpreter interp_arg, std::string context) {
- interp = interp_arg;
- saved_context = interp->push_context(context);
- }
- ~ContextSupport() {
- interp->pop_context(saved_context);
- }
+ ContextSupport(CdlInterpreter interp_arg, std::string context) {
+ interp = interp_arg;
+ saved_context = interp->push_context(context);
+ }
+ ~ContextSupport() {
+ interp->pop_context(saved_context);
+ }
private:
- ContextSupport();
- CdlInterpreter interp;
- std::string saved_context;
+ ContextSupport();
+ CdlInterpreter interp;
+ std::string saved_context;
};
class ContainerSupport {
public:
- ContainerSupport(CdlInterpreter interp_arg, CdlContainer container) {
- interp = interp_arg;
- saved_container = interp->push_container(container);
- }
- ~ContainerSupport() {
- interp->pop_container(saved_container);
- }
+ ContainerSupport(CdlInterpreter interp_arg, CdlContainer container) {
+ interp = interp_arg;
+ saved_container = interp->push_container(container);
+ }
+ ~ContainerSupport() {
+ interp->pop_container(saved_container);
+ }
private:
- ContainerSupport();
- CdlInterpreter interp;
- CdlContainer saved_container;
+ ContainerSupport();
+ CdlInterpreter interp;
+ CdlContainer saved_container;
};
class NodeSupport {
public:
- NodeSupport(CdlInterpreter interp_arg, CdlNode node) {
- interp = interp_arg;
- saved_node = interp->push_node(node);
- }
- ~NodeSupport() {
- interp->pop_node(saved_node);
- }
+ NodeSupport(CdlInterpreter interp_arg, CdlNode node) {
+ interp = interp_arg;
+ saved_node = interp->push_node(node);
+ }
+ ~NodeSupport() {
+ interp->pop_node(saved_node);
+ }
private:
- NodeSupport();
- CdlInterpreter interp;
- CdlNode saved_node;
+ NodeSupport();
+ CdlInterpreter interp;
+ CdlNode saved_node;
};
class CommandSupport {
public:
- CommandSupport(CdlInterpreter interp_arg, std::vector<CdlInterpreterCommandEntry>& commands) {
- interp = interp_arg;
- saved_commands = interp->push_commands(commands);
- }
- CommandSupport(CdlInterpreter interp_arg, CdlInterpreterCommandEntry* commands) {
- unsigned int i;
- for (i = 0; 0 != commands[i].command; i++) {
- new_commands.push_back(commands[i]);
- }
- interp = interp_arg;
- saved_commands = interp->push_commands(new_commands);
- }
- ~CommandSupport() {
- interp->pop_commands(saved_commands);
- }
+ CommandSupport(CdlInterpreter interp_arg, std::vector<CdlInterpreterCommandEntry>& commands) {
+ interp = interp_arg;
+ saved_commands = interp->push_commands(commands);
+ }
+ CommandSupport(CdlInterpreter interp_arg, CdlInterpreterCommandEntry* commands) {
+ unsigned int i;
+ for (i = 0; 0 != commands[i].command; i++) {
+ new_commands.push_back(commands[i]);
+ }
+ interp = interp_arg;
+ saved_commands = interp->push_commands(new_commands);
+ }
+ ~CommandSupport() {
+ interp->pop_commands(saved_commands);
+ }
private:
- CommandSupport();
- CdlInterpreter interp;
- std::vector<CdlInterpreterCommandEntry>* saved_commands;
- std::vector<CdlInterpreterCommandEntry> new_commands;
+ CommandSupport();
+ CdlInterpreter interp;
+ std::vector<CdlInterpreterCommandEntry>* saved_commands;
+ std::vector<CdlInterpreterCommandEntry> new_commands;
};
// Similar utility classes for variables and assoc data.
class VariableSupport {
public:
- VariableSupport(CdlInterpreter interp_arg, std::string varname_arg, std::string data) {
- interp = interp_arg;
- varname = varname_arg;
- interp->set_variable(varname, data);
- }
- ~VariableSupport() {
- interp->unset_variable(varname);
- }
+ VariableSupport(CdlInterpreter interp_arg, std::string varname_arg, std::string data) {
+ interp = interp_arg;
+ varname = varname_arg;
+ interp->set_variable(varname, data);
+ }
+ ~VariableSupport() {
+ interp->unset_variable(varname);
+ }
private:
- VariableSupport();
- CdlInterpreter interp;
- std::string varname;
+ VariableSupport();
+ CdlInterpreter interp;
+ std::string varname;
};
class AssocSupport {
public:
- AssocSupport(CdlInterpreter interp_arg, const char* name_arg, ClientData data, Tcl_InterpDeleteProc* del_proc = 0) {
- interp = interp_arg;
- name = name_arg;
- interp->set_assoc_data(name, data, del_proc);
- }
- ~AssocSupport() {
- interp->delete_assoc_data(name);
- }
+ AssocSupport(CdlInterpreter interp_arg, const char* name_arg, ClientData data, Tcl_InterpDeleteProc* del_proc = 0) {
+ interp = interp_arg;
+ name = name_arg;
+ interp->set_assoc_data(name, data, del_proc);
+ }
+ ~AssocSupport() {
+ interp->delete_assoc_data(name);
+ }
private:
- AssocSupport();
- CdlInterpreter interp;
- const char* name;
+ AssocSupport();
+ CdlInterpreter interp;
+ const char* name;
};
-
+
// Some command implementations may want to access other Tcl library
// routines such as Tcl_SplitList(). This requires convenient access
// to the underlying Tcl interpreter.
Tcl_Interp* get_tcl_interpreter() const;
-
+
// For use by the assertion macros.
bool check_this(cyg_assert_class_zeal = cyg_quick) const;
static int tcl_command_proc(ClientData, Tcl_Interp*, int, const char*[]);
// This key is used to access the CdlInterpreter assoc data.
- static char* cdlinterpreter_assoc_data_key;
-
+ static const char* cdlinterpreter_assoc_data_key;
+
// Do not allow static instances of a Cdl interpreter. There are too
// many possible failure conditions. Cdl interpreters can only be
// created dynamically via make(), which will invoke this.
CdlInterpreterBody(const CdlInterpreterBody&);
CdlInterpreterBody& operator=(const CdlInterpreterBody&);
-
+
Tcl_Interp* tcl_interp; // The underlying Tcl interpreter
bool owns_interp; // Was the Tcl interpreter created by the library?
std::vector<CdlInterpreter> slaves; // All slave interpreters
CdlDiagnosticFnPtr error_fn_ptr;
CdlDiagnosticFnPtr warning_fn_ptr;
bool cdl_result;
-
+
std::vector<CdlInterpreterCommandEntry>* current_commands; // for push() and pop()
-
+
enum {
- CdlInterpreterBody_Invalid = 0,
- CdlInterpreterBody_Magic = 0x0be67689
+ CdlInterpreterBody_Invalid = 0,
+ CdlInterpreterBody_Magic = 0x0be67689
} cdlinterpreterbody_cookie;
};
//}}}
-//{{{ CdlReference/Referrer classes
+//{{{ CdlReference/Referrer classes
// ---------------------------------------------------------------------------
// CDL objects are organised primarily in a tree hierarchy. For
// CdlReferrer must be a friend so that when a package gets unloaded
// it can clean up all references to it.
friend class CdlReferrer;
-
+
public:
// The default constructor should not normally be used, instead
// a string should be supplied. However there are vectors of
// reference objects...
CdlReference();
-
+
// The main constructor supplies the name of the referenced
// entity. The resulting object will be unbound.
CdlReference(const std::string);
// The assignment operator is needed for STL operations.
// Again it only makes sense of unbound objects.
CdlReference& operator=(const CdlReference&);
-
+
// The destructor is only valid for unbound objects. All references
// should be unbound before an entity can be destroyed.
~CdlReference();
-
+
// Access the various fields.
void set_destination_name(const std::string);
const std::string& get_destination_name() const;
// This is used by the ASSERT_CLASS() and ASSERT_THIS() macros.
bool check_this(cyg_assert_class_zeal cyg_quick) const;
CYGDBG_DECLARE_MEMLEAK_COUNTER();
-
+
protected:
private:
-
+
// The data fields. The name is usually filled in by the
// constructor. The destination defaults to zero for an unbound
// object and gets filled in by the bind() operation.
CdlNode dest;
enum {
- CdlReference_Invalid = 0,
- CdlReference_Magic = 0x3f908608
+ CdlReference_Invalid = 0,
+ CdlReference_Magic = 0x3f908608
} cdlreference_cookie;
};
// members, since these two functions are really responsible for
// creating and destroying referrer objects.
friend class CdlReference;
-
+
public:
// The default constructor, copy constructor and assignment
void update(CdlTransaction, CdlNode, CdlUpdate);
bool check_this(cyg_assert_class_zeal=cyg_quick) const;
CYGDBG_DECLARE_MEMLEAK_COUNTER();
-
+
private:
CdlNode source;
CdlProperty source_property;
-
+
enum {
- CdlReferrer_Invalid = 0,
- CdlReferrer_Magic = 0x70e1fc37
+ CdlReferrer_Invalid = 0,
+ CdlReferrer_Magic = 0x70e1fc37
} cdlreferrer_cookie;
};
//}}}
-//{{{ Value and Expression classes
+//{{{ Value and Expression classes
-//{{{ CdlEvalContext
+//{{{ CdlEvalContext
// ----------------------------------------------------------------------------
// Expression evaluation always happens within a certain context.
// evaluation-related routines, a utility class is provided.
class CdlEvalContext {
-
+
friend class CdlTest;
-
+
public:
CdlTransaction transaction;
// a node or, more specifically, a valuable.
CdlNode resolve_reference(CdlExpression, int);
CdlValuable resolve_valuable_reference(CdlExpression, int);
-
+
bool check_this(cyg_assert_class_zeal = cyg_quick) const;
CYGDBG_DECLARE_MEMLEAK_COUNTER();
-
+
protected:
private:
CdlEvalContext();
enum {
- CdlEvalContext_Invalid = 0,
- CdlEvalContext_Magic = 0x03434be9
+ CdlEvalContext_Invalid = 0,
+ CdlEvalContext_Magic = 0x03434be9
} cdlevalcontext_cookie;
-
+
};
//}}}
-//{{{ CdlSimpleValue
+//{{{ CdlSimpleValue
// ----------------------------------------------------------------------------
// Expression evaluation happens in terms of CdlSimpleValue objects.
// The default value is 0.
class CdlSimpleValue {
-
+
friend class CdlTest;
public:
CdlSimpleValue& operator=(std::string);
CdlSimpleValue& operator=(cdl_int);
CdlSimpleValue& operator=(double);
-
+
CdlSimpleValue& operator=(bool);
-
+
bool operator==(const CdlSimpleValue&) const;
bool operator!=(const CdlSimpleValue&) const;
bool operator==(std::string arg) const
{
- CdlSimpleValue val(arg);
- return *this == val;
+ CdlSimpleValue val(arg);
+ return *this == val;
}
bool operator==(cdl_int arg) const
{
- CdlSimpleValue val(arg);
- return *this == val;
+ CdlSimpleValue val(arg);
+ return *this == val;
}
bool operator==(double arg) const
{
- CdlSimpleValue val(arg);
- return *this == val;
+ CdlSimpleValue val(arg);
+ return *this == val;
}
bool operator!=(std::string arg) const
{
- CdlSimpleValue val(arg);
- return *this != val;
+ CdlSimpleValue val(arg);
+ return *this != val;
}
bool operator!=(cdl_int arg) const
{
- CdlSimpleValue val(arg);
- return *this != val;
+ CdlSimpleValue val(arg);
+ return *this != val;
}
bool operator!=(double arg) const
{
- CdlSimpleValue val(arg);
- return *this != val;
+ CdlSimpleValue val(arg);
+ return *this != val;
}
-
+
void set_value(std::string, CdlValueFormat = CdlValueFormat_Default);
std::string get_value() const;
-
+
bool has_integer_value() const;
void set_integer_value(cdl_int, CdlValueFormat = CdlValueFormat_Default);
cdl_int get_integer_value() const;
-
+
bool has_double_value() const;
void set_double_value(double, CdlValueFormat = CdlValueFormat_Default);
double get_double_value() const;
void set_value_format(CdlSimpleValue&, CdlSimpleValue&);
static void eval_valuable(CdlEvalContext&, CdlValuable, CdlSimpleValue&);
-
+
// For expression evaluation, it is often convenient to get hold
// of a boolean as well. This may indicate a non-empty string
// or a non-zero value.
bool get_bool_value() const;
-
+
// This class is too simple to warrant even a cookie validation.
bool check_this(cyg_assert_class_zeal zeal = cyg_quick) const {
- return true;
+ return true;
}
-
+
protected:
private:
enum {
- int_valid = 0x01,
- double_valid = 0x02,
- string_valid = 0x04,
- int_invalid = 0x08,
- double_invalid = 0x10
+ int_valid = 0x01,
+ double_valid = 0x02,
+ string_valid = 0x04,
+ int_invalid = 0x08,
+ double_invalid = 0x10
};
mutable int valid_flags;
mutable std::string value;
};
//}}}
-//{{{ CdlListValue
+//{{{ CdlListValue
// ----------------------------------------------------------------------------
// Evaluating a list expression results in a set of possible values, but
// double to avoid unnecessary string conversions.
class CdlListValue {
-
+
friend class CdlTest;
// A list value will only be filled in when a list expression is evaluated.
// The members cannot be updated by other means.
friend class CdlListExpressionBody;
-
+
public:
CdlListValue();
bool check_this(cyg_assert_class_zeal = cyg_quick) const;
CYGDBG_DECLARE_MEMLEAK_COUNTER();
-
+
private:
std::vector<CdlSimpleValue> table;
std::vector<std::pair<cdl_int, cdl_int> > integer_ranges;
std::vector<std::pair<double, double> > double_ranges;
enum {
- CdlListValue_Invalid = 0,
- CdlListValue_Magic = 0x2183a943
+ CdlListValue_Invalid = 0,
+ CdlListValue_Magic = 0x2183a943
} cdllistvalue_cookie;
};
//}}}
-//{{{ CdlValue
+//{{{ CdlValue
// ----------------------------------------------------------------------------
// Values in CDL are non-trivial compared with some other languages.
// The first function can be used if e.g. the user wants to
// change his or her mind and go back to the default value
// rather than a user value. The user value is not forgotten
-// and can be reinstated.
+// and can be reinstated.
//
// invalidate_source() can be used to completely cancel a
// value source. If that source happens to be the current one
// whatever the flavor happens to be.
class CdlValue {
-
+
friend class CdlTest;
public:
cdl_int get_integer_value(CdlValueSource = CdlValueSource_Current) const;
double get_double_value(CdlValueSource = CdlValueSource_Current) const;
CdlSimpleValue get_simple_value(CdlValueSource = CdlValueSource_Current) const;
-
+
void set_source(CdlValueSource);
void invalidate_source(CdlValueSource);
-
+
void set_enabled(bool, CdlValueSource);
void enable(CdlValueSource source)
{
- set_enabled(true, source);
+ set_enabled(true, source);
}
void disable(CdlValueSource source)
{
- set_enabled(false, source);
+ set_enabled(false, source);
}
void set_value(CdlSimpleValue&, CdlValueSource);
void set_value(std::string data, CdlValueSource source)
{
- CdlSimpleValue val(data);
- set_value(val, source);
+ CdlSimpleValue val(data);
+ set_value(val, source);
}
void set_integer_value(cdl_int data, CdlValueSource source)
{
- CdlSimpleValue val(data);
- set_value(val, source);
+ CdlSimpleValue val(data);
+ set_value(val, source);
}
void set_double_value(double data, CdlValueSource source)
{
- CdlSimpleValue val(data);
- set_value(val, source);
+ CdlSimpleValue val(data);
+ set_value(val, source);
}
void set_enabled_and_value(bool, CdlSimpleValue&, CdlValueSource);
void set_enabled_and_value(bool enabled, std::string data, CdlValueSource source)
{
- CdlSimpleValue val(data);
- set_enabled_and_value(enabled, val, source);
+ CdlSimpleValue val(data);
+ set_enabled_and_value(enabled, val, source);
}
void set_enabled_and_value(bool enabled, cdl_int data, CdlValueSource source)
{
- CdlSimpleValue val(data);
- set_enabled_and_value(enabled, val, source);
+ CdlSimpleValue val(data);
+ set_enabled_and_value(enabled, val, source);
}
void set_enabled_and_value(bool enabled, double data, CdlValueSource source)
{
- CdlSimpleValue val(data);
- set_enabled_and_value(enabled, val, source);
+ CdlSimpleValue val(data);
+ set_enabled_and_value(enabled, val, source);
}
void enable_and_set_value(CdlSimpleValue& val, CdlValueSource source)
{
- set_enabled_and_value(true, val, source);
+ set_enabled_and_value(true, val, source);
}
void enable_and_set_value(std::string data, CdlValueSource source)
{
- set_enabled_and_value(true, data, source);
+ set_enabled_and_value(true, data, source);
}
void enable_and_set_value(cdl_int data, CdlValueSource source)
{
- set_enabled_and_value(true, data, source);
+ set_enabled_and_value(true, data, source);
}
void enable_and_set_value(double data, CdlValueSource source)
{
- set_enabled_and_value(true, data, source);
+ set_enabled_and_value(true, data, source);
}
void disable_and_set_value(CdlSimpleValue& val, CdlValueSource source)
{
- set_enabled_and_value(false, val, source);
+ set_enabled_and_value(false, val, source);
}
void disable_and_set_value(std::string data, CdlValueSource source)
{
- set_enabled_and_value(false, data, source);
+ set_enabled_and_value(false, data, source);
}
void disable_and_set_value(cdl_int data, CdlValueSource source)
{
- set_enabled_and_value(false, data, source);
+ set_enabled_and_value(false, data, source);
}
void disable_and_set_value(double data, CdlValueSource source)
{
- set_enabled_and_value(false, data, source);
+ set_enabled_and_value(false, data, source);
}
void set(CdlSimpleValue&, CdlValueSource);
-
+
bool check_this(cyg_assert_class_zeal = cyg_quick) const;
CYGDBG_DECLARE_MEMLEAK_COUNTER();
// This should only be used by the library itself.
void set_flavor(CdlValueFlavor);
-
+
protected:
-
+
private:
-
+
CdlValueFlavor flavor;
CdlValueSource current_source;
bool source_valid[4];
bool enabled[4];
CdlSimpleValue values[4];
-
+
enum {
- CdlValue_Invalid = 0,
- CdlValue_Magic = 0x41837960
+ CdlValue_Invalid = 0,
+ CdlValue_Magic = 0x41837960
} cdlvalue_cookie;
};
//}}}
-//{{{ CdlSubexpression
+//{{{ CdlSubexpression
// ----------------------------------------------------------------------------
// Expressions come into existence primarily as the result of reading
int lhs_index; // for all non-constant operators
int rhs_index; // for binary and ternary operators only
int rrhs_index; // only for ternary operators.
-
+
int func; // iff CdlExprOp_Function
int args[CdlFunction_MaxArgs];
};
//}}}
-//{{{ CdlFunction
+//{{{ CdlFunction
// ----------------------------------------------------------------------------
// Generic support for function parsing, evaluation, and inference. The
// core via static constructors.
class CdlFunction {
-
+
friend class CdlTest;
-
+
public:
CdlFunction(const char* /* name */, int /* no_args */,
- void (*)(CdlExpression, const CdlSubexpression&),
- void (*)(CdlEvalContext&, CdlExpression, const CdlSubexpression&, CdlSimpleValue&),
- bool (*)(CdlTransaction, CdlExpression, unsigned int, bool, int),
- bool (*)(CdlTransaction, CdlExpression, unsigned int, CdlSimpleValue&, int)
- );
+ void (*)(CdlExpression, const CdlSubexpression&),
+ void (*)(CdlEvalContext&, CdlExpression, const CdlSubexpression&, CdlSimpleValue&),
+ bool (*)(CdlTransaction, CdlExpression, unsigned int, bool, int),
+ bool (*)(CdlTransaction, CdlExpression, unsigned int, CdlSimpleValue&, int)
+ );
~CdlFunction();
-
+
static bool is_function(std::string, int&);
static std::string get_name(int);
static int get_args_count(int);
static void (*null_check)(CdlExpression, const CdlSubexpression&);
static bool (*null_infer_bool)(CdlTransaction, CdlExpression, unsigned int, bool, int);
static bool (*null_infer_value)(CdlTransaction, CdlExpression, unsigned int, CdlSimpleValue&, int);
-
+
protected:
private:
void (*eval_fn)(CdlEvalContext&, CdlExpression, const CdlSubexpression&, CdlSimpleValue&);
bool (*infer_bool_fn)(CdlTransaction, CdlExpression, unsigned int, bool, int);
bool (*infer_value_fn)(CdlTransaction, CdlExpression, unsigned int, CdlSimpleValue&, int);
-
+
// The default constructor is illegal
CdlFunction();
};
//}}}
-//{{{ CdlExpression
+//{{{ CdlExpression
// ----------------------------------------------------------------------------
// And now for the expression class itself.
class CdlExpressionBody {
friend class CdlTest;
-
+
public:
// The default constructor is basically a no-op, new expression
int first_subexpression;
std::vector<CdlReference> references;
bool update(CdlTransaction, CdlNode, CdlProperty, CdlNode, CdlUpdate);
-
+
// There are a number of parsing functions. The first one is
// used by higher-level code to parse a single expression. Its
// argument is a single string (which may be the result of
// expression.
//
// NOTE: possibly this should should be a protected member, since
- // its main use is in parsing goal expressions.
+ // its main use is in parsing goal expressions.
static void continue_parse(CdlExpression, std::string, int&, CdlExprOp&, int&);
// Evaluating expressions. Note that this may fail at run-time
void eval(CdlEvalContext&, CdlSimpleValue&);
void eval_internal(CdlEvalContext&, CdlSimpleValue&);
void eval_subexpression(CdlEvalContext&, int, CdlSimpleValue&);
-
+
// The full original expression is useful for diagnostics purposes
std::string get_original_string() const;
-
+
bool check_this(cyg_assert_class_zeal cyg_quick) const;
CYGDBG_DECLARE_MEMLEAK_COUNTER();
-
+
protected:
// The default constructor does very little, the main work
// is done by the various parsing functions. However it is
// available to derived classes, especially goal expressions.
CdlExpressionBody();
-
+
// The copy constructor has to be usable by derived classes,
// e.g. CdlExpressionProperty
CdlExpressionBody(const CdlExpressionBody&);
-
+
private:
-
+
// The assignment operator is illegal.
CdlExpressionBody& operator=(const CdlExpressionBody&);
// The string that was parsed originally
std::string expression_string;
-
+
enum {
- CdlExpressionBody_Invalid = 0,
- CdlExpressionBody_Magic = 0x760293a3
+ CdlExpressionBody_Invalid = 0,
+ CdlExpressionBody_Magic = 0x760293a3
} cdlexpressionbody_cookie;
};
//}}}
-//{{{ CdlListExpression
+//{{{ CdlListExpression
// ----------------------------------------------------------------------------
// The main use of list expressions is for the legal_values
// properties. Essentially a list expression is just a vector of
-// ordinary expressions and ranges of expressions.
+// ordinary expressions and ranges of expressions.
class CdlListExpressionBody {
// Availability of constructors etc. is as per the ordinary
// expression class.
virtual ~CdlListExpressionBody();
-
+
// The data associated with a list expression is a vector of
// expressions, plus a vector of expression pairs constituting
// ranges. As with ordinary expressions the data is fully public
// Parsing. This involves taking a single string, typically from
// a CDL script, and parsing one or more ordinary expressions.
static CdlListExpression parse(std::string);
-
+
// Evaluation support. A list expression evaluates to a list value.
void eval(CdlEvalContext&, CdlListValue&);
// More commonly client code is going to be interested in whether
// or not a particular value is a legal member. The result
- // cache ensures that it is possible to
+ // cache ensures that it is possible to
bool is_member(CdlEvalContext&, CdlSimpleValue&);
bool is_member(CdlEvalContext&, std::string);
bool is_member(CdlEvalContext&, cdl_int);
// The full original expression is useful for diagnostics purposes
std::string get_original_string() const;
-
+
bool check_this(cyg_assert_class_zeal = cyg_quick) const;
CYGDBG_DECLARE_MEMLEAK_COUNTER();
-
+
protected:
CdlListExpressionBody(const CdlListExpressionBody&);
bool update(CdlTransaction, CdlNode, CdlProperty, CdlNode, CdlUpdate);
void eval_internal(CdlEvalContext&, CdlListValue&);
std::string expression_string;
-
+
enum {
- CdlListExpressionBody_Invalid = 0,
- CdlListExpressionBody_Magic = 0x7da4bcc2
+ CdlListExpressionBody_Invalid = 0,
+ CdlListExpressionBody_Magic = 0x7da4bcc2
} cdllistexpressionbody_cookie;
};
//}}}
-//{{{ CdlGoalExpression
+//{{{ CdlGoalExpression
// ----------------------------------------------------------------------------
// A goal expression inherits privately from ordinary expressions. Essentially
// Provide public access to the underlying expression object,
// useful for the inference engine
CdlExpression get_expression();
-
+
// The full original expression is useful for diagnostics purposes
std::string get_original_string() const;
-
+
bool check_this(cyg_assert_class_zeal = cyg_quick) const;
CYGDBG_DECLARE_MEMLEAK_COUNTER();
-
+
protected:
CdlGoalExpressionBody(const CdlGoalExpressionBody&);
CdlGoalExpressionBody();
CdlGoalExpressionBody& operator=(const CdlGoalExpressionBody&);
void eval_internal(CdlEvalContext&, bool&);
-
+
std::string expression_string;
-
+
enum {
- CdlGoalExpressionBody_Invalid = 0,
- CdlGoalExpressionBody_Magic = 0x5a58bb24
+ CdlGoalExpressionBody_Invalid = 0,
+ CdlGoalExpressionBody_Magic = 0x5a58bb24
} cdlgoalexpressionbody_cookie;
};
//}}}
-//{{{ CdlInfer
+//{{{ CdlInfer
// ----------------------------------------------------------------------------
// A utility class related to inference. This exports the main functions
//}}}
//}}}
-//{{{ CdlConflict classes
+//{{{ CdlConflict classes
// ----------------------------------------------------------------------------
// As a configuration is created and modified there will be times when
// on a global basis, only on a per-transaction basis.
class CdlConflictBody {
-
+
friend class CdlTest;
// Transactions and conflicts are closely connected
friend class CdlTransactionBody;
-
+
public:
// Creation happens only inside a derived class.
// Clearing a conflict only happens inside transactions.
// Destroying a conflict only happens from inside a
// per-transaction clear(), or during a transaction commit.
-
+
// Is this conflict part of a transaction, or has it been committed to the toplevel.
CdlTransaction get_transaction() const;
// CdlToplevel::resolve_all_conflicts(). The conflict may cease to
// exist as a side-effect of this call.
void resolve();
-
+
// Keep track of whether or not this conflict has a solution
// 1) a conflict may have a current solution. This gets invalidated
// whenever there is a change to a value that was referenced
// while identifying the solution.
//
// A current solution is indicated by a non-empty solution vector.
- //
+ //
// 2) a conflict may not have a current solution. Again this gets
// invalidated whenever a referred value changes. There is a boolean
// to keep track of this.
const std::vector<std::pair<CdlValuable, CdlValue> >& get_solution() const;
const std::set<CdlValuable>& get_solution_references() const;
void clear_solution();
-
+
// Provide a text message "explaining" the conflict.
// This only makes sense for derived classes.
virtual std::string get_explanation() const = 0;
void enable();
bool is_enabled() const;
std::string get_disabled_reason() const;
-
+
bool check_this(cyg_assert_class_zeal zeal = cyg_quick) const;
CYGDBG_DECLARE_MEMLEAK_COUNTER();
protected:
CdlConflictBody(CdlTransaction, CdlNode, CdlProperty, bool /* structural */);
-
+
// The destructor gets accessed from inside the friend transaction class,
// either during a clear_conflict() or during a transaction commit.
virtual ~CdlConflictBody();
-
+
// All conflicts are associated with a node and a property.
// This information will be useful to derived classes'
// implementations of get_explanation()
CdlNode node;
CdlProperty property;
-
+
private:
// Attempt to resolve a conflict in a sub-transaction
// There are additional exported interfaces inside and outside
// the transaction class.
virtual bool inner_resolve(CdlTransaction, int);
-
+
// Keep track of the transaction in which this conflict was created.
// The field is cleared at the end of a transaction.
CdlTransaction transaction;
// needs to be available at base constructor time so
// a virtual function is not appropriate.
bool structural;
-
+
// Solution support
bool no_solution;
std::vector<std::pair<CdlValuable, CdlValue> > solution;
std::set<CdlValuable> solution_references;
void update_solution_validity(CdlValuable);
-
+
// Users may disable a conflict. Usually they will have to
// supply a reason for this.
bool enabled;
std::string reason;
enum {
- CdlConflictBody_Invalid = 0,
- CdlConflictBody_Magic = 0x073e8853
+ CdlConflictBody_Invalid = 0,
+ CdlConflictBody_Magic = 0x073e8853
} cdlconflictbody_cookie;
// Illegal operations. Conflicts always live on the heap.
// An unresolved conflict means that there is a reference in some
// property to an entity that is not yet in the current configuration.
// The class provides convenient access to the name of the unresolved
-// entity.
+// entity.
class CdlConflict_UnresolvedBody : public CdlConflictBody {
-
+
friend class CdlTest;
public:
CdlConflict_UnresolvedBody(CdlTransaction, CdlNode, CdlProperty, std::string);
std::string target_name;
enum {
- CdlConflict_UnresolvedBody_Invalid = 0,
- CdlConflict_UnresolvedBody_Magic = 0x1b24bb8a
+ CdlConflict_UnresolvedBody_Invalid = 0,
+ CdlConflict_UnresolvedBody_Magic = 0x1b24bb8a
} cdlconflict_unresolvedbody_cookie;
-
+
CdlConflict_UnresolvedBody();
CdlConflict_UnresolvedBody(const CdlConflict_UnresolvedBody&);
CdlConflict_UnresolvedBody& operator=(const CdlConflict_UnresolvedBody&);
static void make(CdlTransaction, CdlNode, CdlProperty);
bool resolution_implemented() const;
-
+
std::string get_explanation() const;
void set_explanation(std::string);
static bool test(CdlConflict);
CdlConflict_IllegalValueBody(CdlTransaction, CdlNode, CdlProperty);
std::string explanation;
enum {
- CdlConflict_IllegalValueBody_Invalid = 0,
- CdlConflict_IllegalValueBody_Magic = 0x4fb27ed1
+ CdlConflict_IllegalValueBody_Invalid = 0,
+ CdlConflict_IllegalValueBody_Magic = 0x4fb27ed1
} cdlconflict_illegalvaluebody_cookie;
CdlConflict_IllegalValueBody();
CdlConflict_EvalExceptionBody(CdlTransaction, CdlNode, CdlProperty, std::string);
std::string explanation;
enum {
- CdlConflict_EvalExceptionBody_Invalid = 0,
- CdlConflict_EvalExceptionBody_Magic = 0x7e64bc41
+ CdlConflict_EvalExceptionBody_Invalid = 0,
+ CdlConflict_EvalExceptionBody_Magic = 0x7e64bc41
} cdlconflict_evalexceptionbody_cookie;
};
// ----------------------------------------------------------------------------
// A goal expression evaluates to false. Producing sensible diagnostics
-// depends on a detailed understanding of goal expressions, which will
+// depends on a detailed understanding of goal expressions, which will
// have to wait until the inference engine comes along.
class CdlConflict_RequiresBody : public CdlConflictBody {
static void make(CdlTransaction, CdlNode, CdlProperty);
bool resolution_implemented() const;
-
+
std::string get_explanation() const;
static bool test(CdlConflict);
bool check_this(cyg_assert_class_zeal = cyg_quick) const;
bool inner_resolve(CdlTransaction, int);
CdlConflict_RequiresBody(CdlTransaction, CdlNode, CdlProperty);
enum {
- CdlConflict_RequiresBody_Invalid = 0,
- CdlConflict_RequiresBody_Magic = 0x78436331
+ CdlConflict_RequiresBody_Invalid = 0,
+ CdlConflict_RequiresBody_Magic = 0x78436331
} cdlconflict_requiresbody_cookie;
};
CdlConflict_DataBody(CdlTransaction, CdlNode, CdlProperty, std::string);
std::string message;
enum {
- CdlConflict_DataBody_Invalid = 0,
- CdlConflict_DataBody_Magic = 0x2cec7ad8
+ CdlConflict_DataBody_Invalid = 0,
+ CdlConflict_DataBody_Magic = 0x2cec7ad8
} cdlconflict_databody_cookie;
};
//}}}
-//{{{ CdlProperty class and derived classes
+//{{{ CdlProperty class and derived classes
-//{{{ Description
+//{{{ Description
// ---------------------------------------------------------------------------
// There are many different kinds of property. An alias property contains
// constructor.
//}}}
-//{{{ CdlPropertyId_xxx
+//{{{ CdlPropertyId_xxx
// ----------------------------------------------------------------------------
// Properties are identified by strings rather than by an enum or anything
#define CdlPropertyId_Wizard "Wizard"
//}}}
-//{{{ Base class
+//{{{ Base class
// ----------------------------------------------------------------------------
// The base class is never used directly. Instead the appropriate derived
class CdlPropertyBody {
friend class CdlTest;
-
+
public:
// The destructor is public, to avoid possible problems with STL.
virtual ~CdlPropertyBody();
-
+
// These routines provide access to the basic data.
std::string get_property_name() const;
std::string get_option(std::string) const;
const std::vector<std::string>& get_argv() const;
const std::vector<std::pair<std::string,std::string> >& get_options() const;
-
+
// Resolve any references, or generate/update appropriate conflict
// objects. The default implementation is a no-op because not all
// properties involve references.
virtual void update(CdlTransaction, CdlNode /* source */, CdlNode /* dest */, CdlUpdate);
-
+
bool check_this(cyg_assert_class_zeal = cyg_quick) const;
CYGDBG_DECLARE_MEMLEAK_COUNTER();
// <name/value> pairs, and is usually obtained via
// CdlParse::parse_options().
CdlPropertyBody(CdlNode, std::string, int argc, const char* argv[], std::vector<std::pair<std::string,std::string> >&);
-
+
private:
// This string indicates the command used to define this property,
// e.g. "doc" or "define_proc". It is provided to the constructor.
CdlPropertyBody();
CdlPropertyBody(const CdlPropertyBody&);
CdlPropertyBody& operator=(const CdlPropertyBody&);
-
+
enum {
- CdlPropertyBody_Invalid = 0,
- CdlPropertyBody_Magic = 0x60dd58f4
+ CdlPropertyBody_Invalid = 0,
+ CdlPropertyBody_Magic = 0x60dd58f4
} cdlpropertybody_cookie;
};
//}}}
-//{{{ CdlProperty_Minimal
+//{{{ CdlProperty_Minimal
// ----------------------------------------------------------------------------
// This class is used for properties that are simple flags, e.g. no_define.
class CdlProperty_MinimalBody : public CdlPropertyBody {
friend class CdlTest;
-
+
public:
static CdlProperty_Minimal make(CdlNode, std::string, int, const char*[], std::vector<std::pair<std::string,std::string> >&);
virtual ~CdlProperty_MinimalBody( );
CYGDBG_DECLARE_MEMLEAK_COUNTER();
protected:
-
+
private:
typedef CdlPropertyBody inherited;
-
+
CdlProperty_MinimalBody(CdlNode, std::string, int, const char*[], std::vector<std::pair<std::string,std::string> >&);
enum {
- CdlProperty_MinimalBody_Invalid = 0,
- CdlProperty_MinimalBody_Magic = 0x25625b8c
+ CdlProperty_MinimalBody_Invalid = 0,
+ CdlProperty_MinimalBody_Magic = 0x25625b8c
} cdlproperty_minimalbody_cookie;
CdlProperty_MinimalBody();
};
//}}}
-//{{{ CdlProperty_String
+//{{{ CdlProperty_String
// ----------------------------------------------------------------------------
// A string property contains a single piece of additional data in the form
class CdlProperty_StringBody : public CdlPropertyBody {
friend class CdlTest;
-
+
public:
static CdlProperty_String make(CdlNode, std::string, std::string, int, const char*[],
- std::vector<std::pair<std::string,std::string> >&);
+ std::vector<std::pair<std::string,std::string> >&);
virtual ~CdlProperty_StringBody();
std::string get_string(void) const;
CYGDBG_DECLARE_MEMLEAK_COUNTER();
protected:
-
+
private:
typedef CdlPropertyBody inherited;
-
+
CdlProperty_StringBody(CdlNode, std::string /* id */, std::string /* data */, int, const char*[],
- std::vector<std::pair<std::string,std::string> >&);
+ std::vector<std::pair<std::string,std::string> >&);
std::string data;
enum {
- CdlProperty_StringBody_Invalid = 0,
- CdlProperty_StringBody_Magic = 0x78d1ca94
+ CdlProperty_StringBody_Invalid = 0,
+ CdlProperty_StringBody_Magic = 0x78d1ca94
} cdlproperty_stringbody_cookie;
// The only legal constructor supplies all the data.
};
//}}}
-//{{{ CdlProperty_TclCode
+//{{{ CdlProperty_TclCode
// ----------------------------------------------------------------------------
// A TclCode property is currently equivalent to a string property. In
public:
static CdlProperty_TclCode make(CdlNode, std::string, cdl_tcl_code, int, const char*[],
- std::vector<std::pair<std::string,std::string> >&);
+ std::vector<std::pair<std::string,std::string> >&);
static CdlProperty_TclCode make(CdlNode, std::string, cdl_int, cdl_tcl_code, int, const char*[],
- std::vector<std::pair<std::string,std::string> >&);
+ std::vector<std::pair<std::string,std::string> >&);
virtual ~CdlProperty_TclCodeBody();
-
+
cdl_int get_number(void) const;
const cdl_tcl_code& get_code(void) const;
bool check_this(cyg_assert_class_zeal = cyg_quick) const;
CYGDBG_DECLARE_MEMLEAK_COUNTER();
-
+
private:
typedef CdlPropertyBody inherited;
-
+
CdlProperty_TclCodeBody(CdlNode, std::string, cdl_int, cdl_tcl_code, int, const char*[],
- std::vector<std::pair<std::string,std::string> >&);
+ std::vector<std::pair<std::string,std::string> >&);
cdl_int number;
cdl_tcl_code code;
enum {
- CdlProperty_TclCodeBody_Invalid = 0,
- CdlProperty_TclCodeBody_Magic = 0x7b14d4e5
+ CdlProperty_TclCodeBody_Invalid = 0,
+ CdlProperty_TclCodeBody_Magic = 0x7b14d4e5
} cdlproperty_tclcodebody_cookie;
CdlProperty_TclCodeBody();
CdlProperty_TclCodeBody(const CdlProperty_TclCodeBody&);
CdlProperty_TclCodeBody& operator=(const CdlProperty_TclCodeBody&);
-
+
};
//}}}
-//{{{ CdlProperty_StringVector
+//{{{ CdlProperty_StringVector
// ----------------------------------------------------------------------------
// This is used for multiple constant strings, as opposed to a list
public:
static CdlProperty_StringVector make(CdlNode, std::string, const std::vector<std::string>&, int, const char*[],
- std::vector<std::pair<std::string,std::string> >&);
+ std::vector<std::pair<std::string,std::string> >&);
virtual ~CdlProperty_StringVectorBody();
-
+
const std::vector<std::string>& get_strings() const;
std::string get_first_string() const;
unsigned int get_number_of_strings() const;
- std::string get_string(unsigned int) const;
+ std::string get_string(unsigned int) const;
bool check_this(cyg_assert_class_zeal zeal = cyg_quick) const;
CYGDBG_DECLARE_MEMLEAK_COUNTER();
-
+
private:
typedef CdlPropertyBody inherited;
-
+
CdlProperty_StringVectorBody(CdlNode, std::string, const std::vector<std::string>&, int, const char*[],
- std::vector<std::pair<std::string,std::string> >&);
+ std::vector<std::pair<std::string,std::string> >&);
std::vector<std::string> data;
enum {
- CdlProperty_StringVectorBody_Invalid = 0,
- CdlProperty_StringVectorBody_Magic = 0x4ed039f3
+ CdlProperty_StringVectorBody_Invalid = 0,
+ CdlProperty_StringVectorBody_Magic = 0x4ed039f3
} cdlproperty_stringvectorbody_cookie;
CdlProperty_StringVectorBody();
};
//}}}
-//{{{ CdlProperty_Reference
+//{{{ CdlProperty_Reference
// ----------------------------------------------------------------------------
// This is used for properties such as wizard and dialog, where the data
public:
static CdlProperty_Reference make(CdlNode, std::string /* id */, std::string /* destination */,
- CdlUpdateHandler, int, const char*[],
- std::vector<std::pair<std::string,std::string> >&);
+ CdlUpdateHandler, int, const char*[],
+ std::vector<std::pair<std::string,std::string> >&);
virtual ~CdlProperty_ReferenceBody();
-
+
void update(CdlTransaction, CdlNode, CdlNode, CdlUpdate);
-
+
bool check_this(cyg_assert_class_zeal = cyg_quick) const;
CYGDBG_DECLARE_MEMLEAK_COUNTER();
-
+
private:
typedef CdlPropertyBody inherited_property;
typedef CdlReference inherited_reference;
CdlUpdateHandler update_handler;
-
+
CdlProperty_ReferenceBody(CdlNode, std::string /* id */, std::string /* destination */, CdlUpdateHandler, int, const char*[],
- std::vector<std::pair<std::string,std::string> >&);
+ std::vector<std::pair<std::string,std::string> >&);
enum {
- CdlProperty_ReferenceBody_Invalid = 0,
- CdlProperty_ReferenceBody_Magic = 0x78100339
+ CdlProperty_ReferenceBody_Invalid = 0,
+ CdlProperty_ReferenceBody_Magic = 0x78100339
} cdlproperty_referencebody_cookie;
CdlProperty_ReferenceBody();
};
//}}}
-//{{{ CdlProperty_Expression
+//{{{ CdlProperty_Expression
// ----------------------------------------------------------------------------
// An expression property simply inherits its functionality from the basic
class CdlProperty_ExpressionBody : public CdlPropertyBody, public CdlExpressionBody {
friend class CdlTest;
-
+
public:
static CdlProperty_Expression make(CdlNode, std::string, CdlExpression, CdlUpdateHandler, int, const char*[],
- std::vector<std::pair<std::string,std::string> >&);
+ std::vector<std::pair<std::string,std::string> >&);
virtual ~CdlProperty_ExpressionBody();
void update(CdlTransaction, CdlNode, CdlNode, CdlUpdate);
bool check_this(cyg_assert_class_zeal = cyg_quick) const;
typedef CdlExpressionBody inherited_expression;
CdlProperty_ExpressionBody(CdlNode, std::string, CdlExpression, CdlUpdateHandler, int, const char*[],
- std::vector<std::pair<std::string,std::string> >&);
-
+ std::vector<std::pair<std::string,std::string> >&);
+
CdlUpdateHandler update_handler;
enum {
- CdlProperty_ExpressionBody_Invalid = 0,
- CdlProperty_ExpressionBody_Magic = 0x05fb4056
+ CdlProperty_ExpressionBody_Invalid = 0,
+ CdlProperty_ExpressionBody_Magic = 0x05fb4056
} cdlproperty_expressionbody_cookie;
CdlProperty_ExpressionBody();
};
//}}}
-//{{{ CdlProperty_ListExpression
+//{{{ CdlProperty_ListExpression
// ----------------------------------------------------------------------------
// Similarly a list property simply inherits from property and from
class CdlProperty_ListExpressionBody : public CdlPropertyBody, public CdlListExpressionBody {
friend class CdlTest;
-
+
public:
static CdlProperty_ListExpression make(CdlNode, std::string, CdlListExpression, CdlUpdateHandler, int, const char*[],
- std::vector<std::pair<std::string,std::string> >&);
+ std::vector<std::pair<std::string,std::string> >&);
virtual ~CdlProperty_ListExpressionBody();
void update(CdlTransaction, CdlNode, CdlNode, CdlUpdate);
bool check_this(cyg_assert_class_zeal = cyg_quick) const;
typedef CdlListExpressionBody inherited_expression;
CdlProperty_ListExpressionBody(CdlNode, std::string, CdlListExpression, CdlUpdateHandler, int, const char*[],
- std::vector<std::pair<std::string,std::string> >&);
+ std::vector<std::pair<std::string,std::string> >&);
CdlUpdateHandler update_handler;
enum {
- CdlProperty_ListExpressionBody_Invalid = 0,
- CdlProperty_ListExpressionBody_Magic = 0x6b0136f5
+ CdlProperty_ListExpressionBody_Invalid = 0,
+ CdlProperty_ListExpressionBody_Magic = 0x6b0136f5
} cdlproperty_listexpressionbody_cookie;
CdlProperty_ListExpressionBody();
};
//}}}
-//{{{ CdlProperty_GoalExpression
+//{{{ CdlProperty_GoalExpression
// ----------------------------------------------------------------------------
// And a goal property inherits from property and from goal expressions.
class CdlProperty_GoalExpressionBody : public CdlPropertyBody, public CdlGoalExpressionBody {
friend class CdlTest;
-
+
public:
static CdlProperty_GoalExpression make(CdlNode, std::string, CdlGoalExpression, CdlUpdateHandler, int, const char*[],
- std::vector<std::pair<std::string,std::string> >&);
+ std::vector<std::pair<std::string,std::string> >&);
virtual ~CdlProperty_GoalExpressionBody();
void update(CdlTransaction, CdlNode, CdlNode, CdlUpdate);
bool check_this(cyg_assert_class_zeal = cyg_quick) const;
typedef CdlGoalExpressionBody inherited_expression;
CdlProperty_GoalExpressionBody(CdlNode, std::string, CdlGoalExpression, CdlUpdateHandler, int, const char*[],
- std::vector<std::pair<std::string,std::string> >&);
-
+ std::vector<std::pair<std::string,std::string> >&);
+
CdlUpdateHandler update_handler;
enum {
- CdlProperty_GoalExpressionBody_Invalid = 0,
- CdlProperty_GoalExpressionBody_Magic = 0x08b2b31e
+ CdlProperty_GoalExpressionBody_Invalid = 0,
+ CdlProperty_GoalExpressionBody_Magic = 0x08b2b31e
} cdlproperty_goalexpressionbody_cookie;
CdlProperty_GoalExpressionBody();
//}}}
//}}}
-//{{{ CdlParse class
+//{{{ CdlParse class
// ----------------------------------------------------------------------------
// This is another utility class for collecting together parsing-related
// possible to re-use some of the functionality in that class.
class CdlParse {
-
+
public:
// Utility routines.
static std::string get_tcl_cmd_name(std::string);
static std::string concatenate_argv(int, const char*[], int);
- static int parse_options(CdlInterpreter, std::string /* diag_prefix */, char** /* options */,
- int /* argc */, const char*[] /* argv */, int /* start_index */,
- std::vector<std::pair<std::string,std::string> >& /* result */);
+ static int parse_options(CdlInterpreter, std::string /* diag_prefix */, const char** /* options */,
+ int /* argc */, const char*[] /* argv */, int /* start_index */,
+ std::vector<std::pair<std::string,std::string> >& /* result */);
static std::string construct_diagnostic(CdlInterpreter, std::string /* classification */,
- std::string /* sub-identifier */, std::string /* message */);
-
+ std::string /* sub-identifier */, std::string /* message */);
+
static void report_error(CdlInterpreter, std::string /* sub-identifier */, std::string /* message */);
static void report_warning(CdlInterpreter, std::string /* sub-identifier */, std::string /* message */);
static void clear_error_count(CdlInterpreter);
static void incr_error_count(CdlInterpreter, int=1);
static std::string get_expression_error_location(void);
-
+
// Support for Tcl's "unknown" command
static int unknown_command(CdlInterpreter, int, const char*[]);
-
+
// Property-related utilities
static void report_property_parse_error(CdlInterpreter, std::string, std::string);
static void report_property_parse_error(CdlInterpreter, CdlProperty, std::string);
static void report_property_parse_warning(CdlInterpreter, std::string, std::string);
static void report_property_parse_warning(CdlInterpreter, CdlProperty, std::string);
-
+
// Utility parsing routines
static int parse_minimal_property(CdlInterpreter, int, const char*[], std::string,
- char**, void (*)(CdlInterpreter, CdlProperty_Minimal));
+ const char **, void (*)(CdlInterpreter, CdlProperty_Minimal));
static int parse_string_property(CdlInterpreter, int, const char*[], std::string,
- char**, void (*)(CdlInterpreter, CdlProperty_String));
+ const char **, void (*)(CdlInterpreter, CdlProperty_String));
static int parse_tclcode_property(CdlInterpreter, int, const char*[], std::string,
- char**, void (*)(CdlInterpreter, CdlProperty_TclCode));
+ const char **, void (*)(CdlInterpreter, CdlProperty_TclCode));
static int parse_stringvector_property(CdlInterpreter, int, const char*[], std::string,
- char**, void (*)(CdlInterpreter, CdlProperty_StringVector),
- bool /* allow_empty */ = false);
+ const char **, void (*)(CdlInterpreter, CdlProperty_StringVector),
+ bool /* allow_empty */ = false);
static int parse_reference_property(CdlInterpreter, int, const char*[], std::string,
- char**, void (*)(CdlInterpreter, CdlProperty_Reference),
- bool /* allow_empty */,
- CdlUpdateHandler);
- static int parse_expression_property(CdlInterpreter, int, const char*[], std::string,
- char **, void (*)(CdlInterpreter, CdlProperty_Expression),
- CdlUpdateHandler);
+ const char **, void (*)(CdlInterpreter, CdlProperty_Reference),
+ bool /* allow_empty */,
+ CdlUpdateHandler);
+ static int parse_expression_property(CdlInterpreter, int, const char*[], std::string,
+ const char **, void (*)(CdlInterpreter, CdlProperty_Expression),
+ CdlUpdateHandler);
static int parse_listexpression_property(CdlInterpreter, int, const char*[], std::string,
- char **, void (*)(CdlInterpreter, CdlProperty_ListExpression),
- CdlUpdateHandler);
+ const char **, void (*)(CdlInterpreter, CdlProperty_ListExpression),
+ CdlUpdateHandler);
static int parse_goalexpression_property(CdlInterpreter, int, const char*[], std::string,
- char **, void (*)(CdlInterpreter, CdlProperty_GoalExpression),
- CdlUpdateHandler);
+ const char **, void (*)(CdlInterpreter, CdlProperty_GoalExpression),
+ CdlUpdateHandler);
};
//}}}
-//{{{ CdlNode
+//{{{ CdlNode
// ----------------------------------------------------------------------------
// A node object has a name and lives in a hierarchy. Each node keeps
// CdlLoadable must be able to access the destructor
friend class CdlLoadableBody;
-
+
// It is intended that CdlProperties will also add and remove themselves
friend class CdlPropertyBody;
// the referrers vector. So does CdlTransaction::commit()
friend class CdlReference;
friend class CdlTransactionBody;
-
+
public:
// Basic information.
// get applied to nodes as well as to properties. Note that because
// of multiple inheritance this virtual call can get confusing.
virtual void update(CdlTransaction, CdlUpdate);
-
+
// Is this node active or not? The is_active() call refers
// to the global state, things may be different inside a
// transaction.
// active_if constraints. This routine can be used
// to check whether or not a node should become active.
virtual bool test_active(CdlTransaction);
-
+
// Provide access to the various properties. Currently all this
// information is publicly available.
const std::vector<CdlProperty>& get_properties() const;
void get_conflicts(bool (*)(CdlConflict), std::vector<CdlConflict>&) const;
void get_structural_conflicts(std::vector<CdlConflict>&) const;
void get_structural_conflicts(bool (*)(CdlConflict), std::vector<CdlConflict>&) const;
-
+
// Provide access to all the referrers. This may not get used very
// much outside the library itself.
const std::vector<CdlReferrer>& get_referrers() const;
// to have a TCL interpreter available.
virtual void save(CdlInterpreter, Tcl_Channel, int, bool);
bool has_additional_savefile_information() const;
-
+
// Mainly for diagnostics code, what is the actual name for this
// type of CDL object? This should be in terms of CDL data, e.g.
// "package" or "component", rather than in implementation terms
- // such as "CdlPackageBody".
+ // such as "CdlPackageBody".
virtual std::string get_class_name() const;
bool check_this(cyg_assert_class_zeal = cyg_quick) const;
CYGDBG_DECLARE_MEMLEAK_COUNTER();
protected:
-
+
// CdlNodeBodies are only instantiated by derived classes.
// They must always have a name. They need not be placed
// in the hierarchy immediately, that can wait until
// later.
CdlNodeBody(std::string);
// A dummy constructor is needed because of the virtual
- // inheritance.
+ // inheritance.
CdlNodeBody();
// Nodes cannot be destroyed directly by application code,
// Updating the name is rarely required, but is useful for savefiles.
void set_name(std::string);
-
+
// Is the node currently active? This applies to the global state
// only, not per-transaction state. Some derived classes may want
// to override the default value
bool active;
-
+
private:
-
+
// The basic data. The name is known during construction.
// The other three fields get updated by e.g. CdlToplevel::add_node();
std::string name;
// This is used by remove_node_from_toplevel()/add_node_to_toplevel()
// to allow the latter to exactly reverse the former
int remove_node_container_position;
-
+
// Properties normally only get added during the parsing process,
// and only get removed when the object itself is destroyed.
// A vector is the obvious implementation.
// the savefile information so that it can be put in the next
// savefile.
std::vector<std::string> unsupported_savefile_strings;
-
+
enum {
- CdlNodeBody_Invalid = 0,
- CdlNodeBody_Magic = 0x309595b5
+ CdlNodeBody_Invalid = 0,
+ CdlNodeBody_Magic = 0x309595b5
} cdlnodebody_cookie;
-
+
// Illegal operations
CdlNodeBody(const CdlNodeBody&);
CdlNodeBody& operator=(const CdlNodeBody&);
};
//}}}
-//{{{ CdlContainer
+//{{{ CdlContainer
// ----------------------------------------------------------------------------
// A container is a node that can contain other nodes.
// Allow CdlNode::check_this() access to the internals
friend class CdlNodeBody;
-
+
// Adding a node to the hierarchy is done by a CdlToplevel member.
// Ditto for removing.
friend class CdlToplevelBody;
// Deleting a container can happen inside CdlToplevel and CdlLoadable
friend class CdlLoadableBody;
-
+
public:
const std::vector<CdlNode>& get_contents() const;
// Propagation support. Some updates such as active/inactive changes
// get applied to nodes as well as to properties.
virtual void update(CdlTransaction, CdlUpdate);
-
+
// Persistence support.
virtual void save(CdlInterpreter, Tcl_Channel, int, bool);
-
+
virtual std::string get_class_name() const;
bool check_this(cyg_assert_class_zeal = cyg_quick) const;
CYGDBG_DECLARE_MEMLEAK_COUNTER();
-
+
protected:
// Containers cannot be destroyed explicitly, only via higher-level
// The CdlToplevel class needs access to its own contents.
std::vector<CdlNode> contents;
-
+
private:
enum {
- CdlContainerBody_Invalid = 0,
- CdlContainerBody_Magic = 0x543c5f1d
+ CdlContainerBody_Invalid = 0,
+ CdlContainerBody_Magic = 0x543c5f1d
} cdlcontainerbody_cookie;
// Illegal operations
};
//}}}
-//{{{ CdlLoadable
+//{{{ CdlLoadable
// ----------------------------------------------------------------------------
// A loadable object is a container that gets loaded or unloaded
// Allow CdlNode::check_this() access to the internals
friend class CdlNodeBody;
-
+
// Adding nodes to the hierarchy is done by a toplevel member
friend class CdlToplevelBody;
public:
virtual ~CdlLoadableBody();
-
+
const std::vector<CdlNode>& get_owned() const;
bool owns(CdlConstNode) const;
CdlInterpreter get_interpreter() const;
// the various properties, calculating default values, etc.
void bind(CdlTransaction);
void unbind(CdlTransaction);
-
+
virtual std::string get_class_name() const;
bool check_this(cyg_assert_class_zeal = cyg_quick) const;
CYGDBG_DECLARE_MEMLEAK_COUNTER();
// Needed by derived classes, but not actually used.
CdlLoadableBody();
-
+
private:
-
+
std::vector<CdlNode> owned;
CdlInterpreter interp;
std::string directory;
// Used by add/remove_node_from_toplevel()
int remove_node_loadables_position;
-
+
enum {
- CdlLoadableBody_Invalid = 0,
- CdlLoadableBody_Magic = 0x488d6127
+ CdlLoadableBody_Invalid = 0,
+ CdlLoadableBody_Magic = 0x488d6127
} cdlloadablebody_cookie;
// Invalid operations
};
//}}}
-//{{{ CdlToplevel
+//{{{ CdlToplevel
// ----------------------------------------------------------------------------
// Toplevels are containers that live at the top of a hierarchy
// Allow CdlNode::check_this() access to the internals
friend class CdlNodeBody;
-
+
// The CdlTransaction class needs direct access to the lists
// of conflicts.
friend class CdlTransactionBody;
// for some operations like determining build information
// which must operate on a per-loadable basis.
const std::vector<CdlLoadable>& get_loadables() const;
-
+
// Name uniqueness is guaranteed. It is convenient to have an STL
// map as a lookup service.
CdlNode lookup(const std::string) const;
// will be created for this.
void resolve_conflicts(const std::vector<CdlConflict>&);
void resolve_all_conflicts();
-
+
// Toplevels can have descriptions provided by the user. This is
// particularly important for pre-defined templates, target
// board descriptions, etc. where the user would like some
// The default value is an empty string.
std::string get_description() const;
void set_description(std::string);
-
+
// Each toplevel must have an associated master Tcl interpreter.
CdlInterpreter get_interpreter() const;
- // Each toplevel should also have an associated directory for
+ // Each toplevel should also have an associated directory for
// the component repository. It is not required that all loadables
// are relative to this, but that is the default behaviour.
std::string get_directory() const;
// operating on a single toplevel (although nested transactions
// are allowed)
CdlTransaction get_active_transaction() const;
-
+
// Build and define operations are available for all toplevels,
// even if they are not always applicable
void get_build_info(CdlBuildInfo&);
void generate_config_headers(std::string);
void get_config_headers(std::vector<std::string>&);
void generate_build_tree(std::string, std::string = "");
-
- // Values can be stored in limbo. This is useful when unloading
+
+ // Values can be stored in limbo. This is useful when unloading
// and reloading packages, e.g. when changing a version the
// current settings can be preserved as much as possible.
void set_limbo_value(CdlValuable);
CdlValue get_limbo_value(std::string) const;
CdlValue get_and_remove_limbo_value(std::string);
void clear_limbo();
-
+
// Persistence support. These are commented in the source code.
- void initialize_savefile_support();
+ void initialize_savefile_support();
static bool savefile_support_initialized();
- void add_savefile_command(std::string, CdlSaveCallback, CdlInterpreterCommand);
- void add_savefile_subcommand(std::string, std::string, CdlSaveCallback, CdlInterpreterCommand);
- void get_savefile_commands(std::vector<CdlInterpreterCommandEntry>&);
- void get_savefile_subcommands(std::string, std::vector<CdlInterpreterCommandEntry>&);
- void save_command_details(CdlInterpreter, Tcl_Channel, int, bool);
+ void add_savefile_command(std::string, CdlSaveCallback, CdlInterpreterCommand);
+ void add_savefile_subcommand(std::string, std::string, CdlSaveCallback, CdlInterpreterCommand);
+ void get_savefile_commands(std::vector<CdlInterpreterCommandEntry>&);
+ void get_savefile_subcommands(std::string, std::vector<CdlInterpreterCommandEntry>&);
+ void save_command_details(CdlInterpreter, Tcl_Channel, int, bool);
static int savefile_handle_command(CdlInterpreter, int, const char*[]);
static int savefile_handle_unsupported(CdlInterpreter, int, const char*[]);
static int savefile_handle_unknown(CdlInterpreter, int, const char*[]);
- void save_unsupported_commands(CdlInterpreter, Tcl_Channel, int, bool);
+ void save_unsupported_commands(CdlInterpreter, Tcl_Channel, int, bool);
static cdl_int get_library_savefile_version();
static int savefile_handle_version(CdlInterpreter, int, const char*[]);
static cdl_int get_savefile_version(CdlInterpreter);
- void save_conflicts(CdlInterpreter, Tcl_Channel, int, bool);
+ void save_conflicts(CdlInterpreter, Tcl_Channel, int, bool);
static void save_separator(CdlInterpreter, Tcl_Channel, std::string, bool);
-
+
virtual std::string get_class_name() const;
bool check_this(cyg_assert_class_zeal = cyg_quick) const;
CYGDBG_DECLARE_MEMLEAK_COUNTER();
// Keep track of the current active transaction for this toplevel (if any)
CdlTransaction transaction;
-
+
enum {
- CdlToplevelBody_Invalid = 0,
- CdlToplevelBody_Magic = 0x0834666e
+ CdlToplevelBody_Invalid = 0,
+ CdlToplevelBody_Magic = 0x0834666e
} cdltoplevelbody_cookie;
-
+
// Invalid operations
CdlToplevelBody(const CdlToplevelBody&);
CdlToplevelBody& operator=(const CdlToplevelBody&);
};
//}}}
-//{{{ CdlUserVisible
+//{{{ CdlUserVisible
// ----------------------------------------------------------------------------
// A user-visible object is likely to have properties such as display,
// NOTE: this will only work for absolute doc strings or for doc
// strings that are relative to the package.
std::string get_doc_url() const;
-
+
// Add property parsers and validation code appropriate for a
- // user-visible object such as doc and description
+ // user-visible object such as doc and description
static void add_property_parsers(std::vector<CdlInterpreterCommandEntry>& parsers);
void check_properties(CdlInterpreter);
static int parse_description(CdlInterpreter, int, const char*[]);
// Persistence support. The save code simply outputs some comments
// corresponding to the display, doc and description properties.
virtual void save(CdlInterpreter, Tcl_Channel, int, bool);
-
+
virtual std::string get_class_name() const;
bool check_this(cyg_assert_class_zeal = cyg_quick) const;
CYGDBG_DECLARE_MEMLEAK_COUNTER();
-
+
protected:
CdlUserVisibleBody();
private:
enum {
- CdlUserVisibleBody_Invalid = 0,
- CdlUserVisibleBody_Magic = 0x13bbc817
+ CdlUserVisibleBody_Invalid = 0,
+ CdlUserVisibleBody_Magic = 0x13bbc817
} cdluservisiblebody_cookie;
// Illegal operations
};
//}}}
-//{{{ CdlParentable
+//{{{ CdlParentable
// ----------------------------------------------------------------------------
// A parentable object may have the parent property, redefining its
virtual std::string get_class_name() const;
bool check_this(cyg_assert_class_zeal = cyg_quick) const;
CYGDBG_DECLARE_MEMLEAK_COUNTER();
-
+
protected:
CdlParentableBody();
// Unloads may be cancelled. To restore the previous state exactly
// it is necessary to keep track of the old position.
int change_parent_save_position;
-
+
enum {
- CdlParentableBody_Invalid = 0,
- CdlParentableBody_Magic = 0x40c6a077
+ CdlParentableBody_Invalid = 0,
+ CdlParentableBody_Magic = 0x40c6a077
} cdlparentablebody_cookie;
// Illegal operations
};
//}}}
-//{{{ CdlValuable
+//{{{ CdlValuable
// ----------------------------------------------------------------------------
// A valuable body has a value. Many valuables can be modified but not all.
// Transaction commit operations require direct access to the CdlValue
friend class CdlTransactionBody;
-
+
private:
CdlValue value;
-
+
public:
virtual ~CdlValuableBody();
// Accessing the current value. There are variants for the global state
// and for per-transaction operations.
const CdlValue& get_whole_value() const;
-
+
CdlValueFlavor get_flavor() const;
CdlValueFlavor get_flavor(CdlTransaction transaction) const
{ // The transaction is irrelevant, it cannot change the flavor
- return this->get_flavor();
+ return this->get_flavor();
}
CdlValueSource get_source() const;
bool has_double_value( CdlValueSource = CdlValueSource_Current) const;
double get_double_value( CdlValueSource = CdlValueSource_Current) const;
CdlSimpleValue get_simple_value( CdlValueSource = CdlValueSource_Current) const;
-
+
CdlValueSource get_source(CdlTransaction) const;
bool has_source( CdlTransaction, CdlValueSource) const;
bool is_enabled( CdlTransaction, CdlValueSource = CdlValueSource_Current) const;
bool has_double_value( CdlTransaction, CdlValueSource = CdlValueSource_Current) const;
double get_double_value( CdlTransaction, CdlValueSource = CdlValueSource_Current) const;
CdlSimpleValue get_simple_value( CdlTransaction, CdlValueSource = CdlValueSource_Current) const;
-
+
// -----------------------------------------------------------------
// Modify access. There are two variants of all the functions:
//
void set_value(CdlSimpleValue&, CdlValueSource);
void set_enabled_and_value(bool, CdlSimpleValue&, CdlValueSource);
void set(CdlSimpleValue&, CdlValueSource);
-
+
void set_source(CdlTransaction, CdlValueSource);
void invalidate_source(CdlTransaction, CdlValueSource);
void set_enabled(CdlTransaction, bool, CdlValueSource);
void set_enabled_and_value(CdlTransaction, bool, CdlSimpleValue&, CdlValueSource);
void set(CdlTransaction, CdlSimpleValue&, CdlValueSource);
void set(CdlTransaction, const CdlValue&);
-
+
void enable(CdlValueSource source)
{
- set_enabled(true, source);
+ set_enabled(true, source);
}
void disable(CdlValueSource source)
{
- set_enabled(false, source);
+ set_enabled(false, source);
}
void set_value(std::string data, CdlValueSource source)
{
- CdlSimpleValue val(data);
- set_value(val, source);
+ CdlSimpleValue val(data);
+ set_value(val, source);
}
void set_integer_value(cdl_int data, CdlValueSource source)
{
- CdlSimpleValue val(data);
- set_value(val, source);
+ CdlSimpleValue val(data);
+ set_value(val, source);
}
void set_double_value(double data, CdlValueSource source)
{
- CdlSimpleValue val(data);
- set_value(val, source);
+ CdlSimpleValue val(data);
+ set_value(val, source);
}
void set_enabled_and_value(bool enabled, std::string data, CdlValueSource source)
{
- CdlSimpleValue val(data);
- set_enabled_and_value(enabled, val, source);
+ CdlSimpleValue val(data);
+ set_enabled_and_value(enabled, val, source);
}
void set_enabled_and_value(bool enabled, cdl_int data, CdlValueSource source)
{
- CdlSimpleValue val(data);
- set_enabled_and_value(enabled, val, source);
+ CdlSimpleValue val(data);
+ set_enabled_and_value(enabled, val, source);
}
void set_enabled_and_value(bool enabled, double data, CdlValueSource source)
{
- CdlSimpleValue val(data);
- set_enabled_and_value(enabled, val, source);
+ CdlSimpleValue val(data);
+ set_enabled_and_value(enabled, val, source);
}
void enable_and_set_value(CdlSimpleValue& val, CdlValueSource source)
{
- set_enabled_and_value(true, val, source);
+ set_enabled_and_value(true, val, source);
}
void enable_and_set_value(std::string data, CdlValueSource source)
{
- set_enabled_and_value(true, data, source);
+ set_enabled_and_value(true, data, source);
}
void enable_and_set_value(cdl_int data, CdlValueSource source)
{
- set_enabled_and_value(true, data, source);
+ set_enabled_and_value(true, data, source);
}
void enable_and_set_value(double data, CdlValueSource source)
{
- set_enabled_and_value(true, data, source);
+ set_enabled_and_value(true, data, source);
}
void disable_and_set_value(CdlSimpleValue& val, CdlValueSource source)
{
- set_enabled_and_value(false, val, source);
+ set_enabled_and_value(false, val, source);
}
void disable_and_set_value(std::string data, CdlValueSource source)
{
- set_enabled_and_value(false, data, source);
+ set_enabled_and_value(false, data, source);
}
void disable_and_set_value(cdl_int data, CdlValueSource source)
{
- set_enabled_and_value(false, data, source);
+ set_enabled_and_value(false, data, source);
}
void disable_and_set_value(double data, CdlValueSource source)
{
- set_enabled_and_value(false, data, source);
+ set_enabled_and_value(false, data, source);
}
void enable(CdlTransaction transaction, CdlValueSource source)
{
- set_enabled(transaction, true, source);
+ set_enabled(transaction, true, source);
}
void disable(CdlTransaction transaction, CdlValueSource source)
{
- set_enabled(transaction, false, source);
+ set_enabled(transaction, false, source);
}
void set_value(CdlTransaction transaction, std::string data, CdlValueSource source)
{
- CdlSimpleValue val(data);
- set_value(transaction, val, source);
+ CdlSimpleValue val(data);
+ set_value(transaction, val, source);
}
void set_integer_value(CdlTransaction transaction, cdl_int data, CdlValueSource source)
{
- CdlSimpleValue val(data);
- set_value(transaction, val, source);
+ CdlSimpleValue val(data);
+ set_value(transaction, val, source);
}
void set_double_value(CdlTransaction transaction, double data, CdlValueSource source)
{
- CdlSimpleValue val(data);
- set_value(transaction, val, source);
+ CdlSimpleValue val(data);
+ set_value(transaction, val, source);
}
void set_enabled_and_value(CdlTransaction transaction, bool enabled, std::string data, CdlValueSource source)
{
- CdlSimpleValue val(data);
- set_enabled_and_value(transaction, enabled, val, source);
+ CdlSimpleValue val(data);
+ set_enabled_and_value(transaction, enabled, val, source);
}
void set_enabled_and_value(CdlTransaction transaction, bool enabled, cdl_int data, CdlValueSource source)
{
- CdlSimpleValue val(data);
- set_enabled_and_value(transaction, enabled, val, source);
+ CdlSimpleValue val(data);
+ set_enabled_and_value(transaction, enabled, val, source);
}
void set_enabled_and_value(CdlTransaction transaction, bool enabled, double data, CdlValueSource source)
{
- CdlSimpleValue val(data);
- set_enabled_and_value(transaction, enabled, val, source);
+ CdlSimpleValue val(data);
+ set_enabled_and_value(transaction, enabled, val, source);
}
void enable_and_set_value(CdlTransaction transaction, CdlSimpleValue& val, CdlValueSource source)
{
- set_enabled_and_value(transaction, true, val, source);
+ set_enabled_and_value(transaction, true, val, source);
}
void enable_and_set_value(CdlTransaction transaction, std::string data, CdlValueSource source)
{
- set_enabled_and_value(transaction, true, data, source);
+ set_enabled_and_value(transaction, true, data, source);
}
void enable_and_set_value(CdlTransaction transaction, cdl_int data, CdlValueSource source)
{
- set_enabled_and_value(transaction, true, data, source);
+ set_enabled_and_value(transaction, true, data, source);
}
void enable_and_set_value(CdlTransaction transaction, double data, CdlValueSource source)
{
- set_enabled_and_value(transaction, true, data, source);
+ set_enabled_and_value(transaction, true, data, source);
}
void disable_and_set_value(CdlTransaction transaction, CdlSimpleValue& val, CdlValueSource source)
{
- set_enabled_and_value(transaction, false, val, source);
+ set_enabled_and_value(transaction, false, val, source);
}
void disable_and_set_value(CdlTransaction transaction, std::string data, CdlValueSource source)
{
- set_enabled_and_value(transaction, false, data, source);
+ set_enabled_and_value(transaction, false, data, source);
}
void disable_and_set_value(CdlTransaction transaction, cdl_int data, CdlValueSource source)
{
- set_enabled_and_value(transaction, false, data, source);
+ set_enabled_and_value(transaction, false, data, source);
}
void disable_and_set_value(CdlTransaction transaction, double data, CdlValueSource source)
{
- set_enabled_and_value(transaction, false, data, source);
+ set_enabled_and_value(transaction, false, data, source);
}
// -----------------------------------------------------------------
// because e.g. its parent is disabled then this may affect
// requires conflicts etc.
virtual void update(CdlTransaction, CdlUpdate);
-
+
virtual bool test_active(CdlTransaction);
-
+
// -----------------------------------------------------------------
// Property-related stuff.
bool has_calculated_expression() const;
bool has_requires_goals() const;
bool has_dialog() const;
bool has_wizard() const;
-
+
CdlProperty_Expression get_calculated_expression() const;
CdlProperty_Expression get_default_value_expression() const;
CdlProperty_ListExpression get_legal_values() const;
CdlDialog get_dialog() const;
CdlWizard get_wizard() const;
void get_implemented_interfaces(std::vector<CdlInterface>&) const;
-
+
// Add property parsers and validation code appropriate for a
// valuable object such as default_value and legal_values
static void add_property_parsers(std::vector<CdlInterpreterCommandEntry>& parsers);
static void wizard_update_handler(CdlTransaction, CdlNode, CdlProperty, CdlNode, CdlUpdate);
// Persistence suppot
- void save(CdlInterpreter, Tcl_Channel, int, bool /* modifiable */, bool /* minimal */);
+ void _save(CdlInterpreter, Tcl_Channel, int, bool /* modifiable */, bool /* minimal */);
bool value_savefile_entry_needed() const;
static void initialize_savefile_support(CdlToplevel, std::string);
static int savefile_value_source_command(CdlInterpreter, int, const char*[]);
static int savefile_wizard_value_command(CdlInterpreter, int, const char*[]);
static int savefile_inferred_value_command(CdlInterpreter, int, const char*[]);
static int savefile_xxx_value_command(CdlInterpreter, int, const char*[], CdlValueSource);
-
+
// Make sure that the current value is legal. This gets called automatically
// by all the members that modify values. It has to be a virtual function
// since some derived classes, e.g. hardware-related valuables, may impose
virtual std::string get_class_name() const;
bool check_this(cyg_assert_class_zeal = cyg_quick) const;
CYGDBG_DECLARE_MEMLEAK_COUNTER();
-
+
protected:
CdlValuableBody(CdlValueFlavor = CdlValueFlavor_Bool);
-
+
private:
-
+
enum {
- CdlValuableBody_Invalid = 0,
- CdlValuableBody_Magic = 0x2b2acc03
+ CdlValuableBody_Invalid = 0,
+ CdlValuableBody_Magic = 0x2b2acc03
} cdlvaluablebody_cookie;
// Illegal operations
};
//}}}
-//{{{ CdlTransaction etc.
+//{{{ CdlTransaction etc.
-//{{{ Description
+//{{{ Description
// ----------------------------------------------------------------------------
// Transactions. These are used for all changes to a configuration. In some
// Transaction objects are also used during load or unload operations,
// but those are a little bit special. In particular it is not possible
// to cancel such a transaction, there will have been updates to the
-// toplevel. Using a transaction is convenient because there is a
+// toplevel. Using a transaction is convenient because there is a
// need for propagation.
//
// Currently a transaction should be deleted immediately after a
// allowing multiple changes to be processed in one go. There is
// a utility function which combines the functionality from
// the first propagate() call up to but not including the
-// transaction delete operator.
+// transaction delete operator.
//
//
// The inference engine itself is a complicated beast. There are
// a future version.
//}}}
-//{{{ CdlTransactionCommitCancelOp
+//{{{ CdlTransactionCommitCancelOp
// ----------------------------------------------------------------------------
// The CdlTransaction class has built-in knowledge of how to handle values,
// Derived classes should override at least one of these
// functions.
virtual void commit(CdlTransaction transaction) {
- CYG_UNUSED_PARAM(CdlTransaction, transaction);
+ CYG_UNUSED_PARAM(CdlTransaction, transaction);
}
virtual void cancel(CdlTransaction transaction) {
- CYG_UNUSED_PARAM(CdlTransaction, transaction);
+ CYG_UNUSED_PARAM(CdlTransaction, transaction);
}
-
+
protected:
private:
};
//}}}
-//{{{ CdlTransaction class
+//{{{ CdlTransaction class
class CdlTransactionBody {
friend class CdlConflictBody;
friend class CdlValuableBody;
-
+
public:
// Create a toplevel transaction
static CdlTransaction make(CdlToplevel);
virtual ~CdlTransactionBody();
CdlToplevel get_toplevel() const;
-
+
// Or a sub-transaction. Usually these are created in the context of
// a conflict that is being resolved.
CdlTransaction make(CdlConflict = 0);
CdlTransaction get_parent() const;
CdlConflict get_conflict() const;
-
+
// Commit all the changes. Essentially this means transferring
// all of the per-transaction data to the toplevel, and then
// invoking the transaction callback. All propagation, inference,
// A variant which is used for checking the hierarchy when disabling
// a container
bool subnode_changed_by_user(CdlContainer) const;
-
+
// Is one transaction preferable to another?
bool is_preferable_to(CdlTransaction) const;
-
+
// Find out about per-transaction conflicts. This is particularly
// useful for the inference callback. The other containers can
// be accessed as well, for completeness.
const std::set<CdlNode>& get_activated() const;
const std::set<CdlNode>& get_deactivated() const;
const std::set<CdlValuable>& get_legal_values_changes() const;
-
+
// Manipulate the current set of conflicts, allowing for nested
// transactions and toplevel conflicts as well.
void clear_conflict(CdlConflict);
bool has_conflict_been_cleared(CdlConflict);
-
+
bool has_conflict(CdlNode, bool (*)(CdlConflict));
CdlConflict get_conflict(CdlNode, bool (*)(CdlConflict));
void get_conflicts(CdlNode, bool (*)(CdlConflict), std::vector<CdlConflict>&);
void apply_solution(CdlConflict);
void apply_solutions(const std::vector<CdlConflict>&);
void apply_all_solutions();
-
+
// Cancel all the changes done in this transaction. Essentially
// this just involves clearing out all the STL containers.
void cancel();
void cancel_last_commit_cancel_op();
CdlTransactionCommitCancelOp* get_last_commit_cancel_op() const;
const std::vector<CdlTransactionCommitCancelOp*>& get_commit_cancel_ops() const;
-
+
// Propagation support
void add_active_change(CdlNode);
void add_legal_values_change(CdlValuable);
void propagate();
bool is_propagation_required() const;
-
+
// Inference engine support.
void resolve(int = 0); // Process the new conflicts raised by this transaction
void resolve(CdlConflict, int = 0);
void resolve(const std::vector<CdlConflict>&, int = 0);
-
+
// An auxiliary function called by the inference engine to perform recursion
bool resolve_recursion(int);
-
+
// This function combines propagation, inference, and commit
// in one easy-to-use package
void body();
-
+
// Changes.
// There is a call to get hold of a CdlValue reference. Modifications
// should happen via a sequence of the form:
// transactions
bool is_active(CdlNode) const;
void set_active(CdlNode, bool);
-
+
// Callback and parameter settings
static void (*get_callback_fn())(const CdlTransactionCallback&);
static void set_callback_fn(void (*)(const CdlTransactionCallback&));
// wizard or user values.
static void set_inference_override(CdlValueSource);
static CdlValueSource get_inference_override();
-
+
bool check_this(cyg_assert_class_zeal = cyg_quick) const;
CYGDBG_DECLARE_MEMLEAK_COUNTER();
-
+
protected:
private:
CdlToplevel toplevel;
CdlTransaction parent;
CdlConflict conflict;
-
+
// Per-transaction information. All value changes, new conflicts
// etc. first live in the context of a transaction. The global
// configuration only gets updated if the transaction is commited.
std::set<CdlNode> deactivated;
std::set<CdlValuable> legal_values_changes;
bool dirty;
-
+
// Change propagation. It is necessary to keep track of all
// pending value changes, active changes, and of things being
// loaded or unloaded. The set_value() call is used to update the
static int inference_recursion_limit;
static CdlValueSource inference_override;
static void (*callback_fn)(const CdlTransactionCallback&);
-
+
enum {
- CdlTransactionBody_Invalid = 0,
- CdlTransactionBody_Magic = 0x3f91e4df
+ CdlTransactionBody_Invalid = 0,
+ CdlTransactionBody_Magic = 0x3f91e4df
} cdltransactionbody_cookie;
// Illegal operations
};
//}}}
-//{{{ CdlTransactionCallback
+//{{{ CdlTransactionCallback
// ----------------------------------------------------------------------------
// The callback class is used to inform applications about all the
// configurations.
class CdlTransactionCallback {
-
+
friend class CdlTest;
friend class CdlTransactionBody;
-
+
public:
~CdlTransactionCallback();
static void (*get_callback_fn())(const CdlTransactionCallback&);
// of statics.
CdlTransaction get_transaction() const;
CdlToplevel get_toplevel() const;
-
+
// active_changes and legal_values_changes get updated as the
// transaction proceeds, so a set implementation is more
// efficient. The others get filled in during a commit operation.
std::vector<CdlConflict> new_structural_conflicts;
std::vector<CdlNode> nodes_with_resolved_conflicts;
std::vector<CdlNode> nodes_with_resolved_structural_conflicts;
-
+
bool check_this(cyg_assert_class_zeal = cyg_quick) const;
-
+
protected:
private:
// Illegal operation.
CdlTransactionCallback();
-
+
enum {
- CdlTransactionCallback_Invalid = 0,
- CdlTransactionCallback_Magic = 0x0cec3a95
+ CdlTransactionCallback_Invalid = 0,
+ CdlTransactionCallback_Magic = 0x0cec3a95
} cdltransactioncallback_cookie;
};
//}}}
-//{{{ CdlLocalTransaction
+//{{{ CdlLocalTransaction
// ----------------------------------------------------------------------------
// A utility class to create a per-function transaction object which gets
// cleaned up automatically should an exception happen.
class CdlLocalTransaction {
-
+
friend class CdlTrest;
-
+
public:
CdlLocalTransaction(CdlToplevel toplevel) {
- transaction = CdlTransactionBody::make(toplevel);
+ transaction = CdlTransactionBody::make(toplevel);
}
~CdlLocalTransaction() {
- // The destructor may get invoked during exception handling.
- // It is assumed that cancelling the transaction would be a
- // good thing when that happens. Normal operation should
- // go through the body() or commit() members, which clear
- // the transaction field.
- // There is a slight consistency here. Normally after a
- // transaction commit the transaction object is still
- // around. Here the transaction object get deleted. This
- // is unlikely to matter in practice.
- if (0 != transaction) {
- transaction->cancel();
- delete transaction;
- }
+ // The destructor may get invoked during exception handling.
+ // It is assumed that cancelling the transaction would be a
+ // good thing when that happens. Normal operation should
+ // go through the body() or commit() members, which clear
+ // the transaction field.
+ // There is a slight consistency here. Normally after a
+ // transaction commit the transaction object is still
+ // around. Here the transaction object get deleted. This
+ // is unlikely to matter in practice.
+ if (0 != transaction) {
+ transaction->cancel();
+ delete transaction;
+ }
}
CdlTransaction get() {
- return transaction;
+ return transaction;
}
void body() {
- transaction->body();
- delete transaction;
- transaction = 0;
+ transaction->body();
+ delete transaction;
+ transaction = 0;
}
void commit() {
- transaction->commit();
- delete transaction;
- transaction = 0;
+ transaction->commit();
+ delete transaction;
+ transaction = 0;
}
void propagate() {
- transaction->propagate();
+ transaction->propagate();
}
void destroy() {
- if (0 != transaction) {
- transaction->cancel();
- delete transaction;
- transaction = 0;
- }
+ if (0 != transaction) {
+ transaction->cancel();
+ delete transaction;
+ transaction = 0;
+ }
}
private:
//}}}
//}}}
-//{{{ Build and define information
+//{{{ Build and define information
-//{{{ Description
+//{{{ Description
// ----------------------------------------------------------------------------
// There are two related concepts: buildable components, and
//
// Hardware packages have an implicit "define_header hardware.h"
// property.
-//
+//
// A buildable has the following properties:
//
// 1) compile [-library xyz] <file1> <file2> ...
// The latter will only be generated if the resulting symbol is
// a valid C preprocessor symbol, and is intended to allow the
// use of #ifdef as well as #ifdef (useful if the value is
-// non-numerical).
+// non-numerical).
//
// The define_format property provides control over the first of
// these two #defines. The net result is that the #define will be
// not affected by no_define.
//}}}
-//{{{ The build process
+//{{{ The build process
// ----------------------------------------------------------------------------
// For command-line operation the steps involved in doing a build are:
// be in the form of relative pathnames to facilitate this.
//}}}
-//{{{ CdlBuildInfo class
+//{{{ CdlBuildInfo class
// ----------------------------------------------------------------------------
// Extracting the build information.
/*
A typical value for "rules" might be:
- yacc toyslock.y
- $(CC) $(CFLAGS) -o toyslock.o y.tab.c
-
+ yacc toyslock.y
+ $(CC) $(CFLAGS) -o toyslock.o y.tab.c
+
Leading white space is not significant. Newlines are significant.
Backslash escapes in the text will not have been processed yet.
- */
+ */
};
struct CdlBuildInfo_Make {
std::string rules;
/*
Something like:
-
+
$(CC) $(ARCHFLAGS) $(LDARCHFLAGS) -nostdlib -Wl,-r -Wl,--whole-archive $(PREFIX)/lib/libextras.a -o $(PREFIX)/lib/extras.o
-
+
*/
};
class CdlBuildInfo_Loadable {
-
+
friend class CdlTest;
public:
std::vector<CdlBuildInfo_Object> objects;
std::vector<CdlBuildInfo_MakeObject> make_objects;
std::vector<CdlBuildInfo_Make> makes;
-
+
protected:
private:
};
//}}}
-//{{{ CdlBuildLoadable
+//{{{ CdlBuildLoadable
// ----------------------------------------------------------------------------
// BuildLoadables are derived from Loadables and are appropriate for
// An alternative which ignores the active and enabled states.
void update_all_build_info(CdlBuildInfo&) const;
-
+
// Property parsers and validation code appropriate for a
// build-loadable object such as makefile
static void add_property_parsers(std::vector<CdlInterpreterCommandEntry>& parsers);
static int parse_makefile(CdlInterpreter, int, const char*[]);
static int parse_include_dir(CdlInterpreter, int, const char*[]);
static int parse_include_files(CdlInterpreter, int, const char*[]);
-
+
// By default any compiled files will go into libtarget.a, which
// is the default value for this variable. Individual applications may
// specify an alternative default library.
- static char* default_library_name;
+ static const char* default_library_name;
// When filling in a build_info structure the library needs to know
// what constitutes a header file. A glob pattern can be used for this.
// NOTE: in the long term this should come out of a data file.
- static char* default_headers_glob_pattern;
-
+ static const char* default_headers_glob_pattern;
+
virtual std::string get_class_name() const;
bool check_this(cyg_assert_class_zeal = cyg_quick) const;
CYGDBG_DECLARE_MEMLEAK_COUNTER();
-
+
protected:
CdlBuildLoadableBody();
private:
enum {
- CdlBuildLoadableBody_Invalid = 0,
- CdlBuildLoadableBody_Magic = 0x55776643
+ CdlBuildLoadableBody_Invalid = 0,
+ CdlBuildLoadableBody_Magic = 0x55776643
} cdlbuildloadablebody_cookie;
// Illegal operations
};
//}}}
-//{{{ CdlBuildable
+//{{{ CdlBuildable
// ----------------------------------------------------------------------------
// Buildable objects can have properties such as compile and
// An alternative which ignores the active and enabled states.
void update_all_build_info(CdlBuildInfo_Loadable&, std::string) const;
-
+
// Add property parsers and validation code appropriate for a
// buildable object such as compile and make_object
static void add_property_parsers(std::vector<CdlInterpreterCommandEntry>& parsers);
static int parse_make_object(CdlInterpreter, int, const char*[]);
static int parse_object(CdlInterpreter, int, const char*[]);
static bool split_custom_build_step(std::string /* data */, std::string& /* target */, std::string& /* deps */,
- std::string& /* rules*/, std::string& /* error_msg */);
+ std::string& /* rules*/, std::string& /* error_msg */);
virtual std::string get_class_name() const;
bool check_this(cyg_assert_class_zeal = cyg_quick) const;
CYGDBG_DECLARE_MEMLEAK_COUNTER();
-
+
protected:
CdlBuildableBody();
private:
enum {
- CdlBuildableBody_Invalid = 0,
- CdlBuildableBody_Magic = 0x16eb1c04
+ CdlBuildableBody_Invalid = 0,
+ CdlBuildableBody_Magic = 0x16eb1c04
} cdlbuildablebody_cookie;
// Illegal operations
};
//}}}
-//{{{ CdlDefineLoadable
+//{{{ CdlDefineLoadable
// ----------------------------------------------------------------------------
// DefineLoadables are derived from Loadables and are appropriate for
// What header file should be generated for this loadable?
virtual std::string get_config_header() const;
-
+
// Add property parsers and validation code.
static void add_property_parsers(std::vector<CdlInterpreterCommandEntry>& parsers);
void check_properties(CdlInterpreter);
virtual std::string get_class_name() const;
bool check_this(cyg_assert_class_zeal = cyg_quick) const;
CYGDBG_DECLARE_MEMLEAK_COUNTER();
-
+
protected:
CdlDefineLoadableBody();
private:
enum {
- CdlDefineLoadableBody_Invalid = 0,
- CdlDefineLoadableBody_Magic = 0x7e211709
+ CdlDefineLoadableBody_Invalid = 0,
+ CdlDefineLoadableBody_Magic = 0x7e211709
} cdldefineloadablebody_cookie;
// Illegal operations
};
//}}}
-//{{{ CdlDefinable
+//{{{ CdlDefinable
// ----------------------------------------------------------------------------
// Definables are derived from Valuables and provide support for
virtual std::string get_class_name() const;
bool check_this(cyg_assert_class_zeal = cyg_quick) const;
CYGDBG_DECLARE_MEMLEAK_COUNTER();
-
+
protected:
CdlDefinableBody();
private:
enum {
- CdlDefinableBody_Invalid = 0,
- CdlDefinableBody_Magic = 0x65a2c95a
+ CdlDefinableBody_Invalid = 0,
+ CdlDefinableBody_Magic = 0x65a2c95a
} cdldefinablebody_cookie;
// Illegal operations
//}}}
//}}}
-//{{{ CdlDialog
+//{{{ CdlDialog
// ----------------------------------------------------------------------------
// A dialog simply inherits from CdlUserVisible and provides convenient
const cdl_tcl_code& get_display_proc() const;
const cdl_tcl_code& get_confirm_proc() const;
const cdl_tcl_code& get_cancel_proc() const;
-
+
static int parse_dialog(CdlInterpreter, int, const char*[]);
static int parse_display_proc(CdlInterpreter, int, const char*[]);
static int parse_update_proc(CdlInterpreter, int, const char*[]);
-
+
// Persistence support. Dialogs should just be ignored when it
// comes to saving and restoring files.
virtual void save(CdlInterpreter, Tcl_Channel, int, bool);
-
+
virtual std::string get_class_name() const;
bool check_this(cyg_assert_class_zeal = cyg_quick) const;
CYGDBG_DECLARE_MEMLEAK_COUNTER();
CdlDialogBody(std::string);
static bool dialogs_enabled;
-
+
enum {
- CdlDialogBody_Invalid = 0,
- CdlDialogBody_Magic = 0x3f4df391
+ CdlDialogBody_Invalid = 0,
+ CdlDialogBody_Magic = 0x3f4df391
} cdldialogbody_cookie;
-
+
// Illegal operations. The dialog name must be known at the time
// that the object is constructed.
CdlDialogBody();
};
//}}}
-//{{{ CdlWizard
+//{{{ CdlWizard
// ----------------------------------------------------------------------------
// A wizard is very much like a dialog, just a different set of properties.
static int parse_decoration_proc(CdlInterpreter, int, const char*[]);
static int parse_init_proc(CdlInterpreter, int, const char*[]);
static int parse_screen(CdlInterpreter, int, const char*[]);
-
+
// Persistence support. Wizards should just be ignored when it
// comes to saving and restoring files.
virtual void save(CdlInterpreter, Tcl_Channel, int, bool);
-
+
virtual std::string get_class_name() const;
bool check_this(cyg_assert_class_zeal = cyg_quick) const;
CYGDBG_DECLARE_MEMLEAK_COUNTER();
CdlWizardBody();
CdlWizardBody(const CdlWizardBody&);
CdlWizardBody& operator=(const CdlWizardBody&);
-
+
enum {
- CdlWizardBody_Invalid = 0,
- CdlWizardBody_Magic = 0x4ec1c39a
+ CdlWizardBody_Invalid = 0,
+ CdlWizardBody_Magic = 0x4ec1c39a
} cdlwizardbody_cookie;
};
//}}}
-//{{{ CdlInterface class
+//{{{ CdlInterface class
// ----------------------------------------------------------------------------
// Similarly for interfaces.
class CdlInterfaceBody : public virtual CdlNodeBody,
- public virtual CdlUserVisibleBody,
- public virtual CdlValuableBody,
- public virtual CdlParentableBody,
- public virtual CdlBuildableBody,
- public virtual CdlDefinableBody
+ public virtual CdlUserVisibleBody,
+ public virtual CdlValuableBody,
+ public virtual CdlParentableBody,
+ public virtual CdlBuildableBody,
+ public virtual CdlDefinableBody
{
friend class CdlTest;
void get_implementers(std::vector<CdlValuable>&) const;
void recalculate(CdlTransaction);
-
+
static int parse_interface(CdlInterpreter, int, const char*[]);
-
+
// Persistence support. The interface data cannot sensibly be modified
// by users, it is all calculated. However it is useful to have the
// interface data present in the saved file so that users can examine
private:
CdlInterfaceBody(std::string, bool /* generated */);
bool generated;
-
+
enum {
- CdlInterfaceBody_Invalid = 0,
- CdlInterfaceBody_Magic = 0x67f7fbe5
+ CdlInterfaceBody_Invalid = 0,
+ CdlInterfaceBody_Magic = 0x67f7fbe5
} cdlinterfacebody_cookie;
CdlInterfaceBody();
CdlInterfaceBody(const CdlInterfaceBody&);