Skip to content

Commit

Permalink
updated from dagor4 repo on 2023/10/22, rev 0c5bf9c1d82d7491c925febbb…
Browse files Browse the repository at this point in the history
…3bfd48d015637df
  • Loading branch information
NicSavichev committed Oct 22, 2023
1 parent 98b313a commit e97a495
Show file tree
Hide file tree
Showing 3,840 changed files with 98,709 additions and 53,098 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ ForEachMacros:
- FOR_EACH_PRIMARY_RG_LAYER_DO
- FOR_EACH_RG_LAYER_RENDER
- ITERATE_OVER_SUBFX
StatementMacros: ['DAG_DECLARE_NEW', 'decl_ptr', 'decl_dclass_hdr', 'decl_class_name', 'decl_issubof']
StatementMacros: ['DAG_DECLARE_NEW', 'decl_ptr', 'decl_dclass_hdr', 'decl_class_name', 'decl_issubof', 'JPH_IMPLEMENT_SERIALIZABLE_VIRTUAL', 'JPH_ADD_ATTRIBUTE']
IfMacros: ['IF_CONSTEXPR']
IndentCaseLabels: true
IndentWidth: 2
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@
/_output/
*.pyc
*.das.inl
*.sh.log
ShaderLog-*
2 changes: 1 addition & 1 deletion DagorEngine.rev.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
bd13cb3e43d51b1e16daa6d06d4011139f91fbe0
0c5bf9c1d82d7491c925febbb3bfd48d015637df
1 change: 1 addition & 0 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ third-party component as follows:
prog/3rdPartyLibs/mongoose/LICENSE
prog/3rdPartyLibs/nanosvg/LICENSE.txt
prog/3rdPartyLibs/openssl-3.x/LICENSE.txt
prog/3rdPartyLibs/ozz/LICENSE.md
prog/3rdPartyLibs/pcre/LICENSE
prog/3rdPartyLibs/phys/bullet-3/Extras/ConvexDecomposition/LICENSE.txt
prog/3rdPartyLibs/phys/bullet-3/Extras/InverseDynamics/LICENSE.txt
Expand Down
9 changes: 8 additions & 1 deletion build_all.cmd
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
pushd prog\tools
call build_dagor3_cdk_mini.cmd
call build_dagor3_cdk_mini.cmd
if errorlevel 1 (
echo build_dagor3_cdk_mini.cmd failed, trying once more...
call build_dagor3_cdk_mini.cmd
)
if errorlevel 1 (
echo failed to build CDK, stop!
exit /b 1
)
popd

pushd prog\tools\dargbox
Expand Down
60 changes: 48 additions & 12 deletions prog/1stPartyLibs/daScript/daslib/apply.das
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@ require daslib/ast_boost
require daslib/defer
require daslib/templates_boost
require daslib/macro_boost
require math

[macro_function]
def for_each_subrange ( total:int; blk:block<(r:range):void> )
let MAX_ARGUMENTS = DAS_MAX_FUNCTION_ARGUMENTS - 2 // we need one for the data itself
var i = 0
while i < total
let fromI = i
let toI = min(i+MAX_ARGUMENTS,total)
blk |> invoke(range(fromI,toI))
i = toI

/*
def apply`Foo(self:Foo;arg_field1:block<(name:string,value:field1-type):void>;arg_field2:...)
Expand All @@ -19,15 +30,17 @@ require daslib/macro_boost
...
*/
[macro_function]
def generateApplyVisitStruct ( stype:TypeDeclPtr; fnname:string; at:LineInfo )
def generateApplyVisitStruct ( stype:TypeDeclPtr; frange:range; fnname:string; at:LineInfo )
assert(stype.baseType==Type tStructure)
assert(stype.dim |> length==0)
var inscope selfT <- clone_type(stype)
selfT.flags |= TypeDeclFlags isExplicit | TypeDeclFlags explicitConst
var inscope blkList : array<ExpressionPtr>
var inscope func_args : array<VariablePtr>
for fld in stype.structType.fields
// for fld in stype.structType.fields
for fldi in frange
if true
let fld & = unsafe(stype.structType.fields[fldi])
blkList |> emplace_new <| qmacro(invoke($i("__arg_{fld.name}"),$v(string(fld.name)),_`_self.$f(fld.name)))
var inscope argT <- new [[TypeDecl() baseType=Type tBlock, at=at]] // block<(name:string;x:field1type)>
emplace_new(argT.argTypes, new [[TypeDecl() baseType=Type tString, at=at]])
Expand All @@ -45,22 +58,28 @@ def generateApplyVisitStruct ( stype:TypeDeclPtr; fnname:string; at:LineInfo )
fn.flags |= FunctionFlags privateFunction
compiling_module() |> add_function(fn)

[macro_function]
def generateApplyVisitStruct ( stype:TypeDeclPtr; fnname:string; at:LineInfo )
for_each_subrange(length(stype.structType.fields)) <| $ ( frange )
generateApplyVisitStruct(stype,frange,"{fnname}`{frange.x}`{frange.y}",at)

/*
def apply`Foo(self:Foo;arg_field1:block<(name:string,value:field1-type):void>;arg_field2:...)
invoke(arg_field1,"field1",self.field1)
invoke(arg_field2,"field2",self.field2)
...
*/
[macro_function]
def generateApplyVisitTuple ( stype:TypeDeclPtr; fnname:string; at:LineInfo )
def generateApplyVisitTuple ( stype:TypeDeclPtr; frange:range; fnname:string; at:LineInfo )
assert(stype.baseType==Type tTuple)
assert(stype.dim |> length==0)
var inscope selfT <- clone_type(stype)
selfT.flags |= TypeDeclFlags isExplicit | TypeDeclFlags explicitConst
var inscope blkList : array<ExpressionPtr>
var inscope func_args : array<VariablePtr>
for flda,fldi in stype.argTypes,count()
for fldi in frange
if true
assume flda = stype.argTypes[fldi]
let fldname = length(stype.argNames)==length(stype.argTypes) ? string(stype.argNames[fldi]) : "_{fldi}"
blkList |> emplace_new <| qmacro(invoke($i("__arg_{fldname}"),$v(fldname),_`_self.$f(fldname)))
var inscope argT <- new [[TypeDecl() baseType=Type tBlock, at=at]] // block<(name:string;x:field1type)>
Expand All @@ -79,6 +98,11 @@ def generateApplyVisitTuple ( stype:TypeDeclPtr; fnname:string; at:LineInfo )
fn.flags |= FunctionFlags privateFunction
compiling_module() |> add_function(fn)

[macro_function]
def generateApplyVisitTuple ( stype:TypeDeclPtr; fnname:string; at:LineInfo )
for_each_subrange(length(stype.argTypes)) <| $ ( frange )
generateApplyVisitTuple(stype,frange,"{fnname}`{frange.x}`{frange.y}",at)

/*
def apply`Foo(self:Foo;arg_field1:block<(name:string,value:field1-type):void>;arg_field2:...)
if variant_index(self)==0
Expand All @@ -90,15 +114,16 @@ def generateApplyVisitTuple ( stype:TypeDeclPtr; fnname:string; at:LineInfo )
...
*/
[macro_function]
def generateApplyVisitVariant ( stype:TypeDeclPtr; fnname:string; at:LineInfo )
def generateApplyVisitVariant ( stype:TypeDeclPtr; frange:range; fnname:string; at:LineInfo )
assert(stype.baseType==Type tVariant)
assert(stype.dim |> length==0)
var inscope selfT <- clone_type(stype)
selfT.flags |= TypeDeclFlags isExplicit | TypeDeclFlags explicitConst
var inscope blkList : array<ExpressionPtr>
var inscope func_args : array<VariablePtr>
for flda,fldi in stype.argTypes,count()
for fldi in frange
if true
assume flda = stype.argTypes[fldi]
let fldname = length(stype.argNames)==length(stype.argTypes) ? string(stype.argNames[fldi]) : "_{fldi}"
var inscope vexpr <- qmacro_block <|
if variant_index(_`_self)==$v(fldi)
Expand All @@ -121,6 +146,11 @@ def generateApplyVisitVariant ( stype:TypeDeclPtr; fnname:string; at:LineInfo )
fn.flags |= FunctionFlags privateFunction
compiling_module() |> add_function(fn)

[macro_function]
def generateApplyVisitVariant ( stype:TypeDeclPtr; fnname:string; at:LineInfo )
for_each_subrange(length(stype.argTypes)) <| $ ( frange )
generateApplyVisitVariant(stype,frange,"{fnname}`{frange.x}`{frange.y}",at)

[call_macro(name="apply")] // apply(value, block)
class ApplyMacro : AstCallMacro
//! This macro implements the apply() pattern. The idea is that for each entry in the structure, variant, or tuple,
Expand Down Expand Up @@ -158,10 +188,16 @@ class ApplyMacro : AstCallMacro
else
macro_error(prog,expr.at,"internal error. can't apply to {describe(argT)}")
return <- [[ExpressionPtr]]
// make a call
var inscope call <- new [[ExprCall() name:="_::" + callName, at=expr.at]]
emplace_new(call.arguments,clone_expression(expr.arguments[0]))
for _ in range(nfields)
emplace_new(call.arguments,clone_expression(expr.arguments[1]))
return <- call
// make a collection of calls
var inscope calls : array<ExpressionPtr>
for_each_subrange(nfields) <| $ ( frange )
var inscope call <- new [[ExprCall() name:="_::{callName}`{frange.x}`{frange.y}", at=expr.at]]
emplace_new(call.arguments,clone_expression(expr.arguments[0]))
for _ in frange
emplace_new(call.arguments,clone_expression(expr.arguments[1]))
calls |> emplace(call)
if length(calls)==1
return <- calls[0]
var inscope callblock <- new [[ExprBlock() at=expr.at, list := calls]]
return <- callblock
return <- [[ExpressionPtr]]
16 changes: 8 additions & 8 deletions prog/1stPartyLibs/daScript/daslib/ast_boost.das
Original file line number Diff line number Diff line change
Expand Up @@ -314,19 +314,19 @@ class SetupAnyAnnotation : AstStructureAnnotation
emplace(blk.list,cll)
return true

class SetupFunctionAnnotatoin : SetupAnyAnnotation
class SetupFunctionAnnotation : SetupAnyAnnotation
override annotation_function_call : string = "add_new_function_annotation"

class SetupBlockAnnotatoin : SetupAnyAnnotation
class SetupBlockAnnotation : SetupAnyAnnotation
override annotation_function_call : string = "add_new_block_annotation"

class SetupStructureAnnotatoin : SetupAnyAnnotation
class SetupStructureAnnotation : SetupAnyAnnotation
override annotation_function_call : string = "add_new_structure_annotation"

class SetupEnumerationAnnotation : SetupAnyAnnotation
override annotation_function_call : string = "add_new_enumeration_annotation"

class SetupContractAnnotatoin : SetupAnyAnnotation
class SetupContractAnnotation : SetupAnyAnnotation
override annotation_function_call : string = "add_new_contract_annotation"

class SetupReaderMacro : SetupAnyAnnotation
Expand Down Expand Up @@ -766,11 +766,11 @@ def private setup
if is_compiling_macros_in_module("ast_boost")
add_new_function_annotation("macro", new MacroMacro())
add_new_function_annotation("tag_function",new TagFunctionAnnotation())
add_new_structure_annotation("function_macro",new SetupFunctionAnnotatoin())
add_new_structure_annotation("block_macro",new SetupBlockAnnotatoin())
add_new_structure_annotation("structure_macro",new SetupStructureAnnotatoin())
add_new_structure_annotation("function_macro",new SetupFunctionAnnotation())
add_new_structure_annotation("block_macro",new SetupBlockAnnotation())
add_new_structure_annotation("structure_macro",new SetupStructureAnnotation())
add_new_structure_annotation("enumeration_macro",new SetupEnumerationAnnotation())
add_new_structure_annotation("contract",new SetupContractAnnotatoin())
add_new_structure_annotation("contract",new SetupContractAnnotation())
add_new_structure_annotation("reader_macro",new SetupReaderMacro())
add_new_structure_annotation("comment_reader",new SetupCommentReader())
add_new_structure_annotation("call_macro",new SetupCallMacro())
Expand Down
2 changes: 1 addition & 1 deletion prog/1stPartyLibs/daScript/daslib/bitfield_trait.das
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require daslib/contracts
require daslib/strings_boost
require daslib/templates_boost

[expect_any_bitfield(argT),tag_function(each_bitfield_tag)]
[expect_any_bitfield(argT),tag_function(each_bitfield_tag),unused_argument(argT)]
def public each ( argT )
//! Same as assert, only the check will be not be repeated after the asseretion failed the first time.
pass
Expand Down
18 changes: 9 additions & 9 deletions prog/1stPartyLibs/daScript/daslib/cpp_bind.das
Original file line number Diff line number Diff line change
Expand Up @@ -57,40 +57,40 @@ def log_cpp_class_adapter ( cpp_file:file; name:string; cinfo:TypeDeclPtr )
//!
//! log_cpp_class_adapter(cppFileNameDotInc, "daScriptClassName", typeinfo(ast_typedecl type<daScriptClassName>))
assert(cinfo.isClass,"can only make adapter out of a class")
var methods : array<string>
var methods : array<tuple<name:string;index:int>>
var inscope types : array<TypeDeclPtr>
for fld in cinfo.structType.fields
for fld,idx in cinfo.structType.fields,count()
if !fld._type.isFunction || fld.name=="__finalize" || fld.init!=null
continue
push(methods,"{fld.name}")
push(methods,[[auto "{fld.name}",idx]])
push_clone(types,fld._type)
let nmet = length(methods)
fwrite(cpp_file, "class {name} \{\n")
fwrite(cpp_file, "protected:\n")
fwrite(cpp_file, " enum \{\n")
for mn,mni in methods, count()
fwrite(cpp_file, " __fn_{mn} = {mni},\n")
fwrite(cpp_file, " __fn_{mn.name} = {mni},\n")
fwrite(cpp_file, " };\n")
fwrite(cpp_file, "protected:\n")
fwrite(cpp_file, " int _das_class_method_offset[{nmet}];\n")
fwrite(cpp_file, "public:\n")
fwrite(cpp_file, " {name} ( const StructInfo * info ) \{\n")
for mn,mni in methods, count()
fwrite(cpp_file, " _das_class_method_offset[__fn_{mn}] = adapt_field_offset(\"{mn}\",info);\n")
fwrite(cpp_file, " _das_class_method_offset[__fn_{mn.name}] = info->fields[{mn.index}]->offset;\n")
fwrite(cpp_file, " \}\n")
for mn,mt in methods,types
// get
fwrite(cpp_file, " __forceinline Func get_{mn} ( void * self ) const \{\n")
fwrite(cpp_file, " return getDasClassMethod(self,_das_class_method_offset[__fn_{mn}]);\n")
fwrite(cpp_file, " __forceinline Func get_{mn.name} ( void * self ) const \{\n")
fwrite(cpp_file, " return getDasClassMethod(self,_das_class_method_offset[__fn_{mn.name}]);\n")
fwrite(cpp_file, " \}\n")
// invoke
fwrite(cpp_file, " __forceinline ")
log_cpp_class_method(cpp_file, "invoke_{mn}",mt)
log_cpp_class_method(cpp_file, "invoke_{mn.name}",mt)
fwrite(cpp_file, " const \{\n")
fwrite(cpp_file, " ")
if !mt.firstType.isVoid
fwrite(cpp_file, "return ")
log_cpp_class_method_call(cpp_file, mn,mt)
log_cpp_class_method_call(cpp_file,mn.name,mt)
fwrite(cpp_file, ";\n")
fwrite(cpp_file, " \}\n")
fwrite(cpp_file, "};\n\n")
Expand Down
2 changes: 1 addition & 1 deletion prog/1stPartyLibs/daScript/daslib/das_source_formatter.das
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ struct FormatterCtx
spaceCounter: int // space characters before current token
srcLine: int // current line in source
curColumn: int // current column in source
curLineIndex: int // index of the begining of new line in data[]
curLineIndex: int // index of the beginning of new line in data[]
debugMode: bool = false
indenting: int = 0 // convert tab to N spaces
insideOptions: bool = false
Expand Down
16 changes: 16 additions & 0 deletions prog/1stPartyLibs/daScript/daslib/jobque_boost.das
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,22 @@ def push ( channel:Channel?; data : auto? )
//! pushes value to the channel (at the end)
_builtin_channel_push(channel, data)

def push_batch_clone ( channel:Channel?; data : array<auto(TT)> )
//! clones data and pushed values to the channel (at the end)
var heap_data : array<TT?>
for d in data
var tt = new TT
*tt := d
heap_data |> push(tt)
_builtin_channel_push(channel, heap_data)
heap_data |> resize(0)
unsafe
delete heap_data

def push_batch ( channel:Channel?; data : array<auto?> )
//! pushes values to the channel (at the end)
_builtin_channel_push_batch(channel, data)

def set ( box:LockBox?; data : auto(TT) )
//! clones data and sets value to the lock box
var heap_data = new TT
Expand Down
2 changes: 1 addition & 1 deletion prog/1stPartyLibs/daScript/daslib/json.das
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ def try_fixing_broken_json ( var bad:string )
var i = 0
let lstr = length(str)
while i < lstr
// write until begining of string or end
// write until beginning of string or end
while i < lstr && str[i]!='"'u8
if str[i]==','u8
var j = i + 1
Expand Down
46 changes: 46 additions & 0 deletions prog/1stPartyLibs/daScript/daslib/temp_strings.das
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
options indenting = 4
options no_unused_block_arguments = false
options no_unused_function_arguments = false
options no_aot = true
options strict_smart_pointers = true

module temp_strings shared private

require daslib/ast_boost
require strings public

def public build_temp_string(bldr : block<(var writer : StringBuilderWriter) : void>; cb : block<(res : string#) : void>)
//! Same as build_string, but delete the string after the callback is called.
//! Intern strings are not deleted.
var str = build_string(bldr)
unsafe
cb |> invoke(reinterpret<string#> str)
if !is_intern_strings()
delete_string(reinterpret<string> str)

[tag_function(temp_string_tag)]
def public temp_string(str : string; cb : block<(res : string#) : void>)
//! Pass string to the callback and delete it after the callback is called.
//! Accept only strings with substitutions (string builder). Intern strings are not deleted.
unsafe
cb |> invoke(reinterpret<string#> str)
if !is_intern_strings()
delete_string(reinterpret<string> str)

[tag_function_macro(tag="temp_string_tag")]
class TempStringMacro : AstFunctionAnnotation
def override verifyCall(var call : smart_ptr<ExprCallFunc>; args, progArgs : AnnotationArgumentList; var errors : das_string) : bool
if call.arguments[0] is ExprStringBuilder
return true

errors := "temp_string argument must be a string with subtitutions (string builder)"
return false

def public temp_string(arr : array<uint8>; cb : block<(res : string#) : void>)
//! Construct string from array of bytes and pass it to the callback.
//! Delete the string after the callback is called. Intern strings are not deleted.
var str = string(arr)
unsafe
cb |> invoke(reinterpret<string#> str)
if !is_intern_strings()
delete_string(reinterpret<string> str)
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ Operators

expr1 \.\. expr2

This is equivalent to `inverval(expr1,expr2)`. By default `interval(a,b:int)` is implemented as `range(a,b)`,
This is equivalent to `interval(expr1,expr2)`. By default `interval(a,b:int)` is implemented as `range(a,b)`,
and `interval(a,b:uint)` is implemented as `urange(a,b)`. Users can define their own interval functions or generics.

^^^^^^^^^^^^^
Expand Down
8 changes: 8 additions & 0 deletions prog/1stPartyLibs/daScript/doc/source/stdlib/builtin.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3910,6 +3910,14 @@ Memset
Uncategorized
+++++++++++++

.. _function-_at__builtin__c__c_is_intern_strings_C_c:

.. das:function:: is_intern_strings()
is_intern_strings returns bool

|function-builtin-is_intern_strings|

.. _function-_at__builtin__c__c_build_hash_CI0_ls_H_ls__builtin__c__c_HashBuilder_gr__gr_1_ls_v_gr__builtin__C_c_C_l:

.. das:function:: build_hash(block: block<(var arg0:HashBuilder):void> const implicit)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pushes values to the channel (at the end)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
clones data and pushed values to the channel (at the end)
Loading

0 comments on commit e97a495

Please sign in to comment.