change std::make_unique to mmd::make_unique
parent
ccf2bce2b0
commit
8cd0d3b3c7
|
@ -1,19 +1,20 @@
|
|||
#pragma once
|
||||
|
||||
#ifndef MMD_CPP14_H
|
||||
#define MMD_CPP14_H
|
||||
|
||||
#include <cstddef>
|
||||
#include <memory>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
namespace std {
|
||||
namespace mmd {
|
||||
template<class T> struct _Unique_if {
|
||||
typedef unique_ptr<T> _Single_object;
|
||||
typedef std::unique_ptr<T> _Single_object;
|
||||
};
|
||||
|
||||
template<class T> struct _Unique_if<T[]> {
|
||||
typedef unique_ptr<T[]> _Unknown_bound;
|
||||
typedef std::unique_ptr<T[]> _Unknown_bound;
|
||||
};
|
||||
|
||||
template<class T, size_t N> struct _Unique_if<T[N]> {
|
||||
|
@ -23,14 +24,14 @@ namespace std {
|
|||
template<class T, class... Args>
|
||||
typename _Unique_if<T>::_Single_object
|
||||
make_unique(Args&&... args) {
|
||||
return unique_ptr<T>(new T(std::forward<Args>(args)...));
|
||||
return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
|
||||
}
|
||||
|
||||
template<class T>
|
||||
typename _Unique_if<T>::_Unknown_bound
|
||||
make_unique(size_t n) {
|
||||
typedef typename remove_extent<T>::type U;
|
||||
return unique_ptr<T>(new U[n]());
|
||||
typedef typename std::remove_extent<T>::type U;
|
||||
return std::unique_ptr<T>(new U[n]());
|
||||
}
|
||||
|
||||
template<class T, class... Args>
|
||||
|
@ -38,4 +39,4 @@ namespace std {
|
|||
make_unique(Args&&...) = delete;
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -454,7 +454,7 @@ namespace pmd
|
|||
/// ファイルからPmdModelを生成する
|
||||
static std::unique_ptr<PmdModel> LoadFromStream(std::ifstream *stream)
|
||||
{
|
||||
auto result = std::make_unique<PmdModel>();
|
||||
auto result = mmd::make_unique<PmdModel>();
|
||||
char buffer[100];
|
||||
|
||||
// magic
|
||||
|
@ -627,4 +627,4 @@ namespace pmd
|
|||
return result;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -163,19 +163,19 @@ namespace pmx
|
|||
switch (this->skinning_type)
|
||||
{
|
||||
case PmxVertexSkinningType::BDEF1:
|
||||
this->skinning = std::make_unique<PmxVertexSkinningBDEF1>();
|
||||
this->skinning = mmd::make_unique<PmxVertexSkinningBDEF1>();
|
||||
break;
|
||||
case PmxVertexSkinningType::BDEF2:
|
||||
this->skinning = std::make_unique<PmxVertexSkinningBDEF2>();
|
||||
this->skinning = mmd::make_unique<PmxVertexSkinningBDEF2>();
|
||||
break;
|
||||
case PmxVertexSkinningType::BDEF4:
|
||||
this->skinning = std::make_unique<PmxVertexSkinningBDEF4>();
|
||||
this->skinning = mmd::make_unique<PmxVertexSkinningBDEF4>();
|
||||
break;
|
||||
case PmxVertexSkinningType::SDEF:
|
||||
this->skinning = std::make_unique<PmxVertexSkinningSDEF>();
|
||||
this->skinning = mmd::make_unique<PmxVertexSkinningSDEF>();
|
||||
break;
|
||||
case PmxVertexSkinningType::QDEF:
|
||||
this->skinning = std::make_unique<PmxVertexSkinningQDEF>();
|
||||
this->skinning = mmd::make_unique<PmxVertexSkinningQDEF>();
|
||||
break;
|
||||
default:
|
||||
throw "invalid skinning type";
|
||||
|
@ -254,7 +254,7 @@ namespace pmx
|
|||
stream->read((char*) &ik_loop, sizeof(int));
|
||||
stream->read((char*) &ik_loop_angle_limit, sizeof(float));
|
||||
stream->read((char*) &ik_link_count, sizeof(int));
|
||||
this->ik_links = std::make_unique<PmxIkLink []>(ik_link_count);
|
||||
this->ik_links = mmd::make_unique<PmxIkLink []>(ik_link_count);
|
||||
for (int i = 0; i < ik_link_count; i++) {
|
||||
ik_links[i].Read(stream, setting);
|
||||
}
|
||||
|
@ -325,28 +325,28 @@ namespace pmx
|
|||
switch (this->morph_type)
|
||||
{
|
||||
case MorphType::Group:
|
||||
group_offsets = std::make_unique<PmxMorphGroupOffset []>(this->offset_count);
|
||||
group_offsets = mmd::make_unique<PmxMorphGroupOffset []>(this->offset_count);
|
||||
for (int i = 0; i < offset_count; i++)
|
||||
{
|
||||
group_offsets[i].Read(stream, setting);
|
||||
}
|
||||
break;
|
||||
case MorphType::Vertex:
|
||||
vertex_offsets = std::make_unique<PmxMorphVertexOffset []>(this->offset_count);
|
||||
vertex_offsets = mmd::make_unique<PmxMorphVertexOffset []>(this->offset_count);
|
||||
for (int i = 0; i < offset_count; i++)
|
||||
{
|
||||
vertex_offsets[i].Read(stream, setting);
|
||||
}
|
||||
break;
|
||||
case MorphType::Bone:
|
||||
bone_offsets = std::make_unique<PmxMorphBoneOffset []>(this->offset_count);
|
||||
bone_offsets = mmd::make_unique<PmxMorphBoneOffset []>(this->offset_count);
|
||||
for (int i = 0; i < offset_count; i++)
|
||||
{
|
||||
bone_offsets[i].Read(stream, setting);
|
||||
}
|
||||
break;
|
||||
case MorphType::Matrial:
|
||||
material_offsets = std::make_unique<PmxMorphMaterialOffset []>(this->offset_count);
|
||||
material_offsets = mmd::make_unique<PmxMorphMaterialOffset []>(this->offset_count);
|
||||
for (int i = 0; i < offset_count; i++)
|
||||
{
|
||||
material_offsets[i].Read(stream, setting);
|
||||
|
@ -357,7 +357,7 @@ namespace pmx
|
|||
case MorphType::AdditionalUV2:
|
||||
case MorphType::AdditionalUV3:
|
||||
case MorphType::AdditionalUV4:
|
||||
uv_offsets = std::make_unique<PmxMorphUVOffset []>(this->offset_count);
|
||||
uv_offsets = mmd::make_unique<PmxMorphUVOffset []>(this->offset_count);
|
||||
for (int i = 0; i < offset_count; i++)
|
||||
{
|
||||
uv_offsets[i].Read(stream, setting);
|
||||
|
@ -386,7 +386,7 @@ namespace pmx
|
|||
this->frame_english_name = ReadString(stream, setting->encoding);
|
||||
stream->read((char*) &this->frame_flag, sizeof(uint8_t));
|
||||
stream->read((char*) &this->element_count, sizeof(int));
|
||||
this->elements = std::make_unique<PmxFrameElement []>(this->element_count);
|
||||
this->elements = mmd::make_unique<PmxFrameElement []>(this->element_count);
|
||||
for (int i = 0; i < this->element_count; i++)
|
||||
{
|
||||
this->elements[i].Read(stream, setting);
|
||||
|
@ -505,7 +505,7 @@ namespace pmx
|
|||
|
||||
// 頂点
|
||||
stream->read((char*) &vertex_count, sizeof(int));
|
||||
this->vertices = std::make_unique<PmxVertex []>(vertex_count);
|
||||
this->vertices = mmd::make_unique<PmxVertex []>(vertex_count);
|
||||
for (int i = 0; i < vertex_count; i++)
|
||||
{
|
||||
vertices[i].Read(stream, &setting);
|
||||
|
@ -513,7 +513,7 @@ namespace pmx
|
|||
|
||||
// 面
|
||||
stream->read((char*) &index_count, sizeof(int));
|
||||
this->indices = std::make_unique<int []>(index_count);
|
||||
this->indices = mmd::make_unique<int []>(index_count);
|
||||
for (int i = 0; i < index_count; i++)
|
||||
{
|
||||
this->indices[i] = ReadIndex(stream, setting.vertex_index_size);
|
||||
|
@ -521,7 +521,7 @@ namespace pmx
|
|||
|
||||
// テクスチャ
|
||||
stream->read((char*) &texture_count, sizeof(int));
|
||||
this->textures = std::make_unique<std::string []>(texture_count);
|
||||
this->textures = mmd::make_unique<std::string []>(texture_count);
|
||||
for (int i = 0; i < texture_count; i++)
|
||||
{
|
||||
this->textures[i] = ReadString(stream, setting.encoding);
|
||||
|
@ -529,7 +529,7 @@ namespace pmx
|
|||
|
||||
// マテリアル
|
||||
stream->read((char*) &material_count, sizeof(int));
|
||||
this->materials = std::make_unique<PmxMaterial []>(material_count);
|
||||
this->materials = mmd::make_unique<PmxMaterial []>(material_count);
|
||||
for (int i = 0; i < material_count; i++)
|
||||
{
|
||||
this->materials[i].Read(stream, &setting);
|
||||
|
@ -537,7 +537,7 @@ namespace pmx
|
|||
|
||||
// ボーン
|
||||
stream->read((char*) &this->bone_count, sizeof(int));
|
||||
this->bones = std::make_unique<PmxBone []>(this->bone_count);
|
||||
this->bones = mmd::make_unique<PmxBone []>(this->bone_count);
|
||||
for (int i = 0; i < this->bone_count; i++)
|
||||
{
|
||||
this->bones[i].Read(stream, &setting);
|
||||
|
@ -545,7 +545,7 @@ namespace pmx
|
|||
|
||||
// モーフ
|
||||
stream->read((char*) &this->morph_count, sizeof(int));
|
||||
this->morphs = std::make_unique<PmxMorph []>(this->morph_count);
|
||||
this->morphs = mmd::make_unique<PmxMorph []>(this->morph_count);
|
||||
for (int i = 0; i < this->morph_count; i++)
|
||||
{
|
||||
this->morphs[i].Read(stream, &setting);
|
||||
|
@ -553,7 +553,7 @@ namespace pmx
|
|||
|
||||
// 表示枠
|
||||
stream->read((char*) &this->frame_count, sizeof(int));
|
||||
this->frames = std::make_unique<PmxFrame []>(this->frame_count);
|
||||
this->frames = mmd::make_unique<PmxFrame []>(this->frame_count);
|
||||
for (int i = 0; i < this->frame_count; i++)
|
||||
{
|
||||
this->frames[i].Read(stream, &setting);
|
||||
|
@ -561,7 +561,7 @@ namespace pmx
|
|||
|
||||
// 剛体
|
||||
stream->read((char*) &this->rigid_body_count, sizeof(int));
|
||||
this->rigid_bodies = std::make_unique<PmxRigidBody []>(this->rigid_body_count);
|
||||
this->rigid_bodies = mmd::make_unique<PmxRigidBody []>(this->rigid_body_count);
|
||||
for (int i = 0; i < this->rigid_body_count; i++)
|
||||
{
|
||||
this->rigid_bodies[i].Read(stream, &setting);
|
||||
|
@ -569,7 +569,7 @@ namespace pmx
|
|||
|
||||
// ジョイント
|
||||
stream->read((char*) &this->joint_count, sizeof(int));
|
||||
this->joints = std::make_unique<PmxJoint []>(this->joint_count);
|
||||
this->joints = mmd::make_unique<PmxJoint []>(this->joint_count);
|
||||
for (int i = 0; i < this->joint_count; i++)
|
||||
{
|
||||
this->joints[i].Read(stream, &setting);
|
||||
|
@ -579,7 +579,7 @@ namespace pmx
|
|||
//if (this->version == 2.1f)
|
||||
//{
|
||||
// stream->read((char*) &this->soft_body_count, sizeof(int));
|
||||
// this->soft_bodies = std::make_unique<PmxSoftBody []>(this->soft_body_count);
|
||||
// this->soft_bodies = mmd::make_unique<PmxSoftBody []>(this->soft_body_count);
|
||||
// for (int i = 0; i < this->soft_body_count; i++)
|
||||
// {
|
||||
// this->soft_bodies[i].Read(stream, &setting);
|
||||
|
@ -601,7 +601,7 @@ namespace pmx
|
|||
|
||||
//std::unique_ptr<PmxModel> ReadFromStream(std::istream *stream)
|
||||
//{
|
||||
// auto pmx = std::make_unique<PmxModel>();
|
||||
// auto pmx = mmd::make_unique<PmxModel>();
|
||||
// pmx->Read(stream);
|
||||
// return pmx;
|
||||
//}
|
||||
|
|
|
@ -220,7 +220,7 @@ namespace vmd
|
|||
{
|
||||
|
||||
char buffer[30];
|
||||
auto result = std::make_unique<VmdMotion>();
|
||||
auto result = mmd::make_unique<VmdMotion>();
|
||||
|
||||
// magic and version
|
||||
stream->read((char*) buffer, 30);
|
||||
|
@ -364,4 +364,4 @@ namespace vmd
|
|||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue