(namespace, data)
| 746 | |
| 747 | |
| 748 | def outputclasses(namespace, data): |
| 749 | |
| 750 | print("""public class Utils |
| 751 | { |
| 752 | public static IntPtr ToUtf8(string managedString) |
| 753 | { |
| 754 | if (managedString == null) |
| 755 | { |
| 756 | return IntPtr.Zero; |
| 757 | } |
| 758 | |
| 759 | int size = System.Text.Encoding.UTF8.GetByteCount(managedString) + 1; |
| 760 | if (buffer.Length < size) buffer = new byte[size]; |
| 761 | int written = System.Text.Encoding.UTF8.GetBytes(managedString, 0, managedString.Length, buffer, 0); |
| 762 | buffer[written] = 0x00; // null terminate |
| 763 | IntPtr nativeUtf8 = Marshal.AllocHGlobal(written+1); |
| 764 | Marshal.Copy(buffer, 0, nativeUtf8, written+1); |
| 765 | return nativeUtf8; |
| 766 | } |
| 767 | private static byte[] buffer = new byte[1024]; |
| 768 | } |
| 769 | """) |
| 770 | |
| 771 | # the following methods take a mispacked VRControllerState_t on Linux and OSX so we generate |
| 772 | # a special hacky method to account for that on those platforms. |
| 773 | controller_packed_methods = ['GetControllerState', 'GetControllerStateWithPose', 'GetComponentState'] |
| 774 | event_packed_methods = ['PollNextEvent', 'PollNextEventWithPose', 'PollNextOverlayEvent', 'PollNextOverlayEventForAny'] |
| 775 | if(namespace == ''): |
| 776 | namespaceextra = '' |
| 777 | elif(namespace == 'vr'): |
| 778 | namespaceextra = 'VR_' |
| 779 | else: |
| 780 | namespaceextra = namespace+'_' |
| 781 | lastclass = '' |
| 782 | lastmethod = '' |
| 783 | for method in data['methods']: |
| 784 | if (len(method) > 0): |
| 785 | returntype = converttype(method['returntype']) |
| 786 | |
| 787 | interfacename = method['classname'] |
| 788 | |
| 789 | if(namespace != getnamespace(interfacename)): |
| 790 | continue |
| 791 | |
| 792 | interfacename = getclasswithoutnamespace(interfacename) |
| 793 | methodname = method['methodname'] |
| 794 | if(methodname == lastmethod): |
| 795 | methodname = methodname + repr(count) |
| 796 | count = count + 1 |
| 797 | else: |
| 798 | count = 0 |
| 799 | lastmethod = method['methodname'] |
| 800 | |
| 801 | if(interfacename != lastclass): |
| 802 | if(lastclass != ''): |
| 803 | print("}\n\n"); |
| 804 | classname = 'C' + interfacename[1:] |
| 805 | classshort = interfacename[1:] |
nothing calls this directly
no test coverage detected