~vanvugt/compiz/fix-1026920

« back to all changes in this revision

Viewing changes to compizconfig/libcompizconfig/include/ccs.h

  • Committer: Tarmac
  • Author(s): Sam Spilsbury
  • Date: 2012-11-29 11:40:16 UTC
  • mfrom: (3480.4.13 compiz.fix_1063617.6)
  • Revision ID: tarmac-20121129114016-z6m9zjp07ir7wzrc
Provide infrastructure for testing the ccsSet* functions

Provide infrastructure for testing value containers.

It will be useful for later tests to be able to specify a value and allow
the use of templates to automatically create a CCSValue for those. These value
containers handle the tricky issues around how those values have their
lifecycles managed, as every value needs a valid parent setting in order
to be destroyed properly (as type information is stored in the parent
setting).

ContainNormal and ContainList are convenience functions which forward
to NormalValueContainer and ListValueContainer.

NormalValueContainer will wrap a normal "raw" value and provide a means to
construct a CCSValue on-demand and a way to get the raw value.

ListValueContainer will wrap a normal "raw" value as the first member of
a CCSSettingValueList, safely wrap that in a SettingValueListWrapper and
then provde a means to construct a CCSValue from that on-demand and a way
to get the raw CCSSettingValueList.

Both use RawValueCopy in order to handle internal value copy semantics
properly.

RawValueCopy returns a copy of the "raw" value (i.e. not another
CCSSettingValue), doing deep copies as appropriate. It is implemented
as a series of template specializations to handle some of the various
pointer types, such as const char * and CCSSettingValueList.

Also provide SetWithDisallowedValue template + specializations

It will be useful in future to provide methods in the tests to set a
value which would otherwise be disallowed because it is out of range for
a particular type. The actual out-of-range error varies between the
types, so we need to provide some specializations for some of the
different types

Also expose ccsCopyInfo and separate ccsCopyValueInto from ccsCopyValue. The
latter returns a newly allocated copy of the value, the former deep-

There was a bug in ccsCopyInfo which caused the copy-from info to be
overwritten with the copy-to info. That was fixed.

There are no tests at present. The testing framework for this will be
quite similar to what we need to test settings, and will be adapted for
that purpose in testing this code. Fixes: https://bugs.launchpad.net/bugs/1063617.

Approved by Sam Spilsbury, PS Jenkins bot, Daniel van Vugt.

Show diffs side-by-side

added added

removed removed

Lines of Context:
722
722
void ccsFreeSetting (CCSSetting *setting);
723
723
void ccsFreeGroup (CCSGroup *group);
724
724
void ccsFreeSubGroup (CCSSubGroup *subGroup);
 
725
void ccsCleanupSettingInfo (CCSSettingInfo *info,
 
726
                         CCSSettingType type);
725
727
void ccsFreeSettingValue (CCSSettingValue *value);
726
728
void ccsFreeSettingValueWithType (CCSSettingValue *v,
727
729
                                  CCSSettingType  type);
792
794
 
793
795
/* Deep copy setting value */
794
796
CCSSettingValue *
795
 
ccsCopyValue (CCSSettingValue *orig,
796
 
              CCSSettingType  type,
797
 
              CCSSettingInfo  *info);
 
797
ccsCopyValue (const CCSSettingValue *orig,
 
798
              CCSSettingType        type,
 
799
              CCSSettingInfo        *info);
 
800
Bool
 
801
ccsCopyValueInto (const CCSSettingValue *from,
 
802
                  CCSSettingValue       *to,
 
803
                  CCSSettingType        type,
 
804
                  CCSSettingInfo        *info);
 
805
 
 
806
/* Deep copy setting info */
 
807
void
 
808
ccsCopyInfo (const CCSSettingInfo *from, CCSSettingInfo *to, CCSSettingType type);
798
809
 
799
810
/* Converts an array of data items to a setting value list. Behaves similar
800
811
   to ccsGetListFromStringArray */