mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Regression with .gitkeep in project init. List.init incorrectly didn't have the first argument the allocator. Added .init to priority queue. Created mem thread allocator alias. Correctly handle ident aliases. Allow ident on builtin aliases.
This commit is contained in:
@@ -23,7 +23,7 @@ struct List (Printable)
|
||||
@param initial_capacity "The initial capacity to reserve"
|
||||
@param [&inout] allocator "The allocator to use, defaults to the heap allocator"
|
||||
*>
|
||||
fn List* List.init(&self, usz initial_capacity = 16, Allocator allocator)
|
||||
fn List* List.init(&self, Allocator allocator, usz initial_capacity = 16)
|
||||
{
|
||||
self.allocator = allocator;
|
||||
self.size = 0;
|
||||
@@ -54,7 +54,7 @@ fn List* List.new_init(&self, usz initial_capacity = 16, Allocator allocator = a
|
||||
*>
|
||||
fn List* List.temp_init(&self, usz initial_capacity = 16)
|
||||
{
|
||||
return self.init(initial_capacity, allocator::temp()) @inline;
|
||||
return self.init(allocator::temp(), initial_capacity) @inline;
|
||||
}
|
||||
|
||||
<*
|
||||
|
||||
@@ -36,6 +36,11 @@ struct PrivatePriorityQueue (Printable)
|
||||
Heap heap;
|
||||
}
|
||||
|
||||
fn void PrivatePriorityQueue.init(&self, Allocator allocator, usz initial_capacity = 16, ) @inline
|
||||
{
|
||||
self.heap.new_init(initial_capacity, allocator);
|
||||
}
|
||||
|
||||
fn void PrivatePriorityQueue.new_init(&self, usz initial_capacity = 16, Allocator allocator = allocator::heap()) @inline
|
||||
{
|
||||
self.heap.new_init(initial_capacity, allocator);
|
||||
|
||||
@@ -360,6 +360,7 @@ macro void*! @aligned_realloc(#calloc_fn, #free_fn, void* old_pointer, usz bytes
|
||||
// All allocators
|
||||
|
||||
|
||||
def mem = thread_allocator @builtin;
|
||||
tlocal Allocator thread_allocator @private = base_allocator();
|
||||
Allocator temp_base_allocator @private = base_allocator();
|
||||
|
||||
|
||||
@@ -28,9 +28,9 @@ struct FrameScheduler
|
||||
|
||||
fn void FrameScheduler.init(&self)
|
||||
{
|
||||
self.events.new_init();
|
||||
self.pending_events.new_init();
|
||||
self.delayed_events.new_init();
|
||||
self.events.init(mem);
|
||||
self.pending_events.init(mem);
|
||||
self.delayed_events.init(mem);
|
||||
(void)self.mtx.init();
|
||||
bool pending;
|
||||
}
|
||||
|
||||
@@ -92,13 +92,13 @@ fault MatrixError
|
||||
|
||||
def Complexf = Complex(<float>);
|
||||
def Complex = Complex(<double>);
|
||||
def COMPLEX_IDENTITY = complex::IDENTITY(<double>);
|
||||
def COMPLEXF_IDENTITY = complex::IDENTITY(<float>);
|
||||
def COMPLEX_IDENTITY = complex::IDENTITY(<double>) @builtin;
|
||||
def COMPLEXF_IDENTITY = complex::IDENTITY(<float>) @builtin;
|
||||
|
||||
def Quaternionf = Quaternion(<float>);
|
||||
def Quaternion = Quaternion(<double>);
|
||||
def QUATERNION_IDENTITY = quaternion::IDENTITY(<double>);
|
||||
def QUATERNIONF_IDENTITY = quaternion::IDENTITY(<float>);
|
||||
def QUATERNION_IDENTITY = quaternion::IDENTITY(<double>) @builtin;
|
||||
def QUATERNIONF_IDENTITY = quaternion::IDENTITY(<float>) @builtin;
|
||||
|
||||
def Matrix2f = Matrix2x2(<float>);
|
||||
def Matrix2 = Matrix2x2(<double>);
|
||||
@@ -106,17 +106,17 @@ def Matrix3f = Matrix3x3(<float>);
|
||||
def Matrix3 = Matrix3x3(<double>);
|
||||
def Matrix4f = Matrix4x4(<float>);
|
||||
def Matrix4 = Matrix4x4(<double>);
|
||||
def matrix4_ortho = matrix::ortho(<double>);
|
||||
def matrix4_perspective = matrix::perspective(<double>);
|
||||
def matrix4f_ortho = matrix::ortho(<float>);
|
||||
def matrix4f_perspective = matrix::perspective(<float>);
|
||||
def matrix4_ortho = matrix::ortho(<double>) @builtin;
|
||||
def matrix4_perspective = matrix::perspective(<double>) @builtin;
|
||||
def matrix4f_ortho = matrix::ortho(<float>) @builtin;
|
||||
def matrix4f_perspective = matrix::perspective(<float>) @builtin;
|
||||
|
||||
def MATRIX2_IDENTITY = matrix::IDENTITY2(<double>);
|
||||
def MATRIX2F_IDENTITY = matrix::IDENTITY2(<float>);
|
||||
def MATRIX3_IDENTITY = matrix::IDENTITY3(<double>);
|
||||
def MATRIX3F_IDENTITY = matrix::IDENTITY3(<float>);
|
||||
def MATRIX4_IDENTITY = matrix::IDENTITY4(<double>);
|
||||
def MATRIX4F_IDENTITY = matrix::IDENTITY4(<float>);
|
||||
def MATRIX2_IDENTITY = matrix::IDENTITY2(<double>) @builtin;
|
||||
def MATRIX2F_IDENTITY = matrix::IDENTITY2(<float>) @builtin;
|
||||
def MATRIX3_IDENTITY = matrix::IDENTITY3(<double>) @builtin;
|
||||
def MATRIX3F_IDENTITY = matrix::IDENTITY3(<float>) @builtin;
|
||||
def MATRIX4_IDENTITY = matrix::IDENTITY4(<double>) @builtin;
|
||||
def MATRIX4F_IDENTITY = matrix::IDENTITY4(<float>) @builtin;
|
||||
|
||||
|
||||
<*
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
- Correctly give an error if a character literal contains a line break.
|
||||
- Implicitly unwrapped optional value in defer incorrectly copied #1982.
|
||||
- Crash when trying to define a method macro that isn't `@construct` but has no arguments.
|
||||
- Regression, `.gitkeep` files were generated incorrectly.
|
||||
- Aliases are now correctly handled as if they were variables/functions in regards to namespacing and accept `@builtin`.
|
||||
|
||||
### Stdlib changes
|
||||
|
||||
|
||||
@@ -406,6 +406,7 @@ bool decl_needs_prefix(Decl *decl)
|
||||
switch (decl->decl_kind)
|
||||
{
|
||||
case DECL_VAR:
|
||||
case DECL_DEFINE:
|
||||
case DECL_FUNC:
|
||||
case DECL_MACRO:
|
||||
return !decl->is_autoimport;
|
||||
|
||||
@@ -2109,10 +2109,12 @@ static inline Decl *parse_def_attribute(ParseContext *c)
|
||||
CONSUME_OR_RET(TOKEN_LBRACE, poisoned_decl);
|
||||
|
||||
bool is_cond;
|
||||
if (!parse_attributes(c, &attributes, NULL, NULL, &is_cond)) return poisoned_decl;
|
||||
bool is_builtin;
|
||||
if (!parse_attributes(c, &attributes, NULL, decl_needs_prefix(decl) ? &is_builtin : NULL, &is_cond)) return poisoned_decl;
|
||||
CONSUME_OR_RET(TOKEN_RBRACE, poisoned_decl);
|
||||
decl->attr_decl.attrs = attributes;
|
||||
decl->is_cond = is_cond;
|
||||
decl->is_autoimport = is_builtin;
|
||||
if (!parse_attributes_for_global(c, decl)) return poisoned_decl;
|
||||
CONSUME_EOS_OR_RET(poisoned_decl);
|
||||
return decl;
|
||||
|
||||
@@ -1093,6 +1093,9 @@ static inline bool sema_expr_analyse_identifier(SemaContext *context, Type *to,
|
||||
case DECL_MACRO:
|
||||
message = "Macros from other modules must be prefixed with the module name.";
|
||||
break;
|
||||
case DECL_DEFINE:
|
||||
message = "Aliases from other modules must be prefixed with the module name.";
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE
|
||||
}
|
||||
|
||||
@@ -509,7 +509,7 @@ const char *file_append_path_temp(const char *path, const char *name)
|
||||
#endif
|
||||
|
||||
// format the string safely
|
||||
bool insert_separator = path[path_len - 1] == '/' || path[path_len - 1] == separator;
|
||||
bool insert_separator = path[path_len - 1] != '/' && path[path_len - 1] != separator;
|
||||
int written = insert_separator
|
||||
? snprintf(path_buffer, PATH_BUFFER_SIZE, "%s%c%s", path, separator, name)
|
||||
: snprintf(path_buffer, PATH_BUFFER_SIZE, "%s%s", path, name);
|
||||
|
||||
Reference in New Issue
Block a user