浏览代码

Merge pull request #288 from Unity-Technologies/zxw/refine_codegen

refine codegen scripts
/main
GitHub 3 年前
当前提交
8501e188
共有 22 个文件被更改,包括 176 次插入128 次删除
  1. 8
      com.unity.uiwidgets/Runtime/animation/listener_helpers.mixin.gen.cs
  2. 50
      com.unity.uiwidgets/Runtime/animation/listener_helpers.mixin.njk
  3. 8
      com.unity.uiwidgets/Runtime/cupertino/cupertinodynamiccolor.mixin.gen.cs
  4. 8
      com.unity.uiwidgets/Runtime/foundation/diagnosticable.mixin.gen.cs
  5. 11
      com.unity.uiwidgets/Runtime/foundation/node.mixin.gen.cs
  6. 12
      com.unity.uiwidgets/Runtime/rendering/RenderAnimatedOpacityMixin.mixin.gen.cs
  7. 4
      com.unity.uiwidgets/Runtime/rendering/RenderAnimatedOpacityMixin.mixin.njk
  8. 14
      com.unity.uiwidgets/Runtime/rendering/box.mixin.gen.cs
  9. 4
      com.unity.uiwidgets/Runtime/rendering/box.mixin.njk
  10. 11
      com.unity.uiwidgets/Runtime/rendering/object.mixin.gen.cs
  11. 84
      com.unity.uiwidgets/Runtime/rendering/object.mixin.njk
  12. 1
      com.unity.uiwidgets/Runtime/rendering/proxy_box.cs
  13. 10
      com.unity.uiwidgets/Runtime/rendering/proxy_box.mixin.gen.cs
  14. 18
      com.unity.uiwidgets/Runtime/rendering/proxy_box.mixin.njk
  15. 2
      com.unity.uiwidgets/Runtime/rendering/proxy_sliver.cs
  16. 8
      com.unity.uiwidgets/Runtime/widgets/DiagnosticableTree.mixin.gen.cs
  17. 8
      com.unity.uiwidgets/Runtime/widgets/DirectionalFocusTraversalPolicy.mixin.gen.cs
  18. 8
      com.unity.uiwidgets/Runtime/widgets/scroll_notification.mixin.gen.cs
  19. 8
      com.unity.uiwidgets/Runtime/widgets/sliver_persistent_header.mixin.gen.cs
  20. 10
      com.unity.uiwidgets/Scripts/cmds/codegen.js
  21. 10
      com.unity.uiwidgets/Scripts/ReadMe.txt
  22. 7
      com.unity.uiwidgets/Scripts/ReadMe.txt.meta

8
com.unity.uiwidgets/Runtime/animation/listener_helpers.mixin.gen.cs


/*
WARNING!!!: GENERATED BY CODE, DO NOT CHANGE !!!!!!
A file with the suffix .gen.cs is automatically generate from its corresponding template file with suffix .njk using nunjucks.
If you want to update this file, please edit the corresponding .njk file first and execute the following cmd at the Scripts folder:
"node uiwidgets-cli.js codegen"
*/
using System;
using System.Collections.Generic;
using Unity.UIWidgets.foundation;

50
com.unity.uiwidgets/Runtime/animation/listener_helpers.mixin.njk


int _listenerCounter = 0;
protected void didRegisterListener() {
D.assert(this._listenerCounter >= 0);
if (this._listenerCounter == 0) {
this.didStartListening();
D.assert(_listenerCounter >= 0);
if (_listenerCounter == 0) {
didStartListening();
this._listenerCounter += 1;
_listenerCounter += 1;
D.assert(this._listenerCounter >= 1);
this._listenerCounter -= 1;
if (this._listenerCounter == 0) {
this.didStopListening();
D.assert(_listenerCounter >= 1);
_listenerCounter -= 1;
if (_listenerCounter == 0) {
didStopListening();
}
}

public bool isListening {
get { return this._listenerCounter > 0; }
get { return _listenerCounter > 0; }
}
}
{% endmacro %}

readonly ObserverList<VoidCallback> _listeners = new ObserverList<VoidCallback>();
public override void addListener(VoidCallback listener) {
this.didRegisterListener();
this._listeners.Add(listener);
didRegisterListener();
_listeners.Add(listener);
bool removed = this._listeners.Remove(listener);
bool removed = _listeners.Remove(listener);
this.didUnregisterListener();
didUnregisterListener();
var localListeners = new List<VoidCallback>(this._listeners);
var localListeners = new List<VoidCallback>(_listeners);
"The " + this.GetType() + " notifying listeners was",
"The " + GetType() + " notifying listeners was",
this,
style: DiagnosticsTreeStyle.errorProperty
);

});
try {
if (this._listeners.Contains(listener)) {
if (_listeners.Contains(listener)) {
listener();
}
} catch (Exception exception) {

context: new ErrorDescription("while notifying listeners for " + this.GetType()),
context: new ErrorDescription("while notifying listeners for " + GetType()),
informationCollector: collector
));
}

readonly ObserverList<AnimationStatusListener> _statusListeners = new ObserverList<AnimationStatusListener>();
public override void addStatusListener(AnimationStatusListener listener) {
this.didRegisterListener();
this._statusListeners.Add(listener);
didRegisterListener();
_statusListeners.Add(listener);
bool removed = this._statusListeners.Remove(listener);
bool removed = _statusListeners.Remove(listener);
this.didUnregisterListener();
didUnregisterListener();
var localListeners = new List<AnimationStatusListener>(this._statusListeners);
var localListeners = new List<AnimationStatusListener>(_statusListeners);
if (this._statusListeners.Contains(listener)) {
if (_statusListeners.Contains(listener)) {
listener(status);
}
} catch (Exception exception) {

yield return new DiagnosticsProperty<AnimationLocalStatusListenersMixin{{with | safe}}>(
"The " + this.GetType() + " notifying status listeners was",
"The " + GetType() + " notifying status listeners was",
this,
style: DiagnosticsTreeStyle.errorProperty
);

UIWidgetsError.reportError(new UIWidgetsErrorDetails(
exception: exception,
library: "animation library",
context: new ErrorDescription("while notifying status listeners for " + this.GetType()),
context: new ErrorDescription("while notifying status listeners for " + GetType()),
informationCollector: collector
));
}

8
com.unity.uiwidgets/Runtime/cupertino/cupertinodynamiccolor.mixin.gen.cs


/*
WARNING!!!: GENERATED BY CODE, DO NOT CHANGE !!!!!!
A file with the suffix .gen.cs is automatically generate from its corresponding template file with suffix .njk using nunjucks.
If you want to update this file, please edit the corresponding .njk file first and execute the following cmd at the Scripts folder:
"node uiwidgets-cli.js codegen"
*/
using System;
using System.Collections.Generic;
using System.Linq;

8
com.unity.uiwidgets/Runtime/foundation/diagnosticable.mixin.gen.cs


/*
WARNING!!!: GENERATED BY CODE, DO NOT CHANGE !!!!!!
A file with the suffix .gen.cs is automatically generate from its corresponding template file with suffix .njk using nunjucks.
If you want to update this file, please edit the corresponding .njk file first and execute the following cmd at the Scripts folder:
"node uiwidgets-cli.js codegen"
*/
namespace Unity.UIWidgets.foundation {
public class DiagnosticableMixinChangeNotifier : ChangeNotifier, IDiagnosticable {
protected DiagnosticableMixinChangeNotifier() {

11
com.unity.uiwidgets/Runtime/foundation/node.mixin.gen.cs


/*
WARNING!!!: GENERATED BY CODE, DO NOT CHANGE !!!!!!
A file with the suffix .gen.cs is automatically generate from its corresponding template file with suffix .njk using nunjucks.
If you want to update this file, please edit the corresponding .njk file first and execute the following cmd at the Scripts folder:
"node uiwidgets-cli.js codegen"
*/
namespace Unity.UIWidgets.foundation {

if (attached) {
child.attach(_owner);
}
redepthChild(child);
}

if (attached) {
child.attach(_owner);
}
redepthChild(child);
}

}
}
}
}

12
com.unity.uiwidgets/Runtime/rendering/RenderAnimatedOpacityMixin.mixin.gen.cs


/*
WARNING!!!: GENERATED BY CODE, DO NOT CHANGE !!!!!!
A file with the suffix .gen.cs is automatically generate from its corresponding template file with suffix .njk using nunjucks.
If you want to update this file, please edit the corresponding .njk file first and execute the following cmd at the Scripts folder:
"node uiwidgets-cli.js codegen"
*/
using System.Collections.Generic;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.foundation;

public int _alpha { get; set;}
public new bool alwaysNeedsCompositing {
protected override bool alwaysNeedsCompositing {
get { return child != null && _currentlyNeedsCompositing;}
}
public bool _currentlyNeedsCompositing { get;set; }

properties.add(new FlagProperty("alwaysIncludeSemantics", value: alwaysIncludeSemantics, ifTrue: "alwaysIncludeSemantics"));
}
public bool debugValidateChild(RenderObject child) {
public override bool debugValidateChild(RenderObject child) {
D.assert(() => {
if (!(child is ChildType)) {
throw new UIWidgetsError(new List<DiagnosticsNode>{

4
com.unity.uiwidgets/Runtime/rendering/RenderAnimatedOpacityMixin.mixin.njk


public int _alpha { get; set;}
public new bool alwaysNeedsCompositing {
protected override bool alwaysNeedsCompositing {
get { return child != null && _currentlyNeedsCompositing;}
}
public bool _currentlyNeedsCompositing { get;set; }

properties.add(new FlagProperty("alwaysIncludeSemantics", value: alwaysIncludeSemantics, ifTrue: "alwaysIncludeSemantics"));
}
public bool debugValidateChild(RenderObject child) {
public override bool debugValidateChild(RenderObject child) {
D.assert(() => {
if (!(child is ChildType)) {
throw new UIWidgetsError(new List<DiagnosticsNode>{

14
com.unity.uiwidgets/Runtime/rendering/box.mixin.gen.cs


/*
WARNING!!!: GENERATED BY CODE, DO NOT CHANGE !!!!!!
A file with the suffix .gen.cs is automatically generate from its corresponding template file with suffix .njk using nunjucks.
If you want to update this file, please edit the corresponding .njk file first and execute the following cmd at the Scripts folder:
"node uiwidgets-cli.js codegen"
*/
using System;
using UnityEngine;
using Unity.UIWidgets.gestures;
using UnityEngine;
namespace Unity.UIWidgets.rendering {

bool isHit = result.addWithPaintOffset(
offset: childParentData.offset,
position: position,
hitTest: (boxHitTestResult, transformed) => {
hitTest: (BoxHitTestResult boxHitTestResult, Offset transformed) => {
D.assert(transformed == position - childParentData.offset);
return child.hitTest(boxHitTestResult, position: transformed);
}

4
com.unity.uiwidgets/Runtime/rendering/box.mixin.njk


public bool defaultHitTestChildren(BoxHitTestResult result, Offset position) {
ChildType child = this.lastChild;
ChildType child = lastChild;
while (child != null) {
ParentDataType childParentData = child.parentData as ParentDataType;
bool isHit = result.addWithPaintOffset(

public List<ChildType> getChildrenAsList() {
var result = new List<ChildType>();
var child = this.firstChild;
var child = firstChild;
while (child != null) {
var childParentData = (ParentDataType) child.parentData;
result.Add(child);

11
com.unity.uiwidgets/Runtime/rendering/object.mixin.gen.cs


/*
WARNING!!!: GENERATED BY CODE, DO NOT CHANGE !!!!!!
A file with the suffix .gen.cs is automatically generate from its corresponding template file with suffix .njk using nunjucks.
If you want to update this file, please edit the corresponding .njk file first and execute the following cmd at the Scripts folder:
"node uiwidgets-cli.js codegen"
*/
// AUTO-GENERATED, DO NOT EDIT BY HAND
using System.Collections.Generic;

public abstract class
RelayoutWhenSystemFontsChangeMixinRenderBoxContainerDefaultsMixinContainerRenderObjectMixinRenderBox<ChildType, ParentDataType>
: RenderBoxContainerDefaultsMixinContainerRenderObjectMixinRenderBox<ChildType, ParentDataType>, RelayoutWhenSystemFontsChangeMixin
public virtual void systemFontsDidChange() {
markNeedsLayout();
}

84
com.unity.uiwidgets/Runtime/rendering/object.mixin.njk


{% macro RelayoutWhenSystemFontsChangeMixin(with) %}
public abstract class RelayoutWhenSystemFontsChangeMixin{{with}} : {{with}}, RelayoutWhenSystemFontsChangeMixin {
public void systemFontsDidChange() {
public virtual void systemFontsDidChange() {
markNeedsLayout();
}

public abstract class
RelayoutWhenSystemFontsChangeMixin{{with | safe}}
: {{with | safe}}
: {{with | safe}}, RelayoutWhenSystemFontsChangeMixin
public float? defaultComputeDistanceToFirstActualBaseline(TextBaseline baseline) {
var child = firstChild;
while (child != null) {
var childParentData = (ParentDataType) child.parentData;
float? result = child.getDistanceToActualBaseline(baseline);
if (result != null) {
return result.Value + childParentData.offset.dy;
}
child = childParentData.nextSibling;
}
return null;
}
public float? defaultComputeDistanceToHighestActualBaseline(TextBaseline baseline) {
float? result = null;
var child = firstChild;
while (child != null) {
var childParentData = (ParentDataType) child.parentData;
float? candidate = child.getDistanceToActualBaseline(baseline);
if (candidate != null) {
candidate += childParentData.offset.dy;
if (result != null) {
result = Mathf.Min(result.Value, candidate.Value);
} else {
result = candidate;
}
}
child = childParentData.nextSibling;
}
return result;
}
public void defaultPaint(PaintingContext context, Offset offset) {
var child = firstChild;
while (child != null) {
var childParentData = (ParentDataType) child.parentData;
context.paintChild(child, childParentData.offset + offset);
child = childParentData.nextSibling;
}
}
public bool defaultHitTestChildren(BoxHitTestResult result, Offset position) {
ChildType child = lastChild;
while (child != null) {
ParentDataType childParentData = child.parentData as ParentDataType;
bool isHit = result.addWithPaintOffset(
offset: childParentData.offset,
position: position,
hitTest: (BoxHitTestResult boxHitTestResult, Offset transformed) => {
D.assert(transformed == position - childParentData.offset);
return child.hitTest(boxHitTestResult, position: transformed);
}
);
if (isHit)
return true;
child = childParentData.previousSibling;
}
return false;
}
public List<ChildType> getChildrenAsList() {
var result = new List<ChildType>();
var child = firstChild;
while (child != null) {
var childParentData = (ParentDataType) child.parentData;
result.Add(child);
child = childParentData.nextSibling;
}
return result;
}
public void systemFontsDidChange() {
public virtual void systemFontsDidChange() {
markNeedsLayout();
}

1
com.unity.uiwidgets/Runtime/rendering/proxy_box.cs


public interface RenderAnimatedOpacityMixin<T> : RenderObjectWithChildMixin<T> where T : RenderObject {
int _alpha { get; set; }
bool alwaysNeedsCompositing { get; }
bool _currentlyNeedsCompositing { get; set; }
Animation<float> _opacity { get; set; }

10
com.unity.uiwidgets/Runtime/rendering/proxy_box.mixin.gen.cs


/*
WARNING!!!: GENERATED BY CODE, DO NOT CHANGE !!!!!!
A file with the suffix .gen.cs is automatically generate from its corresponding template file with suffix .njk using nunjucks.
If you want to update this file, please edit the corresponding .njk file first and execute the following cmd at the Scripts folder:
"node uiwidgets-cli.js codegen"
*/
using Unity.UIWidgets.gestures;
using UnityEngine;
namespace Unity.UIWidgets.rendering {

18
com.unity.uiwidgets/Runtime/rendering/proxy_box.mixin.njk


protected internal override float computeMinIntrinsicWidth(float height) {
if (this.child != null) {
return this.child.getMinIntrinsicWidth(height);
if (child != null) {
return child.getMinIntrinsicWidth(height);
}
return 0.0f;
}

if (this.child != null) {
return this.child.getMaxIntrinsicWidth(height);
if (child != null) {
return child.getMaxIntrinsicWidth(height);
}

protected internal override float computeMinIntrinsicHeight(float width) {
if (this.child != null) {
return this.child.getMinIntrinsicHeight(width);
if (child != null) {
return child.getMinIntrinsicHeight(width);
}

protected internal override float computeMaxIntrinsicHeight(float width) {
if (this.child != null) {
return this.child.getMaxIntrinsicHeight(width);
if (child != null) {
return child.getMaxIntrinsicHeight(width);
protected override float? computeDistanceToActualBaseline(TextBaseline baseline) {
public override float? computeDistanceToActualBaseline(TextBaseline baseline) {
if (child != null) {
return child.getDistanceToActualBaseline(baseline);
}

2
com.unity.uiwidgets/Runtime/rendering/proxy_sliver.cs


childParentData.applyPaintTransform(transform);
}
public bool debugValidateChild(RenderObject child)
public virtual bool debugValidateChild(RenderObject child)
{
D.assert(() =>
{

8
com.unity.uiwidgets/Runtime/widgets/DiagnosticableTree.mixin.gen.cs


/*
WARNING!!!: GENERATED BY CODE, DO NOT CHANGE !!!!!!
A file with the suffix .gen.cs is automatically generate from its corresponding template file with suffix .njk using nunjucks.
If you want to update this file, please edit the corresponding .njk file first and execute the following cmd at the Scripts folder:
"node uiwidgets-cli.js codegen"
*/
using System.Collections.Generic;
using System.Linq;
using System.Text;

8
com.unity.uiwidgets/Runtime/widgets/DirectionalFocusTraversalPolicy.mixin.gen.cs


/*
WARNING!!!: GENERATED BY CODE, DO NOT CHANGE !!!!!!
A file with the suffix .gen.cs is automatically generate from its corresponding template file with suffix .njk using nunjucks.
If you want to update this file, please edit the corresponding .njk file first and execute the following cmd at the Scripts folder:
"node uiwidgets-cli.js codegen"
*/
using System.Collections.Generic;
using System.Linq;
using Unity.UIWidgets.foundation;

8
com.unity.uiwidgets/Runtime/widgets/scroll_notification.mixin.gen.cs


/*
WARNING!!!: GENERATED BY CODE, DO NOT CHANGE !!!!!!
A file with the suffix .gen.cs is automatically generate from its corresponding template file with suffix .njk using nunjucks.
If you want to update this file, please edit the corresponding .njk file first and execute the following cmd at the Scripts folder:
"node uiwidgets-cli.js codegen"
*/
using System.Collections.Generic;
using Unity.UIWidgets.rendering;

8
com.unity.uiwidgets/Runtime/widgets/sliver_persistent_header.mixin.gen.cs


/*
WARNING!!!: GENERATED BY CODE, DO NOT CHANGE !!!!!!
A file with the suffix .gen.cs is automatically generate from its corresponding template file with suffix .njk using nunjucks.
If you want to update this file, please edit the corresponding .njk file first and execute the following cmd at the Scripts folder:
"node uiwidgets-cli.js codegen"
*/
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.rendering;

10
com.unity.uiwidgets/Scripts/cmds/codegen.js


};
function render(env, cwd, file, data) {
warning_prefix =
"/*\n" +
" WARNING!!!: GENERATED BY CODE, DO NOT CHANGE !!!!!!\n" +
" A file with the suffix .gen.cs is automatically generate from its corresponding template file with suffix .njk using nunjucks.\n" +
" If you want to update this file, please edit the corresponding .njk file first and execute the following cmd at the Scripts folder:\n" +
" \"node uiwidgets-cli.js codegen\"\n" +
"*/\n\n\n";
env.render(file, data, function (err, res) {
if (err) {
return console.error(chalk.red(err));

console.log(chalk.blue('Rendering: ' + file));
fs.writeFileSync(path.resolve(cwd, outputFile), res);
fs.writeFileSync(path.resolve(cwd, outputFile), warning_prefix + res);
});
}

10
com.unity.uiwidgets/Scripts/ReadMe.txt


UIWidgets Codegen Toolkit
This toolkit is based on nodejs, please install nodejs to your PC first. Then please install the following dependencies:
npm i yargs
npm i chalk
npm i nunjucks
npm i chokidar
Then you can execute the codegen scripts in this directory using:
nodejs uiwidgets-cli.js codegen

7
com.unity.uiwidgets/Scripts/ReadMe.txt.meta


fileFormatVersion: 2
guid: 48673785649454536b8a628b40cfd2b2
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存