New feature attributes added

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@5998 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2004-06-27 20:53:22 +00:00
commit f7306ec0cb
2 changed files with 30 additions and 5 deletions

View file

@ -520,9 +520,9 @@ Swig_name_object_inherit(Hash *namehash, String *base, String *derived) {
}
/* -----------------------------------------------------------------------------
* Swig_features_get()
* merge_features()
*
* Given a node, this function merges features.
* Given a hash, this function merges the features in the hash into the node.
* ----------------------------------------------------------------------------- */
static void merge_features(Hash *features, Node *n) {
@ -537,6 +537,13 @@ static void merge_features(Hash *features, Node *n) {
}
}
/* -----------------------------------------------------------------------------
* Swig_features_get()
*
* Attaches any features in the features hash to the node that matches
* the declaration, decl.
* ----------------------------------------------------------------------------- */
void
Swig_features_get(Hash *features, String *prefix, String *name, SwigType *decl, Node *node) {
String *tname;
@ -634,11 +641,13 @@ Swig_features_get(Hash *features, String *prefix, String *name, SwigType *decl,
/* -----------------------------------------------------------------------------
* Swig_feature_set()
*
* Sets a feature name and value.
* Sets a feature name and value. Also sets optional feature attributes as
* passed in by featureattribs. Optional feature attributes are given a full name
* concatenating the feature name plus ':' plus the attribute name.
* ----------------------------------------------------------------------------- */
void
Swig_feature_set(Hash *features, const String_or_char *name, SwigType *decl, const String_or_char *featurename, String *value) {
Swig_feature_set(Hash *features, const String_or_char *name, SwigType *decl, const String_or_char *featurename, String *value, Hash *featureattribs) {
Hash *n;
Hash *fhash;
/* Printf(stdout,"feature: %s %s %s %s\n", name, decl, featurename, value);*/
@ -666,6 +675,22 @@ Swig_feature_set(Hash *features, const String_or_char *name, SwigType *decl, con
} else {
Delattr(fhash,featurename);
}
{
/* Add in the optional feature attributes */
Hash *attribs = featureattribs;
while(attribs) {
String *attribname = Getattr(attribs,"name");
String *featureattribname = NewStringf("%s:%s", featurename, attribname);
if (value) {
String *attribvalue = Getattr(attribs,"value");
Setattr(fhash,featureattribname,attribvalue);
} else {
Delattr(fhash,featureattribname);
}
attribs = nextSibling(attribs);
}
}
}

View file

@ -400,7 +400,7 @@ extern void Swig_name_object_set(Hash *namehash, String_or_char *name, Swig
extern DOH *Swig_name_object_get(Hash *namehash, String_or_char *prefix, String_or_char *name, SwigType *decl);
extern void Swig_name_object_inherit(Hash *namehash, String *base, String *derived);
extern void Swig_features_get(Hash *features, String_or_char *prefix, String_or_char *name, SwigType *decl, Node *n);
extern void Swig_feature_set(Hash *features, const String_or_char *name, SwigType *decl, const String_or_char *featurename, String *value);
extern void Swig_feature_set(Hash *features, const String_or_char *name, SwigType *decl, const String_or_char *featurename, String *value, Hash *featureattribs);
/* --- Misc --- */
extern char *Swig_copy_string(const char *c);