Your approach to it seems reasonable, although I find myself writing extension modules (for R, PHP, Python, Perl even) in regular old C... not because I particularly dislike C++ or Java, but because if I can get away with just C, it's less likely that I'll step in a template-error or uncaught-exception shitstorm with a 10-page backtrace.