It is possible to find the winding number of a path $C \subset \mathbb{C}$ using complex analysis:

$$n = \oint_C\frac{dz}{z}.$$ You can also count the number of roots of $f(z) = 0$ inside a close curved $C$:

$$n = \oint_C dz\,\frac{f'(z)}{f(z)}.$$

How do we count the number of self-intersections or self-tangencies of $C$ with itself?

$$\#[C \cap C] = \oint \frac{dz}{z}\frac{dw}{w} f(z,w)?$$ Self-intersection is a global event depending on two points - probably it is some kind of double-integral.