OpenCore  1.0.4
OpenCore Bootloader
Loading...
Searching...
No Matches
OcTemplateLib.h File Reference
#include <Library/BaseMemoryLib.h>

Go to the source code of this file.

Macros

#define PRIV_OC_STRUCTOR_IGNORE(...)
 
#define PRIV_OC_STRUCTOR_EXPAND(...)
 
#define PRIV_OC_SELECT_NEXT_INNER(Dummy, Next, ...)
 
#define PRIV_OC_SELECT_NEXT_INNER_INDIR(...)
 
#define PRIV_OC_SELECT_NEXT(...)
 
#define PRIV_OC_REMOVE_NEXT(...)
 
#define PRIV_OC_DECLARE_STRUCT_MEMBER(Type, Name, Suffix, Constructor, Destructor)
 
#define PRIV_OC_CONSTRUCT_STRUCT_MEMBER(Type, Name, Suffix, Constructor, Destructor)
 
#define PRIV_OC_DESTRUCT_STRUCT_MEMBER(Type, Name, Suffix, Constructor, Destructor)
 
#define PRIV_OC_INVOKE_DESTRUCTOR(Destructor, Obj, Size)
 
#define PRIV_NO_KEY_TYPE   UINT8
 
#define OC_DECLARE(Name)
 
#define OC_STRUCTORS(Name, Destructor)
 
#define OC_CONSTR(A, _, __)
 
#define OC_CONSTR1(A, _, __)
 
#define OC_CONSTR2(A, _, __)
 
#define OC_CONSTR3(A, _, __)
 
#define OC_CONSTR5(A, _, __)
 
#define OC_DESTR(A)
 
#define OC_BLOB(Type, Count, Default, _, __)
 
#define OC_BLOB_STRUCTORS(Name)
 
#define OC_BLOB_CONSTR(Type, Constructor, SizeConstructor, _, __)
 
#define OC_MAP(KeyType, Type, _, __)
 
#define OC_MAP_STRUCTORS(Name)
 
#define OC_ARRAY(Type, _, __)
 
#define OC_ARRAY_STRUCTORS(Name)
 
#define OC_BLOB_GET(Blob)
 
#define OC_STRING_FIELDS(_, __)
 
#define OC_STRING_CONSTR(Constructor, _, __)
 
#define OC_ESTRING_CONSTR(_, __)
 
#define OC_DATA_FIELDS(_, __)
 
#define OC_EDATA_CONSTR(_, __)
 
#define OC_DATA_CONSTR(Constructor, _, __)
 
#define OC_ASSOC_FIELDS(_, __)
 

Typedefs

typedef VOID(* OC_STRUCTOR) (VOID *Ptr, UINT32 Size)
 

Functions

VOID OcFreePointer (VOID *Pointer, UINT32 Size)
 
VOID OcZeroField (VOID *Pointer, UINT32 Size)
 
VOID OcDestructEmpty (VOID *Pointer, UINT32 Size)
 
VOID OcFreeMap (VOID *Pointer, UINT32 Size)
 
VOID OcFreeArray (VOID *Pointer, UINT32 Size)
 
VOID * OcBlobAllocate (VOID *Pointer, UINT32 Size, UINT32 **OutSize OPTIONAL)
 
BOOLEAN OcListEntryAllocate (VOID *Pointer, VOID **Value, VOID **Key)
 

Detailed Description

OcTemplateLib

Copyright (c) 2018, vit9696

All rights reserved.

This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php

THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.

Definition in file OcTemplateLib.h.

Macro Definition Documentation

◆ OC_ARRAY

#define OC_ARRAY ( Type,
_,
__ )
Value:
_(UINT32 , Count , , 0 , () ) \
_(UINT32 , AllocCount , , 0 , () ) \
_(OC_STRUCTOR , Construct , , Type ## _CONSTRUCT , () ) \
_(OC_STRUCTOR , Destruct , , Type ## _DESTRUCT , () ) \
_(Type ** , Values , , NULL , () ) \
_(UINT32 , ValueSize , , sizeof (Type) , () )
VOID(* OC_STRUCTOR)(VOID *Ptr, UINT32 Size)

Definition at line 173 of file OcTemplateLib.h.

◆ OC_ARRAY_STRUCTORS

#define OC_ARRAY_STRUCTORS ( Name)
Value:
#define OC_STRUCTORS(Name, Destructor)
VOID OcFreeArray(VOID *Pointer, UINT32 Size)

Definition at line 181 of file OcTemplateLib.h.

◆ OC_ASSOC_FIELDS

#define OC_ASSOC_FIELDS ( _,
__ )
Value:
OC_MAP (OC_STRING, OC_DATA, _, __)
#define OC_MAP(KeyType, Type, _, __)

Definition at line 286 of file OcTemplateLib.h.

◆ OC_BLOB

#define OC_BLOB ( Type,
Count,
Default,
_,
__ )
Value:
_(UINT32 , Size , , 0 , OcZeroField ) \
_(UINT32 , MaxSize , , sizeof (Type Count) , OcZeroField ) \
_(Type * , DynValue , , NULL , OcFreePointer ) \
_(Type , Value , Count , __(Default) , () )
DMG_SIZE_DEVICE_PATH Size
VOID OcZeroField(VOID *Pointer, UINT32 Size)
VOID OcFreePointer(VOID *Pointer, UINT32 Size)

Definition at line 126 of file OcTemplateLib.h.

◆ OC_BLOB_CONSTR

#define OC_BLOB_CONSTR ( Type,
Constructor,
SizeConstructor,
_,
__ )
Value:
__({.Size = SizeConstructor, .MaxSize = sizeof (((Type *)0)->Value), .DynValue = NULL, .Value = Constructor})

Definition at line 135 of file OcTemplateLib.h.

◆ OC_BLOB_GET

#define OC_BLOB_GET ( Blob)
Value:
(((Blob)->DynValue) != NULL ? ((Blob)->DynValue) : ((Blob)->Value))

Definition at line 247 of file OcTemplateLib.h.

◆ OC_BLOB_STRUCTORS

#define OC_BLOB_STRUCTORS ( Name)
Value:
OC_STRUCTORS(Name, ())

Definition at line 132 of file OcTemplateLib.h.

◆ OC_CONSTR

#define OC_CONSTR ( A,
_,
__ )
Value:
{A ## _FIELDS(_, __)}

Definition at line 115 of file OcTemplateLib.h.

◆ OC_CONSTR1

#define OC_CONSTR1 ( A,
_,
__ )
Value:
{A ## _FIELDS(_, __)}

Definition at line 116 of file OcTemplateLib.h.

◆ OC_CONSTR2

#define OC_CONSTR2 ( A,
_,
__ )
Value:
{A ## _FIELDS(_, __)}

Definition at line 117 of file OcTemplateLib.h.

◆ OC_CONSTR3

#define OC_CONSTR3 ( A,
_,
__ )
Value:
{A ## _FIELDS(_, __)}

Definition at line 118 of file OcTemplateLib.h.

◆ OC_CONSTR5

#define OC_CONSTR5 ( A,
_,
__ )
Value:
{A ## _FIELDS(_, __)}

Definition at line 119 of file OcTemplateLib.h.

◆ OC_DATA_CONSTR

#define OC_DATA_CONSTR ( Constructor,
_,
__ )
Value:
OC_BLOB_CONSTR (OC_DATA, __(Constructor), sizeof ((UINT8[]) Constructor), _, __)
#define OC_BLOB_CONSTR(Type, Constructor, SizeConstructor, _, __)

Definition at line 283 of file OcTemplateLib.h.

◆ OC_DATA_FIELDS

#define OC_DATA_FIELDS ( _,
__ )
Value:
OC_BLOB (UINT8, [64], {0}, _, __)
#define OC_BLOB(Type, Count, Default, _, __)

Definition at line 276 of file OcTemplateLib.h.

◆ OC_DECLARE

#define OC_DECLARE ( Name)
Value:
typedef struct Name ## _ { \
} Name; \
VOID Name ## _CONSTRUCT(VOID *Ptr, UINT32 Size); \
VOID Name ## _DESTRUCT(VOID *Ptr, UINT32 Size);
#define PRIV_OC_DECLARE_STRUCT_MEMBER(Type, Name, Suffix, Constructor, Destructor)
#define PRIV_OC_STRUCTOR_IGNORE(...)

Definition at line 79 of file OcTemplateLib.h.

◆ OC_DESTR

#define OC_DESTR ( A)
Value:
A ## _DESTRUCT

Definition at line 120 of file OcTemplateLib.h.

◆ OC_EDATA_CONSTR

#define OC_EDATA_CONSTR ( _,
__ )
Value:
OC_BLOB_CONSTR (OC_DATA, __({0}), 0, _, __)

Definition at line 280 of file OcTemplateLib.h.

◆ OC_ESTRING_CONSTR

#define OC_ESTRING_CONSTR ( _,
__ )
Value:
OC_BLOB_CONSTR (OC_STRING, __(""), 0, _, __)

Definition at line 273 of file OcTemplateLib.h.

◆ OC_MAP

#define OC_MAP ( KeyType,
Type,
_,
__ )
Value:
_(UINT32 , Count , , 0 , () ) \
_(UINT32 , AllocCount , , 0 , () ) \
_(OC_STRUCTOR , Construct , , Type ## _CONSTRUCT , () ) \
_(OC_STRUCTOR , Destruct , , Type ## _DESTRUCT , () ) \
_(Type ** , Values , , NULL , () ) \
_(UINT32 , ValueSize , , sizeof (Type) , () ) \
_(UINT32 , KeySize , , sizeof (KeyType) , () ) \
_(OC_STRUCTOR , KeyConstruct , , KeyType ## _CONSTRUCT , () ) \
_(OC_STRUCTOR , KeyDestruct , , KeyType ## _DESTRUCT , () ) \
_(KeyType ** , Keys , , NULL , () )

Definition at line 148 of file OcTemplateLib.h.

◆ OC_MAP_STRUCTORS

#define OC_MAP_STRUCTORS ( Name)
Value:
VOID OcFreeMap(VOID *Pointer, UINT32 Size)

Definition at line 160 of file OcTemplateLib.h.

◆ OC_STRING_CONSTR

#define OC_STRING_CONSTR ( Constructor,
_,
__ )
Value:
OC_BLOB_CONSTR (OC_STRING, __(Constructor), sizeof (Constructor), _, __)

Definition at line 270 of file OcTemplateLib.h.

◆ OC_STRING_FIELDS

#define OC_STRING_FIELDS ( _,
__ )
Value:
OC_BLOB (CHAR8, [64], {0}, _, __)

Definition at line 266 of file OcTemplateLib.h.

◆ OC_STRUCTORS

#define OC_STRUCTORS ( Name,
Destructor )
Value:
VOID Name ## _CONSTRUCT(VOID *Ptr, UINT32 Size) { \
STATIC Name Obj = { \
}; \
CopyMem (Ptr, &Obj, sizeof (Name)); \
} \
VOID Name ## _DESTRUCT(VOID *Ptr, UINT32 Size) { \
Name *Obj = (Name *) Ptr; (VOID) Obj; \
PRIV_OC_INVOKE_DESTRUCTOR(Destructor, Obj, sizeof (Name)); \
}
#define PRIV_OC_DESTRUCT_STRUCT_MEMBER(Type, Name, Suffix, Constructor, Destructor)
#define PRIV_OC_STRUCTOR_EXPAND(...)
#define PRIV_OC_CONSTRUCT_STRUCT_MEMBER(Type, Name, Suffix, Constructor, Destructor)

Definition at line 91 of file OcTemplateLib.h.

◆ PRIV_NO_KEY_TYPE

#define PRIV_NO_KEY_TYPE   UINT8

Definition at line 63 of file OcTemplateLib.h.

◆ PRIV_OC_CONSTRUCT_STRUCT_MEMBER

#define PRIV_OC_CONSTRUCT_STRUCT_MEMBER ( Type,
Name,
Suffix,
Constructor,
Destructor )
Value:
.Name = Constructor,

Definition at line 54 of file OcTemplateLib.h.

◆ PRIV_OC_DECLARE_STRUCT_MEMBER

#define PRIV_OC_DECLARE_STRUCT_MEMBER ( Type,
Name,
Suffix,
Constructor,
Destructor )
Value:
Type Name Suffix;

Definition at line 51 of file OcTemplateLib.h.

◆ PRIV_OC_DESTRUCT_STRUCT_MEMBER

#define PRIV_OC_DESTRUCT_STRUCT_MEMBER ( Type,
Name,
Suffix,
Constructor,
Destructor )
Value:
PRIV_OC_SELECT_NEXT(PRIV_OC_REMOVE_NEXT Destructor, Destructor(&Obj->Name, sizeof (Type Suffix)));
#define PRIV_OC_REMOVE_NEXT(...)
#define PRIV_OC_SELECT_NEXT(...)

Definition at line 57 of file OcTemplateLib.h.

◆ PRIV_OC_INVOKE_DESTRUCTOR

#define PRIV_OC_INVOKE_DESTRUCTOR ( Destructor,
Obj,
Size )
Value:
PRIV_OC_SELECT_NEXT(PRIV_OC_REMOVE_NEXT Destructor, Destructor(Obj, Size))

Definition at line 60 of file OcTemplateLib.h.

◆ PRIV_OC_REMOVE_NEXT

#define PRIV_OC_REMOVE_NEXT ( ...)
Value:
, do { } while (0),

Definition at line 49 of file OcTemplateLib.h.

◆ PRIV_OC_SELECT_NEXT

#define PRIV_OC_SELECT_NEXT ( ...)
Value:
PRIV_OC_SELECT_NEXT_INNER_INDIR((__VA_ARGS__, Unused))
#define PRIV_OC_SELECT_NEXT_INNER_INDIR(...)

Definition at line 48 of file OcTemplateLib.h.

◆ PRIV_OC_SELECT_NEXT_INNER

#define PRIV_OC_SELECT_NEXT_INNER ( Dummy,
Next,
... )
Value:
Next

Definition at line 41 of file OcTemplateLib.h.

◆ PRIV_OC_SELECT_NEXT_INNER_INDIR

#define PRIV_OC_SELECT_NEXT_INNER_INDIR ( ...)
Value:
#define PRIV_OC_SELECT_NEXT_INNER(Dummy, Next,...)

Definition at line 47 of file OcTemplateLib.h.

◆ PRIV_OC_STRUCTOR_EXPAND

#define PRIV_OC_STRUCTOR_EXPAND ( ...)
Value:
__VA_ARGS__

Definition at line 39 of file OcTemplateLib.h.

◆ PRIV_OC_STRUCTOR_IGNORE

#define PRIV_OC_STRUCTOR_IGNORE ( ...)

Definition at line 38 of file OcTemplateLib.h.

Typedef Documentation

◆ OC_STRUCTOR

typedef VOID(* OC_STRUCTOR) (VOID *Ptr, UINT32 Size)

Definition at line 28 of file OcTemplateLib.h.

Function Documentation

◆ OcBlobAllocate()

VOID * OcBlobAllocate ( VOID * Pointer,
UINT32 Size,
UINT32 **OutSize OPTIONAL )

Definition at line 138 of file OcTemplateLib.c.

◆ OcDestructEmpty()

VOID OcDestructEmpty ( VOID * Pointer,
UINT32 Size )

Definition at line 79 of file OcTemplateLib.c.

◆ OcFreeArray()

VOID OcFreeArray ( VOID * Pointer,
UINT32 Size )

Definition at line 129 of file OcTemplateLib.c.

◆ OcFreeMap()

VOID OcFreeMap ( VOID * Pointer,
UINT32 Size )

Definition at line 120 of file OcTemplateLib.c.

◆ OcFreePointer()

VOID OcFreePointer ( VOID * Pointer,
UINT32 Size )

Definition at line 56 of file OcTemplateLib.c.

◆ OcListEntryAllocate()

BOOLEAN OcListEntryAllocate ( VOID * Pointer,
VOID ** Value,
VOID ** Key )

Definition at line 199 of file OcTemplateLib.c.

◆ OcZeroField()

VOID OcZeroField ( VOID * Pointer,
UINT32 Size )

Definition at line 70 of file OcTemplateLib.c.