From e28a878b0e5c5e056f01120cebcfa9a6f9ff94de Mon Sep 17 00:00:00 2001 From: Twarit Date: Tue, 2 Jul 2019 23:25:59 +0530 Subject: [PATCH] Add singleton recognition in engine --- .gitignore | 1 + ...y.obj-ff1e0f18f4d5d0574974da75c2f21313.md5 | 3 + ....obj-ff1e0f18f4d5d0574974da75c2f21313.mesh | Bin 0 -> 275 bytes ...i.obj-354b740fe44ec55047e8eac5458d0ec2.md5 | 3 + ....obj-354b740fe44ec55047e8eac5458d0ec2.mesh | Bin 0 -> 275 bytes demo/demo.tscn | 10 +- demo/project.godot | 5 +- godot-git-plugin/.clang-format | 127 ++++++++++++++++++ godot-git-plugin/.editorconfig | 18 +++ godot-git-plugin/godot-git-plugin.vcxproj | 5 + .../godot-git-plugin.vcxproj.filters | 2 + .../godot-git-plugin.vcxproj.user | 2 +- godot-git-plugin/src/gdlibrary.cpp | 15 ++- godot-git-plugin/src/git_api.cpp | 4 +- godot-git-plugin/src/git_api.h | 23 ++-- 15 files changed, 193 insertions(+), 25 deletions(-) create mode 100644 demo/.import/gdlibrary.obj-ff1e0f18f4d5d0574974da75c2f21313.md5 create mode 100644 demo/.import/gdlibrary.obj-ff1e0f18f4d5d0574974da75c2f21313.mesh create mode 100644 demo/.import/git_api.obj-354b740fe44ec55047e8eac5458d0ec2.md5 create mode 100644 demo/.import/git_api.obj-354b740fe44ec55047e8eac5458d0ec2.mesh create mode 100644 godot-git-plugin/.clang-format create mode 100644 godot-git-plugin/.editorconfig diff --git a/.gitignore b/.gitignore index fe26574..7cdb7cb 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,4 @@ bin/ *.dylib *.exe *.out +.import/ diff --git a/demo/.import/gdlibrary.obj-ff1e0f18f4d5d0574974da75c2f21313.md5 b/demo/.import/gdlibrary.obj-ff1e0f18f4d5d0574974da75c2f21313.md5 new file mode 100644 index 0000000..6f5f3a1 --- /dev/null +++ b/demo/.import/gdlibrary.obj-ff1e0f18f4d5d0574974da75c2f21313.md5 @@ -0,0 +1,3 @@ +source_md5="acc86098bce4ae4c28cadb6a53ffcdb6" +dest_md5="2f1e2ef0a20f671eac9200fabb450d48" + diff --git a/demo/.import/gdlibrary.obj-ff1e0f18f4d5d0574974da75c2f21313.mesh b/demo/.import/gdlibrary.obj-ff1e0f18f4d5d0574974da75c2f21313.mesh new file mode 100644 index 0000000000000000000000000000000000000000..e974cd7767474c4905e902df272bcfbd27487a33 GIT binary patch literal 275 zcmbtQy9xq942%j2B7)fX7h-EC);8w{guT7sF6`sj>=pX&f^%XaSUNCdG9iRXb8XJ_ z!3=c@j&%v1N-_6~sDu6wbFA;cBASO{g+sO`aLue%lF<5lmP{1d!U_K7YBW8oe+WCD zDs5o5K~l%+OfMXBC$xfT2dz1>F>Ol=^lFRmD+JL59OJxi9{2kLJx3e(4cXuwFLXCC A;Q#;t literal 0 HcmV?d00001 diff --git a/demo/.import/git_api.obj-354b740fe44ec55047e8eac5458d0ec2.md5 b/demo/.import/git_api.obj-354b740fe44ec55047e8eac5458d0ec2.md5 new file mode 100644 index 0000000..df94a11 --- /dev/null +++ b/demo/.import/git_api.obj-354b740fe44ec55047e8eac5458d0ec2.md5 @@ -0,0 +1,3 @@ +source_md5="4d5c95052707b1c45aa645159a17d4d3" +dest_md5="2f1e2ef0a20f671eac9200fabb450d48" + diff --git a/demo/.import/git_api.obj-354b740fe44ec55047e8eac5458d0ec2.mesh b/demo/.import/git_api.obj-354b740fe44ec55047e8eac5458d0ec2.mesh new file mode 100644 index 0000000000000000000000000000000000000000..e974cd7767474c4905e902df272bcfbd27487a33 GIT binary patch literal 275 zcmbtQy9xq942%j2B7)fX7h-EC);8w{guT7sF6`sj>=pX&f^%XaSUNCdG9iRXb8XJ_ z!3=c@j&%v1N-_6~sDu6wbFA;cBASO{g+sO`aLue%lF<5lmP{1d!U_K7YBW8oe+WCD zDs5o5K~l%+OfMXBC$xfT2dz1>F>Ol=^lFRmD+JL59OJxi9{2kLJx3e(4cXuwFLXCC A;Q#;t literal 0 HcmV?d00001 diff --git a/demo/demo.tscn b/demo/demo.tscn index b3f2515..b171e8d 100644 --- a/demo/demo.tscn +++ b/demo/demo.tscn @@ -1,11 +1,3 @@ -[gd_scene load_steps=3 format=2] - -[ext_resource path="res://bin/gitapi.gdns" type="Script" id=1] -[ext_resource path="res://icon.png" type="Texture" id=2] +[gd_scene format=2] [node name="Node2D" type="Node2D"] - -[node name="Sprite" type="Sprite" parent="."] -texture = ExtResource( 2 ) -centered = false -script = ExtResource( 1 ) diff --git a/demo/project.godot b/demo/project.godot index 2974ce3..f573b98 100644 --- a/demo/project.godot +++ b/demo/project.godot @@ -16,9 +16,12 @@ _global_script_class_icons={ [application] config/name="demo" -run/main_scene="res://demo.tscn" config/icon="res://icon.png" +[gdnative] + +singletons=[ "res://bin/git_api.gdnlib" ] + [rendering] environment/default_environment="res://default_env.tres" diff --git a/godot-git-plugin/.clang-format b/godot-git-plugin/.clang-format new file mode 100644 index 0000000..237fd9c --- /dev/null +++ b/godot-git-plugin/.clang-format @@ -0,0 +1,127 @@ +# Commented out parameters are those with the same value as base LLVM style +# We can uncomment them if we want to change their value, or enforce the +# chosen value in case the base style changes (last sync: Clang 6.0.1). +--- +### General config, applies to all languages ### +BasedOnStyle: LLVM +AccessModifierOffset: -4 +AlignAfterOpenBracket: DontAlign +# AlignConsecutiveAssignments: false +# AlignConsecutiveDeclarations: false +# AlignEscapedNewlines: Right +# AlignOperands: true +AlignTrailingComments: false +AllowAllParametersOfDeclarationOnNextLine: false +# AllowShortBlocksOnASingleLine: false +AllowShortCaseLabelsOnASingleLine: true +AllowShortFunctionsOnASingleLine: Inline +AllowShortIfStatementsOnASingleLine: true +# AllowShortLoopsOnASingleLine: false +# AlwaysBreakAfterDefinitionReturnType: None +# AlwaysBreakAfterReturnType: None +# AlwaysBreakBeforeMultilineStrings: false +# AlwaysBreakTemplateDeclarations: false +# BinPackArguments: true +# BinPackParameters: true +# BraceWrapping: +# AfterClass: false +# AfterControlStatement: false +# AfterEnum: false +# AfterFunction: false +# AfterNamespace: false +# AfterObjCDeclaration: false +# AfterStruct: false +# AfterUnion: false +# AfterExternBlock: false +# BeforeCatch: false +# BeforeElse: false +# IndentBraces: false +# SplitEmptyFunction: true +# SplitEmptyRecord: true +# SplitEmptyNamespace: true +# BreakBeforeBinaryOperators: None +# BreakBeforeBraces: Attach +# BreakBeforeInheritanceComma: false +BreakBeforeTernaryOperators: false +# BreakConstructorInitializersBeforeComma: false +BreakConstructorInitializers: AfterColon +# BreakStringLiterals: true +ColumnLimit: 0 +# CommentPragmas: '^ IWYU pragma:' +# CompactNamespaces: false +ConstructorInitializerAllOnOneLineOrOnePerLine: true +ConstructorInitializerIndentWidth: 8 +ContinuationIndentWidth: 8 +Cpp11BracedListStyle: false +# DerivePointerAlignment: false +# DisableFormat: false +# ExperimentalAutoDetectBinPacking: false +# FixNamespaceComments: true +# ForEachMacros: +# - foreach +# - Q_FOREACH +# - BOOST_FOREACH +# IncludeBlocks: Preserve +IncludeCategories: + - Regex: '".*"' + Priority: 1 + - Regex: '^<.*\.h>' + Priority: 2 + - Regex: '^<.*' + Priority: 3 +# IncludeIsMainRegex: '(Test)?$' +IndentCaseLabels: true +# IndentPPDirectives: None +IndentWidth: 4 +# IndentWrappedFunctionNames: false +# JavaScriptQuotes: Leave +# JavaScriptWrapImports: true +# KeepEmptyLinesAtTheStartOfBlocks: true +# MacroBlockBegin: '' +# MacroBlockEnd: '' +# MaxEmptyLinesToKeep: 1 +# NamespaceIndentation: None +# PenaltyBreakAssignment: 2 +# PenaltyBreakBeforeFirstCallParameter: 19 +# PenaltyBreakComment: 300 +# PenaltyBreakFirstLessLess: 120 +# PenaltyBreakString: 1000 +# PenaltyExcessCharacter: 1000000 +# PenaltyReturnTypeOnItsOwnLine: 60 +# PointerAlignment: Right +# RawStringFormats: +# - Delimiter: pb +# Language: TextProto +# BasedOnStyle: google +# ReflowComments: true +# SortIncludes: true +# SortUsingDeclarations: true +# SpaceAfterCStyleCast: false +# SpaceAfterTemplateKeyword: true +# SpaceBeforeAssignmentOperators: true +# SpaceBeforeParens: ControlStatements +# SpaceInEmptyParentheses: false +# SpacesBeforeTrailingComments: 1 +# SpacesInAngles: false +# SpacesInContainerLiterals: true +# SpacesInCStyleCastParentheses: false +# SpacesInParentheses: false +# SpacesInSquareBrackets: false +TabWidth: 4 +UseTab: Always +--- +### C++ specific config ### +Language: Cpp +Standard: Cpp03 +--- +### ObjC specific config ### +Language: ObjC +Standard: Cpp03 +ObjCBlockIndentWidth: 4 +# ObjCSpaceAfterProperty: false +# ObjCSpaceBeforeProtocolList: true +--- +### Java specific config ### +Language: Java +# BreakAfterJavaFieldAnnotations: false +... diff --git a/godot-git-plugin/.editorconfig b/godot-git-plugin/.editorconfig new file mode 100644 index 0000000..56cc2e9 --- /dev/null +++ b/godot-git-plugin/.editorconfig @@ -0,0 +1,18 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +indent_style = tab +insert_final_newline = true + +[*.{cpp,hpp,c,h,mm}] +trim_trailing_whitespace = true + +[{*.{py,cs},SConstruct,SCsub}] +indent_style = space +indent_size = 4 + +[.travis.yml] +indent_style = space +indent_size = 2 diff --git a/godot-git-plugin/godot-git-plugin.vcxproj b/godot-git-plugin/godot-git-plugin.vcxproj index 4432a1d..bec0a41 100644 --- a/godot-git-plugin/godot-git-plugin.vcxproj +++ b/godot-git-plugin/godot-git-plugin.vcxproj @@ -73,6 +73,9 @@ .\src\;..\godot-cpp\godot_headers\;..\godot-cpp\include\gen;..\godot-cpp\include\core\;..\godot-cpp\include\;$(IncludePath) ..\godot-cpp\bin;$(LibraryPath) .\src\;$(VC_SourcePath); + $(SolutionDir)..\demo\bin\win64\ + $(SolutionDir)..\demo\bin\win64\intermediate\ + libgitapi @@ -131,6 +134,8 @@ + + diff --git a/godot-git-plugin/godot-git-plugin.vcxproj.filters b/godot-git-plugin/godot-git-plugin.vcxproj.filters index aabca1a..f6607dc 100644 --- a/godot-git-plugin/godot-git-plugin.vcxproj.filters +++ b/godot-git-plugin/godot-git-plugin.vcxproj.filters @@ -29,5 +29,7 @@ + + \ No newline at end of file diff --git a/godot-git-plugin/godot-git-plugin.vcxproj.user b/godot-git-plugin/godot-git-plugin.vcxproj.user index baf2417..0b0f24d 100644 --- a/godot-git-plugin/godot-git-plugin.vcxproj.user +++ b/godot-git-plugin/godot-git-plugin.vcxproj.user @@ -1,6 +1,6 @@  - false + true \ No newline at end of file diff --git a/godot-git-plugin/src/gdlibrary.cpp b/godot-git-plugin/src/gdlibrary.cpp index 707bb90..248df94 100644 --- a/godot-git-plugin/src/gdlibrary.cpp +++ b/godot-git-plugin/src/gdlibrary.cpp @@ -1,15 +1,26 @@ +#include #include "git_api.h" extern "C" void GDN_EXPORT godot_gdnative_init(godot_gdnative_init_options *o) { - godot::Godot::gdnative_init(o); + + godot::Godot::gdnative_init(o); +} + +//extern "C" void GDN_EXPORT godot_singelton_init(godot_gdnative_init_options *o) { +// godot::Godot::print("godot_singelton_init"); +//} + +extern "C" void GDN_EXPORT godot_gdnative_singleton(godot_gdnative_init_options *o) { + } extern "C" void GDN_EXPORT godot_gdnative_terminate(godot_gdnative_terminate_options *o) { + godot::Godot::gdnative_terminate(o); } extern "C" void GDN_EXPORT godot_nativescript_init(void *handle) { - godot::Godot::nativescript_init(handle); + godot::Godot::nativescript_init(handle); godot::register_class(); } diff --git a/godot-git-plugin/src/git_api.cpp b/godot-git-plugin/src/git_api.cpp index f7cae97..2b3dda1 100644 --- a/godot-git-plugin/src/git_api.cpp +++ b/godot-git-plugin/src/git_api.cpp @@ -8,6 +8,8 @@ void GitAPI::_register_methods() { } GitAPI::GitAPI() { + + register_singleton((Node *)this); } GitAPI::~GitAPI() { @@ -15,7 +17,7 @@ GitAPI::~GitAPI() { void GitAPI::_init() { - EditorVCS::replace_singleton((Node *) this); + WARN_PRINT("Gitinit!"); } void GitAPI::_process(float delta) { diff --git a/godot-git-plugin/src/git_api.h b/godot-git-plugin/src/git_api.h index 9bb1112..2a2a718 100644 --- a/godot-git-plugin/src/git_api.h +++ b/godot-git-plugin/src/git_api.h @@ -2,26 +2,27 @@ #define GIT_API_H #include -#include +#include namespace godot { - class GitAPI : public EditorVCS { +class GitAPI : public EditorVCSInterface { - GODOT_CLASS(GitAPI, EditorVCS) // This base class is temporary + GODOT_CLASS(GitAPI, EditorVCSInterface) - private: +private: - public: - static void _register_methods(); +public: + static void _register_methods(); - GitAPI(); - ~GitAPI(); + GitAPI(); + ~GitAPI(); - void _init(); + void _init(); + + void _process(float delta); +}; - void _process(float delta); - }; } #endif // !GIT_API_H