wip updating gencpp to latest
testing new library
This commit is contained in:
@ -67,7 +67,7 @@ Example using each construction interface:
|
||||
Validation and construction through a functional interface.
|
||||
|
||||
```cpp
|
||||
Code t_uw = def_type( name(uw) );
|
||||
Code t_uw = def_type( name(usize) );
|
||||
Code t_allocator = def_type( name(allocator) );
|
||||
Code t_string_const = def_type( name(char), def_specifiers( args( ESpecifier::Const, ESpecifier::Ptr ) ));
|
||||
|
||||
@ -90,8 +90,8 @@ Validation through ast construction.
|
||||
Code header = parse_struct( code(
|
||||
struct ArrayHeader
|
||||
{
|
||||
uw Num;
|
||||
uw Capacity;
|
||||
usize Num;
|
||||
usize Capacity;
|
||||
allocator Allocator;
|
||||
};
|
||||
));
|
||||
@ -106,8 +106,8 @@ No validation, just glorified text injection.
|
||||
Code header = code_str(
|
||||
struct ArrayHeader
|
||||
{
|
||||
uw Num;
|
||||
uw Capacity;
|
||||
usize Num;
|
||||
usize Capacity;
|
||||
allocator Allocator;
|
||||
};
|
||||
);
|
||||
@ -123,8 +123,8 @@ All three constrcuton interfaces will generate the following C code:
|
||||
```cpp
|
||||
struct ArrayHeader
|
||||
{
|
||||
uw Num;
|
||||
uw Capacity;
|
||||
usize Num;
|
||||
usize Capacity;
|
||||
allocator Allocator;
|
||||
};
|
||||
```
|
||||
|
@ -136,7 +136,7 @@ The width dictates how much the static array can hold before it must give way to
|
||||
|
||||
```cpp
|
||||
constexpr static
|
||||
uw ArrSpecs_Cap =
|
||||
usize ArrSpecs_Cap =
|
||||
(
|
||||
AST_POD_Size
|
||||
- sizeof(AST*) * 3
|
||||
@ -158,7 +158,7 @@ Data Notes:
|
||||
* Most of the work is just defining the allocation procedure:
|
||||
|
||||
```cpp
|
||||
void* ( void* allocator_data, AllocType type, sw size, sw alignment, void* old_memory, sw old_size, u64 flags );
|
||||
void* ( void* allocator_data, AllocType type, ssize size, ssize alignment, void* old_memory, ssize old_size, u64 flags );
|
||||
```
|
||||
|
||||
* ASTs are wrapped for the user in a Code struct which is a wrapper for a AST* type.
|
||||
|
@ -2293,6 +2293,44 @@ struct String
|
||||
return Data[ length() - 1 ];
|
||||
}
|
||||
|
||||
bool contains(StrC substring) const
|
||||
{
|
||||
Header const& header = * rcast( Header const*, Data - sizeof( Header ));
|
||||
|
||||
if (substring.Len > header.Length)
|
||||
return false;
|
||||
|
||||
ssize main_len = header.Length;
|
||||
ssize sub_len = substring.Len;
|
||||
|
||||
for (ssize i = 0; i <= main_len - sub_len; ++i)
|
||||
{
|
||||
if (str_compare(Data + i, substring.Ptr, sub_len) == 0)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool contains(String const& substring) const
|
||||
{
|
||||
Header const& header = * rcast( Header const*, Data - sizeof( Header ));
|
||||
|
||||
if (substring.length() > header.Length)
|
||||
return false;
|
||||
|
||||
ssize main_len = header.Length;
|
||||
ssize sub_len = substring.length();
|
||||
|
||||
for (ssize i = 0; i <= main_len - sub_len; ++i)
|
||||
{
|
||||
if (str_compare(Data + i, substring.Data, sub_len) == 0)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
ssize capacity() const
|
||||
{
|
||||
Header const&
|
||||
|
Reference in New Issue
Block a user