mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-20 17:08:00 +02:00
Moving corlib files out of "System" directory into root
This commit is contained in:
parent
4cd58262e4
commit
7dbfd15292
179 changed files with 3 additions and 0 deletions
204
BeefLibs/corlib/src/System.bf
Normal file
204
BeefLibs/corlib/src/System.bf
Normal file
|
@ -0,0 +1,204 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace System
|
||||
{
|
||||
// Collection size type
|
||||
typealias int_cosize = int32;
|
||||
|
||||
[AlwaysInclude]
|
||||
static class CompilerSettings
|
||||
{
|
||||
#if BF_ENABLE_OBJECT_DEBUG_FLAGS
|
||||
public const bool cHasDebugFlags = true;
|
||||
#else
|
||||
public const bool cHasDebugFlags = false;
|
||||
#endif
|
||||
public const bool cHasVDataExtender = true;
|
||||
public const int32 cVDataIntefaceSlotCount = 16;
|
||||
|
||||
static this()
|
||||
{
|
||||
// This ensures this gets included in vdata
|
||||
}
|
||||
}
|
||||
|
||||
#if BF_ENABLE_OBJECT_DEBUG_FLAGS
|
||||
[AlwaysInclude]
|
||||
#endif
|
||||
struct CallStackAddr : int
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
interface IDisposable
|
||||
{
|
||||
void Dispose() mut;
|
||||
}
|
||||
|
||||
struct DeferredCall
|
||||
{
|
||||
public int64 mMethodId;
|
||||
public DeferredCall* mNext;
|
||||
|
||||
public void Cancel() mut
|
||||
{
|
||||
mMethodId = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static
|
||||
{
|
||||
public static mixin NOP()
|
||||
{
|
||||
}
|
||||
|
||||
public static mixin ToStackString(var obj)
|
||||
{
|
||||
var str = scope:: String();
|
||||
obj.ToString(str);
|
||||
str
|
||||
}
|
||||
|
||||
public static mixin StringAppend(var str, var str1, var str2)
|
||||
{
|
||||
str.Clear();
|
||||
str.Append(str1);
|
||||
str.Append(str2);
|
||||
str
|
||||
}
|
||||
|
||||
public static mixin StringAppend(var str, var str1, var str2, var str3)
|
||||
{
|
||||
str.Clear();
|
||||
str.Append(str1);
|
||||
str.Append(str2);
|
||||
str.Append(str3);
|
||||
str
|
||||
}
|
||||
|
||||
/*static mixin StackStringFormat(String format, params Object[] args)
|
||||
{
|
||||
var str = stack String();
|
||||
str.AppendF(format, args);
|
||||
}*/
|
||||
|
||||
public static mixin StackStringFormat(String format, var arg1)
|
||||
{
|
||||
var str = scope:: String();
|
||||
str.AppendF(format, arg1);
|
||||
str
|
||||
}
|
||||
|
||||
public static mixin StackStringFormat(String format, var arg1, var arg2)
|
||||
{
|
||||
var str = scope:: String();
|
||||
str.AppendF(format, arg1, arg2);
|
||||
str
|
||||
}
|
||||
|
||||
public static mixin StackStringFormat(String format, var arg1, var arg2, var arg3)
|
||||
{
|
||||
var str = scope:: String();
|
||||
str.AppendF(format, arg1, arg2, arg3);
|
||||
str
|
||||
}
|
||||
|
||||
public static mixin Try(var result)
|
||||
{
|
||||
if (result case .Err(var err))
|
||||
return .Err((.)err);
|
||||
result.Get()
|
||||
}
|
||||
|
||||
public static mixin TrySilent(var result)
|
||||
{
|
||||
if (result case .Err)
|
||||
return default;
|
||||
result.Get()
|
||||
}
|
||||
|
||||
public static mixin Swap(var a, var b)
|
||||
{
|
||||
let swap = a;
|
||||
a = b;
|
||||
b = swap;
|
||||
}
|
||||
|
||||
public static mixin DeleteContainerAndItems(var container)
|
||||
{
|
||||
if (container != null)
|
||||
{
|
||||
for (var value in container)
|
||||
delete value;
|
||||
delete container;
|
||||
}
|
||||
}
|
||||
|
||||
public static mixin DeleteAndClearItems(var container)
|
||||
{
|
||||
for (var value in container)
|
||||
delete value;
|
||||
container.Clear();
|
||||
}
|
||||
|
||||
public static void ClearAndDeleteItems<T>(List<T> container) where T : var
|
||||
{
|
||||
for (var value in container)
|
||||
delete value;
|
||||
container.Clear();
|
||||
}
|
||||
|
||||
public static mixin DeleteDictionyAndKeys(var container)
|
||||
{
|
||||
if (container != null)
|
||||
{
|
||||
for (var value in container)
|
||||
{
|
||||
delete value.key;
|
||||
}
|
||||
delete container;
|
||||
}
|
||||
}
|
||||
|
||||
public static mixin DeleteDictionyAndKeysAndItems(var container)
|
||||
{
|
||||
if (container != null)
|
||||
{
|
||||
for (var value in container)
|
||||
{
|
||||
delete value.key;
|
||||
delete value.value;
|
||||
}
|
||||
delete container;
|
||||
}
|
||||
}
|
||||
|
||||
public static mixin DeleteAndNullify(var val)
|
||||
{
|
||||
delete val;
|
||||
val = null;
|
||||
}
|
||||
|
||||
[NoReturn]
|
||||
public static void ThrowUnimplemented()
|
||||
{
|
||||
Runtime.FatalError("Unimplemented");
|
||||
}
|
||||
|
||||
public static mixin ScopedAlloc(int size, int align)
|
||||
{
|
||||
void* data;
|
||||
if (size <= 128)
|
||||
{
|
||||
data = scope:mixin uint8[size]* { ? };
|
||||
}
|
||||
else
|
||||
{
|
||||
data = new uint8[size]* { ? };
|
||||
defer:mixin delete data;
|
||||
}
|
||||
data
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue