Properties Update
This commit is contained in:
parent
ae960523cf
commit
378ff808ec
|
@ -1,6 +1,6 @@
|
||||||
const fs = require( "node:fs/promises" );
|
const fs = require( "node:fs/promises" );
|
||||||
const path = require( "path" );
|
const path = require( "path" );
|
||||||
const { loadJSON, getFiles, saveUTF8, getMatches, loadUTF8, insertText } = require( "./library.js" );
|
const { loadJSON, getFiles, saveUTF8, getMatches, loadUTF8, insertText, isDirectory } = require( "./library.js" );
|
||||||
const { CppClassMember } = require( "./cpp-class-member.js" );
|
const { CppClassMember } = require( "./cpp-class-member.js" );
|
||||||
|
|
||||||
function createCppHeader( className, extendingClassName, headerDefine, protectedMembers,
|
function createCppHeader( className, extendingClassName, headerDefine, protectedMembers,
|
||||||
|
@ -121,7 +121,7 @@ async function main()
|
||||||
|
|
||||||
for ( let file of files )
|
for ( let file of files )
|
||||||
{
|
{
|
||||||
await createCppFiles( file, types, missingTypes );
|
await createCppFiles( path.join( definitionsPath, file ), types, missingTypes );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( missingTypes.length === 0 )
|
if ( missingTypes.length === 0 )
|
||||||
|
@ -175,9 +175,29 @@ function grabMembers( membersData )
|
||||||
let nameDefinition = it;
|
let nameDefinition = it;
|
||||||
let memberData = membersData[ it ];
|
let memberData = membersData[ it ];
|
||||||
|
|
||||||
let classMember = new CppClassMember( nameDefinition, memberData );
|
let actionRegex = /^\s*action\s+(\w+)\s*$/;
|
||||||
|
|
||||||
|
if ( actionRegex.test( nameDefinition ) )
|
||||||
|
{
|
||||||
|
let name = actionRegex.exec( nameDefinition )[ 1 ];
|
||||||
|
let upperCaseName = name[ 0 ].toUpperCase() + name.substring( 1 );
|
||||||
|
let actionName = `on${upperCaseName}`;
|
||||||
|
|
||||||
|
let signal = `signal ${name}()`;
|
||||||
|
let actionGetter = `virtual get_${actionName}():Ref<RJAction>`;
|
||||||
|
let actionSetter = `virtual set_${actionName}()`;
|
||||||
|
|
||||||
|
members.push( new CppClassMember( signal, {} ) );
|
||||||
|
members.push( new CppClassMember( actionGetter, {} ) );
|
||||||
|
members.push( new CppClassMember( actionSetter, { "action":"Ref<RJAction>"} ) );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
let classMember = new CppClassMember( nameDefinition, memberData );
|
||||||
|
members.push( classMember );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
members.push( classMember );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return members;
|
return members;
|
||||||
|
@ -230,7 +250,22 @@ async function createCppFiles( definitionPath, types, missingTypes )
|
||||||
{
|
{
|
||||||
console.log( "Creating: ", definitionPath );
|
console.log( "Creating: ", definitionPath );
|
||||||
|
|
||||||
let jsonPath = path.join( definitionsPath, definitionPath );
|
let jsonPath = definitionPath;
|
||||||
|
// path.join( definitionsPath, definitionPath );
|
||||||
|
|
||||||
|
let isDir = await isDirectory( jsonPath );
|
||||||
|
|
||||||
|
if ( isDir )
|
||||||
|
{
|
||||||
|
let files = await getFiles( jsonPath );
|
||||||
|
|
||||||
|
for ( let file of files )
|
||||||
|
{
|
||||||
|
await createCppFiles( path.join( jsonPath, file ), types, missingTypes );
|
||||||
|
}
|
||||||
|
|
||||||
|
return Promise.resolve();
|
||||||
|
}
|
||||||
|
|
||||||
let data = await loadJSON( jsonPath );
|
let data = await loadJSON( jsonPath );
|
||||||
|
|
||||||
|
@ -297,6 +332,8 @@ async function createCppFiles( definitionPath, types, missingTypes )
|
||||||
let rawFilePath = path.join( outputPath, className );
|
let rawFilePath = path.join( outputPath, className );
|
||||||
await saveUTF8( rawFilePath + ".h", header );
|
await saveUTF8( rawFilePath + ".h", header );
|
||||||
await saveUTF8( rawFilePath + ".cpp", implementation );
|
await saveUTF8( rawFilePath + ".cpp", implementation );
|
||||||
|
|
||||||
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
2
godot
2
godot
|
@ -1 +1 @@
|
||||||
Subproject commit 11d3768132582d192b8464769f26b493ae822321
|
Subproject commit f0e20efb33adbf9d6d9c111d646685a30bdd8f4f
|
|
@ -6,6 +6,13 @@ async function getFiles( filePath )
|
||||||
return await fs.readdir( filePath );
|
return await fs.readdir( filePath );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function isDirectory( filePath )
|
||||||
|
{
|
||||||
|
let stats = await fs.stat( filePath );
|
||||||
|
|
||||||
|
return stats.isDirectory();
|
||||||
|
}
|
||||||
|
|
||||||
async function exists( filePath )
|
async function exists( filePath )
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -154,6 +161,7 @@ function insertText( sourceText, insertText, insertPosition )
|
||||||
module.exports =
|
module.exports =
|
||||||
{
|
{
|
||||||
exists,
|
exists,
|
||||||
|
isDirectory,
|
||||||
loadUTF8,
|
loadUTF8,
|
||||||
saveUTF8,
|
saveUTF8,
|
||||||
loadJSON,
|
loadJSON,
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit c19d8b71d88206e99fa2c987d369ac713c275d41
|
Subproject commit 650c34164ae6a39bdce2d748888092c660a1ebd6
|
|
@ -38,8 +38,8 @@
|
||||||
"isPersistent": "bool"
|
"isPersistent": "bool"
|
||||||
},
|
},
|
||||||
|
|
||||||
"signal onEvent()" : { "callbackID": "int" },
|
"signal onEvent()" : { "callbackID": "int" },
|
||||||
|
|
||||||
"signal onSpan()" : { "callbackID": "int", "spanType": "int" }
|
"signal onSpan()" : { "callbackID": "int", "spanType": "int" }
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
{
|
||||||
|
"class":"RJBoolProperty:RJNetworkNode",
|
||||||
|
|
||||||
|
"public":
|
||||||
|
{
|
||||||
|
"virtual set()" : { "value":"bool" },
|
||||||
|
"virtual get():bool": {},
|
||||||
|
"signal onChange()" : {}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
{
|
||||||
|
"class":"RJNodeProperty:RJNetworkNode",
|
||||||
|
|
||||||
|
"public":
|
||||||
|
{
|
||||||
|
"virtual set()" : { "value":"Ref<Node>" },
|
||||||
|
"virtual get():Ref<Node>": {},
|
||||||
|
"signal onChange()" : {}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
{
|
||||||
|
"class":"RJNumberProperty:RJNetworkNode",
|
||||||
|
|
||||||
|
"includes":[ "./RJAction.h" ],
|
||||||
|
|
||||||
|
"public":
|
||||||
|
{
|
||||||
|
"virtual set()" : { "value":"double" },
|
||||||
|
"virtual get():double": {},
|
||||||
|
"action changed" : {}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
{
|
||||||
|
"class":"RJStringProperty:RJNetworkNode",
|
||||||
|
|
||||||
|
"public":
|
||||||
|
{
|
||||||
|
"virtual set()" : { "value":"String" },
|
||||||
|
"virtual get():String": {},
|
||||||
|
"signal onChange()" : {}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue