Commit a62b00f8 authored by George Nash's avatar George Nash Committed by Rick Bell

swig move oc_rep into its own interface

This reduces the size of the OCMain and removes
the need to prefix all of the code from oc_rep.h with the
prefix rep since they are now all part of the OCRep class.

Change-Id: Ib8954e3046c91dd9bcbaf7a737a5835f1be89498
Signed-off-by: George Nash's avatarGeorge Nash <george.nash@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/29405Tested-by: default avatarIoTivity Jenkins <jenkins-daemon@iotivity.org>
Reviewed-by: Larry Sachs's avatarLarry Sachs <larry.j.sachs@intel.com>
Reviewed-by: default avatarRick Bell <richard.s.bell@intel.com>
parent 5b61e7a2
......@@ -159,6 +159,10 @@ ${OBJDIR}/swig/oc_collection_wrap.o: ${SWIG_DIR}/oc_collection_wrap.c
@mkdir -p ${@D}
${CC} -c -o $@ $< ${CFLAGS} -I../ -DOC_CLIENT -DOC_SERVER
${OBJDIR}/swig/oc_rep_wrap.o: ${SWIG_DIR}/oc_rep_wrap.c
@mkdir -p ${@D}
${CC} -c -o $@ $< ${CFLAGS} -I../ -DOC_CLIENT -DOC_SERVER
${OBJDIR}/swig/oc_obt_wrap.o: ${SWIG_DIR}/oc_obt_wrap.c
@mkdir -p ${@D}
${CC} -c -o $@ $< ${CFLAGS} -I../ -DOC_CLIENT -DOC_SERVER
......
......@@ -175,6 +175,7 @@
<ClCompile Include="..\..\..\..\swig\java_lang\oc_clock_wrap.c" />
<ClCompile Include="..\..\..\..\swig\java_lang\oc_collection_wrap.c" />
<ClCompile Include="..\..\..\..\swig\java_lang\oc_obt_wrap.c" />
<ClCompile Include="..\..\..\..\swig\java_lang\oc_rep_wrap.c" />
<ClCompile Include="..\..\..\..\swig\java_lang\oc_storage_wrap.c" />
<ClCompile Include="..\..\..\..\swig\java_lang\oc_uuid_wrap.c" />
</ItemGroup>
......
......@@ -5,6 +5,7 @@ import org.iotivity.OCClientResponse;
import org.iotivity.OCMain;
import org.iotivity.OCQos;
import org.iotivity.OCRepresentation;
import org.iotivity.OCRep;
import org.iotivity.OCResponseHandler;
public class GetLightResponseHandler implements OCResponseHandler {
......@@ -46,10 +47,10 @@ public class GetLightResponseHandler implements OCResponseHandler {
PutLightResponseHandler putLight = new PutLightResponseHandler(activity, light);
if (OCMain.initPut(light.serverUri, light.serverEndpoint, null, putLight, OCQos.LOW_QOS)) {
CborEncoder root = OCMain.repBeginRootObject();
OCMain.repSetBoolean(root, "state", true);
OCMain.repSetLong(root, "power", 15);
OCMain.repEndRootObject();
CborEncoder root = OCRep.beginRootObject();
OCRep.setBoolean(root, "state", true);
OCRep.setLong(root, "power", 15);
OCRep.endRootObject();
if (OCMain.doPut()) {
activity.msg("\tSent PUT request");
......
......@@ -5,6 +5,7 @@ import org.iotivity.OCClientResponse;
import org.iotivity.OCMain;
import org.iotivity.OCQos;
import org.iotivity.OCStatus;
import org.iotivity.OCRep;
import org.iotivity.OCResponseHandler;
public class PostLightResponseHandler implements OCResponseHandler {
......@@ -33,10 +34,10 @@ public class PostLightResponseHandler implements OCResponseHandler {
Post2LightResponseHandler postLight = new Post2LightResponseHandler(activity, light);
if (OCMain.initPost(light.serverUri, light.serverEndpoint, null, postLight, OCQos.LOW_QOS)) {
CborEncoder root = OCMain.repBeginRootObject();
OCMain.repSetBoolean(root, "state", true);
OCMain.repSetLong(root, "power", 55);
OCMain.repEndRootObject();
CborEncoder root = OCRep.beginRootObject();
OCRep.setBoolean(root, "state", true);
OCRep.setLong(root, "power", 55);
OCRep.endRootObject();
if (OCMain.doPost()) {
activity.msg("\tSent POST2 request");
......
......@@ -5,6 +5,7 @@ import org.iotivity.OCClientResponse;
import org.iotivity.OCMain;
import org.iotivity.OCQos;
import org.iotivity.OCStatus;
import org.iotivity.OCRep;
import org.iotivity.OCResponseHandler;
public class PutLightResponseHandler implements OCResponseHandler {
......@@ -31,10 +32,10 @@ public class PutLightResponseHandler implements OCResponseHandler {
PostLightResponseHandler postLight = new PostLightResponseHandler(activity, light);
if (OCMain.initPost(light.serverUri, light.serverEndpoint, null, postLight, OCQos.LOW_QOS)) {
CborEncoder root = OCMain.repBeginRootObject();
OCMain.repSetBoolean(root, "state", false);
OCMain.repSetLong(root, "power", 105);
OCMain.repEndRootObject();
CborEncoder root = OCRep.beginRootObject();
OCRep.setBoolean(root, "state", false);
OCRep.setLong(root, "power", 105);
OCRep.endRootObject();
if (OCMain.doPost()) {
activity.msg("\tSent POST request");
......
......@@ -5,6 +5,7 @@ import android.util.Log;
import org.iotivity.CborEncoder;
import org.iotivity.OCInterfaceMask;
import org.iotivity.OCMain;
import org.iotivity.OCRep;
import org.iotivity.OCRequest;
import org.iotivity.OCRequestHandler;
import org.iotivity.OCStatus;
......@@ -32,22 +33,22 @@ public class GetLightRequestHandler implements OCRequestHandler {
activity.msg("\t" + light.name + ", " + light.power + ", " + light.state);
activity.printLine();
CborEncoder root = OCMain.repBeginRootObject();
CborEncoder root = OCRep.beginRootObject();
switch (interfaces) {
case OCInterfaceMask.BASELINE: {
OCMain.processBaselineInterface(request.getResource());
break;
}
case OCInterfaceMask.RW: {
OCMain.repSetBoolean(root, "state", light.state);
OCMain.repSetLong(root, "power", light.power);
OCMain.repSetTextString(root, "name", light.name);
OCRep.setBoolean(root, "state", light.state);
OCRep.setLong(root, "power", light.power);
OCRep.setTextString(root, "name", light.name);
break;
}
default:
break;
}
OCMain.repEndRootObject();
OCRep.endRootObject();
OCMain.sendResponse(request, OCStatus.OC_STATUS_OK);
}
}
......@@ -4,8 +4,10 @@ import org.iotivity.CborEncoder;
import org.iotivity.OCClientResponse;
import org.iotivity.OCMain;
import org.iotivity.OCQos;
import org.iotivity.OCRep;
import org.iotivity.OCRepresentation;
import org.iotivity.OCResponseHandler;
import org.iotivity.OCType;
public class GetLightResponseHandler implements OCResponseHandler {
......@@ -35,10 +37,10 @@ public class GetLightResponseHandler implements OCResponseHandler {
PutLightResponseHandler putLight = new PutLightResponseHandler();
if (OCMain.initPut(Light.serverUri, Light.serverEndpoint, null, putLight, OCQos.LOW_QOS)) {
CborEncoder root = OCMain.repBeginRootObject();
OCMain.repSetBoolean(root, "state", true);
OCMain.repSetLong(root, "power", 15);
OCMain.repEndRootObject();
CborEncoder root = OCRep.beginRootObject();
OCRep.setBoolean(root, "state", true);
OCRep.setLong(root, "power", 15);
OCRep.endRootObject();
if (OCMain.doPut()) {
System.out.println("\tSent PUT request");
......
......@@ -3,6 +3,7 @@ package java_lite_simple_client;
import org.iotivity.OCClientResponse;
import org.iotivity.OCRepresentation;
import org.iotivity.OCResponseHandler;
import org.iotivity.OCType;
public class ObserveLightResponseHandler implements OCResponseHandler {
......
......@@ -4,6 +4,7 @@ import org.iotivity.CborEncoder;
import org.iotivity.OCClientResponse;
import org.iotivity.OCMain;
import org.iotivity.OCQos;
import org.iotivity.OCRep;
import org.iotivity.OCStatus;
import org.iotivity.OCResponseHandler;
......@@ -22,10 +23,10 @@ public class PostLightResponseHandler implements OCResponseHandler {
Post2LightResponseHandler postLight = new Post2LightResponseHandler();
if (OCMain.initPost(Light.serverUri, Light.serverEndpoint, null, postLight, OCQos.LOW_QOS)) {
CborEncoder root = OCMain.repBeginRootObject();
OCMain.repSetBoolean(root, "state", true);
OCMain.repSetLong(root, "power", 55);
OCMain.repEndRootObject();
CborEncoder root = OCRep.beginRootObject();
OCRep.setBoolean(root, "state", true);
OCRep.setLong(root, "power", 55);
OCRep.endRootObject();
if (OCMain.doPost()) {
System.out.println("\tSent POST2 request");
......
......@@ -4,6 +4,7 @@ import org.iotivity.CborEncoder;
import org.iotivity.OCClientResponse;
import org.iotivity.OCMain;
import org.iotivity.OCQos;
import org.iotivity.OCRep;
import org.iotivity.OCStatus;
import org.iotivity.OCResponseHandler;
......@@ -20,10 +21,10 @@ public class PutLightResponseHandler implements OCResponseHandler {
PostLightResponseHandler postLight = new PostLightResponseHandler();
if (OCMain.initPost(Light.serverUri, Light.serverEndpoint, null, postLight, OCQos.LOW_QOS)) {
CborEncoder root = OCMain.repBeginRootObject();
OCMain.repSetBoolean(root, "state", false);
OCMain.repSetLong(root, "power", 105);
OCMain.repEndRootObject();
CborEncoder root = OCRep.beginRootObject();
OCRep.setBoolean(root, "state", false);
OCRep.setLong(root, "power", 105);
OCRep.endRootObject();
if (OCMain.doPost()) {
System.out.println("\tSent POST request");
......
......@@ -3,6 +3,7 @@ package java_lite_simple_server;
import org.iotivity.CborEncoder;
import org.iotivity.OCInterfaceMask;
import org.iotivity.OCMain;
import org.iotivity.OCRep;
import org.iotivity.OCRequest;
import org.iotivity.OCStatus;
import org.iotivity.OCRequestHandler;
......@@ -15,21 +16,21 @@ public class GetCounter implements OCRequestHandler {
Counter.count++;
System.out.println("GET COUNTER:");
CborEncoder root = OCMain.repBeginRootObject();
CborEncoder root = OCRep.beginRootObject();
switch (interfaces) {
case OCInterfaceMask.BASELINE: {
OCMain.processBaselineInterface(request.getResource());
/* fall through */
}
case OCInterfaceMask.R: {
OCMain.repSetLong(root, "count", Counter.count);
OCMain.repSetTextString(root, "name", Counter.name);
OCRep.setLong(root, "count", Counter.count);
OCRep.setTextString(root, "name", Counter.name);
break;
}
default:
break;
}
OCMain.repEndRootObject();
OCRep.endRootObject();
OCMain.sendResponse(request, OCStatus.OC_STATUS_OK);
}
}
......@@ -3,6 +3,7 @@ package java_lite_simple_server;
import org.iotivity.CborEncoder;
import org.iotivity.OCInterfaceMask;
import org.iotivity.OCMain;
import org.iotivity.OCRep;
import org.iotivity.OCRequest;
import org.iotivity.OCStatus;
import org.iotivity.OCRequestHandler;
......@@ -14,22 +15,22 @@ public class GetLight implements OCRequestHandler {
System.out.println("Inside the GetLight RequestHandler");
Light.power++;
System.out.println("GET LIGHT:");
CborEncoder root = OCMain.repBeginRootObject();
CborEncoder root = OCRep.beginRootObject();
switch (interfaces) {
case OCInterfaceMask.BASELINE: {
OCMain.processBaselineInterface(request.getResource());
/* fall through */
}
case OCInterfaceMask.RW: {
OCMain.repSetBoolean(root, "state", Light.state);
OCMain.repSetLong(root, "power", Light.power);
OCMain.repSetTextString(root, "name", Light.name);
OCRep.setBoolean(root, "state", Light.state);
OCRep.setLong(root, "power", Light.power);
OCRep.setTextString(root, "name", Light.name);
break;
}
default:
break;
}
OCMain.repEndRootObject();
OCRep.endRootObject();
OCMain.sendResponse(request, OCStatus.OC_STATUS_OK);
}
}
......@@ -2,10 +2,12 @@ package java_lite_simple_server;
import org.iotivity.CborEncoder;
import org.iotivity.OCMain;
import org.iotivity.OCRep;
import org.iotivity.OCRequest;
import org.iotivity.OCRequestHandler;
import org.iotivity.OCRepresentation;
import org.iotivity.OCStatus;
import org.iotivity.OCType;
public class PostCounter implements OCRequestHandler {
......@@ -35,9 +37,9 @@ public class PostCounter implements OCRequestHandler {
rep = rep.getNext();
}
CborEncoder root = OCMain.repBeginRootObject();
OCMain.repSetLong(root, "count", Counter.count);
OCMain.repEndRootObject();
CborEncoder root = OCRep.beginRootObject();
OCRep.setLong(root, "count", Counter.count);
OCRep.endRootObject();
OCMain.sendResponse(request, OCStatus.OC_STATUS_CHANGED);
}
......
......@@ -2,6 +2,7 @@ package java_lite_simple_server;
import org.iotivity.CborEncoder;
import org.iotivity.OCMain;
import org.iotivity.OCRep;
import org.iotivity.OCRequest;
import org.iotivity.OCRequestHandler;
import org.iotivity.OCRepresentation;
......@@ -39,10 +40,10 @@ public class PostLight implements OCRequestHandler {
rep = rep.getNext();
}
CborEncoder root = OCMain.repBeginRootObject();
OCMain.repSetBoolean(root, "state", Light.state);
OCMain.repSetLong(root, "power", Light.power);
OCMain.repEndRootObject();
CborEncoder root = OCRep.beginRootObject();
OCRep.setBoolean(root, "state", Light.state);
OCRep.setLong(root, "power", Light.power);
OCRep.endRootObject();
OCMain.sendResponse(request, OCStatus.OC_STATUS_CHANGED);
}
......
......@@ -17,6 +17,8 @@ gcc -c -fPIC -fno-asynchronous-unwind-tables -fno-omit-frame-pointer -ffreestand
gcc -c -fPIC -fno-asynchronous-unwind-tables -fno-omit-frame-pointer -ffreestanding -Os -fno-stack-protector -ffunction-sections -fdata-sections -fno-reorder-functions -fno-defer-pop -fno-strict-overflow -I"$JAVA_HOME/include/" -I"$JAVA_HOME/include/linux/" -I../.. -I../../include/ -I../../port/ -I../../port/linux/ -I../../util/ -I../../deps/tinycbor/src/ -Wall -Wextra -Werror -pedantic -D__OC_RANDOM -DOC_CLIENT -DOC_SERVER -DOC_IPV4 -DOC_DYNAMIC_ALLOCATION -DOC_DEBUG -DOC_SECURITY -g -O0 -Wno-unused-parameter -Wno-strict-aliasing -Wno-unused-function -Wno-sign-compare -Wno-address oc_obt_wrap.c -o ./obj/oc_obt_wrap.o
gcc -c -fPIC -fno-asynchronous-unwind-tables -fno-omit-frame-pointer -ffreestanding -Os -fno-stack-protector -ffunction-sections -fdata-sections -fno-reorder-functions -fno-defer-pop -fno-strict-overflow -I"$JAVA_HOME/include/" -I"$JAVA_HOME/include/linux/" -I../.. -I../../include/ -I../../port/ -I../../port/linux/ -I../../util/ -I../../deps/tinycbor/src/ -Wall -Wextra -Werror -pedantic -D__OC_RANDOM -DOC_CLIENT -DOC_SERVER -DOC_IPV4 -DOC_DYNAMIC_ALLOCATION -DOC_DEBUG -DOC_SECURITY -g -O0 -Wno-unused-parameter -Wno-strict-aliasing -Wno-unused-function -Wno-unused-variable -Wno-sign-compare -Wno-address oc_rep_wrap.c -o ./obj/oc_rep_wrap.o
gcc -c -fPIC -fno-asynchronous-unwind-tables -fno-omit-frame-pointer -ffreestanding -Os -fno-stack-protector -ffunction-sections -fdata-sections -fno-reorder-functions -fno-defer-pop -fno-strict-overflow -I"$JAVA_HOME/include/" -I"$JAVA_HOME/include/linux/" -I../.. -I../../include/ -I../../port/ -I../../port/linux/ -I../../util/ -I../../deps/tinycbor/src/ -Wall -Wextra -Werror -pedantic -D__OC_RANDOM -DOC_CLIENT -DOC_SERVER -DOC_IPV4 -DOC_DYNAMIC_ALLOCATION -DOC_DEBUG -DOC_SECURITY -g -O0 -Wno-unused-parameter -Wno-strict-aliasing -Wno-unused-function -Wno-sign-compare -Wno-address -Wno-unused-variable oc_uuid_wrap.c -o ./obj/oc_uuid_wrap.o
# create shared library
......
......@@ -11,6 +11,8 @@ swig -java -package org.iotivity -outcurrentdir -outdir ../iotivity-lite-java/sr
swig -java -package org.iotivity -outcurrentdir -outdir ../iotivity-lite-java/src/org/iotivity/ -I../../include/ ../swig_interfaces/oc_collection.i
swig -java -package org.iotivity -outcurrentdir -outdir ../iotivity-lite-java/src/org/iotivity/ -I../../include/ ../swig_interfaces/oc_rep.i
if [ "$#" -ge 1 ] && [ "$1" = "linux" ]
then
echo Building wrapper for linux clock
......
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment