openLib static method

int openLib(
  1. LuaState state
)

Implementation

static int openLib(LuaState state) {
  state.newLib({
    'newColor': _luaNewColor,
    'newColorFrom': _luaNewColorFrom,
    'newOffset': _luaNewOffset,
    'newOffsetFromDirection': _luaNewOffsetFromDirection,
    'newRectFromCenter': _luaNewRectFromCenter,
    'newRectFromCircle': _luaNewRectFromCircle,
    'newRectFromLTRB': _luaNewRectFromLTRB,
    'newRectFromLTWH': _luaNewRectFromLTWH,
    'newRectFromPoints': _luaNewRectFromPoints,
    'newRRectFromLTRBAndCorners': _luaRRectFromLTRBAndCorners,
    'newRRectFromLTRBR': _luaRRectFromLTRBR,
    'newRRectFromLTRBXY': _luaRRectFromLTRBXY,
    'newRRectFromRectAndCorners': _luaRRectFromRectAndCorners,
    'newRRectFromRectAndRadius': _luaRRectFromRectAndRadius,
    'newRRectFromRectXY': _luaRRectFromRectXY,
    'newPaint': _luaNewPaint,
    'newRadiusCircular': _luaNewRadiusCircular,
    'newRadiusElliptical': _luaNewRadiusElliptical,
    'newPath': _luaNewPath,
    'newPathFrom': _luaNewPathFrom,
    'newParagraphStyle': _luaNewParagraphStyle,
    'newParagraphBuilder': _luaNewParagraphBuilder,
    'newTextStyle': _luaNewTextStyle,
    'newLinearShader': _luaNewLinearShader,
    'newRadialGradient': _luaNewRadialGradient,
    'newMaskFilterBlur': _luaNewMaskFilterBlur,
    'newImageFilterBlur': _luaNewImageFilterBlur,
    'newImageFilterMatrix': _luaNewImageFilterMatrix,
    'newSize': _luaNewSize,
    'newSizeSquare': _luaNewSizeSquare,
    'newSizeFromWidth': _luaNewSizeFromWidth,
    'newSizeFromHeight': _luaNewSizeFromHeight,
    'newSizeFromRadius': _luaNewSizeFromRadius,
    'newColorFilterMode': _luaNewColorFilterMode,
    'newColorFilterMatrix': _luaNewColorFilterMatrix,
    'newColorFilterLinearToSrgbGamma': _luaNewColorFilterLinearToSrgbGamma,
    'newColorFilterSrgbToLinearGamma': _luaNewColorFilterSrgbToLinearGamma,
    'newVertices': _luaNewVertices,
    'newPictureRecorder': _luaNewPictureRecorder,
    'newCanvas': _luaNewCanvas,
    'newShadow': _luaNewShadow,
    'newFontFeature': _luaNewFontFeature,
    'newFontFeatureEnable': _luaNewFontFeatureEnable,
    'newFontFeatureDisable': _luaNewFontFeatureDisable,
    'newFontVariation': _luaNewFontVariation,
    'newLocale': _luaNewLocale,
    'newTextHeightBehavior': _luaNewTextHeightBehavior,
    'newStrutStyle': _luaNewStrutStyle,
    'newTextPosition': _luaNewTextPosition,
    'newTextRange': _luaNewTextRange,
    'newPathCombine': _luaNewPathCombine,
    'bounceIn': _luaBounceIn,
    'bounceInOut': _luaBounceInOut,
    'bounceOut': _luaBounceOut,
    'decelerate': _luaDecelerate,
    'ease': _luaEase,
    'easeIn': _luaEaseIn,
    'easeInBack': _luaEaseInBack,
    'easeInCirc': _luaEaseInCirc,
    'easeInCubic': _luaEaseInCubic,
    'easeInExpo': _luaEaseInExpo,
    'easeInOut': _luaEaseInOut,
    'easeInOutBack': _luaEaseInOutBack,
    'easeInOutCirc': _luaEaseInOutCirc,
    'easeInOutCubic': _luaEaseInOutCubic,
    'easeInOutCubicEmphasized': _luaEaseInOutCubicEmphasized,
    'easeInOutExpo': _luaEaseInOutExpo,
    'easeInOutQuad': _luaEaseInOutQuad,
    'easeInOutQuart': _luaEaseInOutQuart,
    'easeInOutQuint': _luaEaseInOutQuint,
    'easeInOutSine': _luaEaseInOutSine,
    'easeInQuad': _luaEaseInQuad,
    'easeInQuart': _luaEaseInQuart,
    'easeInQuint': _luaEaseInQuint,
    'easeInSine': _luaEaseInSine,
    'easeInToLinear': _luaEaseInToLinear,
    'easeOut': _luaEaseOut,
    'easeOutBack': _luaEaseOutBack,
    'easeOutCirc': _luaEaseOutCirc,
    'easeOutCubic': _luaEaseOutCubic,
    'easeOutExpo': _luaEaseOutExpo,
    'easeOutQuad': _luaEaseOutQuad,
    'easeOutQuart': _luaEaseOutQuart,
    'easeOutQuint': _luaEaseOutQuint,
    'easeOutSine': _luaEaseOutSine,
    'elasticIn': _luaElasticIn,
    'elasticInOut': _luaElasticInOut,
    'elasticOut': _luaElasticOut,
    'fastEaseInToSlowEaseOut': _luaFastEaseInToSlowEaseOut,
    'fastLinearToSlowEaseIn': _luaFastLinearToSlowEaseIn,
    'fastOutSlowIn': _luaFastOutSlowIn,
    'linear': _luaLinear,
    'linearToEaseOut': _luaLinearToEaseOut,
    'slowMiddle': _luaSlowMiddle,
  });

  state.newTable();
  for (int a=0; a<TileMode.values.length; a++) {
    state.pushString(TileMode.values[a].name);
    state.pushInteger(a);
    state.setTable(-3);
  }
  state.setField(-2,"TileMode");

  state.newTable();
  for (int a=0; a<BlurStyle.values.length; a++) {
    state.pushString(BlurStyle.values[a].name);
    state.pushInteger(a);
    state.setTable(-3);
  }
  state.setField(-2,"BlurStyle");

  state.newTable();
  for (int a=0; a<BlendMode.values.length; a++) {
    state.pushString(BlendMode.values[a].name);
    state.pushInteger(a);
    state.setTable(-3);
  }
  state.setField(-2,"BlendMode");

  state.newTable();
  for (int a=0; a<PaintingStyle.values.length; a++) {
    state.pushString(PaintingStyle.values[a].name);
    state.pushInteger(a);
    state.setTable(-3);
  }
  state.setField(-2,"PaintingStyle");

  state.newTable();
  for (int a=0; a<FilterQuality.values.length; a++) {
    state.pushString(FilterQuality.values[a].name);
    state.pushInteger(a);
    state.setTable(-3);
  }
  state.setField(-2,"FilterQuality");

  state.newTable();
  for (int a=0; a<StrokeCap.values.length; a++) {
    state.pushString(StrokeCap.values[a].name);
    state.pushInteger(a);
    state.setTable(-3);
  }
  state.setField(-2,"StrokeCap");

  state.newTable();
  for (int a=0; a<StrokeJoin.values.length; a++) {
    state.pushString(StrokeJoin.values[a].name);
    state.pushInteger(a);
    state.setTable(-3);
  }
  state.setField(-2,"StrokeJoin");

  state.newTable();
  for (int a=0; a<ColorSpace.values.length; a++) {
    state.pushString(ColorSpace.values[a].name);
    state.pushInteger(a);
    state.setTable(-3);
  }
  state.setField(-2,"ColorSpace");

  state.newTable();
  for (int a=0; a<ClipOp.values.length; a++) {
    state.pushString(ClipOp.values[a].name);
    state.pushInteger(a);
    state.setTable(-3);
  }
  state.setField(-2,"ClipOp");

  state.newTable();
  for (int a=0; a<PathFillType.values.length; a++) {
    state.pushString(PathFillType.values[a].name);
    state.pushInteger(a);
    state.setTable(-3);
  }
  state.setField(-2,"PathFillType");

  state.newTable();
  for (int a=0; a<TextAlign.values.length; a++) {
    state.pushString(TextAlign.values[a].name);
    state.pushInteger(a);
    state.setTable(-3);
  }
  state.setField(-2,"TextAlign");

  state.newTable();
  for (int a=0; a<TextDirection.values.length; a++) {
    state.pushString(TextDirection.values[a].name);
    state.pushInteger(a);
    state.setTable(-3);
  }
  state.setField(-2,"TextDirection");

  state.newTable();
  for (int a=0; a<FontStyle.values.length; a++) {
    state.pushString(FontStyle.values[a].name);
    state.pushInteger(a);
    state.setTable(-3);
  }
  state.setField(-2,"FontStyle");

  state.newTable();
  for (int a=0; a<PlaceholderAlignment.values.length; a++) {
    state.pushString(PlaceholderAlignment.values[a].name);
    state.pushInteger(a);
    state.setTable(-3);
  }
  state.setField(-2,"PlaceholderAlignment");

  state.newTable();
  for (int a=0; a<TextBaseline.values.length; a++) {
    state.pushString(TextBaseline.values[a].name);
    state.pushInteger(a);
    state.setTable(-3);
  }
  state.setField(-2,"TextBaseline");

  state.newTable();
  for (int a=0; a<TextDecorationStyle.values.length; a++) {
    state.pushString(TextDecorationStyle.values[a].name);
    state.pushInteger(a);
    state.setTable(-3);
  }
  state.setField(-2,"TextDecorationStyle");

  state.newTable();
  for (int a=0; a<TextLeadingDistribution.values.length; a++) {
    state.pushString(TextLeadingDistribution.values[a].name);
    state.pushInteger(a);
    state.setTable(-3);
  }
  state.setField(-2,"TextLeadingDistribution");

  state.newTable();
  for (int a=0; a<PointMode.values.length; a++) {
    state.pushString(PointMode.values[a].name);
    state.pushInteger(a);
    state.setTable(-3);
  }
  state.setField(-2,"PointMode");

  state.newTable();
  for (int a=0; a<VertexMode.values.length; a++) {
    state.pushString(VertexMode.values[a].name);
    state.pushInteger(a);
    state.setTable(-3);
  }
  state.setField(-2,"VertexMode");

  state.newTable();
  for (int a=0; a<PathOperation.values.length; a++) {
    state.pushString(PathOperation.values[a].name);
    state.pushInteger(a);
    state.setTable(-3);
  }
  state.setField(-2,"PathOperation");

  state.newTable();
  for (int a=0; a<TextAffinity.values.length; a++) {
    state.pushString(TextAffinity.values[a].name);
    state.pushInteger(a);
    state.setTable(-3);
  }
  state.setField(-2,"TextAffinity");

  state.newTable();
  for (int a=0; a<BoxHeightStyle.values.length; a++) {
    state.pushString(BoxHeightStyle.values[a].name);
    state.pushInteger(a);
    state.setTable(-3);
  }
  state.setField(-2,"BoxHeightStyle");

  state.newTable();
  for (int a=0; a<BoxWidthStyle.values.length; a++) {
    state.pushString(BoxWidthStyle.values[a].name);
    state.pushInteger(a);
    state.setTable(-3);
  }
  state.setField(-2,"BoxWidthStyle");

  state.newTable();
  for (int a=0; a<Clip.values.length; a++) {
    state.pushString(Clip.values[a].name);
    state.pushInteger(a);
    state.setTable(-3);
  }
  state.setField(-2,"Clip");

  state.newTable();
  for (final entry in <String, FontWeight>{
    'w100': FontWeight.w100, 'w200': FontWeight.w200,
    'w300': FontWeight.w300, 'w400': FontWeight.w400,
    'w500': FontWeight.w500, 'w600': FontWeight.w600,
    'w700': FontWeight.w700, 'w800': FontWeight.w800,
    'w900': FontWeight.w900, 'normal': FontWeight.normal,
    'bold': FontWeight.bold,
  }.entries) {
    state.pushString(entry.key);
    var ud = state.newUserdata();
    ud.data = entry.value;
    state.setTable(-3);
  }
  state.setField(-2,"FontWeight");

  state.newTable();
  for (final entry in <String, TextDecoration>{
    'none': TextDecoration.none, 'underline': TextDecoration.underline,
    'overline': TextDecoration.overline, 'lineThrough': TextDecoration.lineThrough,
  }.entries) {
    state.pushString(entry.key);
    var ud = state.newUserdata();
    ud.data = entry.value;
    state.setTable(-3);
  }
  state.setField(-2,"TextDecoration");

  // Canvas metatable
  state.newMetatable('MTCanvas');
  state.pushValue(-1);
  state.setField(-2, '__index');
  state.pushDartFunction(_luaClipPath);
  state.setField(-2, 'clipPath');
  state.pushDartFunction(_luaClipRect);
  state.setField(-2, 'clipRect');
  state.pushDartFunction(_luaClipRRect);
  state.setField(-2, 'clipRRect');
  state.pushDartFunction(_luaDrawArc);
  state.setField(-2, 'drawArc');
  // TODO drawAtlas
  state.pushDartFunction(_luaDrawCircle);
  state.setField(-2, 'drawCircle');
  state.pushDartFunction(_luaDrawColor);
  state.setField(-2, 'drawColor');
  state.pushDartFunction(_luaDrawDRRect);
  state.setField(-2, 'drawDRRect');
  state.pushDartFunction(_luaDrawImage);
  state.setField(-2, 'drawImage');
  state.pushDartFunction(_luaDrawImageNine);
  state.setField(-2, 'drawImageNine');
  state.pushDartFunction(_luaDrawImageRect);
  state.setField(-2, 'drawImageRect');
  state.pushDartFunction(_luaDrawLine);
  state.setField(-2, 'drawLine');
  state.pushDartFunction(_luaDrawOval);
  state.setField(-2, 'drawOval');
  state.pushDartFunction(_luaDrawPaint);
  state.setField(-2, 'drawPaint');
  state.pushDartFunction(_luaDrawParagraph);
  state.setField(-2, 'drawParagraph');
  state.pushDartFunction(_luaDrawPath);
  state.setField(-2, 'drawPath');
  state.pushDartFunction(_luaDrawPicture);
  state.setField(-2, 'drawPicture');
  state.pushDartFunction(_luaDrawPoints);
  state.setField(-2, 'drawPoints');
  state.pushDartFunction(_luaDrawRect);
  state.setField(-2, 'drawRect');
  state.pushDartFunction(_luaDrawRRect);
  state.setField(-2, 'drawRRect');
  state.pushDartFunction(_luaDrawShadow);
  state.setField(-2, 'drawShadow');
  state.pushDartFunction(_luaDrawVertices);
  state.setField(-2, 'drawVertices');
  state.pushDartFunction(_luaGetDestinationClipBounds);
  state.setField(-2, 'getDestinationClipBounds');
  state.pushDartFunction(_luaGetLocalClipBounds);
  state.setField(-2, 'getLocalClipBounds');
  state.pushDartFunction(_luaGetSaveCount);
  state.setField(-2, 'getSaveCount');
  state.pushDartFunction(_luaGetTransform);
  state.setField(-2, 'getTransform');
  state.pushDartFunction(_luaRestore);
  state.setField(-2, 'restore');
  state.pushDartFunction(_luaRestoreToCount);
  state.setField(-2, 'restoreToCount');
  state.pushDartFunction(_luaRotate);
  state.setField(-2, 'rotate');
  state.pushDartFunction(_luaSave);
  state.setField(-2, 'save');
  state.pushDartFunction(_luaSaveLayer);
  state.setField(-2, 'saveLayer');
  state.pushDartFunction(_luaScale);
  state.setField(-2, 'scale');
  state.pushDartFunction(_luaSkew);
  state.setField(-2, 'skew');
  state.pushDartFunction(_luaCanvasTransform);
  state.setField(-2, 'transform');
  state.pushDartFunction(_luaTranslate);
  state.setField(-2, 'translate');
  state.setField(-2, 'MTCanvas');

  // Color metatable
  state.newMetatable('MTColor');
  state.pushDartFunction(_luaColorIndex);
  state.setField(-2, '__index');
  state.pushDartFunction(_luaColorComputeLuminance);
  state.setField(-2, 'computeLuminance');
  state.setField(-2, 'MTColor');

  // Paint metatable
  state.newMetatable('MTPaint');
  state.pushDartFunction(_luaPaintIndex);
  state.setField(-2, '__index');
  state.pushDartFunction(_luaPaintNewIndex);
  state.setField(-2, '__newindex');
  state.setField(-2, 'MTPaint');

  // Offset metatable
  state.newMetatable('MTOffset');
  state.pushDartFunction(_luaOffsetIndex);
  state.setField(-2, '__index');
  state.pushDartFunction(_luaOffsetScale);
  state.setField(-2, 'scale');
  state.pushDartFunction(_luaOffsetTranslate);
  state.setField(-2, 'translate');
  state.setField(-2, 'MTOffset');

  // Size metatable
  state.newMetatable('MTSize');
  state.pushDartFunction(_luaSizeIndex);
  state.setField(-2, '__index');
  state.pushDartFunction(_luaSizeToString);
  state.setField(-2, '__tostring');
  state.setField(-2, 'MTSize');

  // Rect metatable
  state.newMetatable('MTRect');
  state.pushDartFunction(_luaRectIndex);
  state.setField(-2, '__index');
  state.pushDartFunction(_luaRectContains);
  state.setField(-2, 'contains');
  state.pushDartFunction(_luaRectDeflate);
  state.setField(-2, 'deflate');
  state.pushDartFunction(_luaRectExpandToInclude);
  state.setField(-2, 'expandToInclude');
  state.pushDartFunction(_luaRectInflate);
  state.setField(-2, 'inflate');
  state.pushDartFunction(_luaRectIntersect);
  state.setField(-2, 'intersect');
  state.pushDartFunction(_luaRectOverlaps);
  state.setField(-2, 'overlaps');
  state.pushDartFunction(_luaRectShift);
  state.setField(-2, 'shift');
  state.pushDartFunction(_luaRectTranslate);
  state.setField(-2, 'translate');
  state.pushDartFunction(_luaRectLerp);
  state.setField(-2, 'lerp');
  state.setField(-2, 'MTRect');

  // RRect metatable
  state.newMetatable('MTRRect');
  state.pushDartFunction(_luaRRectIndex);
  state.setField(-2, '__index');
  state.pushDartFunction(_luaRRectContains);
  state.setField(-2, 'contains');
  state.pushDartFunction(_luaRRectDeflate);
  state.setField(-2, 'deflate');
  state.pushDartFunction(_luaRRectInflate);
  state.setField(-2, 'inflate');
  state.pushDartFunction(_luaRRectScaleRadii);
  state.setField(-2, 'scaleRadii');
  state.pushDartFunction(_luaRRectShift);
  state.setField(-2, 'shift');
  state.setField(-2, 'MTRRect');

  // Radius metatable
  state.newMetatable('MTRadius');
  state.pushDartFunction(_luaRadiusIndex);
  state.setField(-2, '__index');
  state.pushDartFunction(_luaRadiusClamp);
  state.setField(-2, 'clamp');
  state.pushDartFunction(_luaRadiusClampValues);
  state.setField(-2, 'clampValues');
  state.setField(-2, 'MTRadius');

  // Path metatable
  state.newMetatable('MTPath');
  state.pushValue(-1);
  state.setField(-2, '__index');
  state.pushDartFunction(_luaPathSetFillType);
  state.setField(-2, 'setFillType');
  state.pushDartFunction(_luaPathGetFillType);
  state.setField(-2, 'getFillType');
  state.pushDartFunction(_luaPathAddArc);
  state.setField(-2, 'addArc');
  state.pushDartFunction(_luaPathAddOval);
  state.setField(-2, 'addOval');
  state.pushDartFunction(_luaPathAddPath);
  state.setField(-2, 'addPath');
  state.pushDartFunction(_luaPathAddPolygon);
  state.setField(-2, 'addPolygon');
  state.pushDartFunction(_luaPathAddRect);
  state.setField(-2, 'addRect');
  state.pushDartFunction(_luaPathAddRRect);
  state.setField(-2, 'addRRect');
  state.pushDartFunction(_luaPathArcTo);
  state.setField(-2, 'arcTo');
  state.pushDartFunction(_luaPathArcToPoint);
  state.setField(-2, 'arcToPoint');
  state.pushDartFunction(_luaPathClose);
  state.setField(-2, 'close');
  state.pushDartFunction(_luaPathComputeMetrics);
  state.setField(-2, 'computeMetrics');
  state.pushDartFunction(_luaPathConicTo);
  state.setField(-2, 'conicTo');
  state.pushDartFunction(_luaPathContains);
  state.setField(-2, 'contains');
  state.pushDartFunction(_luaPathCubicTo);
  state.setField(-2, 'cubicTo');
  state.pushDartFunction(_luaPathExtendWithPath);
  state.setField(-2, 'extendWithPath');
  state.pushDartFunction(_luaPathGetBounds);
  state.setField(-2, 'getBounds');
  state.pushDartFunction(_luaPathLineTo);
  state.setField(-2, 'lineTo');
  state.pushDartFunction(_luaPathMoveTo);
  state.setField(-2, 'moveTo');
  state.pushDartFunction(_luaPathQuadraticBezierTo);
  state.setField(-2, 'quadraticBezierTo');
  state.pushDartFunction(_luaPathRelativeArcToPoint);
  state.setField(-2, 'relativeArcToPoint');
  state.pushDartFunction(_luaPathRelativeConicTo);
  state.setField(-2, 'relativeConicTo');
  state.pushDartFunction(_luaPathRelativeCubicTo);
  state.setField(-2, 'relativeCubicTo');
  state.pushDartFunction(_luaPathRelativeLineTo);
  state.setField(-2, 'relativeLineTo');
  state.pushDartFunction(_luaPathRelativeMoveTo);
  state.setField(-2, 'relativeMoveTo');
  state.pushDartFunction(_luaPathRelativeQuadraticBezierTo);
  state.setField(-2, 'relativeQuadraticBezierTo');
  state.pushDartFunction(_luaPathReset);
  state.setField(-2, 'reset');
  state.pushDartFunction(_luaPathShift);
  state.setField(-2, 'shift');
  state.pushDartFunction(_luaPathTransform);
  state.setField(-2, 'transform');
  state.setField(-2, 'MTPath');

  // Paragraph metatable
  state.newMetatable('MTParagraph');
  state.pushValue(-1);
  state.setField(-2, '__index');
  state.pushDartFunction(_luaParagraphAlphabeticBaseline);
  state.setField(-2, 'alphabeticBaseline');
  state.pushDartFunction(_luaParagraphDidExceedMaxLines);
  state.setField(-2, 'didExceedMaxLines');
  state.pushDartFunction(_luaParagraphHeight);
  state.setField(-2, 'height');
  state.pushDartFunction(_luaParagraphIdeographicBaseline);
  state.setField(-2, 'ideographicBaseline');
  state.pushDartFunction(_luaParagraphLongestLine);
  state.setField(-2, 'longestLine');
  state.pushDartFunction(_luaParagraphMaxIntrinsicWidth);
  state.setField(-2, 'maxIntrinsicWidth');
  state.pushDartFunction(_luaParagraphMinIntrinsicWidth);
  state.setField(-2, 'minIntrinsicWidth');
  state.pushDartFunction(_luaParagraphNumberOfLines);
  state.setField(-2, 'numberOfLines');
  state.pushDartFunction(_luaParagraphWidth);
  state.setField(-2, 'width');
  state.pushDartFunction(_luaParagraphComputeLineMetrics);
  state.setField(-2, 'computeLineMetrics');
  state.pushDartFunction(_luaParagraphDispose);
  state.setField(-2, 'dispose');
  state.pushDartFunction(_luaParagraphGetBoxesForPlaceholders);
  state.setField(-2, 'getBoxesForPlaceholders');
  state.pushDartFunction(_luaParagraphGetBoxesForRange);
  state.setField(-2, 'getBoxesForRange');
  state.pushDartFunction(_luaParagraphGetLineBoundary);
  state.setField(-2, 'getLineBoundary');
  state.pushDartFunction(_luaParagraphGetLineMetricsAt);
  state.setField(-2, 'getLineMetricsAt');
  state.pushDartFunction(_luaParagraphGetLineNumberAt);
  state.setField(-2, 'getLineNumberAt');
  state.pushDartFunction(_luaParagraphGetPositionForOffset);
  state.setField(-2, 'getPositionForOffset');
  state.pushDartFunction(_luaParagraphGetWordBoundary);
  state.setField(-2, 'getWordBoundary');
  state.pushDartFunction(_luaParagraphLayout);
  state.setField(-2, 'layout');
  state.setField(-2, 'MTParagraph');

  // ParagraphBuilder metatable
  state.newMetatable('MTParagraphBuilder');
  state.pushValue(-1);
  state.setField(-2, '__index');
  state.pushDartFunction(_luaParagraphBuilderPlaceholderCount);
  state.setField(-2, 'placeholderCount');
  state.pushDartFunction(_luaParagraphBuilderAddPlaceholder);
  state.setField(-2, 'addPlaceholder');
  state.pushDartFunction(_luaParagraphBuilderAddText);
  state.setField(-2, 'addText');
  state.pushDartFunction(_luaParagraphBuilderBuild);
  state.setField(-2, 'build');
  state.pushDartFunction(_luaParagraphBuilderPop);
  state.setField(-2, 'pop');
  state.pushDartFunction(_luaParagraphBuilderPushStyle);
  state.setField(-2, 'pushStyle');
  state.setField(-2, 'MTParagraphBuilder');

  state.newMetatable('MTImage');
  state.pushDartFunction(_luaImageIndex);
  state.setField(-2, '__index');
  state.setField(-2, 'MTImage');

  // ColorFilter metatable (opaque)
  state.newMetatable('MTColorFilter');
  state.pushValue(-1);
  state.setField(-2, '__index');
  state.setField(-2, 'MTColorFilter');

  // Vertices metatable (opaque)
  state.newMetatable('MTVertices');
  state.pushValue(-1);
  state.setField(-2, '__index');
  state.setField(-2, 'MTVertices');

  // Shadow metatable
  state.newMetatable('MTShadow');
  state.pushDartFunction(_luaShadowIndex);
  state.setField(-2, '__index');
  state.setField(-2, 'MTShadow');

  // FontFeature metatable
  state.newMetatable('MTFontFeature');
  state.pushDartFunction(_luaFontFeatureIndex);
  state.setField(-2, '__index');
  state.setField(-2, 'MTFontFeature');

  // FontVariation metatable
  state.newMetatable('MTFontVariation');
  state.pushDartFunction(_luaFontVariationIndex);
  state.setField(-2, '__index');
  state.setField(-2, 'MTFontVariation');

  // TextPosition metatable
  state.newMetatable('MTTextPosition');
  state.pushDartFunction(_luaTextPositionIndex);
  state.setField(-2, '__index');
  state.setField(-2, 'MTTextPosition');

  // TextRange metatable
  state.newMetatable('MTTextRange');
  state.pushDartFunction(_luaTextRangeIndex);
  state.setField(-2, '__index');
  state.pushDartFunction(_luaTextRangeTextBefore);
  state.setField(-2, 'textBefore');
  state.pushDartFunction(_luaTextRangeTextAfter);
  state.setField(-2, 'textAfter');
  state.pushDartFunction(_luaTextRangeTextInside);
  state.setField(-2, 'textInside');
  state.setField(-2, 'MTTextRange');

  // TextBox metatable
  state.newMetatable('MTTextBox');
  state.pushDartFunction(_luaTextBoxIndex);
  state.setField(-2, '__index');
  state.pushDartFunction(_luaTextBoxToRect);
  state.setField(-2, 'toRect');
  state.setField(-2, 'MTTextBox');

  // LineMetrics metatable
  state.newMetatable('MTLineMetrics');
  state.pushDartFunction(_luaLineMetricsIndex);
  state.setField(-2, '__index');
  state.setField(-2, 'MTLineMetrics');

  // Tangent metatable
  state.newMetatable('MTTangent');
  state.pushDartFunction(_luaTangentIndex);
  state.setField(-2, '__index');
  state.setField(-2, 'MTTangent');

  // PathMetric metatable
  state.newMetatable('MTPathMetric');
  state.pushDartFunction(_luaPathMetricIndex);
  state.setField(-2, '__index');
  state.pushDartFunction(_luaPathMetricGetTangentForOffset);
  state.setField(-2, 'getTangentForOffset');
  state.pushDartFunction(_luaPathMetricExtractPath);
  state.setField(-2, 'extractPath');
  state.setField(-2, 'MTPathMetric');

  // PathMetrics metatable
  state.newMetatable('MTPathMetrics');
  state.pushValue(-1);
  state.setField(-2, '__index');
  state.pushDartFunction(_luaPathMetricsToList);
  state.setField(-2, 'toList');
  state.setField(-2, 'MTPathMetrics');

  // PictureRecorder metatable
  state.newMetatable('MTPictureRecorder');
  state.pushDartFunction(_luaPictureRecorderIndex);
  state.setField(-2, '__index');
  state.pushDartFunction(_luaPictureRecorderEndRecording);
  state.setField(-2, 'endRecording');
  state.setField(-2, 'MTPictureRecorder');

  // Picture metatable
  state.newMetatable('MTPicture');
  state.pushValue(-1);
  state.setField(-2, '__index');
  state.pushDartFunction(_luaPictureDispose);
  state.setField(-2, 'dispose');
  state.setField(-2, 'MTPicture');

  return 1;
}