MCPcopy Create free account
hub / github.com/SakuraEngine/SakuraEngine / _Import

Method _Import

modules/tools/tool_core/src/asset/cook_context.cpp:101–145  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

99}
100
101void* SCookContextImpl::_Import()
102{
103 SkrZoneScoped;
104 //-----load importer
105 simdjson::ondemand::parser parser;
106 auto doc = parser.iterate(record->meta);
107 auto importerJson = doc["importer"]; // import from asset
108 if (importerJson.error() == simdjson::SUCCESS)
109 {
110 skr_guid_t importerTypeGuid = {};
111 importer = GetImporterRegistry()->LoadImporter(record, std::move(importerJson).value_unsafe(), &importerTypeGuid);
112 if(!importer)
113 {
114 SKR_LOG_ERROR(u8"[SCookContext::Cook] importer failed to load, asset: %s", record->path.u8string().c_str());
115 return nullptr;
116 }
117 importerVersion = importer->Version();
118 importerType = importerTypeGuid;
119 //-----import raw data
120 SkrZoneScopedN("Importer.Import");
121 skr::String name_holder = u8"unknown";
122 if (auto type = skr::rttr::get_type_from_guid(importerType))
123 {
124 name_holder = type->name().u8_str();
125 }
126 else
127 {
128 name_holder = skr::format(u8"{}", importerType);
129 SKR_LOG_WARN(u8"[SCookContext::Cook] importer without RTTI INFO detected: %s", name_holder.c_str());
130 }
131 [[maybe_unused]] const char* type_name = name_holder.c_str();
132 ZoneName(type_name, strlen(type_name));
133 auto rawData = importer->Import(ioService, this);
134 SKR_LOG_INFO(u8"[SCookContext::Cook] asset imported for asset: %s", record->path.u8string().c_str());
135 return rawData;
136 }
137 // auto parentJson = doc["parent"]; // derived from resource
138 // if (parentJson.error() == simdjson::SUCCESS)
139 // {
140 // skr_guid_t parentGuid;
141 // skr::json::Read(std::move(parentJson).value_unsafe(), parentGuid);
142 // return AddStaticDependency(parentGuid);
143 // }
144 return nullptr;
145}
146
147skr::filesystem::path SCookContextImpl::GetOutputPath() const
148{

Callers

nothing calls this directly

Calls 12

GetImporterRegistryFunction · 0.85
get_type_from_guidFunction · 0.85
LoadImporterMethod · 0.80
moveFunction · 0.50
formatFunction · 0.50
iterateMethod · 0.45
errorMethod · 0.45
c_strMethod · 0.45
VersionMethod · 0.45
u8_strMethod · 0.45
nameMethod · 0.45
ImportMethod · 0.45

Tested by

no test coverage detected