Fix problems with NDK Sampler implementation.

Creation methods should be static and we need to use the proper Context
pointer for the dispatch methods.

Change-Id: I43c25a7348c9a9aa9a2a82e184d4ac644625800b
diff --git a/tests/cppbasic/compute.cpp b/tests/cppbasic/compute.cpp
index d977667..96aa324 100644
--- a/tests/cppbasic/compute.cpp
+++ b/tests/cppbasic/compute.cpp
@@ -6,9 +6,8 @@
 using namespace android;
 using namespace RSC;
 
-int main()
+int test_compute()
 {
-
     sp<RS> rs = new RS();
     printf("New RS %p\n", rs.get());
 
@@ -32,9 +31,17 @@
     sp<Allocation> aout = Allocation::createTyped(rs, t);
     printf("Allocation %p %p\n", ain.get(), aout.get());
 
-    ScriptC_mono* sc = new ScriptC_mono(rs);
+    sp<ScriptC_mono> sc = new ScriptC_mono(rs);
     printf("new script\n");
 
+    sc->set_alloc(a1);
+    sc->set_elem(e);
+    sc->set_type(t);
+    sc->set_script(sc);
+    sc->set_script(NULL);
+    sp<const Sampler> samp = Sampler::CLAMP_NEAREST(rs);
+    sc->set_sampler(samp);
+
     // We read back the status from the script-side via a "failed" allocation.
     sp<const Element> failed_e = Element::BOOLEAN(rs);
     Type::Builder failed_tb(rs, failed_e);
@@ -88,9 +95,11 @@
         failed_alloc->copy1DTo(&failed);
     }
 
-    printf("Deleting stuff\n");
-    delete sc;
-    printf("Delete OK\n");
+    return failed;
+}
+
+int main() {
+    bool failed = test_compute();
 
     if (failed) {
         printf("TEST FAILED!\n");
diff --git a/tests/cppbasic/mono.rs b/tests/cppbasic/mono.rs
index eab0336..9e262e7 100644
--- a/tests/cppbasic/mono.rs
+++ b/tests/cppbasic/mono.rs
@@ -42,6 +42,12 @@
     char c[3];
 };
 
+rs_allocation alloc;
+rs_element elem;
+rs_type type;
+rs_sampler sampler;
+rs_script script;
+
 void root(const uchar4 *v_in, uchar4 *v_out) {
     float4 f4 = rsUnpackColor8888(*v_in);