Class Metadata

java.lang.Object
net.codecrete.windowsapi.metadata.Metadata

public class Metadata extends Object
Windows API metadata.

An instance of this class contains the entire Windows API metadata.

  • Constructor Details

    • Metadata

      public Metadata()
      Creates a new instance.
  • Method Details

    • namespaces

      public Map<String,Namespace> namespaces()
      Gets a map of all namespaces.

      In the map, namespaces are indexed by their name.

      Returns:
      the namespace map
    • createNamespace

      public Namespace createNamespace(String name)
      Creates a new namespace with the given name.
      Parameters:
      name - the namespace name
      Returns:
      the created namespace
    • getOrCreateNamespace

      public Namespace getOrCreateNamespace(String name)
      Gets the namespace with the given name or creates it if it does not yet exist.
      Parameters:
      name - the namespace name
      Returns:
      the existing or new namespace
    • types

      public Stream<Type> types()
      Gets all types.
      Returns:
      the types as a stream
    • getType

      public Type getType(String namespace, String name)
      Gets the type with the specified name.

      If different architecture variants exist for this type, one of the variants is returned.

      Parameters:
      namespace - the namespace name
      name - the type name
      Returns:
      type, or null if it is not found
    • getPrimitive

      public Primitive getPrimitive(PrimitiveKind kind)
      Gets the primitive type for the given kind.
      Parameters:
      kind - the primitive type kind
      Returns:
      the primitive
    • getTypeByTypeDefIndex

      public Type getTypeByTypeDefIndex(int typeDefIndex)
      Gets the type with the specified TypeDef index.
      Parameters:
      typeDefIndex - the TypeDef index
      Returns:
      the type, or null if it is not found
    • addType

      public void addType(Type type, boolean nameIsUnique)
      Adds a type to this metadata.
      Parameters:
      type - the type
      nameIsUnique - if true, checks that the type does not exist yet
    • removeType

      public void removeType(Type type, boolean nameExists)
      Removes a type from this metadata.
      Parameters:
      type - the type
      nameExists - if true, checks that the type actually exists
    • methods

      public Stream<Method> methods()
      Gets all methods.
      Returns:
      the methods as a stream
    • addMethod

      public void addMethod(Method method)
      Adds a method to this metadata.
      Parameters:
      method - the method
    • constants

      public Stream<ConstantValue> constants()
      Gets all constants.
      Returns:
      the constants as a stream
    • makePointerFor

      public Pointer makePointerFor(Type type)
      Creates a pointer referencing the specified type.

      It will reuse an exising pointer type if available.

      Parameters:
      type - the type to reference
      Returns:
      the pointer
    • makeAliasFor

      public TypeAlias makeAliasFor(int typeDefIndex, String name, Namespace namespace)
      Creates an alias for the specified TypeDef index.

      It will reuse an exising alias type if available.

      Parameters:
      typeDefIndex - the TypeDef index of the alias
      name - the alias name
      namespace - the alias namespace
      Returns:
      the alias
    • findStructs

      public List<Type> findStructs(Set<String> names)
      Finds the structs with the given names.

      The names are without the namespace, and they are case-sensitive. If a name is not found, it is ignored.

      Parameters:
      names - the set of names
      Returns:
      the found structs (as a list)
    • findEnums

      public List<Type> findEnums(Set<String> names)
      Finds the enums with the given names.

      The names are without the namespace, and they are case-sensitive. If a name is not found, it is ignored.

      Parameters:
      names - the set of names
      Returns:
      the found enumerations (as a list)
    • findEnumWithMember

      public List<EnumType> findEnumWithMember(String memberName)
      Finds enumerations containing a member with the given name.
      Parameters:
      memberName - the member name
      Returns:
      the enumerations
    • findDelegates

      public List<Type> findDelegates(Set<String> names)
      Finds the delegates with the given names.

      The names are without the namespace, and they are case-sensitive. If a name is not found, it is ignored.

      Parameters:
      names - set of names
      Returns:
      the found delegates (as a list)
    • findComInterfaces

      public List<Type> findComInterfaces(Set<String> names)
      Finds the COM interfaces with the given names.

      The names are without the namespace, and they are case-sensitive. If a name is not found, it is ignored.

      Parameters:
      names - set of names
      Returns:
      the found COM interfaces (as a list)
    • findFunctions

      public List<Method> findFunctions(Set<String> names)
      Finds the functions with the given names.

      The names are without the namespace, they are case-sensitive, and they are compared to the native Windows name. If a name is not found, it is ignored.

      Parameters:
      names - the set of names
      Returns:
      the found functions (as a list)
    • findConstants

      public List<ConstantValue> findConstants(Set<String> names)
      Finds the constants with the given names.

      The names are without the namespace, and they are case-sensitive. If a name is not found, it is ignored.

      Parameters:
      names - set of names
      Returns:
      the found constants (as a list)