[zbar-commits] push rev [271]: fix support for GS1 AIs
Status: Beta
Brought to you by:
spadix
|
From: <sp...@us...> - 2010-11-29 03:14:53
|
changeset: 271:ee89b89ef55e user: sp...@us... date: Sun Nov 28 19:13:52 2010 -0800 details: http://zbar.hg.sourceforge.net:8000/hgroot/zbar/zbarzbar/rev/ee89b89ef55e description: fix support for GS1 AIs - thanks to jockusch for a patch! - add decoder/symbol "modifier" flags and config read access - set flags or emit GS appropriately for Code 128 FNC1 - add iphone, java, perl, python bindings for modifiers and configs diffstat: ChangeLog | 5 + include/zbar.h | 62 +++++++++++++++ iphone/ZBarSymbol.m | 13 +++- iphone/include/ZBarSDK/ZBarSymbol.h | 2 + java/Makefile.am | 6 +- java/net/sourceforge/zbar/Modifier.java | 42 ++++++++++ java/net/sourceforge/zbar/Symbol.java | 6 + java/zbarjni.c | 36 +++++++++ perl/ZBar.pm | 10 ++ perl/ZBar.xs | 49 ++++++++++++- perl/t/Decoder.t | 16 +++- perl/t/Image.t | 17 +++- perl/t/ZBar.t | 9 ++- perl/typemap | 1 + python/decoder.c | 38 +++++++++ python/enum.c | 15 +++ python/image.c | 4 +- python/symbol.c | 18 ++++ python/test/test_zbar.py | 27 ++++++ python/zbarmodule.c | 13 +++- python/zbarmodule.h | 3 + zbar/decoder.c | 34 +++++++- zbar/decoder.h | 4 +- zbar/decoder/code128.c | 10 ++- zbar/decoder/code39.c | 1 + zbar/decoder/code93.c | 1 + zbar/decoder/databar.c | 2 + zbar/decoder/ean.c | 1 + zbar/decoder/i25.c | 1 + zbar/decoder/pdf417.c | 1 + zbar/img_scanner.c | 4 + zbar/symbol.c | 125 ++++++++++++++++++++++++------- zbar/symbol.h | 2 + 33 files changed, 528 insertions(+), 50 deletions(-) diffs (truncated from 1200 to 300 lines): diff -r 0c715cdd469f -r ee89b89ef55e ChangeLog --- a/ChangeLog Wed Nov 24 12:33:47 2010 -0800 +++ b/ChangeLog Sun Nov 28 19:13:52 2010 -0800 @@ -1,4 +1,9 @@ current: + * fix support for GS1 AIs + - thanks to jockusch for a patch! + - add decoder/symbol "modifier" flags and config read access + - set flags or emit GS appropriately for Code 128 FNC1 + - add iphone, java, perl, python bindings for modifiers and configs * add support for Code 93 symbology * add video size request to (Py)GTK widget (req #3034522) - thanks to Jerome Charaoui for the patch! diff -r 0c715cdd469f -r ee89b89ef55e include/zbar.h --- a/include/zbar.h Wed Nov 24 12:33:47 2010 -0800 +++ b/include/zbar.h Sun Nov 28 19:13:52 2010 -0800 @@ -155,6 +155,25 @@ ZBAR_CFG_Y_DENSITY, /**< image scanner horizontal scan density */ } zbar_config_t; +/** decoder symbology modifier flags. + * @since 0.11 + */ +typedef enum zbar_modifier_e { + /** barcode tagged as GS1 (EAN.UCC) reserved + * (eg, FNC1 before first data character). + * data may be parsed as a sequence of GS1 AIs + */ + ZBAR_MOD_GS1 = 0, + + /** barcode tagged as AIM reserved + * (eg, FNC1 after first character or digit pair) + */ + ZBAR_MOD_AIM, + + /** number of modifiers */ + ZBAR_MOD_NUM, +} zbar_modifier_t; + /** retrieve runtime library version information. * @param major set to the running major version (unless NULL) * @param minor set to the running minor version (unless NULL) @@ -187,6 +206,20 @@ */ extern const char *zbar_get_addon_name(zbar_symbol_type_t sym); +/** retrieve string name for configuration setting. + * @param config setting to name + * @returns static string name for config, + * or the empty string if value is not a known config + */ +extern const char *zbar_get_config_name(zbar_config_t config); + +/** retrieve string name for modifier. + * @param modifier flag to name + * @returns static string name for modifier, + * or the empty string if the value is not a known flag + */ +extern const char *zbar_get_modifier_name(zbar_modifier_t modifier); + /** retrieve string name for orientation. * @param orientation orientation encoding * @returns the static string name for the specified orientation, @@ -277,6 +310,20 @@ */ extern zbar_symbol_type_t zbar_symbol_get_type(const zbar_symbol_t *symbol); +/** retrieve symbology boolean config settings. + * @returns a bitmask indicating which configs were set for the detected + * symbology during decoding. + * @since 0.11 + */ +extern unsigned int zbar_symbol_get_configs(const zbar_symbol_t *symbol); + +/** retrieve symbology modifier flag settings. + * @returns a bitmask indicating which characteristics were detected + * during decoding. + * @since 0.11 + */ +extern unsigned int zbar_symbol_get_modifiers(const zbar_symbol_t *symbol); + /** retrieve data decoded from symbol. * @returns the data string */ @@ -1243,6 +1290,14 @@ zbar_decoder_set_config(decoder, sym, cfg, val)); } +/** retrieve symbology boolean config settings. + * @returns a bitmask indicating which configs are currently set for the + * specified symbology. + * @since 0.11 + */ +extern unsigned int zbar_decoder_get_configs(const zbar_decoder_t *decoder, + zbar_symbol_type_t symbology); + /** clear all decoder state. * any partial symbols are flushed */ @@ -1290,6 +1345,13 @@ extern zbar_symbol_type_t zbar_decoder_get_type(const zbar_decoder_t *decoder); +/** retrieve modifier flags for the last decoded symbol. + * @returns a bitmask indicating which characteristics were detected + * during decoding. + * @since 0.11 + */ +extern unsigned int zbar_decoder_get_modifiers(const zbar_decoder_t *decoder); + /** retrieve last decode direction. * @returns 1 for forward and -1 for reverse * @returns 0 if the decode direction is unknown or does not apply diff -r 0c715cdd469f -r ee89b89ef55e iphone/ZBarSymbol.m --- a/iphone/ZBarSymbol.m Wed Nov 24 12:33:47 2010 -0800 +++ b/iphone/ZBarSymbol.m Sun Nov 28 19:13:52 2010 -0800 @@ -25,7 +25,8 @@ @implementation ZBarSymbol -@dynamic type, typeName, data, quality, count, zbarSymbol; +@dynamic type, typeName, configMask, modifierMask, data, quality, count, + zbarSymbol; + (NSString*) nameForType: (zbar_symbol_type_t) type { @@ -60,6 +61,16 @@ return([[self class] nameForType: zbar_symbol_get_type(symbol)]); } +- (NSUInteger) configMask +{ + return(zbar_symbol_get_configs(symbol)); +} + +- (NSUInteger) modifierMask +{ + return(zbar_symbol_get_modifiers(symbol)); +} + - (NSString*) data { return([NSString stringWithUTF8String: zbar_symbol_get_data(symbol)]); diff -r 0c715cdd469f -r ee89b89ef55e iphone/include/ZBarSDK/ZBarSymbol.h --- a/iphone/include/ZBarSDK/ZBarSymbol.h Wed Nov 24 12:33:47 2010 -0800 +++ b/iphone/include/ZBarSDK/ZBarSymbol.h Sun Nov 28 19:13:52 2010 -0800 @@ -54,6 +54,8 @@ @property (readonly, nonatomic) zbar_symbol_type_t type; @property (readonly, nonatomic) NSString *typeName; +@property (readonly, nonatomic) NSUInteger configMask; +@property (readonly, nonatomic) NSUInteger modifierMask; @property (readonly, nonatomic) NSString *data; @property (readonly, nonatomic) int quality; @property (readonly, nonatomic) int count; diff -r 0c715cdd469f -r ee89b89ef55e java/Makefile.am --- a/java/Makefile.am Wed Nov 24 12:33:47 2010 -0800 +++ b/java/Makefile.am Sun Nov 28 19:13:52 2010 -0800 @@ -12,7 +12,7 @@ MAINTAINERCLEANFILES = zbarjni.h zbar_jar_SRCS = \ - $(PKG)/Config.java $(PKG)/Orientation.java \ + $(PKG)/Config.java $(PKG)/Modifier.java $(PKG)/Orientation.java \ $(PKG)/Symbol.java $(PKG)/SymbolIterator.java $(PKG)/SymbolSet.java \ $(PKG)/Image.java $(PKG)/ImageScanner.java @@ -35,5 +35,5 @@ check-local: echo "making check in java" - cd $(abs_srcdir); $(JAVAC) -classpath $(CLASSPATH):$(abs_builddir)/zbar.jar -d $(abs_builddir) $(test_SRCS) - $(top_builddir)/libtool -dlopen libzbarjni.la --mode=execute $(JAVA) -classpath zbar.jar:$(CLASSPATH):. -Xcheck:jni org.junit.runner.JUnitCore $(test_CLASSES) + cd $(abs_srcdir); $(JAVAC) -classpath $(abs_builddir)/zbar.jar:.:$(CLASSPATH) -d $(abs_builddir) $(test_SRCS) + $(top_builddir)/libtool -dlopen $(top_builddir)/zbar/libzbar.la -dlopen libzbarjni.la --mode=execute $(JAVA) -Xcheck:jni -classpath zbar.jar:.:$(CLASSPATH) org.junit.runner.JUnitCore $(test_CLASSES) diff -r 0c715cdd469f -r ee89b89ef55e java/net/sourceforge/zbar/Modifier.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/java/net/sourceforge/zbar/Modifier.java Sun Nov 28 19:13:52 2010 -0800 @@ -0,0 +1,42 @@ +/*------------------------------------------------------------------------ + * Modifier + * + * Copyright 2010 (c) Jeff Brown <sp...@us...> + * + * This file is part of the ZBar Bar Code Reader. + * + * The ZBar Bar Code Reader is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * The ZBar Bar Code Reader is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser Public License for more details. + * + * You should have received a copy of the GNU Lesser Public License + * along with the ZBar Bar Code Reader; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * http://sourceforge.net/projects/zbar + *------------------------------------------------------------------------*/ + +package net.sourceforge.zbar; + +/** Decoder symbology modifiers. + */ +public class Modifier +{ + /** barcode tagged as GS1 (EAN.UCC) reserved + * (eg, FNC1 before first data character). + * data may be parsed as a sequence of GS1 AIs + */ + public static final int GS1 = 0; + + /** barcode tagged as AIM reserved + * (eg, FNC1 after first character or digit pair) + */ + public static final int AIM = 1; +} diff -r 0c715cdd469f -r ee89b89ef55e java/net/sourceforge/zbar/Symbol.java --- a/java/net/sourceforge/zbar/Symbol.java Wed Nov 24 12:33:47 2010 -0800 +++ b/java/net/sourceforge/zbar/Symbol.java Sun Nov 28 19:13:52 2010 -0800 @@ -110,6 +110,12 @@ private native int getType(long peer); + /** Retrieve symbology boolean configs settings used during decode. */ + public native int getConfigMask(); + + /** Retrieve symbology characteristics detected during decode. */ + public native int getModifierMask(); + /** Retrieve data decoded from symbol as a String. */ public native String getData(); diff -r 0c715cdd469f -r ee89b89ef55e java/zbarjni.c --- a/java/zbarjni.c Wed Nov 24 12:33:47 2010 -0800 +++ b/java/zbarjni.c Sun Nov 28 19:13:52 2010 -0800 @@ -1,3 +1,25 @@ +/*------------------------------------------------------------------------ + * Copyright 2010 (c) Jeff Brown <sp...@us...> + * + * This file is part of the ZBar Bar Code Reader. + * + * The ZBar Bar Code Reader is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * The ZBar Bar Code Reader is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser Public License for more details. + * + * You should have received a copy of the GNU Lesser Public License + * along with the ZBar Bar Code Reader; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * http://sourceforge.net/projects/zbar + *------------------------------------------------------------------------*/ #include <inttypes.h> #include <assert.h> #include <zbar.h> @@ -153,6 +175,20 @@ return(zbar_symbol_get_type(PEER_CAST(peer))); } +JNIEXPORT jint JNICALL +Java_net_sourceforge_zbar_Symbol_getConfigMask (JNIEnv *env, + jobject obj) +{ + return(zbar_symbol_get_configs(GET_PEER(Symbol, obj))); +} + +JNIEXPORT jint JNICALL +Java_net_sourceforge_zbar_Symbol_getModifierMask (JNIEnv *env, + jobject obj) +{ + return(zbar_symbol_get_modifiers(GET_PEER(Symbol, obj))); +} + JNIEXPORT jstring JNICALL Java_net_sourceforge_zbar_Symbol_getData (JNIEnv *env, jobject obj) diff -r 0c715cdd469f -r ee89b89ef55e perl/ZBar.pm --- a/perl/ZBar.pm Wed Nov 24 12:33:47 2010 -0800 +++ b/perl/ZBar.pm Sun Nov 28 19:13:52 2010 -0800 @@ -161,6 +161,16 @@ =back +Symbology modifier constants: + +=over 4 + +=item Modifier::GS1 + |