FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
daScript/examples/tutorial/tutorial00.cpp at master · ilyabelow/daScript · GitHub
ilyabelow
/
daScript
Public
forked from
GaijinEntertainment/daScript
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
daScript
/
examples
/
tutorial
/
tutorial00.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
36 lines (33 loc) · 1.18 KB
Breadcrumbs
daScript
/
examples
/
tutorial
/
tutorial00.cpp
Copy path
File metadata and controls
36 lines (33 loc) · 1.18 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#
include
"
daScript/daScript.h
"
using
namespace
das
;
const
char
* tutorial_text =
R""""(
[export]
def test
print("this is nano tutorial\n")
)""""
;
int
main
(
int
,
char
* [] ) {
//
request all da-script built in modules
NEED_ALL_DEFAULT_MODULES
;
//
Initialize modules
Module::Initialize
();
//
make file access, introduce string as if it was a file
auto
fAccess
= make_smart<FsFileAccess>();
auto
fileInfo = make_unique<TextFileInfo>(tutorial_text,
uint32_t
(
strlen
(tutorial_text)),
false
);
fAccess
->
setFileInfo
(
"
dummy.das
"
,
das::move
(fileInfo));
//
compile script
TextPrinter tout;
ModuleGroup dummyLibGroup;
auto
program =
compileDaScript
(
"
dummy.das
"
,
fAccess
, tout, dummyLibGroup);
if
( program->
failed
() )
return
-
1
;
//
create context
Context
ctx
(program->
getContextStackSize
());
if
( !program->
simulate
(ctx, tout) )
return
-
2
;
//
find function. its up to application to check, if function is not null
auto
function = ctx.
findFunction
(
"
test
"
);
if
( !function )
return
-
3
;
//
call context function
ctx.
evalWithCatch
(function,
nullptr
);
//
shut-down daScript, free all memory
Module::Shutdown
();
return
0
;
}
Back
|
FazBrowse Home
|
New Git URL