Guard against crashes when "Guide" layer active

This change implements checks against crashes in some vulnerable routines
that can fail when the current displayed layer in CharView is the
"Guide" aka 'grid' layer.

Testing of various UI actions revealed that these routines would crash
using the layer index value -1, which is the 'grid' layer index:
   fontforge/cvundoes.c    SCPreserveHints()
   fontforge/splinechar.c  SCNumberPoints()
   fontforge/autohint.c    _SCClearHintMasks()
   fontforge/stemdb.c      GlyphDataInit()
   fontforge/cvhints.c     SCModifyHintMasksAdd()
Code was added to these routines to simply return if the layer value
was outside the valid range for the layers array.

During testing using Python scripts a further set of problem routines
were identified in python.c and fixes applied.

Finally, the original investigation found a number of places where code
was using "magic numbers" that were equivalent to the `enum layer_type`
values defined in splinefont.h.  This obscured the intent of such code
and enum definitions were used to replace those numbers (-1, -2, etc.)

Tested with debug printf()'s to demonstrate usefulness, with all these
added checks being hit and preventing crashes.

"Doctor Doctor when I touch my head it hurts. When I touch my arm it hurts. When I touch my knees it hurts." The doctor replied, "You have a broken finger."
Python script crash on 'empty' contour/layer/glyph

While investigating issue #1750 and trying to test scenarios with scripts,
I found vulnerabilities when certain Python scripting APIs were called
with empty ('new') FF objects.  Internal routines would return NULL
pointers in consequence of the empty objects but sometimes calling code
would not guard against these, and following calls would crash trying to
use the NULL pointers.

This change fixes the following scenarios:
```
    contour1 = fontforge.contour()
    contour1.is_quadratic = 1

    contour1 = fontforge.contour()
    contour1.spiros()

    layerEmpty1 = fontforge.layer()
    layerEmpty2 = fontforge.layer()
    layerEmpty1.stroke("polygonal", layerEmpty2)
```
The last example pattern is seen for all three of `contour`, `layer`, and
`glyph`.

All these combinations (and many others) were tested and no longer crash,
or were proven not to crash originally.

Additionally, another crashing scenario with an empty tuple was found:
```
    contour1 = fontforge.contour()
    contour1.spiros = ()
```
This change fixes that problem by simple checking for empty tuple.
Merge pull request #1755 from tshinnic/1750_invalid_layer_index_2

Guard against crashes when "Guide" layer active
Merge pull request #1759 from tshinnic/python_spiro_null_checks_1

Python script crash on 'empty' contour/layer/glyph/tuple