-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
children_count, get_child, find_child_by_name, find_child_by_tag
1 parent
3a145c7
commit 75141bc
Showing
15 changed files
with
457 additions
and
135 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,64 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net472</TargetFramework> | ||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> | ||
<Version>0.1.1.0</Version> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<TargetFramework>net472</TargetFramework> | ||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> | ||
<Version>0.1.3.0</Version> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup> | ||
<ResonitePath>$(MSBuildThisFileDirectory)Resonite</ResonitePath> | ||
<ResonitePath Condition="Exists('C:\Program Files (x86)\Steam\steamapps\common\Resonite\')">C:\Program Files (x86)\Steam\steamapps\common\Resonite\</ResonitePath> | ||
<ResonitePath Condition="Exists('D:\Program Files (x86)\Steam\steamapps\common\Resonite\')">D:\Program Files (x86)\Steam\steamapps\common\Resonite\</ResonitePath> | ||
<ResonitePath Condition="Exists('C:\SteamLibrary\steamapps\common\Resonite\')">C:\SteamLibrary\steamapps\common\Resonite\</ResonitePath> | ||
<ResonitePath Condition="Exists('D:\SteamLibrary\steamapps\common\Resonite\')">D:\SteamLibrary\steamapps\common\Resonite\</ResonitePath> | ||
<ResonitePath Condition="Exists('$(HOME)/.steam/steam/steamapps/common/Resonite/')">$(HOME)/.steam/steam/steamapps/common/Resonite/</ResonitePath> | ||
<ResonitePath Condition="Exists('E:\Programs\Steam\steamapps\common\Resonite')">E:\Programs\Steam\steamapps\common\Resonite\</ResonitePath> | ||
<ResonitePath Condition="Exists('F:\Steam\steamapps\common\Resonite')">F:\Steam\steamapps\common\Resonite\</ResonitePath> | ||
<ResoniteCoreLibs>$(ResonitePath)\Resonite_Data\Managed</ResoniteCoreLibs> | ||
<ResoniteNmlLibs>$(ResonitePath)\rml_libs</ResoniteNmlLibs> | ||
<ResoniteNmlMods>$(ResonitePath)\rml_mods</ResoniteNmlMods> | ||
<ResoniteLibs>$(ResonitePath)\Libraries</ResoniteLibs> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<ResonitePath>$(MSBuildThisFileDirectory)Resonite</ResonitePath> | ||
<ResonitePath Condition="Exists('C:\Program Files (x86)\Steam\steamapps\common\Resonite\')">C:\Program Files (x86)\Steam\steamapps\common\Resonite\</ResonitePath> | ||
<ResonitePath Condition="Exists('D:\Program Files (x86)\Steam\steamapps\common\Resonite\')">D:\Program Files (x86)\Steam\steamapps\common\Resonite\</ResonitePath> | ||
<ResonitePath Condition="Exists('C:\SteamLibrary\steamapps\common\Resonite\')">C:\SteamLibrary\steamapps\common\Resonite\</ResonitePath> | ||
<ResonitePath Condition="Exists('D:\SteamLibrary\steamapps\common\Resonite\')">D:\SteamLibrary\steamapps\common\Resonite\</ResonitePath> | ||
<ResonitePath Condition="Exists('$(HOME)/.steam/steam/steamapps/common/Resonite/')">$(HOME)/.steam/steam/steamapps/common/Resonite/</ResonitePath> | ||
<ResonitePath Condition="Exists('E:\Programs\Steam\steamapps\common\Resonite')">E:\Programs\Steam\steamapps\common\Resonite\</ResonitePath> | ||
<ResonitePath Condition="Exists('F:\Steam\steamapps\common\Resonite')">F:\Steam\steamapps\common\Resonite\</ResonitePath> | ||
<ResoniteCoreLibs>$(ResonitePath)\Resonite_Data\Managed</ResoniteCoreLibs> | ||
<ResoniteNmlLibs>$(ResonitePath)\rml_libs</ResoniteNmlLibs> | ||
<ResoniteNmlMods>$(ResonitePath)\rml_mods</ResoniteNmlMods> | ||
<ResoniteLibs>$(ResonitePath)\Libraries</ResoniteLibs> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<Reference Include="0Harmony"> | ||
<HintPath>$(ResoniteNmlLibs)\0Harmony.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Elements.Assets"> | ||
<HintPath>$(ResoniteCoreLibs)\Elements.Assets.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Elements.Core"> | ||
<HintPath>$(ResoniteCoreLibs)\Elements.Core.dll</HintPath> | ||
</Reference> | ||
<Reference Include="FrooxEngine"> | ||
<HintPath>$(ResoniteCoreLibs)\FrooxEngine.dll</HintPath> | ||
</Reference> | ||
<Reference Include="ProtoFlux.Core"> | ||
<HintPath>$(ResoniteCoreLibs)\ProtoFlux.Core.dll</HintPath> | ||
</Reference> | ||
<Reference Include="ProtoFlux.Nodes.FrooxEngine"> | ||
<HintPath>$(ResoniteCoreLibs)\ProtoFlux.Nodes.FrooxEngine.dll</HintPath> | ||
</Reference> | ||
<Reference Include="ResoniteModLoader"> | ||
<HintPath>$(ResoniteLibs)\ResoniteModLoader.dll</HintPath> | ||
</Reference> | ||
<Reference Include="SkyFrost.Base"> | ||
<HintPath>$(ResoniteCoreLibs)\SkyFrost.Base.dll</HintPath> | ||
</Reference> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Reference Include="0Harmony"> | ||
<HintPath>$(ResoniteNmlLibs)\0Harmony.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Elements.Assets"> | ||
<HintPath>$(ResoniteCoreLibs)\Elements.Assets.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Elements.Core"> | ||
<HintPath>$(ResoniteCoreLibs)\Elements.Core.dll</HintPath> | ||
</Reference> | ||
<Reference Include="FrooxEngine"> | ||
<HintPath>$(ResoniteCoreLibs)\FrooxEngine.dll</HintPath> | ||
</Reference> | ||
<Reference Include="ProtoFlux.Core"> | ||
<HintPath>$(ResoniteCoreLibs)\ProtoFlux.Core.dll</HintPath> | ||
</Reference> | ||
<Reference Include="ProtoFlux.Nodes.FrooxEngine"> | ||
<HintPath>$(ResoniteCoreLibs)\ProtoFlux.Nodes.FrooxEngine.dll</HintPath> | ||
</Reference> | ||
<Reference Include="ResoniteModLoader"> | ||
<HintPath>$(ResoniteLibs)\ResoniteModLoader.dll</HintPath> | ||
</Reference> | ||
<Reference Include="SkyFrost.Base"> | ||
<HintPath>$(ResoniteCoreLibs)\SkyFrost.Base.dll</HintPath> | ||
</Reference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="System.Memory" Version="4.5.5" /> | ||
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="6.0.0" /> | ||
<PackageReference Include="System.Threading.Tasks.Extensions" Version="4.5.4" /> | ||
<PackageReference Include="System.ValueTuple" Version="4.5.0" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<PackageReference Include="System.Memory" Version="4.5.5" /> | ||
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="6.0.0" /> | ||
<PackageReference Include="System.Threading.Tasks.Extensions" Version="4.5.4" /> | ||
<PackageReference Include="System.ValueTuple" Version="4.5.0" /> | ||
</ItemGroup> | ||
|
||
<Target Name="CopyPluginLibrary" AfterTargets="PostBuildEvent" | ||
Condition="Exists($(ResoniteNmlMods))"> | ||
<Exec | ||
Command="copy "$(TargetDir)\$(TargetName).dll" "$(ResoniteNmlMods)\"" /> | ||
</Target> | ||
<Target Name="CopyPluginLibrary" AfterTargets="PostBuildEvent" | ||
Condition="Exists($(ResoniteNmlMods))"> | ||
<Exec | ||
Command="copy "$(TargetDir)\$(TargetName).dll" "$(ResoniteNmlMods)\"" /> | ||
</Target> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#include "py/obj.h" | ||
#include "py/runtime.h" | ||
|
||
#include "mp_resonite_slot.h" | ||
|
||
// Define all attributes of the module. | ||
// Table entries are key/value pairs of the attribute name (a string) | ||
// and the MicroPython object reference. | ||
// All identifiers and strings are written as MP_QSTR_xxx and will be | ||
// optimized to word-sized integers by the build system (interned strings). | ||
STATIC const mp_rom_map_elem_t resonite_module_globals_table[] = { | ||
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_resonite) }, | ||
{ MP_ROM_QSTR(MP_QSTR_Slot), MP_ROM_PTR(&resonite_Slot_type) }, | ||
}; | ||
// Create a const dict named resonite_module_globals, with content resonite_module_globals_table. | ||
STATIC MP_DEFINE_CONST_DICT(resonite_module_globals, resonite_module_globals_table); | ||
|
||
|
||
// Define module object. | ||
const mp_obj_module_t resonite_user_cmodule = { | ||
.base = { &mp_type_module }, | ||
.globals = (mp_obj_dict_t*)&resonite_module_globals, | ||
}; | ||
|
||
// Register the module to make it available in Python. | ||
MP_REGISTER_MODULE(MP_QSTR_resonite, resonite_user_cmodule); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
#include "mp_resonite_utils.h" | ||
|
||
#include <math.h> | ||
#include <stdint.h> | ||
|
||
#include "py/obj.h" | ||
#include "py/runtime.h" | ||
#include "py/mpz.h" | ||
#include "py/objint.h" | ||
#include "py/smallint.h" | ||
|
||
// An MPZ is stored as an array of n-bit "digits". In the WASM port, each digit is 16 bits. | ||
// They are stored little-endian. For example, the value 0x1234567890 is stored as | ||
// { 0x7890, 0x3456, 0x0012 }. | ||
static bool mpz_as_int64_checked(const mpz_t* i, int64_t* value) { | ||
uint64_t val = 0; | ||
mpz_dig_t* d = i->dig + i->len; | ||
|
||
while (d-- > i->dig) { | ||
if (val > (0x7FFFFFFFFFFFFFFFULL >> MPZ_DIG_SIZE)) { | ||
// will overflow when shifted left by MPZ_DIG_SIZE. | ||
return false; | ||
} | ||
val = (val << MPZ_DIG_SIZE) | *d; | ||
} | ||
|
||
if (i->neg != 0) { | ||
val = -val; | ||
} | ||
|
||
*value = val; | ||
return true; | ||
} | ||
|
||
static bool mpz_as_uint64_checked(const mpz_t* i, uint64_t* value) { | ||
if (i->neg != 0) { | ||
// Can't represent negative numbers. | ||
return false; | ||
} | ||
|
||
uint64_t val = 0; | ||
mpz_dig_t* d = i->dig + i->len; | ||
|
||
while (d-- > i->dig) { | ||
if (val > (0x7FFFFFFFFFFFFFFFULL >> (MPZ_DIG_SIZE - 1))) { | ||
// will overflow when shifted left by MPZ_DIG_SIZE. | ||
return false; | ||
} | ||
val = (val << MPZ_DIG_SIZE) | *d; | ||
} | ||
|
||
*value = val; | ||
return true; | ||
} | ||
|
||
int64_t mp_obj_int_get_int64_checked(mp_const_obj_t self_in) { | ||
if (mp_obj_is_small_int(self_in)) { | ||
return MP_OBJ_SMALL_INT_VALUE(self_in); | ||
} | ||
const mp_obj_int_t* self = MP_OBJ_TO_PTR(self_in); | ||
int64_t value; | ||
if (mpz_as_int64_checked(&self->mpz, &value)) { | ||
return value; | ||
} | ||
mp_raise_msg(&mp_type_OverflowError, MP_ERROR_TEXT("overflow converting Python int to 64-bit unsigned int")); | ||
} | ||
|
||
uint64_t mp_obj_int_get_uint64_checked(mp_const_obj_t self_in) { | ||
if (mp_obj_is_small_int(self_in)) { | ||
if (MP_OBJ_SMALL_INT_VALUE(self_in) > 0) { | ||
return MP_OBJ_SMALL_INT_VALUE(self_in); | ||
} | ||
} | ||
else { | ||
const mp_obj_int_t* self = MP_OBJ_TO_PTR(self_in); | ||
uint64_t value; | ||
if (mpz_as_uint64_checked(&self->mpz, &value)) { | ||
return value; | ||
} | ||
} | ||
mp_raise_msg(&mp_type_OverflowError, MP_ERROR_TEXT("overflow converting Python int to 64-bit signed int")); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#ifndef __RESONITE_RESONITE_UTILS_H__ | ||
#define __RESONITE_RESONITE_UTILS_H__ | ||
|
||
#include <stdint.h> | ||
|
||
#include "py/obj.h" | ||
#include "py/runtime.h" | ||
#include "resonite_api_types.h" | ||
|
||
extern int64_t mp_obj_int_get_int64_checked(mp_const_obj_t o); | ||
extern uint64_t mp_obj_int_get_uint64_checked(mp_const_obj_t o); | ||
|
||
#endif // __RESONITE_RESONITE_UTILS_H__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,9 @@ | ||
mergeInto(LibraryManager.library, { | ||
slot__root_slot: function () { } | ||
}); | ||
mergeInto(LibraryManager.library, { | ||
slot__get_parent: function () { } | ||
}); | ||
mergeInto(LibraryManager.library, { | ||
slot__get_object_root: function () { } | ||
}); | ||
mergeInto(LibraryManager.library, { | ||
slot__get_name: function () { } | ||
}); | ||
mergeInto(LibraryManager.library, { | ||
slot__set_name: function () { } | ||
}); | ||
mergeInto(LibraryManager.library, { slot__root_slot: function () { } }); | ||
mergeInto(LibraryManager.library, { slot__get_parent: function () { } }); | ||
mergeInto(LibraryManager.library, { slot__get_object_root: function () { } }); | ||
mergeInto(LibraryManager.library, { slot__get_name: function () { } }); | ||
mergeInto(LibraryManager.library, { slot__set_name: function () { } }); | ||
mergeInto(LibraryManager.library, { slot__get_num_children: function () { } }); | ||
mergeInto(LibraryManager.library, { slot__get_child: function () { } }); | ||
mergeInto(LibraryManager.library, { slot__find_child_by_name: function () { } }); | ||
mergeInto(LibraryManager.library, { slot__find_child_by_tag: function () { } }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters