summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2024-12-11 13:34:54 -0800
committerGitHub <noreply@github.com>2024-12-11 13:34:54 -0800
commit941f07040a505f1f673c96da959bde839c629aba (patch)
treefe5cd3cd0a63919ad8971d32cd18e8161f9cbd99 /include
parente50aac13e2c161d672b137a62f6d66820d0f9ff1 (diff)
Fix attribute reflection. (#5823)
* Fix attribute reflection. * Fix. * Fix.
Diffstat (limited to 'include')
-rw-r--r--include/slang.h46
1 files changed, 29 insertions, 17 deletions
diff --git a/include/slang.h b/include/slang.h
index 2dfee6b28..2ba7150ec 100644
--- a/include/slang.h
+++ b/include/slang.h
@@ -1776,6 +1776,7 @@ public: \
typedef struct SlangReflectionVariableLayout SlangReflectionVariableLayout;
typedef struct SlangReflectionTypeParameter SlangReflectionTypeParameter;
typedef struct SlangReflectionUserAttribute SlangReflectionUserAttribute;
+ typedef SlangReflectionUserAttribute SlangReflectionAttribute;
typedef struct SlangReflectionFunction SlangReflectionFunction;
typedef struct SlangReflectionGeneric SlangReflectionGeneric;
@@ -2140,46 +2141,48 @@ union GenericArgReflection
bool boolVal;
};
-struct UserAttribute
+struct Attribute
{
char const* getName()
{
- return spReflectionUserAttribute_GetName((SlangReflectionUserAttribute*)this);
+ return spReflectionUserAttribute_GetName((SlangReflectionAttribute*)this);
}
uint32_t getArgumentCount()
{
return (uint32_t)spReflectionUserAttribute_GetArgumentCount(
- (SlangReflectionUserAttribute*)this);
+ (SlangReflectionAttribute*)this);
}
TypeReflection* getArgumentType(uint32_t index)
{
return (TypeReflection*)spReflectionUserAttribute_GetArgumentType(
- (SlangReflectionUserAttribute*)this,
+ (SlangReflectionAttribute*)this,
index);
}
SlangResult getArgumentValueInt(uint32_t index, int* value)
{
return spReflectionUserAttribute_GetArgumentValueInt(
- (SlangReflectionUserAttribute*)this,
+ (SlangReflectionAttribute*)this,
index,
value);
}
SlangResult getArgumentValueFloat(uint32_t index, float* value)
{
return spReflectionUserAttribute_GetArgumentValueFloat(
- (SlangReflectionUserAttribute*)this,
+ (SlangReflectionAttribute*)this,
index,
value);
}
const char* getArgumentValueString(uint32_t index, size_t* outSize)
{
return spReflectionUserAttribute_GetArgumentValueString(
- (SlangReflectionUserAttribute*)this,
+ (SlangReflectionAttribute*)this,
index,
outSize);
}
};
+typedef Attribute UserAttribute;
+
struct TypeReflection
{
enum class Kind
@@ -2320,13 +2323,15 @@ struct TypeReflection
return (UserAttribute*)spReflectionType_GetUserAttribute((SlangReflectionType*)this, index);
}
- UserAttribute* findUserAttributeByName(char const* name)
+ UserAttribute* findAttributeByName(char const* name)
{
return (UserAttribute*)spReflectionType_FindUserAttributeByName(
(SlangReflectionType*)this,
name);
}
+ UserAttribute* findUserAttributeByName(char const* name) { return findAttributeByName(name); }
+
TypeReflection* applySpecializations(GenericReflection* generic)
{
return (TypeReflection*)spReflectionType_applySpecializations(
@@ -2777,14 +2782,14 @@ struct VariableReflection
return spReflectionVariable_GetUserAttributeCount((SlangReflectionVariable*)this);
}
- UserAttribute* getUserAttributeByIndex(unsigned int index)
+ Attribute* getUserAttributeByIndex(unsigned int index)
{
return (UserAttribute*)spReflectionVariable_GetUserAttribute(
(SlangReflectionVariable*)this,
index);
}
- UserAttribute* findUserAttributeByName(SlangSession* globalSession, char const* name)
+ Attribute* findAttributeByName(SlangSession* globalSession, char const* name)
{
return (UserAttribute*)spReflectionVariable_FindUserAttributeByName(
(SlangReflectionVariable*)this,
@@ -2792,6 +2797,11 @@ struct VariableReflection
name);
}
+ Attribute* findUserAttributeByName(SlangSession* globalSession, char const* name)
+ {
+ return findAttributeByName(globalSession, name);
+ }
+
bool hasDefaultValue()
{
return spReflectionVariable_HasDefaultValue((SlangReflectionVariable*)this);
@@ -2908,20 +2918,22 @@ struct FunctionReflection
{
return spReflectionFunction_GetUserAttributeCount((SlangReflectionFunction*)this);
}
- UserAttribute* getUserAttributeByIndex(unsigned int index)
+ Attribute* getUserAttributeByIndex(unsigned int index)
{
- return (UserAttribute*)spReflectionFunction_GetUserAttribute(
- (SlangReflectionFunction*)this,
- index);
+ return (
+ Attribute*)spReflectionFunction_GetUserAttribute((SlangReflectionFunction*)this, index);
}
- UserAttribute* findUserAttributeByName(SlangSession* globalSession, char const* name)
+ Attribute* findAttributeByName(SlangSession* globalSession, char const* name)
{
- return (UserAttribute*)spReflectionFunction_FindUserAttributeByName(
+ return (Attribute*)spReflectionFunction_FindUserAttributeByName(
(SlangReflectionFunction*)this,
globalSession,
name);
}
-
+ Attribute* findUserAttributeByName(SlangSession* globalSession, char const* name)
+ {
+ return findAttributeByName(globalSession, name);
+ }
Modifier* findModifier(Modifier::ID id)
{
return (Modifier*)spReflectionFunction_FindModifier(