Collapse boolean/double/enum properties into just integer.

This commit is contained in:
Peter Johnson
2016-09-20 22:17:12 -07:00
parent 8fbc23b1fa
commit d5e5755ff4
13 changed files with 123 additions and 357 deletions

View File

@@ -60,30 +60,24 @@ enum CS_StatusValue {
enum CS_PropertyType {
CS_PROP_NONE = 0,
CS_PROP_BOOLEAN,
CS_PROP_DOUBLE,
CS_PROP_STRING,
CS_PROP_ENUM
CS_PROP_BOOLEAN = 1,
CS_PROP_INTEGER = 2,
CS_PROP_STRING = 4,
CS_PROP_ENUM = 8
};
enum CS_PropertyType CS_GetPropertyType(CS_Property property,
CS_Status* status);
char* CS_GetPropertyName(CS_Property property, CS_Status* status);
CS_Bool CS_GetBooleanProperty(CS_Property property, CS_Status* status);
void CS_SetBooleanProperty(CS_Property property, CS_Bool value,
CS_Status* status);
double CS_GetDoubleProperty(CS_Property property, CS_Status* status);
void CS_SetDoubleProperty(CS_Property property, double value,
CS_Status* status);
double CS_GetPropertyMin(CS_Property property, CS_Status* status);
double CS_GetPropertyMax(CS_Property property, CS_Status* status);
double CS_GetPropertyStep(CS_Property property, CS_Status* status);
double CS_GetPropertyDefault(CS_Property property, CS_Status* status);
int CS_GetProperty(CS_Property property, CS_Status* status);
void CS_SetProperty(CS_Property property, int value, CS_Status* status);
int CS_GetPropertyMin(CS_Property property, CS_Status* status);
int CS_GetPropertyMax(CS_Property property, CS_Status* status);
int CS_GetPropertyStep(CS_Property property, CS_Status* status);
int CS_GetPropertyDefault(CS_Property property, CS_Status* status);
char* CS_GetStringProperty(CS_Property property, CS_Status* status);
void CS_SetStringProperty(CS_Property property, const char* value,
CS_Status* status);
int CS_GetEnumProperty(CS_Property property, CS_Status* status);
void CS_SetEnumProperty(CS_Property property, int value, CS_Status* status);
char** CS_GetEnumPropertyChoices(CS_Property property, int* count,
CS_Status* status);

View File

@@ -51,22 +51,18 @@ std::string GetPropertyName(CS_Property property, CS_Status* status);
llvm::StringRef GetPropertyName(CS_Property property,
llvm::SmallVectorImpl<char>& buf,
CS_Status* status);
bool GetBooleanProperty(CS_Property property, CS_Status* status);
void SetBooleanProperty(CS_Property property, bool value, CS_Status* status);
double GetDoubleProperty(CS_Property property, CS_Status* status);
void SetDoubleProperty(CS_Property property, double value, CS_Status* status);
double GetPropertyMin(CS_Property property, CS_Status* status);
double GetPropertyMax(CS_Property property, CS_Status* status);
double GetPropertyStep(CS_Property property, CS_Status* status);
double GetPropertyDefault(CS_Property property, CS_Status* status);
int GetProperty(CS_Property property, CS_Status* status);
void SetProperty(CS_Property property, int value, CS_Status* status);
int GetPropertyMin(CS_Property property, CS_Status* status);
int GetPropertyMax(CS_Property property, CS_Status* status);
int GetPropertyStep(CS_Property property, CS_Status* status);
int GetPropertyDefault(CS_Property property, CS_Status* status);
std::string GetStringProperty(CS_Property property, CS_Status* status);
llvm::StringRef GetStringProperty(CS_Property property,
llvm::SmallVectorImpl<char>& buf,
CS_Status* status);
void SetStringProperty(CS_Property property, llvm::StringRef value,
CS_Status* status);
int GetEnumProperty(CS_Property property, CS_Status* status);
void SetEnumProperty(CS_Property property, int value, CS_Status* status);
std::vector<std::string> GetEnumPropertyChoices(CS_Property property,
CS_Status* status);

View File

@@ -32,7 +32,7 @@ class VideoProperty {
enum Type {
kNone = CS_PROP_NONE,
kBoolean = CS_PROP_BOOLEAN,
kDouble = CS_PROP_DOUBLE,
kInteger = CS_PROP_INTEGER,
kString = CS_PROP_STRING,
kEnum = CS_PROP_ENUM
};
@@ -47,21 +47,16 @@ class VideoProperty {
// Type checkers
bool IsBoolean() const { return m_type == kBoolean; }
bool IsDouble() const { return m_type == kDouble; }
bool IsInteger() const { return m_type == kInteger; }
bool IsString() const { return m_type == kString; }
bool IsEnum() const { return m_type == kEnum; }
// Boolean-specific functions
bool GetBoolean() const;
void SetBoolean(bool value);
// Double-specific functions
double GetDouble() const;
void SetDouble(double value);
double GetMin() const;
double GetMax() const;
double GetStep() const;
double GetDefault() const;
int Get() const;
void Set(int value);
int GetMin() const;
int GetMax() const;
int GetStep() const;
int GetDefault() const;
// String-specific functions
std::string GetString() const;
@@ -69,8 +64,6 @@ class VideoProperty {
void SetString(llvm::StringRef value);
// Enum-specific functions
int GetEnum() const;
void SetEnum(int value);
std::vector<std::string> GetChoices() const;
CS_Status GetLastStatus() const { return m_status; }

View File

@@ -15,42 +15,32 @@ inline std::string VideoProperty::GetName() const {
return GetPropertyName(m_handle, &m_status);
}
inline bool VideoProperty::GetBoolean() const {
inline int VideoProperty::Get() const {
m_status = 0;
return GetBooleanProperty(m_handle, &m_status);
return GetProperty(m_handle, &m_status);
}
inline void VideoProperty::SetBoolean(bool value) {
inline void VideoProperty::Set(int value) {
m_status = 0;
SetBooleanProperty(m_handle, value, &m_status);
SetProperty(m_handle, value, &m_status);
}
inline double VideoProperty::GetDouble() const {
m_status = 0;
return GetDoubleProperty(m_handle, &m_status);
}
inline void VideoProperty::SetDouble(double value) {
m_status = 0;
SetDoubleProperty(m_handle, value, &m_status);
}
inline double VideoProperty::GetMin() const {
inline int VideoProperty::GetMin() const {
m_status = 0;
return GetPropertyMin(m_handle, &m_status);
}
inline double VideoProperty::GetMax() const {
inline int VideoProperty::GetMax() const {
m_status = 0;
return GetPropertyMax(m_handle, &m_status);
}
inline double VideoProperty::GetStep() const {
inline int VideoProperty::GetStep() const {
m_status = 0;
return GetPropertyStep(m_handle, &m_status);
}
inline double VideoProperty::GetDefault() const {
inline int VideoProperty::GetDefault() const {
m_status = 0;
return GetPropertyDefault(m_handle, &m_status);
}
@@ -71,16 +61,6 @@ inline void VideoProperty::SetString(llvm::StringRef value) {
SetStringProperty(m_handle, value, &m_status);
}
inline int VideoProperty::GetEnum() const {
m_status = 0;
return GetEnumProperty(m_handle, &m_status);
}
inline void VideoProperty::SetEnum(int value) {
m_status = 0;
SetEnumProperty(m_handle, value, &m_status);
}
inline std::vector<std::string> VideoProperty::GetChoices() const {
m_status = 0;
return GetEnumPropertyChoices(m_handle, &m_status);