Skip to content

Commit

Permalink
Fix a bug: the parser can't parse the array that it's item type is a map
Browse files Browse the repository at this point in the history
  • Loading branch information
jixingcn committed Jan 29, 2021
1 parent 476c24e commit ff305a3
Show file tree
Hide file tree
Showing 24 changed files with 56 additions and 51 deletions.
10 changes: 7 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Change Log

## 0.1.7 (2020/10/15)
## 0.1.8 (2021-01-29)

* Fix a bug: the parser can't parse the array that it's item type is a map

## 0.1.7 (2020-10-15)

* Supports the `KHR_lights_punctual`
* Compile by github action
Expand All @@ -13,11 +17,11 @@

* Fix some bugs

## 0.1.4 (2018/11/5)
## 0.1.4 (2018-11-5)

* Support Android and iOS platforms

## 0.0.1 (2017/12/5)
## 0.0.1 (2017-12-5)

### Changes

Expand Down
18 changes: 8 additions & 10 deletions LICENSE → LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
# The MIT License
MIT License

This software is released under the MIT license.
Copyright (c) 2017-2021 Code 4 Game, Org. All Rights Reserved.

Copyright (c) 2017-2020 Alex Chi, The Code 4 Game Organization

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
Expand Down
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
# -- Project information -----------------------------------------------------

project = 'libgltf'
copyright = '2020, Alex Chi'
author = 'Alex Chi'
copyright = '2021, Code 4 Game'
author = 'Xing Ji'


# -- General configuration ---------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions include/libgltf/libgltf.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This software is released under the MIT license.
*
* Copyright (c) 2017-2020 Alex Chi, The Code 4 Game Organization
* Copyright (c) 2017-2021 Code 4 Game, Org. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
Expand Down Expand Up @@ -660,7 +660,7 @@ namespace libgltf
// The type of primitives to render.
int32_t mode;
// An array of Morph Targets, each Morph Target is a dictionary mapping attributes (only `POSITION`, `NORMAL`, and `TANGENT` supported) to their deviations in the Morph Target.
std::vector<std::shared_ptr<SGlTFId>> targets;
std::vector<std::map<string_t, std::shared_ptr<SGlTFId>>> targets;
};

/*!
Expand Down
2 changes: 1 addition & 1 deletion source/libgltf/common.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This software is released under the MIT license.
*
* Copyright (c) 2017-2020 Alex Chi, The Code 4 Game Organization
* Copyright (c) 2017-2021 Alex Chi, The Code 4 Game Organization
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
Expand Down
2 changes: 1 addition & 1 deletion source/libgltf/common.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This software is released under the MIT license.
*
* Copyright (c) 2017-2020 Alex Chi, The Code 4 Game Organization
* Copyright (c) 2017-2021 Alex Chi, The Code 4 Game Organization
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
Expand Down
2 changes: 1 addition & 1 deletion source/libgltf/extensions/google_draco.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This software is released under the MIT license.
*
* Copyright (c) 2017-2020 Alex Chi, The Code 4 Game Organization
* Copyright (c) 2017-2021 Alex Chi, The Code 4 Game Organization
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
Expand Down
2 changes: 1 addition & 1 deletion source/libgltf/extensions/google_draco.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This software is released under the MIT license.
*
* Copyright (c) 2017-2020 Alex Chi, The Code 4 Game Organization
* Copyright (c) 2017-2021 Alex Chi, The Code 4 Game Organization
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
Expand Down
2 changes: 1 addition & 1 deletion source/libgltf/file_loader.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This software is released under the MIT license.
*
* Copyright (c) 2017-2020 Alex Chi, The Code 4 Game Organization
* Copyright (c) 2017-2021 Alex Chi, The Code 4 Game Organization
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
Expand Down
2 changes: 1 addition & 1 deletion source/libgltf/file_loader.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This software is released under the MIT license.
*
* Copyright (c) 2017-2020 Alex Chi, The Code 4 Game Organization
* Copyright (c) 2017-2021 Alex Chi, The Code 4 Game Organization
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
Expand Down
2 changes: 1 addition & 1 deletion source/libgltf/gltf_loader.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This software is released under the MIT license.
*
* Copyright (c) 2017-2020 Alex Chi, The Code 4 Game Organization
* Copyright (c) 2017-2021 Alex Chi, The Code 4 Game Organization
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
Expand Down
2 changes: 1 addition & 1 deletion source/libgltf/gltf_loader.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This software is released under the MIT license.
*
* Copyright (c) 2017-2020 Alex Chi, The Code 4 Game Organization
* Copyright (c) 2017-2021 Code 4 Game, Org. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
Expand Down
2 changes: 1 addition & 1 deletion source/libgltf/libgltf.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This software is released under the MIT license.
*
* Copyright (c) 2017-2020 Alex Chi, The Code 4 Game Organization
* Copyright (c) 2017-2021 Code 4 Game, Org. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
Expand Down
2 changes: 1 addition & 1 deletion source/libgltf/libgltfloader.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This software is released under the MIT license.
*
* Copyright (c) 2017-2020 Alex Chi, The Code 4 Game Organization
* Copyright (c) 2017-2021 Alex Chi, The Code 4 Game Organization
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
Expand Down
4 changes: 2 additions & 2 deletions source/libgltf/libgltfparser.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This software is released under the MIT license.
*
* Copyright (c) 2017-2020 Alex Chi, The Code 4 Game Organization
* Copyright (c) 2017-2021 Code 4 Game, Org. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
Expand Down Expand Up @@ -2374,7 +2374,7 @@ namespace libgltf
if (!_rData.data.targets.empty())
{
GLTFCharValue json_value;
if (!(TDataDoc<std::vector<std::shared_ptr<SGlTFId>>>(_rData.data.targets, _rData.doc) >> json_value)) return false;
if (!(TDataDoc<std::vector<std::map<string_t, std::shared_ptr<SGlTFId>>>>(_rData.data.targets, _rData.doc) >> json_value)) return false;
_JsonValue.AddMember(GLTFTEXT("targets"), json_value, _rData.doc->GetAllocator());
}
return true;
Expand Down
2 changes: 1 addition & 1 deletion source/libgltf/libgltfparser.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This software is released under the MIT license.
*
* Copyright (c) 2017-2020 Alex Chi, The Code 4 Game Organization
* Copyright (c) 2017-2021 Code 4 Game, Org. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
Expand Down
2 changes: 1 addition & 1 deletion source/libgltf/libgltfpch.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This software is released under the MIT license.
*
* Copyright (c) 2017-2020 Alex Chi, The Code 4 Game Organization
* Copyright (c) 2017-2021 Alex Chi, The Code 4 Game Organization
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
Expand Down
2 changes: 1 addition & 1 deletion source/libgltf/utility.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This software is released under the MIT license.
*
* Copyright (c) 2017-2020 Alex Chi, The Code 4 Game Organization
* Copyright (c) 2017-2021 Alex Chi, The Code 4 Game Organization
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
Expand Down
2 changes: 1 addition & 1 deletion source/libgltf/utility.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This software is released under the MIT license.
*
* Copyright (c) 2017-2020 Alex Chi, The Code 4 Game Organization
* Copyright (c) 2017-2021 Alex Chi, The Code 4 Game Organization
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
Expand Down
2 changes: 1 addition & 1 deletion source/runtest/runtest.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This software is released under the MIT license.
*
* Copyright (c) 2017-2020 Alex Chi, The Code 4 Game Organization
* Copyright (c) 2017-2021 Alex Chi, The Code 4 Game Organization
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
Expand Down
2 changes: 1 addition & 1 deletion source/runtest/runtest.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This software is released under the MIT license.
*
* Copyright (c) 2017-2020 Alex Chi, The Code 4 Game Organization
* Copyright (c) 2017-2021 Alex Chi, The Code 4 Game Organization
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
Expand Down
2 changes: 1 addition & 1 deletion tools/batch/codes/libgltf.license.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This software is released under the MIT license.
*
* Copyright (c) 2017-2020 Alex Chi, The Code 4 Game Organization
* Copyright (c) 2017-2021 Code 4 Game, Org. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
Expand Down
18 changes: 15 additions & 3 deletions tools/jsonschematoc11/c11types/c11typearray.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,15 @@ def __init__(self):
def buildC11Type(cls, schemaValue):
c11Type = None
schemaValueType = None
variableSchemaValue = schemaValue
if u'type' in schemaValue:
schemaValueType = schemaValue[u'type']
if schemaValueType == u'object' and u'additionalProperties' in schemaValue:
schemaValueType = u'map'
variableSchemaValue = schemaValue[u'additionalProperties']
elif u'$ref' in schemaValue:
schemaValueType = schemaValue[u'$ref']

if schemaValueType == u'bool' or schemaValueType == u'boolean':
from .c11typebool import C11TypeBool
c11Type = C11TypeBool()
Expand All @@ -28,6 +33,10 @@ def buildC11Type(cls, schemaValue):
c11Type = C11TypeString()
elif schemaValueType == u'array':
c11Type = C11TypeArray()
elif schemaValueType == u'map':
from .c11typemap import C11TypeMap
c11Type = C11TypeMap()
c11Type.setItemSchema(variableSchemaValue)
if c11Type is None:
from .c11typestruct import C11TypeStruct
c11Type = C11TypeStruct()
Expand All @@ -46,7 +55,8 @@ def setItemSchema(self, schemaValue):

def revise(self, c11Types):
from .c11typestruct import C11TypeStruct
if not isinstance(self.c11Type, C11TypeStruct):
from .c11typemap import C11TypeMap
if not isinstance(self.c11Type, C11TypeStruct) and not isinstance(self.c11Type, C11TypeMap):
return (0, None)
schemaValueType = None
schemaValueItem = None
Expand All @@ -56,14 +66,16 @@ def revise(self, c11Types):
schemaValueItem = self.schemaValue
if schemaValueItem is None:
return (1, u'Can\'t find the items in schema of array')
if u'$ref' in schemaValueItem:
elif u'$ref' in schemaValueItem:
schemaValueType = schemaValueItem[u'$ref']
if schemaValueType not in c11Types:
if u'additionalProperties' in schemaValueItem:
schemaValueAdditionalProperties = schemaValueItem[u'additionalProperties']
if u'$ref' in schemaValueAdditionalProperties:
schemaValueType = schemaValueAdditionalProperties[u'$ref']
if schemaValueType in c11Types:
if isinstance(self.c11Type, C11TypeMap):
self.c11Type.revise(c11Types)
elif schemaValueType in c11Types:
self.c11Type = c11Types[schemaValueType]
else:
from .c11typenone import C11TypeNone
Expand Down
15 changes: 3 additions & 12 deletions tools/jsonschematoc11/c11types/c11typemap.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,23 +49,14 @@ def revise(self, c11Types):
if not isinstance(self.c11Type, C11TypeStruct):
return (0, None)
schemaValueType = None
schemaValueItem = self.schemaValue
if u'items' in self.schemaValue:
schemaValueItem = self.schemaValue[u'items']
if schemaValueItem == None:
return (1, u'Can\'t find the items in schema of array')
if u'$ref' in schemaValueItem:
schemaValueType = schemaValueItem[u'$ref']
if schemaValueType not in c11Types:
if u'additionalProperties' in schemaValueItem:
schemaValueAdditionalProperties = schemaValueItem[u'additionalProperties']
if u'$ref' in schemaValueAdditionalProperties:
schemaValueType = schemaValueAdditionalProperties[u'$ref']
if u'$ref' in self.schemaValue:
schemaValueType = self.schemaValue[u'$ref']
if schemaValueType in c11Types:
self.c11Type = c11Types[schemaValueType]
else:
from .c11typenone import C11TypeNone
self.c11Type = C11TypeNone()
self.c11Type.revise(c11Types)
return (0, u'')

def codeTypeName(self, withDeclare=False, asVariable=False, withDocument=False):
Expand Down

0 comments on commit ff305a3

Please sign in to comment.