Permalink
Fetching contributors…
Cannot retrieve contributors at this time
120 lines (108 sloc) 3.07 KB
//
// Authors:
// Sebastien Pouliot <sebastien@xamarin.com>
//
// Copyright 2013 Xamarin Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
using System;
using System.Reflection;
using NUnit.Framework;
using TouchUnit.Bindings;
#if MONOMAC
using MonoMac.Cocos2D;
#else
using MonoTouch.Cocos2D;
using MonoTouch.Foundation;
#endif
namespace Cocos2D.Bindings {
[TestFixture]
public class BindingSignatureTest : ApiSignatureTest {
public BindingSignatureTest ()
{
// Useful to know what was being tried if things crash
LogProgress = true;
// Useful for fixing several errors before rebuilding the bindings
ContinueOnFailure = true;
}
protected override Assembly Assembly {
get {
var assembly = typeof (CCAccelAmplitude).Assembly;
#if MONOMAC
MonoMac.ObjCRuntime.Runtime.RegisterAssembly (assembly);
#endif
return assembly;
}
}
protected override bool Skip (Type type, MethodBase method, string selector)
{
switch (type.Name) {
case "CCMenu":
switch (selector) {
case "alignItemsInColumns:": // "vaList: (va_list) args" is not detectable from the signature
case "alignItemsInRows:": // same as above
return true;
}
break;
case "CCTextureAtlas":
switch (selector) {
case "setQuads:": // ref is used (autogenerated) because of the structure (stret)
return true;
}
break;
}
return base.Skip (type, method, selector);
}
protected override bool IsValidStruct (Type type, string structName)
{
switch (structName) {
case "ccArray":
return type.Name == "CCArray";
case "_ccBezierConfig":
return type.Name == "CCBezierConfig";
case "_ccBlendFunc":
return type.Name == "CCBlendFunc";
case "_ccColor3B":
return type.Name == "CCColor3B";
case "_ccColor4B":
return type.Name == "CCColor4B";
case "_ccColor4F":
return type.Name == "CCColor4F";
case "sCCParticle":
return type.Name == "CCParticle";
case "_ccQuad3":
return type.Name == "CCQuad3";
case "_ccVertex3F": // =fff
return type.Name == "CCVertex3F";
case "_ccV2F_C4B_T2F":
return type.Name == "CCV2F_C4B_T2F";
case "_ccV3F_C4B_T2F_Quad":
return type.Name == "CCV3F_C4B_T2F_Quad";
default:
return base.IsValidStruct (type, structName);
}
}
protected override bool Check (char encodedType, Type type)
{
switch (encodedType) {
// allow signed integer in place of unsigned integer (not to break existing API / code)
case 'I':
if (type.FullName == "System.Int32")
return true;
break;
}
return base.Check (encodedType, type);
}
}
}