Skip to content

Commit 5d76600

Browse files
authored
Merge pull request #1271 from ThatOpen/NewFunc
Updates
2 parents 9c8b6d7 + 6e8aad8 commit 5d76600

File tree

6 files changed

+15349
-10
lines changed

6 files changed

+15349
-10
lines changed

src/cpp/web-ifc/parsing/IfcLoader.cpp

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ namespace webifc::parsing {
1818
void p21encode(std::string_view input, std::ostringstream &output);
1919
std::string p21decode(std::string_view & str);
2020

21-
IfcLoader::IfcLoader(uint32_t tapeSize, uint32_t memoryLimit,uint32_t lineWriterBuffer, const schema::IfcSchemaManager &schemaManager) :_lineWriterBuffer(lineWriterBuffer), _schemaManager(schemaManager)
21+
IfcLoader::IfcLoader(uint32_t tapeSize, uint64_t memoryLimit,uint32_t lineWriterBuffer, const schema::IfcSchemaManager &schemaManager) :_lineWriterBuffer(lineWriterBuffer), _schemaManager(schemaManager)
2222
{
2323
_tokenStream = new IfcTokenStream(tapeSize,memoryLimit/tapeSize);
2424
_maxExpressId=0;
@@ -642,6 +642,51 @@ namespace webifc::parsing {
642642
}
643643
}
644644
}
645+
646+
uint32_t IfcLoader::GetNoLineArguments() const
647+
{
648+
uint32_t noArguments = 0;
649+
uint32_t setDepth = 0;
650+
while (true)
651+
{
652+
if (setDepth == 1) noArguments++;
653+
654+
IfcTokenType t = static_cast<IfcTokenType>(_tokenStream->Read<char>());
655+
656+
switch (t)
657+
{
658+
case IfcTokenType::LINE_END: return noArguments;
659+
case IfcTokenType::UNKNOWN:
660+
case IfcTokenType::EMPTY:
661+
break;
662+
case IfcTokenType::SET_BEGIN:
663+
setDepth++;
664+
break;
665+
case IfcTokenType::SET_END:
666+
setDepth--;
667+
if (setDepth == 0) return noArguments;
668+
break;
669+
case IfcTokenType::STRING:
670+
case IfcTokenType::ENUM:
671+
case IfcTokenType::LABEL:
672+
case IfcTokenType::INTEGER:
673+
case IfcTokenType::REAL:
674+
{
675+
uint16_t length = _tokenStream->Read<uint16_t>();
676+
_tokenStream->Forward(length);
677+
break;
678+
}
679+
case IfcTokenType::REF:
680+
{
681+
_tokenStream->Read<uint32_t>();
682+
break;
683+
}
684+
default:
685+
break;
686+
}
687+
}
688+
return noArguments;
689+
}
645690

646691
void IfcLoader::MoveToArgumentOffset(const uint32_t expressID, const uint32_t argumentIndex) const
647692
{

src/cpp/web-ifc/parsing/IfcLoader.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ namespace webifc::parsing
2020
class IfcLoader {
2121

2222
public:
23-
IfcLoader(uint32_t tapeSize, uint32_t memoryLimit,uint32_t lineWriterBuffer, const schema::IfcSchemaManager &schemaManager);
23+
IfcLoader(uint32_t tapeSize, uint64_t memoryLimit,uint32_t lineWriterBuffer, const schema::IfcSchemaManager &schemaManager);
2424
~IfcLoader();
2525
const std::vector<uint32_t> GetHeaderLinesWithType(const uint32_t type) const;
2626
void LoadFile(const std::function<uint32_t(char *, size_t, size_t)> &requestData);
@@ -51,6 +51,7 @@ namespace webifc::parsing
5151
std::vector<uint32_t> GetAllLines() const;
5252
const std::vector<std::vector<uint32_t>> GetSetListArgument() const;
5353
void MoveToArgumentOffset(const uint32_t expressID, const uint32_t argumentIndex) const;
54+
uint32_t GetNoLineArguments() const;
5455
void StepBack() const;
5556
IFC_SCHEMA GetSchema() const;
5657
void Push(void *v, const uint64_t size);

src/cpp/web-ifc/parsing/IfcTokenStream.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
namespace webifc::parsing
1010
{
1111

12-
IfcTokenStream::IfcTokenStream(const size_t chunkSize, const size_t maxChunks)
12+
IfcTokenStream::IfcTokenStream(const size_t chunkSize, const uint64_t maxChunks)
1313
: _chunkSize(chunkSize), _maxChunks(maxChunks)
1414
{
1515
_cChunk=nullptr;

src/cpp/web-ifc/parsing/IfcTokenStream.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ namespace webifc::parsing
3434
class IfcTokenStream
3535
{
3636
public:
37-
IfcTokenStream(const size_t chunkSize, const size_t maxChunks);
37+
IfcTokenStream(const size_t chunkSize, const uint64_t maxChunks);
3838
~IfcTokenStream();
3939
void SetTokenSource(const std::function<uint32_t(char *, size_t, size_t)> &requestData);
4040
void SetTokenSource(std::istream &requestData);
@@ -67,7 +67,7 @@ namespace webifc::parsing
6767
size_t _currentChunk = 0;
6868
size_t _activeChunks = 0;
6969
size_t _chunkSize;
70-
size_t _maxChunks;
70+
uint64_t _maxChunks;
7171
class IfcFileStream
7272
{
7373
public:

src/cpp/web-ifc/schema/schema-names.h

Lines changed: 15265 additions & 0 deletions
Large diffs are not rendered by default.

src/schema-generator/gen_functional_types.ts

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ console.log("Starting...");
1111

1212
let tsSchema: Array<string> = [];
1313
let cppSchema: Array<string> = [];
14+
let cppPropertyNames: Array<string> = [];
15+
let cppPropertyNamesList: Array<String> = [];
1416
let chSchema: Array<string> = [];
1517

1618
let completeifcElementList = new Set<string>();
@@ -22,6 +24,8 @@ completeEntityList.add("FILE_DESCRIPTION");
2224

2325
let typeList = new Set<string>();
2426

27+
cppPropertyNames.push("std::string getPropertyName(IFC_SCHEMA schema,uint32_t typeCode,uint32_t prop) {")
28+
2529
tsSchema.push('/**');
2630
tsSchema.push(' * Web-IFC IFC Schema Representation');
2731
tsSchema.push(' * @module ifc-schema');
@@ -97,7 +101,6 @@ for (var i = 0; i < files.length; i++) {
97101
let entities: Array<Entity> = sortEntities(parsed.entities);
98102
let types = parsed.types;
99103

100-
101104
entities.forEach((e) => {
102105
walkParents(e,entities);
103106
});
@@ -254,14 +257,26 @@ for (var i = 0; i < files.length; i++) {
254257

255258
for (var x=0; x < entities.length; x++) generateClass(entities[x], tsSchema,types,crcTable);
256259
tsSchema.push("}");
260+
261+
for (var x=0; x < entities.length; x++) {
262+
let crcCode = crc32(entities[x].name.toUpperCase(),crcTable);
263+
for (let i=0; i < entities[x].derivedProps.length;i++) {
264+
let idex = cppPropertyNamesList.indexOf(entities[x].derivedProps[i].name);
265+
if (idex == -1 ) {
266+
idex=cppPropertyNamesList.length;
267+
cppPropertyNamesList.push(entities[x].derivedProps[i] .name);
268+
}
269+
cppPropertyNames.push("if (schema == "+schemaNameClean+" && prop=="+i+" && typeCode=="+crcCode+") return propyNames["+idex+"];");
270+
271+
}
272+
}
273+
257274
}
258275

259276
// now write out the global c++/ts metadata. All the WASM needs to know about is a list of all entities
260277

261278
console.log(`Writing Global WASM/TS Metadata!...`);
262279

263-
264-
265280
chSchema.push("#pragma once");
266281
chSchema.push("// unique list of crc32 codes for ifc classes - this is a generated file - please see schema generator in src/schema");
267282
chSchema.push("");
@@ -307,8 +322,21 @@ cppSchema.push("}");
307322
cppSchema.push("}");
308323
cppSchema.push("}");
309324

310-
fs.writeFileSync("../cpp/schema/ifc-schema.h", chSchema.join("\n"));
311-
fs.writeFileSync("../cpp/schema/schema-functions.cpp", cppSchema.join("\n"));
325+
let nameList ="std::array<std::string,"+cppPropertyNamesList.length+"> propyNames = {";
326+
for (let x=0; x < cppPropertyNamesList.length; x++) {
327+
nameList+="\""+cppPropertyNamesList[x]+"\"";
328+
if (x!+cppPropertyNamesList.length-1) nameList+=",";
329+
}
330+
nameList+="};";
331+
cppPropertyNames.unshift(nameList);
332+
cppPropertyNames.push("}")
333+
334+
335+
336+
337+
fs.writeFileSync("../cpp/web-ifc/schema/ifc-schema.h", chSchema.join("\n"));
338+
fs.writeFileSync("../cpp/web-ifc/schema/schema-functions.cpp", cppSchema.join("\n"));
339+
fs.writeFileSync("../cpp/web-ifc/schema/schema-names.h", cppPropertyNames.join("\n"));
312340
fs.writeFileSync("../ts/ifc-schema.ts", tsSchema.join("\n"));
313341

314342
console.log(`...Done!`);

0 commit comments

Comments
 (0)