Skip to content

Commit

Permalink
[haxe] Remove superfluous OpenFL imports.
Browse files Browse the repository at this point in the history
  • Loading branch information
badlogic committed Sep 14, 2023
1 parent fd62fee commit 0222027
Show file tree
Hide file tree
Showing 25 changed files with 88 additions and 111 deletions.
2 changes: 1 addition & 1 deletion spine-haxe/example/src/SequenceExample.hx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import starling.events.TouchEvent;
import starling.events.TouchPhase;

class SequenceExample extends Scene {
var loadBinary = false;
var loadBinary = true;

public function load():Void {
var atlas = TextureAtlas.fromAssets("assets/dragon.atlas");
Expand Down
5 changes: 2 additions & 3 deletions spine-haxe/spine-haxe/spine/Bone.hx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package spine;

import openfl.errors.ArgumentError;
import openfl.Vector;

class Bone implements Updatable {
Expand Down Expand Up @@ -37,9 +36,9 @@ class Bone implements Updatable {
/** @param parent May be null. */
public function new(data:BoneData, skeleton:Skeleton, parent:Bone) {
if (data == null)
throw new ArgumentError("data cannot be null.");
throw new SpineException("data cannot be null.");
if (skeleton == null)
throw new ArgumentError("skeleton cannot be null.");
throw new SpineException("skeleton cannot be null.");
_data = data;
_skeleton = skeleton;
_parent = parent;
Expand Down
6 changes: 2 additions & 4 deletions spine-haxe/spine-haxe/spine/BoneData.hx
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package spine;

import openfl.errors.ArgumentError;

class BoneData {
private var _index:Int;
private var _name:String;
Expand All @@ -22,9 +20,9 @@ class BoneData {
/** @param parent May be null. */
public function new(index:Int, name:String, parent:BoneData) {
if (index < 0)
throw new ArgumentError("index must be >= 0");
throw new SpineException("index must be >= 0");
if (name == null)
throw new ArgumentError("name cannot be null.");
throw new SpineException("name cannot be null.");
_index = index;
_name = name;
_parent = parent;
Expand Down
4 changes: 1 addition & 3 deletions spine-haxe/spine-haxe/spine/Event.hx
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package spine;

import openfl.errors.ArgumentError;

class Event {
private var _data:EventData;

Expand All @@ -14,7 +12,7 @@ class Event {

public function new(time:Float, data:EventData) {
if (data == null)
throw new ArgumentError("data cannot be null.");
throw new SpineException("data cannot be null.");
this.time = time;
_data = data;
}
Expand Down
4 changes: 1 addition & 3 deletions spine-haxe/spine-haxe/spine/EventData.hx
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package spine;

import openfl.errors.ArgumentError;

class EventData {
private var _name:String;

Expand All @@ -14,7 +12,7 @@ class EventData {

public function new(name:String) {
if (name == null)
throw new ArgumentError("name cannot be null.");
throw new SpineException("name cannot be null.");
_name = name;
}

Expand Down
5 changes: 2 additions & 3 deletions spine-haxe/spine-haxe/spine/IkConstraint.hx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package spine;

import openfl.errors.ArgumentError;
import openfl.Vector;

class IkConstraint implements Updatable {
Expand All @@ -17,9 +16,9 @@ class IkConstraint implements Updatable {

public function new(data:IkConstraintData, skeleton:Skeleton) {
if (data == null)
throw new ArgumentError("data cannot be null.");
throw new SpineException("data cannot be null.");
if (skeleton == null)
throw new ArgumentError("skeleton cannot be null.");
throw new SpineException("skeleton cannot be null.");
_data = data;
mix = data.mix;
softness = data.softness;
Expand Down
5 changes: 2 additions & 3 deletions spine-haxe/spine-haxe/spine/PathConstraint.hx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package spine;

import openfl.errors.ArgumentError;
import openfl.Vector;
import spine.attachments.PathAttachment;

Expand Down Expand Up @@ -31,9 +30,9 @@ class PathConstraint implements Updatable {

public function new(data:PathConstraintData, skeleton:Skeleton) {
if (data == null)
throw new ArgumentError("data cannot be null.");
throw new SpineException("data cannot be null.");
if (skeleton == null)
throw new ArgumentError("skeleton cannot be null.");
throw new SpineException("skeleton cannot be null.");
_data = data;
_bones = new Vector<Bone>();
for (boneData in data.bones) {
Expand Down
7 changes: 6 additions & 1 deletion spine-haxe/spine-haxe/spine/Pool.hx
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
package spine;

import openfl.utils.Function;
import openfl.Vector;

#if flash
typedef Function = Dynamic;
#else
typedef Function = haxe.Constraints.Function;
#end

@:generic class Pool<T> {
private var items:Vector<T>;
private var instantiator:Function;
Expand Down
25 changes: 12 additions & 13 deletions spine-haxe/spine-haxe/spine/Skeleton.hx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package spine;

import openfl.geom.Rectangle;
import openfl.errors.ArgumentError;
import openfl.utils.Dictionary;
import openfl.Vector;
import spine.attachments.Attachment;
Expand Down Expand Up @@ -30,7 +29,7 @@ class Skeleton {

public function new(data:SkeletonData) {
if (data == null) {
throw new ArgumentError("data cannot be null.");
throw new SpineException("data cannot be null.");
}
_data = data;

Expand Down Expand Up @@ -400,7 +399,7 @@ class Skeleton {
/** @return May be null. */
public function findBone(boneName:String):Bone {
if (boneName == null) {
throw new ArgumentError("boneName cannot be null.");
throw new SpineException("boneName cannot be null.");
}
for (bone in bones) {
if (bone.data.name == boneName)
Expand All @@ -412,7 +411,7 @@ class Skeleton {
/** @return -1 if the bone was not found. */
public function findBoneIndex(boneName:String):Int {
if (boneName == null) {
throw new ArgumentError("boneName cannot be null.");
throw new SpineException("boneName cannot be null.");
}
var i:Int = 0;
for (bone in bones) {
Expand All @@ -426,7 +425,7 @@ class Skeleton {
/** @return May be null. */
public function findSlot(slotName:String):Slot {
if (slotName == null) {
throw new ArgumentError("slotName cannot be null.");
throw new SpineException("slotName cannot be null.");
}
for (slot in slots) {
if (slot.data.name == slotName)
Expand All @@ -440,7 +439,7 @@ class Skeleton {
private function set_skinName(skinName:String):String {
var skin:Skin = data.findSkin(skinName);
if (skin == null)
throw new ArgumentError("Skin not found: " + skinName);
throw new SpineException("Skin not found: " + skinName);
this.skin = skin;
return skinName;
}
Expand Down Expand Up @@ -492,7 +491,7 @@ class Skeleton {
/** @return May be null. */
public function getAttachmentForSlotIndex(slotIndex:Int, attachmentName:String):Attachment {
if (attachmentName == null)
throw new ArgumentError("attachmentName cannot be null.");
throw new SpineException("attachmentName cannot be null.");
if (skin != null) {
var attachment:Attachment = skin.getAttachment(slotIndex, attachmentName);
if (attachment != null)
Expand All @@ -506,29 +505,29 @@ class Skeleton {
/** @param attachmentName May be null. */
public function setAttachment(slotName:String, attachmentName:String):Void {
if (slotName == null)
throw new ArgumentError("slotName cannot be null.");
throw new SpineException("slotName cannot be null.");
var i:Int = 0;
for (slot in slots) {
if (slot.data.name == slotName) {
var attachment:Attachment = null;
if (attachmentName != null) {
attachment = getAttachmentForSlotIndex(i, attachmentName);
if (attachment == null) {
throw new ArgumentError("Attachment not found: " + attachmentName + ", for slot: " + slotName);
throw new SpineException("Attachment not found: " + attachmentName + ", for slot: " + slotName);
}
}
slot.attachment = attachment;
return;
}
i++;
}
throw new ArgumentError("Slot not found: " + slotName);
throw new SpineException("Slot not found: " + slotName);
}

/** @return May be null. */
public function findIkConstraint(constraintName:String):IkConstraint {
if (constraintName == null)
throw new ArgumentError("constraintName cannot be null.");
throw new SpineException("constraintName cannot be null.");
for (ikConstraint in ikConstraints) {
if (ikConstraint.data.name == constraintName)
return ikConstraint;
Expand All @@ -539,7 +538,7 @@ class Skeleton {
/** @return May be null. */
public function findTransformConstraint(constraintName:String):TransformConstraint {
if (constraintName == null)
throw new ArgumentError("constraintName cannot be null.");
throw new SpineException("constraintName cannot be null.");
for (transformConstraint in transformConstraints) {
if (transformConstraint.data.name == constraintName)
return transformConstraint;
Expand All @@ -550,7 +549,7 @@ class Skeleton {
/** @return May be null. */
public function findPathConstraint(constraintName:String):PathConstraint {
if (constraintName == null)
throw new ArgumentError("constraintName cannot be null.");
throw new SpineException("constraintName cannot be null.");
for (pathConstraint in pathConstraints) {
if (pathConstraint.data.name == constraintName)
return pathConstraint;
Expand Down
11 changes: 4 additions & 7 deletions spine-haxe/spine-haxe/spine/SkeletonBinary.hx
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
package spine;

import spine.attachments.AtlasAttachmentLoader;
import openfl.utils.Endian;
import spine.animation.SequenceTimeline;
import openfl.errors.ArgumentError;
import openfl.errors.Error;
import openfl.utils.ByteArray;
import StringTools;
import openfl.Vector;
import openfl.utils.ByteArray;
import openfl.utils.Endian;
import spine.animation.AlphaTimeline;
import spine.animation.Animation;
import spine.animation.AttachmentTimeline;
Expand All @@ -28,6 +25,7 @@ import spine.animation.RotateTimeline;
import spine.animation.ScaleTimeline;
import spine.animation.ScaleXTimeline;
import spine.animation.ScaleYTimeline;
import spine.animation.SequenceTimeline;
import spine.animation.ShearTimeline;
import spine.animation.ShearXTimeline;
import spine.animation.ShearYTimeline;
Expand All @@ -46,7 +44,6 @@ import spine.attachments.PathAttachment;
import spine.attachments.PointAttachment;
import spine.attachments.RegionAttachment;
import spine.attachments.VertexAttachment;
import StringTools;

class SkeletonBinary {
public var attachmentLoader:AttachmentLoader;
Expand Down
29 changes: 14 additions & 15 deletions spine-haxe/spine-haxe/spine/SkeletonData.hx
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package spine;

import spine.attachments.AtlasAttachmentLoader;
import openfl.utils.Assets;
import spine.atlas.TextureAtlas;
import openfl.errors.ArgumentError;
import openfl.Vector;
import openfl.utils.Assets;
import spine.animation.Animation;
import spine.atlas.TextureAtlas;
import spine.attachments.AtlasAttachmentLoader;

class SkeletonData {
/** May be null. */
Expand Down Expand Up @@ -53,7 +52,7 @@ class SkeletonData {
/** @return May be null. */
public function findBone(boneName:String):BoneData {
if (boneName == null)
throw new ArgumentError("boneName cannot be null.");
throw new SpineException("boneName cannot be null.");
for (i in 0...bones.length) {
var bone:BoneData = bones[i];
if (bone.name == boneName)
Expand All @@ -65,7 +64,7 @@ class SkeletonData {
/** @return -1 if the bone was not found. */
public function findBoneIndex(boneName:String):Int {
if (boneName == null)
throw new ArgumentError("boneName cannot be null.");
throw new SpineException("boneName cannot be null.");
for (i in 0...bones.length) {
if (bones[i].name == boneName)
return i;
Expand All @@ -78,7 +77,7 @@ class SkeletonData {
/** @return May be null. */
public function findSlot(slotName:String):SlotData {
if (slotName == null)
throw new ArgumentError("slotName cannot be null.");
throw new SpineException("slotName cannot be null.");
for (i in 0...slots.length) {
var slot:SlotData = slots[i];
if (slot.name == slotName)
Expand All @@ -92,7 +91,7 @@ class SkeletonData {
/** @return May be null. */
public function findSkin(skinName:String):Skin {
if (skinName == null)
throw new ArgumentError("skinName cannot be null.");
throw new SpineException("skinName cannot be null.");
for (skin in skins) {
if (skin.name == skinName)
return skin;
Expand All @@ -105,7 +104,7 @@ class SkeletonData {
/** @return May be null. */
public function findEvent(eventName:String):EventData {
if (eventName == null)
throw new ArgumentError("eventName cannot be null.");
throw new SpineException("eventName cannot be null.");
for (eventData in events) {
if (eventData.name == eventName)
return eventData;
Expand All @@ -118,7 +117,7 @@ class SkeletonData {
/** @return May be null. */
public function findAnimation(animationName:String):Animation {
if (animationName == null)
throw new ArgumentError("animationName cannot be null.");
throw new SpineException("animationName cannot be null.");
for (animation in animations) {
if (animation.name == animationName)
return animation;
Expand All @@ -131,7 +130,7 @@ class SkeletonData {
/** @return May be null. */
public function findIkConstraint(constraintName:String):IkConstraintData {
if (constraintName == null)
throw new ArgumentError("constraintName cannot be null.");
throw new SpineException("constraintName cannot be null.");
for (ikConstraintData in ikConstraints) {
if (ikConstraintData.name == constraintName)
return ikConstraintData;
Expand All @@ -144,7 +143,7 @@ class SkeletonData {
/** @return May be null. */
public function findTransformConstraint(constraintName:String):TransformConstraintData {
if (constraintName == null)
throw new ArgumentError("constraintName cannot be null.");
throw new SpineException("constraintName cannot be null.");
for (transformConstraintData in transformConstraints) {
if (transformConstraintData.name == constraintName)
return transformConstraintData;
Expand All @@ -155,7 +154,7 @@ class SkeletonData {
/** @return -1 if the transform constraint was not found. */
public function findTransformConstraintIndex(transformConstraintName:String):Int {
if (transformConstraintName == null)
throw new ArgumentError("transformConstraintName cannot be null.");
throw new SpineException("transformConstraintName cannot be null.");
for (i in 0...transformConstraints.length) {
if (transformConstraints[i].name == transformConstraintName)
return i;
Expand All @@ -168,7 +167,7 @@ class SkeletonData {
/** @return May be null. */
public function findPathConstraint(constraintName:String):PathConstraintData {
if (constraintName == null)
throw new ArgumentError("constraintName cannot be null.");
throw new SpineException("constraintName cannot be null.");
for (i in 0...pathConstraints.length) {
var constraint:PathConstraintData = pathConstraints[i];
if (constraint.name == constraintName)
Expand All @@ -180,7 +179,7 @@ class SkeletonData {
/** @return -1 if the path constraint was not found. */
public function findPathConstraintIndex(pathConstraintName:String):Int {
if (pathConstraintName == null)
throw new ArgumentError("pathConstraintName cannot be null.");
throw new SpineException("pathConstraintName cannot be null.");
for (i in 0...pathConstraints.length) {
if (pathConstraints[i].name == pathConstraintName)
return i;
Expand Down
Loading

0 comments on commit 0222027

Please sign in to comment.