Add support for getting arbitrary kernel and field IDs.

bug 7318821

Change-Id: I7f5999a8c6e6c2eb55d1bb502033eb9be02e55a8
diff --git a/slang_rs_reflection.cpp b/slang_rs_reflection.cpp
index 05ec938..b559417 100644
--- a/slang_rs_reflection.cpp
+++ b/slang_rs_reflection.cpp
@@ -666,18 +666,39 @@
     }
   }
 
+  const RSExportType *IET = EF->getInType();
+  const RSExportType *OET = EF->getOutType();
+
+  if (mRSContext->getTargetAPI() >= SLANG_JB_MR1_TARGET_API) {
+      int signature = 0;
+      C.startFunction(Context::AM_Public,
+                      false,
+                      "Script.KernelID",
+                      "getKernelID_" + EF->getName(),
+                      0);
+
+      if (IET)
+          signature |= 1;
+      if (OET)
+          signature |= 2;
+
+      //TODO: add element checking
+      C.indent() << "return createKernelID(" << RS_EXPORT_FOREACH_INDEX_PREFIX
+                 << EF->getName() << ", " << signature << ", null, null);"
+                 << std::endl;
+
+      C.endFunction();
+  }
+
   C.startFunction(Context::AM_Public,
                   false,
                   "void",
                   "forEach_" + EF->getName(),
                   Args);
 
-  const RSExportType *IET = EF->getInType();
   if (IET) {
     genTypeCheck(C, IET, "ain");
   }
-
-  const RSExportType *OET = EF->getOutType();
   if (OET) {
     genTypeCheck(C, OET, "aout");
   }
@@ -1067,6 +1088,19 @@
   C.indent() << "return "RS_EXPORT_VAR_PREFIX << VarName << ";" << std::endl;
 
   C.endFunction();
+  if (mRSContext->getTargetAPI() >= SLANG_JB_MR1_TARGET_API) {
+      C.startFunction(Context::AM_Public,
+                      false,
+                      "Script.FieldID",
+                      "getFieldID_" + VarName,
+                      0);
+
+      C.indent() << "return createFieldID(" << RS_EXPORT_VAR_INDEX_PREFIX
+                 << VarName << ", null);" << std::endl;
+
+      C.endFunction();
+  }
+
   return;
 }