aboutsummaryrefslogtreecommitdiff
path: root/PureData/PureData.cs
blob: 6e556934bda9328139bd96c96ee1bafe35733c5a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
using System;
using System.Runtime.CompilerServices; // for extern import
using System.Runtime.InteropServices; // for structures

namespace PureData
{
    // PD core functions
    public unsafe class Internal 
    {
        [MethodImplAttribute (MethodImplOptions.InternalCall)]
        internal extern static void *SymGen(string sym);        

        [MethodImplAttribute (MethodImplOptions.InternalCall)]
        internal extern static string SymEval(void *sym);        
    }
    
    // This is the base class for a PD/CLR external
    public unsafe abstract class External
    {
        // PD object pointer
        private readonly void *ptr;

        // --------------------------------------------------------------------------

        [MethodImplAttribute (MethodImplOptions.InternalCall)]
        protected extern static void Post(string message);        

        [MethodImplAttribute (MethodImplOptions.InternalCall)]
        protected extern static void PostError(string message);        

        [MethodImplAttribute (MethodImplOptions.InternalCall)]
        protected extern static void PostBug(string message);        

        [MethodImplAttribute (MethodImplOptions.InternalCall)]
        protected extern static void PostVerbose(string message);        

        // --------------------------------------------------------------------------

        protected delegate void MethodBang();
        protected delegate void MethodFloat(float f);
        protected delegate void MethodSymbol(Symbol s);
        protected delegate void MethodPointer(Pointer p);
        protected delegate void MethodList(AtomList lst);
        protected delegate void MethodAnything(Symbol tag,AtomList lst);

        [MethodImplAttribute (MethodImplOptions.InternalCall)]
        protected extern static void Add(MethodBang m);

        [MethodImplAttribute (MethodImplOptions.InternalCall)]
        protected extern static void Add(MethodFloat m);

        [MethodImplAttribute (MethodImplOptions.InternalCall)]
        protected extern static void Add(MethodSymbol m);

        [MethodImplAttribute (MethodImplOptions.InternalCall)]
        protected extern static void Add(MethodPointer m);

        [MethodImplAttribute (MethodImplOptions.InternalCall)]
        protected extern static void Add(MethodList m);

        [MethodImplAttribute (MethodImplOptions.InternalCall)]
        protected extern static void Add(Symbol sel,MethodList m);

        protected static void Add(string sel,MethodList m) { Add(new Symbol(sel),m); }

        [MethodImplAttribute (MethodImplOptions.InternalCall)]
        protected extern static void Add(MethodAnything m);
    }
}