max_stars_count
int64
301
224k
text
stringlengths
6
1.05M
token_count
int64
3
727k
335
{ "word": "Devil", "definitions": [ "Act as a junior assistant for a barrister or other professional.", "Harass or worry (someone)" ], "parts-of-speech": "Verb" }
81
6,059
/* * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ #pragma once #include <cstdlib> #include <cstring> #include <unordered_set> #include <utility> #include <vector> #include "Debug.h" #include "DexClass.h" class DexStore; using DexStoresVector = std::vector<DexStore>; class DexMetadata { std::string id; std::vector<std::string> dependencies; std::vector<std::string> files; public: const std::string& get_id() const { return id; } void set_id(std::string name) { id = std::move(name); } void set_files(const std::vector<std::string>& f) { files = f; } const std::vector<std::string>& get_files() const { return files; } const std::vector<std::string>& get_dependencies() const { return dependencies; } std::vector<std::string>& get_dependencies() { return dependencies; } void parse(const std::string& path); }; class DexStore { std::vector<DexClasses> m_dexen; DexMetadata m_metadata; std::string dex_magic = ""; bool m_generated = false; public: explicit DexStore(const DexMetadata& metadata) : m_metadata(metadata){}; explicit DexStore(const std::string& name); std::string get_name() const; const std::string& get_dex_magic() const { return dex_magic; } void set_dex_magic(const std::string& input_dex_magic) { dex_magic = input_dex_magic; } std::vector<DexClasses>& get_dexen(); const std::vector<DexClasses>& get_dexen() const; std::vector<std::string> get_dependencies() const; bool is_root_store() const; void set_generated() { m_generated = true; } bool is_generated() const { return m_generated; } void remove_classes(const DexClasses& classes); void add_classes(DexClasses classes); /** * Add a class to the dex stores. If dex_id is none, add the class to the last * dex of root_store. */ static void add_class(DexClass* new_cls, DexStoresVector& stores, boost::optional<size_t> dex_id); }; class DexStoreClassesIterator : public std::iterator<std::input_iterator_tag, DexClasses> { using classes_iterator = std::vector<DexClasses>::iterator; using store_iterator = std::vector<DexStore>::iterator; std::vector<DexStore>& m_stores; store_iterator m_current_store; classes_iterator m_current_classes; public: explicit DexStoreClassesIterator(std::vector<DexStore>& stores) : m_stores(stores), m_current_store(stores.begin()), m_current_classes(m_current_store->get_dexen().begin()) { advance_end_classes(); } explicit DexStoreClassesIterator(const std::vector<DexStore>& stores) : m_stores(const_cast<std::vector<DexStore>&>(stores)), m_current_store(m_stores.begin()), m_current_classes(m_current_store->get_dexen().begin()) { advance_end_classes(); } DexStoreClassesIterator(std::vector<DexStore>& stores, store_iterator current_store, classes_iterator current_classes) : m_stores(stores), m_current_store(current_store), m_current_classes(current_classes) { advance_end_classes(); } DexStoreClassesIterator& operator++() { ++m_current_classes; advance_end_classes(); return *this; } DexStoreClassesIterator begin() const { return DexStoreClassesIterator(m_stores); }; DexStoreClassesIterator end() const { return DexStoreClassesIterator(m_stores, m_stores.end(), m_stores.back().get_dexen().end()); }; bool operator==(const DexStoreClassesIterator& rhs) { return m_current_classes == rhs.m_current_classes; } bool operator!=(const DexStoreClassesIterator& rhs) { return m_current_classes != rhs.m_current_classes; } DexClasses& operator*() { return *m_current_classes; } private: void advance_end_classes() { while (m_current_store != m_stores.end() && m_current_classes != m_stores.back().get_dexen().end() && m_current_classes == m_current_store->get_dexen().end()) { ++m_current_store; m_current_classes = m_current_store->get_dexen().begin(); } } }; /** * Return all the root store types if `include_primary_dex` is true, otherwise * return all the types from secondary dexes. */ std::unordered_set<const DexType*> get_root_store_types( const DexStoresVector& stores, bool include_primary_dex = true); /** * Provide an API to determine whether an illegal cross DexStore * reference/dependency is created. * TODO: this probably need to rely on metadata to be correct. Right now it * just uses order of DexStores. */ class XStoreRefs { private: /** * Set of classes in each logical store. A primary DEX goes in its own * bucket (first element in the array). */ std::vector<std::unordered_set<const DexType*>> m_xstores; /** * Pointers to original stores in the same order as used to populate * m_xstores */ std::vector<const DexStore*> m_stores; /** * Number of root stores. */ size_t m_root_stores; static std::string show_type(const DexType* type); // To avoid "Show.h" in the // header. public: explicit XStoreRefs(const DexStoresVector& stores); /** * If there's no secondary dexes, it returns 0. Otherwise it returns 1. */ size_t largest_root_store_id() const { return m_root_stores - 1; } /** * Return a stored idx for a given type. * The store idx can be used in the 'bool illegal_ref(size_t, const DexType*)' * api. */ size_t get_store_idx(const DexType* type) const { for (size_t store_idx = 0; store_idx < m_xstores.size(); store_idx++) { if (m_xstores[store_idx].count(type) > 0) return store_idx; } not_reached_log("type %s not in the current APK", show_type(type).c_str()); } /** * Returns true if the class is in the root store. False if not. * * NOTE: False will be returned also for the cases where the type is not in * the current scope. */ bool is_in_root_store(const DexType* type) const { for (size_t store_idx = 0; store_idx < m_root_stores; store_idx++) { if (m_xstores[store_idx].count(type) > 0) { return true; } } return false; } bool is_in_primary_dex(const DexType* type) const { return !m_xstores.empty() && m_xstores[0].count(type); } const DexStore* get_store(size_t idx) const { return m_stores[idx]; } const DexStore* get_store(const DexType* type) const { return m_stores[get_store_idx(type)]; } /** * Verify that a 'type' can be moved in the DexStore where 'location' is * defined. * Use it for one time calls where 'type' is moved either in a method (member * in general) of 'location' or more broadly a reference to 'type' is made * in 'location'. */ bool illegal_ref(const DexType* location, const DexType* type) const { return illegal_ref(get_store_idx(location), type); } // Similar to the above, but correctly checks the class hierarchy. This // may be expensive, and only includes the classes that are guaranteed // to be resolved when the given class is loaded, but not further. bool illegal_ref_load_types(const DexType* location, const DexClass* cls) const; /** * Verify that a 'type' can be moved in the DexStore identified by * 'store_idx'. * Use it when an anlaysis over a given DEX (or instructions in a given * method/class) needs to be performed by an optimization. */ bool illegal_ref(size_t store_idx, const DexType* type) const { if (type_class_internal(type) == nullptr) return false; // Temporary HACK: optimizations may leave references to dead classes and // if we just call get_store_idx() - as we should - the assert will fire... size_t type_store_idx = 0; for (; type_store_idx < m_xstores.size(); type_store_idx++) { if (m_xstores[type_store_idx].count(type) > 0) break; } if ((store_idx >= m_xstores.size()) || (type_store_idx >= m_xstores.size())) { return type_store_idx > store_idx; } return illegal_ref_between_stores(store_idx, type_store_idx); } bool illegal_ref_between_stores(size_t caller_store_idx, size_t callee_store_idx) const { if (caller_store_idx == callee_store_idx) { return false; } bool callee_in_root_store = callee_store_idx < m_root_stores; if (callee_in_root_store) { // Check if primary to secondary reference return callee_store_idx > caller_store_idx; } // Check if the caller depends on the callee, // TODO - do it transitively. if (caller_store_idx >= m_root_stores) { const auto& callee_store_name = get_store(callee_store_idx)->get_name(); const auto& caller_dependencies = get_store(caller_store_idx)->get_dependencies(); if (std::find(caller_dependencies.begin(), caller_dependencies.end(), callee_store_name) != caller_dependencies.end()) { return false; } } return true; } bool cross_store_ref(const DexMethod* caller, const DexMethod* callee) const { size_t store_idx = get_store_idx(caller->get_class()); return illegal_ref(store_idx, callee->get_class()); } size_t size() const { return m_xstores.size(); } }; /** * We can not increase method references of any dex after interdex. The XDexRefs * is used for quick validation for crossing-dex references. */ class XDexRefs { std::unordered_map<const DexType*, size_t> m_dexes; size_t m_num_dexes; public: explicit XDexRefs(const DexStoresVector& stores); size_t get_dex_idx(const DexType* type) const; /** * Return true if the caller and callee are in different dexes. */ bool cross_dex_ref(const DexMethod* caller, const DexMethod* callee) const; /** * Return true if the overridden and overriding methods, or any of the * intermediate classes in the inheritance hierarchy, are in different dexes. * The two methods must be non-interface virtual methods in the same virtual * scope, where the overriding method is defined in a (possibly nested) * sub-class of the class where the overridden method is defined. */ bool cross_dex_ref_override(const DexMethod* overridden, const DexMethod* overriding) const; /** * Return true if the method is located in the primary dex. */ bool is_in_primary_dex(const DexMethod* method) const; /** * Number of dexes. */ size_t num_dexes() const; }; /** * Squash the stores into a single dex. */ void squash_into_one_dex(DexStoresVector& stores); /** * Generate the name of the dex in format "${store_name}${new_id}.dex". * Primary dex has no numeral `new_id`. Secondaries and other dex stores do not * have a primary and their `new_id` start at 2. * Example: classes.dex, classes2.dex, classes3.dex, secondstore2.dex. */ std::string dex_name(const DexStore& store, size_t dex_id);
4,122
2,368
package view_inspector.dagger; import android.app.Application; import android.content.SharedPreferences; import android.database.sqlite.SQLiteOpenHelper; import android.view.WindowManager; import com.f2prateek.rx.preferences.Preference; import com.f2prateek.rx.preferences.RxSharedPreferences; import dagger.Module; import dagger.Provides; import java.util.HashSet; import java.util.Set; import javax.inject.Singleton; import view_inspector.R; import view_inspector.dagger.qualifier.BypassInterceptor; import view_inspector.dagger.qualifier.LogViewEvents; import view_inspector.dagger.qualifier.ProbeMeasures; import view_inspector.dagger.qualifier.Profiling; import view_inspector.dagger.qualifier.Scalpel3D; import view_inspector.dagger.qualifier.ScalpelShowId; import view_inspector.dagger.qualifier.ScalpelWireframe; import view_inspector.dagger.qualifier.ShowMargin; import view_inspector.dagger.qualifier.ShowMeasureCount; import view_inspector.dagger.qualifier.ShowOutline; import view_inspector.dagger.qualifier.ShowPadding; import view_inspector.dagger.qualifier.ViewFilter; import view_inspector.dagger.qualifier.ViewTag; import view_inspector.database.DbOpenHelper; import static android.content.Context.MODE_PRIVATE; import static android.content.Context.WINDOW_SERVICE; @Module public class ApplicationModule { private final Application application; public ApplicationModule(Application application) { this.application = application; } @Provides @Singleton Application provideApplicationContext() { return this.application; } @Provides @Singleton SharedPreferences provideSharedPreferences(Application app) { return app.getSharedPreferences("view-inspector", MODE_PRIVATE); } @Provides @Singleton RxSharedPreferences provideRxSharedPreferences(SharedPreferences prefs) { return RxSharedPreferences.create(prefs); } @Provides @Singleton @ShowOutline Preference<Boolean> provideShowOutlineFlag( RxSharedPreferences prefs) { return prefs.getBoolean("showOutline", false); } @Provides @Singleton @ShowMargin Preference<Boolean> provideShowMarginFlag( RxSharedPreferences prefs) { return prefs.getBoolean("showMargin", false); } @Provides @Singleton @ShowPadding Preference<Boolean> provideShowPaddingFlag( RxSharedPreferences prefs) { return prefs.getBoolean("showPadding", false); } @Provides @Singleton @BypassInterceptor Preference<Boolean> provideBypassInterceptorFlag( RxSharedPreferences prefs) { return prefs.getBoolean("bypassInterceptor", false); } @Provides @Singleton @ProbeMeasures Preference<Boolean> provideProbeMeasuresFlag( RxSharedPreferences prefs) { return prefs.getBoolean("probeMeasures", false); } @Provides @Singleton @Profiling Preference<Boolean> provideProfilingFlag( RxSharedPreferences prefs) { return prefs.getBoolean("profiling", false); } @Provides @Singleton @LogViewEvents Preference<Boolean> provideLogViewEventsFlag( RxSharedPreferences prefs) { return prefs.getBoolean("logViewEvents", false); } @Provides @Singleton @Scalpel3D Preference<Boolean> provideScalpel3dFlag( RxSharedPreferences prefs) { return prefs.getBoolean("scalpel3d", false); } @Provides @Singleton @ScalpelWireframe Preference<Boolean> provideScalpelWireframeFlag( RxSharedPreferences prefs) { return prefs.getBoolean("scalpelWireframe", false); } @Provides @Singleton @ScalpelShowId Preference<Boolean> provideScalpelIdFlag( RxSharedPreferences prefs) { return prefs.getBoolean("scalpelId", false); } @Provides @Singleton @ShowMeasureCount Preference<Boolean> provideShowMeasureCountFlag( RxSharedPreferences prefs) { return prefs.getBoolean("showMeasureCount", false); } @Provides @Singleton @ViewFilter Preference<Set<String>> provideViewFilterSet( RxSharedPreferences prefs) { return prefs.getStringSet("viewFilter", new HashSet<String>()); } @Provides @Singleton SQLiteOpenHelper provideDbOpenHelper(Application application) { return new DbOpenHelper(application); } @Provides @Singleton WindowManager provideWindowManager() { return (WindowManager) application.getSystemService(WINDOW_SERVICE); } @Provides @Singleton @ViewTag String provideViewTag() { return application.getResources().getString(R.string.view_inspector_view_tag); } }
1,462
463
<reponame>pblew/jmockit1 package mockit; import static org.junit.Assert.*; import org.junit.*; public final class TestedClassInjectedFromMockParametersTest { enum AnEnum { Abc, Xyz } public static final class TestedClass { private int i; private String s; private boolean b; private char[] chars; AnEnum enumValue; public TestedClass(boolean b) { this.b = b; } public TestedClass(int i, String s, boolean b, char... chars) { this.i = i; this.s = s; this.b = b; this.chars = chars; } public TestedClass(boolean b1, byte b2, boolean b3) { b = b1; chars = new char[] {(char) b2, b3 ? 'X' : 'x'}; } public TestedClass(char first, char second, char third) { chars = new char[] {first, second, third}; } } @Tested TestedClass tested; @Test(expected = IllegalArgumentException.class) public void attemptToInstantiateTestedClassWithNoInjectables() {} @Test public void instantiateTestedObjectFromMockParametersUsingOneConstructor( @Injectable("Text") String s, @Injectable("123") int mock1, @Injectable("true") boolean mock2, @Injectable("A") char c1, @Injectable("bB") char c2 ) { assertEquals("Text", s); assertEquals(s, tested.s); assertEquals(mock1, tested.i); assertEquals(mock2, tested.b); assertEquals(2, tested.chars.length); assertEquals(c1, tested.chars[0]); assertEquals(c2, tested.chars[1]); assertEquals('b', c2); } @Test public void instantiateTestedObjectFromMockParametersUsingAnotherConstructor( @Injectable("true") boolean b1, @Injectable("true") boolean b3, @Injectable("65") byte b2 ) { assertTrue(tested.b); assertEquals('A', tested.chars[0]); assertEquals('X', tested.chars[1]); } @Test public void instantiateTestedObjectUsingConstructorWithMultipleParametersOfTheSameTypeMatchedByName( @Injectable("S") char second, @Injectable("T") char third, @Injectable("F") char first ) { assertArrayEquals(new char[] {'F', 'S', 'T'}, tested.chars); } @Test public void setEnumFieldInTestedObjectFromValueProvidedInParameter( @Injectable("false") boolean flag, @Injectable("Xyz") AnEnum enumVal ) { assertSame(AnEnum.Xyz, tested.enumValue); } }
978
4,901
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.harmony.tests.java.util; import java.util.Observable; import java.util.Observer; import java.util.Vector; import java.util.concurrent.atomic.AtomicReference; public class ObservableTest extends junit.framework.TestCase { static class TestObserver implements Observer { public Vector objv = new Vector(); int updateCount = 0; public void update(Observable observed, Object arg) { ++updateCount; objv.add(arg); } public int updateCount() { return updateCount; } } static class DeleteTestObserver implements Observer { int updateCount = 0; boolean deleteAll = false; public DeleteTestObserver(boolean all) { deleteAll = all; } public void update(Observable observed, Object arg) { ++updateCount; if (deleteAll) observed.deleteObservers(); else observed.deleteObserver(this); } public int updateCount() { return updateCount; } } static class TestObservable extends Observable { public void doChange() { setChanged(); } public void clearChange() { clearChanged(); } } Observer observer; TestObservable observable; /** * java.util.Observable#Observable() */ public void test_Constructor() { // Test for method java.util.Observable() try { Observable ov = new Observable(); assertTrue("Wrong initial values.", !ov.hasChanged()); assertEquals("Wrong initial values.", 0, ov.countObservers()); } catch (Exception e) { fail("Exception during test : " + e.getMessage()); } } /** * java.util.Observable#addObserver(java.util.Observer) */ public void test_addObserverLjava_util_Observer() { // Test for method void // java.util.Observable.addObserver(java.util.Observer) TestObserver test = new TestObserver(); observable.addObserver(test); assertEquals("Failed to add observer", 1, observable.countObservers()); observable.addObserver(test); assertEquals("Duplicate observer", 1, observable.countObservers()); Observable o = new Observable(); try { o.addObserver(null); fail("Expected adding a null observer to throw a NPE."); } catch (NullPointerException ex) { // expected; } catch (Throwable ex) { fail("Did not expect adding a new observer to throw a " + ex.getClass().getName()); } } /** * java.util.Observable#countObservers() */ public void test_countObservers() { // Test for method int java.util.Observable.countObservers() assertEquals("New observable had > 0 observers", 0, observable .countObservers()); observable.addObserver(new TestObserver()); assertEquals("Observable with observer returned other than 1", 1, observable .countObservers()); } /** * java.util.Observable#deleteObserver(java.util.Observer) */ public void test_deleteObserverLjava_util_Observer() { // Test for method void // java.util.Observable.deleteObserver(java.util.Observer) observable.addObserver(observer = new TestObserver()); observable.deleteObserver(observer); assertEquals("Failed to delete observer", 0, observable.countObservers()); observable.deleteObserver(observer); observable.deleteObserver(null); } /** * java.util.Observable#deleteObservers() */ public void test_deleteObservers() { // Test for method void java.util.Observable.deleteObservers() observable.addObserver(new TestObserver()); observable.addObserver(new TestObserver()); observable.addObserver(new TestObserver()); observable.addObserver(new TestObserver()); observable.addObserver(new TestObserver()); observable.addObserver(new TestObserver()); observable.addObserver(new TestObserver()); observable.addObserver(new TestObserver()); observable.deleteObservers(); assertEquals("Failed to delete observers", 0, observable.countObservers()); } /** * java.util.Observable#hasChanged() */ public void test_hasChanged() { assertFalse(observable.hasChanged()); observable.addObserver(observer = new TestObserver()); observable.doChange(); assertTrue(observable.hasChanged()); } public void test_clearChanged() { assertFalse(observable.hasChanged()); observable.addObserver(observer = new TestObserver()); observable.doChange(); assertTrue(observable.hasChanged()); observable.clearChange(); assertFalse(observable.hasChanged()); } /** * java.util.Observable#notifyObservers() */ public void test_notifyObservers() { // Test for method void java.util.Observable.notifyObservers() observable.addObserver(observer = new TestObserver()); observable.notifyObservers(); assertEquals("Notified when unchnaged", 0, ((TestObserver) observer) .updateCount()); ((TestObservable) observable).doChange(); observable.notifyObservers(); assertEquals("Failed to notify", 1, ((TestObserver) observer).updateCount()); DeleteTestObserver observer1, observer2; observable.deleteObservers(); observable.addObserver(observer1 = new DeleteTestObserver(false)); observable.addObserver(observer2 = new DeleteTestObserver(false)); observable.doChange(); observable.notifyObservers(); assertTrue("Failed to notify all", observer1.updateCount() == 1 && observer2.updateCount() == 1); assertEquals("Failed to delete all", 0, observable.countObservers()); observable.addObserver(observer1 = new DeleteTestObserver(false)); observable.addObserver(observer2 = new DeleteTestObserver(false)); observable.doChange(); observable.notifyObservers(); assertTrue("Failed to notify all 2", observer1.updateCount() == 1 && observer2.updateCount() == 1); assertEquals("Failed to delete all 2", 0, observable.countObservers()); } /** * java.util.Observable#notifyObservers(java.lang.Object) */ public void test_notifyObserversLjava_lang_Object() { // Test for method void // java.util.Observable.notifyObservers(java.lang.Object) Object obj; observable.addObserver(observer = new TestObserver()); observable.notifyObservers(); assertEquals("Notified when unchanged", 0, ((TestObserver) observer) .updateCount()); ((TestObservable) observable).doChange(); observable.notifyObservers(obj = new Object()); assertEquals("Failed to notify", 1, ((TestObserver) observer).updateCount()); assertTrue("Failed to pass Object arg", ((TestObserver) observer).objv .elementAt(0).equals(obj)); } static final class AlwaysChangedObservable extends Observable { @Override public boolean hasChanged() { return true; } } // http://b/28797950 public void test_observableWithOverridenHasChanged() throws Exception { final AtomicReference<Observable> updated = new AtomicReference<>(); final Observer observer = (observable1, data) -> updated.set(observable1); Observable alwaysChanging = new AlwaysChangedObservable(); alwaysChanging.addObserver(observer); alwaysChanging.notifyObservers(null); assertSame(alwaysChanging, updated.get()); } /** * Sets up the fixture, for example, open a network connection. This method * is called before a test is executed. */ protected void setUp() { observable = new TestObservable(); } /** * Tears down the fixture, for example, close a network connection. This * method is called after a test is executed. */ protected void tearDown() { } }
3,620
7,604
<reponame>yzthr/assimp /* * m3d.h * * Copyright (C) 2019 bzt (<EMAIL>) * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation * files (the "Software"), to deal in the Software without * restriction, including without limitation the rights to use, copy, * modify, merge, publish, distribute, sublicense, and/or sell copies * of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. * * @brief ANSI C89 / C++11 single header importer / exporter SDK for the Model 3D (.M3D) format * https://gitlab.com/bztsrc/model3d * * PNG decompressor included from (with minor modifications to make it C89 valid): * stb_image - v2.13 - public domain image loader - http://nothings.org/stb_image.h * * @version: 1.0.0 */ #ifndef _M3D_H_ #define _M3D_H_ #ifdef __cplusplus extern "C" { #endif #include <stdint.h> /*** configuration ***/ #ifndef M3D_MALLOC #define M3D_MALLOC(sz) malloc(sz) #endif #ifndef M3D_REALLOC #define M3D_REALLOC(p, nsz) realloc(p, nsz) #endif #ifndef M3D_FREE #define M3D_FREE(p) free(p) #endif #ifndef M3D_LOG #define M3D_LOG(x) #endif #ifndef M3D_APIVERSION #define M3D_APIVERSION 0x0100 #ifndef M3D_DOUBLE typedef float M3D_FLOAT; #ifndef M3D_EPSILON /* carefully chosen for IEEE 754 don't change */ #define M3D_EPSILON ((M3D_FLOAT)1e-7) #endif #else typedef double M3D_FLOAT; #ifndef M3D_EPSILON #define M3D_EPSILON ((M3D_FLOAT)1e-14) #endif #endif #if !defined(M3D_SMALLINDEX) typedef uint32_t M3D_INDEX; #define M3D_UNDEF 0xffffffff #define M3D_INDEXMAX 0xfffffffe #else typedef uint16_t M3D_INDEX; #define M3D_UNDEF 0xffff #define M3D_INDEXMAX 0xfffe #endif #define M3D_NOTDEFINED 0xffffffff #ifndef M3D_NUMBONE #define M3D_NUMBONE 4 #endif #ifndef M3D_BONEMAXLEVEL #define M3D_BONEMAXLEVEL 8 #endif #if !defined(_MSC_VER) || defined(__clang__) #ifndef _inline #define _inline __inline__ #endif #define _pack __attribute__((packed)) #define _unused __attribute__((unused)) #else #define _inline #define _pack #define _unused __pragma(warning(suppress : 4100)) #endif #ifndef __cplusplus #define _register register #else #define _register #endif #if _MSC_VER > 1920 && !defined(__clang__) # pragma warning(push) # pragma warning(disable : 4100 4127 4189 4505 4244 4403 4701 4703) # if (_MSC_VER > 1800 ) # pragma warning(disable : 5573 5744) # endif #endif // _MSC_VER /*** File format structures ***/ /** * M3D file format structure * 3DMO m3dchunk_t file header chunk, may followed by compressed data * HEAD m3dhdr_t model header chunk * n x m3dchunk_t more chunks follow * PRVW preview chunk (optional) * CMAP color map chunk (optional) * TMAP texture map chunk (optional) * VRTS vertex data chunk (optional if it's a material library) * BONE bind-pose skeleton, bone hierarchy chunk (optional) * n x m3db_t contains probably more, but at least one bone * n x m3ds_t skin group records * MTRL* material chunk(s), can be more (optional) * n x m3dp_t each material contains propapbly more, but at least one property * the properties are configurable with a static array, see m3d_propertytypes * n x m3dchunk_t at least one, but maybe more face chunks * PROC* procedural face, or * MESH* triangle mesh (vertex index list) or * SHPE* mathematical shapes like parameterized surfaces * LBLS* annotation label chunks, can be more (optional) * ACTN* action chunk(s), animation-pose skeletons, can be more (optional) * n x m3dfr_t each action contains probably more, but at least one frame * n x m3dtr_t each frame contains probably more, but at least one transformation * ASET* inlined asset chunk(s), can be more (optional) * OMD3 end chunk * * Typical chunks for a game engine: 3DMO, HEAD, CMAP, TMAP, VRTS, BONE, MTRL, MESH, ACTN, OMD3 * Typical chunks for CAD software: 3DMO, HEAD, PRVW, CMAP, TMAP, VRTS, MTRL, SHPE, LBLS, OMD3 */ #ifdef _MSC_VER #pragma pack(push) #pragma pack(1) #endif typedef struct { char magic[4]; uint32_t length; float scale; /* deliberately not M3D_FLOAT */ uint32_t types; } _pack m3dhdr_t; typedef struct { char magic[4]; uint32_t length; } _pack m3dchunk_t; #ifdef _MSC_VER #pragma pack(pop) #endif /*** in-memory model structure ***/ /* textmap entry */ typedef struct { M3D_FLOAT u; M3D_FLOAT v; } m3dti_t; #define m3d_textureindex_t m3dti_t /* texture */ typedef struct { char *name; /* texture name */ uint8_t *d; /* pixels data */ uint16_t w; /* width */ uint16_t h; /* height */ uint8_t f; /* format, 1 = grayscale, 2 = grayscale+alpha, 3 = rgb, 4 = rgba */ } m3dtx_t; #define m3d_texturedata_t m3dtx_t typedef struct { M3D_INDEX vertexid; M3D_FLOAT weight; } m3dw_t; #define m3d_weight_t m3dw_t /* bone entry */ typedef struct { M3D_INDEX parent; /* parent bone index */ char *name; /* name for this bone */ M3D_INDEX pos; /* vertex index position */ M3D_INDEX ori; /* vertex index orientation (quaternion) */ M3D_INDEX numweight; /* number of controlled vertices */ m3dw_t *weight; /* weights for those vertices */ M3D_FLOAT mat4[16]; /* transformation matrix */ } m3db_t; #define m3d_bone_t m3db_t /* skin: bone per vertex entry */ typedef struct { M3D_INDEX boneid[M3D_NUMBONE]; M3D_FLOAT weight[M3D_NUMBONE]; } m3ds_t; #define m3d_skin_t m3ds_t /* vertex entry */ typedef struct { M3D_FLOAT x; /* 3D coordinates and weight */ M3D_FLOAT y; M3D_FLOAT z; M3D_FLOAT w; uint32_t color; /* default vertex color */ M3D_INDEX skinid; /* skin index */ #ifdef M3D_VERTEXTYPE uint8_t type; #endif } m3dv_t; #define m3d_vertex_t m3dv_t /* material property formats */ enum { m3dpf_color, m3dpf_uint8, m3dpf_uint16, m3dpf_uint32, m3dpf_float, m3dpf_map }; typedef struct { uint8_t format; uint8_t id; #define M3D_PROPERTYDEF(f, i, n) \ { (f), (i), (char *)(n) } char *key; } m3dpd_t; /* material property types */ /* You shouldn't change the first 8 display and first 4 physical property. Assign the rest as you like. */ enum { m3dp_Kd = 0, /* scalar display properties */ m3dp_Ka, m3dp_Ks, m3dp_Ns, m3dp_Ke, m3dp_Tf, m3dp_Km, m3dp_d, m3dp_il, m3dp_Pr = 64, /* scalar physical properties */ m3dp_Pm, m3dp_Ps, m3dp_Ni, m3dp_Nt, m3dp_map_Kd = 128, /* textured display map properties */ m3dp_map_Ka, m3dp_map_Ks, m3dp_map_Ns, m3dp_map_Ke, m3dp_map_Tf, m3dp_map_Km, /* bump map */ m3dp_map_D, m3dp_map_N, /* normal map */ m3dp_map_Pr = 192, /* textured physical map properties */ m3dp_map_Pm, m3dp_map_Ps, m3dp_map_Ni, m3dp_map_Nt }; enum { /* aliases */ m3dp_bump = m3dp_map_Km, m3dp_map_il = m3dp_map_N, m3dp_refl = m3dp_map_Pm }; /* material property */ typedef struct { uint8_t type; /* property type, see "m3dp_*" enumeration */ union { uint32_t color; /* if value is a color, m3dpf_color */ uint32_t num; /* if value is a number, m3dpf_uint8, m3pf_uint16, m3dpf_uint32 */ float fnum; /* if value is a floating point number, m3dpf_float */ M3D_INDEX textureid; /* if value is a texture, m3dpf_map */ } value; } m3dp_t; #define m3d_property_t m3dp_t /* material entry */ typedef struct { char *name; /* name of the material */ uint8_t numprop; /* number of properties */ m3dp_t *prop; /* properties array */ } m3dm_t; #define m3d_material_t m3dm_t /* face entry */ typedef struct { M3D_INDEX materialid; /* material index */ M3D_INDEX vertex[3]; /* 3D points of the triangle in CCW order */ M3D_INDEX normal[3]; /* normal vectors */ M3D_INDEX texcoord[3]; /* UV coordinates */ } m3df_t; #define m3d_face_t m3df_t /* shape command types. must match the row in m3d_commandtypes */ enum { /* special commands */ m3dc_use = 0, /* use material */ m3dc_inc, /* include another shape */ m3dc_mesh, /* include part of polygon mesh */ /* approximations */ m3dc_div, /* subdivision by constant resolution for both u, v */ m3dc_sub, /* subdivision by constant, different for u and v */ m3dc_len, /* spacial subdivision by maxlength */ m3dc_dist, /* subdivision by maxdistance and maxangle */ /* modifiers */ m3dc_degu, /* degree for both u, v */ m3dc_deg, /* separate degree for u and v */ m3dc_rangeu, /* range for u */ m3dc_range, /* range for u and v */ m3dc_paru, /* u parameters (knots) */ m3dc_parv, /* v parameters */ m3dc_trim, /* outer trimming curve */ m3dc_hole, /* inner trimming curve */ m3dc_scrv, /* spacial curve */ m3dc_sp, /* special points */ /* helper curves */ m3dc_bez1, /* Bezier 1D */ m3dc_bsp1, /* B-spline 1D */ m3dc_bez2, /* bezier 2D */ m3dc_bsp2, /* B-spline 2D */ /* surfaces */ m3dc_bezun, /* Bezier 3D with control, UV, normal */ m3dc_bezu, /* with control and UV */ m3dc_bezn, /* with control and normal */ m3dc_bez, /* control points only */ m3dc_nurbsun, /* B-spline 3D */ m3dc_nurbsu, m3dc_nurbsn, m3dc_nurbs, m3dc_conn, /* connect surfaces */ /* geometrical */ m3dc_line, m3dc_polygon, m3dc_circle, m3dc_cylinder, m3dc_shpere, m3dc_torus, m3dc_cone, m3dc_cube }; /* shape command argument types */ enum { m3dcp_mi_t = 1, /* material index */ m3dcp_hi_t, /* shape index */ m3dcp_fi_t, /* face index */ m3dcp_ti_t, /* texture map index */ m3dcp_vi_t, /* vertex index */ m3dcp_qi_t, /* vertex index for quaternions */ m3dcp_vc_t, /* coordinate or radius, float scalar */ m3dcp_i1_t, /* int8 scalar */ m3dcp_i2_t, /* int16 scalar */ m3dcp_i4_t, /* int32 scalar */ m3dcp_va_t /* variadic arguments */ }; #define M3D_CMDMAXARG 8 /* if you increase this, add more arguments to the macro below */ typedef struct { #define M3D_CMDDEF(t, n, p, a, b, c, d, e, f, g, h) \ { \ (char *)(n), (p), { (a), (b), (c), (d), (e), (f), (g), (h) } \ } char *key; uint8_t p; uint8_t a[M3D_CMDMAXARG]; } m3dcd_t; /* shape command */ typedef struct { uint16_t type; /* shape type */ uint32_t *arg; /* arguments array */ } m3dc_t; #define m3d_shapecommand_t m3dc_t /* shape entry */ typedef struct { char *name; /* name of the mathematical shape */ M3D_INDEX group; /* group this shape belongs to or -1 */ uint32_t numcmd; /* number of commands */ m3dc_t *cmd; /* commands array */ } m3dh_t; #define m3d_shape_t m3dh_t /* label entry */ typedef struct { char *name; /* name of the annotation layer or NULL */ char *lang; /* language code or NULL */ char *text; /* the label text */ uint32_t color; /* color */ M3D_INDEX vertexid; /* the vertex the label refers to */ } m3dl_t; #define m3d_label_t m3dl_t /* frame transformations / working copy skeleton entry */ typedef struct { M3D_INDEX boneid; /* selects a node in bone hierarchy */ M3D_INDEX pos; /* vertex index new position */ M3D_INDEX ori; /* vertex index new orientation (quaternion) */ } m3dtr_t; #define m3d_transform_t m3dtr_t /* animation frame entry */ typedef struct { uint32_t msec; /* frame's position on the timeline, timestamp */ M3D_INDEX numtransform; /* number of transformations in this frame */ m3dtr_t *transform; /* transformations */ } m3dfr_t; #define m3d_frame_t m3dfr_t /* model action entry */ typedef struct { char *name; /* name of the action */ uint32_t durationmsec; /* duration in millisec (1/1000 sec) */ M3D_INDEX numframe; /* number of frames in this animation */ m3dfr_t *frame; /* frames array */ } m3da_t; #define m3d_action_t m3da_t /* inlined asset */ typedef struct { char *name; /* asset name (same pointer as in texture[].name) */ uint8_t *data; /* compressed asset data */ uint32_t length; /* compressed data length */ } m3di_t; #define m3d_inlinedasset_t m3di_t /*** in-memory model structure ***/ #define M3D_FLG_FREERAW (1 << 0) #define M3D_FLG_FREESTR (1 << 1) #define M3D_FLG_MTLLIB (1 << 2) #define M3D_FLG_GENNORM (1 << 3) typedef struct { m3dhdr_t *raw; /* pointer to raw data */ char flags; /* internal flags */ signed char errcode; /* returned error code */ char vc_s, vi_s, si_s, ci_s, ti_s, bi_s, nb_s, sk_s, fc_s, hi_s, fi_s; /* decoded sizes for types */ char *name; /* name of the model, like "Utah teapot" */ char *license; /* usage condition or license, like "MIT", "LGPL" or "BSD-3clause" */ char *author; /* nickname, email, homepage or github URL etc. */ char *desc; /* comments, descriptions. May contain '\n' newline character */ M3D_FLOAT scale; /* the model's bounding cube's size in SI meters */ M3D_INDEX numcmap; uint32_t *cmap; /* color map */ M3D_INDEX numtmap; m3dti_t *tmap; /* texture map indices */ M3D_INDEX numtexture; m3dtx_t *texture; /* uncompressed textures */ M3D_INDEX numbone; m3db_t *bone; /* bone hierarchy */ M3D_INDEX numvertex; m3dv_t *vertex; /* vertex data */ M3D_INDEX numskin; m3ds_t *skin; /* skin data */ M3D_INDEX nummaterial; m3dm_t *material; /* material list */ M3D_INDEX numface; m3df_t *face; /* model face, polygon (triangle) mesh */ M3D_INDEX numshape; m3dh_t *shape; /* model face, shape commands */ M3D_INDEX numlabel; m3dl_t *label; /* annotation labels */ M3D_INDEX numaction; m3da_t *action; /* action animations */ M3D_INDEX numinlined; m3di_t *inlined; /* inlined assets */ M3D_INDEX numextra; m3dchunk_t **extra; /* unknown chunks, application / engine specific data probably */ m3di_t preview; /* preview chunk */ } m3d_t; /*** export parameters ***/ #define M3D_EXP_INT8 0 #define M3D_EXP_INT16 1 #define M3D_EXP_FLOAT 2 #define M3D_EXP_DOUBLE 3 #define M3D_EXP_NOCMAP (1 << 0) #define M3D_EXP_NOMATERIAL (1 << 1) #define M3D_EXP_NOFACE (1 << 2) #define M3D_EXP_NONORMAL (1 << 3) #define M3D_EXP_NOTXTCRD (1 << 4) #define M3D_EXP_FLIPTXTCRD (1 << 5) #define M3D_EXP_NORECALC (1 << 6) #define M3D_EXP_IDOSUCK (1 << 7) #define M3D_EXP_NOBONE (1 << 8) #define M3D_EXP_NOACTION (1 << 9) #define M3D_EXP_INLINE (1 << 10) #define M3D_EXP_EXTRA (1 << 11) #define M3D_EXP_NOZLIB (1 << 14) #define M3D_EXP_ASCII (1 << 15) /*** error codes ***/ #define M3D_SUCCESS 0 #define M3D_ERR_ALLOC -1 #define M3D_ERR_BADFILE -2 #define M3D_ERR_UNIMPL -65 #define M3D_ERR_UNKPROP -66 #define M3D_ERR_UNKMESH -67 #define M3D_ERR_UNKIMG -68 #define M3D_ERR_UNKFRAME -69 #define M3D_ERR_UNKCMD -70 #define M3D_ERR_TRUNC -71 #define M3D_ERR_CMAP -72 #define M3D_ERR_TMAP -73 #define M3D_ERR_VRTS -74 #define M3D_ERR_BONE -75 #define M3D_ERR_MTRL -76 #define M3D_ERR_SHPE -77 #define M3D_ERR_ISFATAL(x) ((x) < 0 && (x) > -65) /* callbacks */ typedef unsigned char *(*m3dread_t)(char *filename, unsigned int *size); /* read file contents into buffer */ typedef void (*m3dfree_t)(void *buffer); /* free file contents buffer */ typedef int (*m3dtxsc_t)(const char *name, const void *script, uint32_t len, m3dtx_t *output); /* interpret texture script */ typedef int (*m3dprsc_t)(const char *name, const void *script, uint32_t len, m3d_t *model); /* interpret surface script */ #endif /* ifndef M3D_APIVERSION */ /*** C prototypes ***/ /* import / export */ m3d_t *m3d_load(unsigned char *data, m3dread_t readfilecb, m3dfree_t freecb, m3d_t *mtllib); unsigned char *m3d_save(m3d_t *model, int quality, int flags, unsigned int *size); void m3d_free(m3d_t *model); /* generate animation pose skeleton */ m3dtr_t *m3d_frame(m3d_t *model, M3D_INDEX actionid, M3D_INDEX frameid, m3dtr_t *skeleton); m3db_t *m3d_pose(m3d_t *model, M3D_INDEX actionid, uint32_t msec); /* private prototypes used by both importer and exporter */ char *_m3d_safestr(char *in, int morelines); /*** C implementation ***/ #ifdef M3D_IMPLEMENTATION #if !defined(M3D_NOIMPORTER) || defined(M3D_EXPORTER) /* material property definitions */ static m3dpd_t m3d_propertytypes[] = { M3D_PROPERTYDEF(m3dpf_color, m3dp_Kd, "Kd"), /* diffuse color */ M3D_PROPERTYDEF(m3dpf_color, m3dp_Ka, "Ka"), /* ambient color */ M3D_PROPERTYDEF(m3dpf_color, m3dp_Ks, "Ks"), /* specular color */ M3D_PROPERTYDEF(m3dpf_float, m3dp_Ns, "Ns"), /* specular exponent */ M3D_PROPERTYDEF(m3dpf_color, m3dp_Ke, "Ke"), /* emissive (emitting light of this color) */ M3D_PROPERTYDEF(m3dpf_color, m3dp_Tf, "Tf"), /* transmission color */ M3D_PROPERTYDEF(m3dpf_float, m3dp_Km, "Km"), /* bump strength */ M3D_PROPERTYDEF(m3dpf_float, m3dp_d, "d"), /* dissolve (transparency) */ M3D_PROPERTYDEF(m3dpf_uint8, m3dp_il, "il"), /* illumination model (informational, ignored by PBR-shaders) */ M3D_PROPERTYDEF(m3dpf_float, m3dp_Pr, "Pr"), /* roughness */ M3D_PROPERTYDEF(m3dpf_float, m3dp_Pm, "Pm"), /* metallic, also reflection */ M3D_PROPERTYDEF(m3dpf_float, m3dp_Ps, "Ps"), /* sheen */ M3D_PROPERTYDEF(m3dpf_float, m3dp_Ni, "Ni"), /* index of refraction (optical density) */ M3D_PROPERTYDEF(m3dpf_float, m3dp_Nt, "Nt"), /* thickness of face in millimeter, for printing */ /* aliases, note that "map_*" aliases are handled automatically */ M3D_PROPERTYDEF(m3dpf_map, m3dp_map_Km, "bump"), M3D_PROPERTYDEF(m3dpf_map, m3dp_map_N, "map_N"), /* as normal map has no scalar version, it's counterpart is 'il' */ M3D_PROPERTYDEF(m3dpf_map, m3dp_map_Pm, "refl") }; /* shape command definitions. if more commands start with the same string, the longer must come first */ static m3dcd_t m3d_commandtypes[] = { /* technical */ M3D_CMDDEF(m3dc_use, "use", 1, m3dcp_mi_t, 0, 0, 0, 0, 0, 0, 0), M3D_CMDDEF(m3dc_inc, "inc", 3, m3dcp_hi_t, m3dcp_vi_t, m3dcp_qi_t, m3dcp_vi_t, 0, 0, 0, 0), M3D_CMDDEF(m3dc_mesh, "mesh", 1, m3dcp_fi_t, m3dcp_fi_t, m3dcp_vi_t, m3dcp_qi_t, m3dcp_vi_t, 0, 0, 0), /* approximations */ M3D_CMDDEF(m3dc_div, "div", 1, m3dcp_vc_t, 0, 0, 0, 0, 0, 0, 0), M3D_CMDDEF(m3dc_sub, "sub", 2, m3dcp_vc_t, m3dcp_vc_t, 0, 0, 0, 0, 0, 0), M3D_CMDDEF(m3dc_len, "len", 1, m3dcp_vc_t, 0, 0, 0, 0, 0, 0, 0), M3D_CMDDEF(m3dc_dist, "dist", 2, m3dcp_vc_t, m3dcp_vc_t, 0, 0, 0, 0, 0, 0), /* modifiers */ M3D_CMDDEF(m3dc_degu, "degu", 1, m3dcp_i1_t, 0, 0, 0, 0, 0, 0, 0), M3D_CMDDEF(m3dc_deg, "deg", 2, m3dcp_i1_t, m3dcp_i1_t, 0, 0, 0, 0, 0, 0), M3D_CMDDEF(m3dc_rangeu, "rangeu", 1, m3dcp_ti_t, 0, 0, 0, 0, 0, 0, 0), M3D_CMDDEF(m3dc_range, "range", 2, m3dcp_ti_t, m3dcp_ti_t, 0, 0, 0, 0, 0, 0), M3D_CMDDEF(m3dc_paru, "paru", 2, m3dcp_va_t, m3dcp_vc_t, 0, 0, 0, 0, 0, 0), M3D_CMDDEF(m3dc_parv, "parv", 2, m3dcp_va_t, m3dcp_vc_t, 0, 0, 0, 0, 0, 0), M3D_CMDDEF(m3dc_trim, "trim", 3, m3dcp_va_t, m3dcp_ti_t, m3dcp_i2_t, 0, 0, 0, 0, 0), M3D_CMDDEF(m3dc_hole, "hole", 3, m3dcp_va_t, m3dcp_ti_t, m3dcp_i2_t, 0, 0, 0, 0, 0), M3D_CMDDEF(m3dc_scrv, "scrv", 3, m3dcp_va_t, m3dcp_ti_t, m3dcp_i2_t, 0, 0, 0, 0, 0), M3D_CMDDEF(m3dc_sp, "sp", 2, m3dcp_va_t, m3dcp_vi_t, 0, 0, 0, 0, 0, 0), /* helper curves */ M3D_CMDDEF(m3dc_bez1, "bez1", 2, m3dcp_va_t, m3dcp_vi_t, 0, 0, 0, 0, 0, 0), M3D_CMDDEF(m3dc_bsp1, "bsp1", 2, m3dcp_va_t, m3dcp_vi_t, 0, 0, 0, 0, 0, 0), M3D_CMDDEF(m3dc_bez2, "bez2", 2, m3dcp_va_t, m3dcp_vi_t, 0, 0, 0, 0, 0, 0), M3D_CMDDEF(m3dc_bsp2, "bsp2", 2, m3dcp_va_t, m3dcp_vi_t, 0, 0, 0, 0, 0, 0), /* surfaces */ M3D_CMDDEF(m3dc_bezun, "bezun", 4, m3dcp_va_t, m3dcp_vi_t, m3dcp_ti_t, m3dcp_vi_t, 0, 0, 0, 0), M3D_CMDDEF(m3dc_bezu, "bezu", 3, m3dcp_va_t, m3dcp_vi_t, m3dcp_ti_t, 0, 0, 0, 0, 0), M3D_CMDDEF(m3dc_bezn, "bezn", 3, m3dcp_va_t, m3dcp_vi_t, m3dcp_vi_t, 0, 0, 0, 0, 0), M3D_CMDDEF(m3dc_bez, "bez", 2, m3dcp_va_t, m3dcp_vi_t, 0, 0, 0, 0, 0, 0), M3D_CMDDEF(m3dc_nurbsun, "nurbsun", 4, m3dcp_va_t, m3dcp_vi_t, m3dcp_ti_t, m3dcp_vi_t, 0, 0, 0, 0), M3D_CMDDEF(m3dc_nurbsu, "nurbsu", 3, m3dcp_va_t, m3dcp_vi_t, m3dcp_ti_t, 0, 0, 0, 0, 0), M3D_CMDDEF(m3dc_nurbsn, "nurbsn", 3, m3dcp_va_t, m3dcp_vi_t, m3dcp_vi_t, 0, 0, 0, 0, 0), M3D_CMDDEF(m3dc_nurbs, "nurbs", 2, m3dcp_va_t, m3dcp_vi_t, 0, 0, 0, 0, 0, 0), M3D_CMDDEF(m3dc_conn, "conn", 6, m3dcp_i2_t, m3dcp_ti_t, m3dcp_i2_t, m3dcp_i2_t, m3dcp_ti_t, m3dcp_i2_t, 0, 0), /* geometrical */ M3D_CMDDEF(m3dc_line, "line", 2, m3dcp_va_t, m3dcp_vi_t, 0, 0, 0, 0, 0, 0), M3D_CMDDEF(m3dc_polygon, "polygon", 2, m3dcp_va_t, m3dcp_vi_t, 0, 0, 0, 0, 0, 0), M3D_CMDDEF(m3dc_circle, "circle", 3, m3dcp_vi_t, m3dcp_qi_t, m3dcp_vc_t, 0, 0, 0, 0, 0), M3D_CMDDEF(m3dc_cylinder, "cylinder", 6, m3dcp_vi_t, m3dcp_qi_t, m3dcp_vc_t, m3dcp_vi_t, m3dcp_qi_t, m3dcp_vc_t, 0, 0), M3D_CMDDEF(m3dc_shpere, "shpere", 2, m3dcp_vi_t, m3dcp_vc_t, 0, 0, 0, 0, 0, 0), M3D_CMDDEF(m3dc_torus, "torus", 4, m3dcp_vi_t, m3dcp_qi_t, m3dcp_vc_t, m3dcp_vc_t, 0, 0, 0, 0), M3D_CMDDEF(m3dc_cone, "cone", 3, m3dcp_vi_t, m3dcp_vi_t, m3dcp_vi_t, 0, 0, 0, 0, 0), M3D_CMDDEF(m3dc_cube, "cube", 3, m3dcp_vi_t, m3dcp_vi_t, m3dcp_vi_t, 0, 0, 0, 0, 0) }; #endif #include <stdlib.h> #include <string.h> #if defined(M3D_EXPORTER) && !defined(INCLUDE_STB_IMAGE_WRITE_H) /* zlib_compressor from stb_image_write - v1.13 - public domain - http://nothings.org/stb/stb_image_write.h */ typedef unsigned char _m3dstbiw__uc; typedef unsigned short _m3dstbiw__us; typedef uint16_t _m3dstbiw__uint16; typedef int16_t _m3dstbiw__int16; typedef uint32_t _m3dstbiw__uint32; typedef int32_t _m3dstbiw__int32; #define STBIW_MALLOC(s) M3D_MALLOC(s) #define STBIW_REALLOC(p, ns) M3D_REALLOC(p, ns) #define STBIW_REALLOC_SIZED(p, oldsz, newsz) STBIW_REALLOC(p, newsz) #define STBIW_FREE M3D_FREE #define STBIW_MEMMOVE memmove #define STBIW_UCHAR (uint8_t) #define STBIW_ASSERT(x) #define _m3dstbiw___sbraw(a) ((int *)(a)-2) #define _m3dstbiw___sbm(a) _m3dstbiw___sbraw(a)[0] #define _m3dstbiw___sbn(a) _m3dstbiw___sbraw(a)[1] #define _m3dstbiw___sbneedgrow(a, n) ((a) == 0 || _m3dstbiw___sbn(a) + n >= _m3dstbiw___sbm(a)) #define _m3dstbiw___sbmaybegrow(a, n) (_m3dstbiw___sbneedgrow(a, (n)) ? _m3dstbiw___sbgrow(a, n) : 0) #define _m3dstbiw___sbgrow(a, n) _m3dstbiw___sbgrowf((void **)&(a), (n), sizeof(*(a))) #define _m3dstbiw___sbpush(a, v) (_m3dstbiw___sbmaybegrow(a, 1), (a)[_m3dstbiw___sbn(a)++] = (v)) #define _m3dstbiw___sbcount(a) ((a) ? _m3dstbiw___sbn(a) : 0) #define _m3dstbiw___sbfree(a) ((a) ? STBIW_FREE(_m3dstbiw___sbraw(a)), 0 : 0) static void *_m3dstbiw___sbgrowf(void **arr, int increment, int itemsize) { int m = *arr ? 2 * _m3dstbiw___sbm(*arr) + increment : increment + 1; void *p = STBIW_REALLOC_SIZED(*arr ? _m3dstbiw___sbraw(*arr) : 0, *arr ? (_m3dstbiw___sbm(*arr) * itemsize + sizeof(int) * 2) : 0, itemsize * m + sizeof(int) * 2); STBIW_ASSERT(p); if (p) { if (!*arr) ((int *)p)[1] = 0; *arr = (void *)((int *)p + 2); _m3dstbiw___sbm(*arr) = m; } return *arr; } static unsigned char *_m3dstbiw___zlib_flushf(unsigned char *data, unsigned int *bitbuffer, int *bitcount) { while (*bitcount >= 8) { _m3dstbiw___sbpush(data, STBIW_UCHAR(*bitbuffer)); *bitbuffer >>= 8; *bitcount -= 8; } return data; } static int _m3dstbiw___zlib_bitrev(int code, int codebits) { int res = 0; while (codebits--) { res = (res << 1) | (code & 1); code >>= 1; } return res; } static unsigned int _m3dstbiw___zlib_countm(unsigned char *a, unsigned char *b, int limit) { int i; for (i = 0; i < limit && i < 258; ++i) if (a[i] != b[i]) break; return i; } static unsigned int _m3dstbiw___zhash(unsigned char *data) { _m3dstbiw__uint32 hash = data[0] + (data[1] << 8) + (data[2] << 16); hash ^= hash << 3; hash += hash >> 5; hash ^= hash << 4; hash += hash >> 17; hash ^= hash << 25; hash += hash >> 6; return hash; } #define _m3dstbiw___zlib_flush() (out = _m3dstbiw___zlib_flushf(out, &bitbuf, &bitcount)) #define _m3dstbiw___zlib_add(code, codebits) \ (bitbuf |= (code) << bitcount, bitcount += (codebits), _m3dstbiw___zlib_flush()) #define _m3dstbiw___zlib_huffa(b, c) _m3dstbiw___zlib_add(_m3dstbiw___zlib_bitrev(b, c), c) #define _m3dstbiw___zlib_huff1(n) _m3dstbiw___zlib_huffa(0x30 + (n), 8) #define _m3dstbiw___zlib_huff2(n) _m3dstbiw___zlib_huffa(0x190 + (n)-144, 9) #define _m3dstbiw___zlib_huff3(n) _m3dstbiw___zlib_huffa(0 + (n)-256, 7) #define _m3dstbiw___zlib_huff4(n) _m3dstbiw___zlib_huffa(0xc0 + (n)-280, 8) #define _m3dstbiw___zlib_huff(n) ((n) <= 143 ? _m3dstbiw___zlib_huff1(n) : (n) <= 255 ? _m3dstbiw___zlib_huff2(n) : (n) <= 279 ? _m3dstbiw___zlib_huff3(n) : _m3dstbiw___zlib_huff4(n)) #define _m3dstbiw___zlib_huffb(n) ((n) <= 143 ? _m3dstbiw___zlib_huff1(n) : _m3dstbiw___zlib_huff2(n)) #define _m3dstbiw___ZHASH 16384 unsigned char *_m3dstbi_zlib_compress(unsigned char *data, int data_len, int *out_len, int quality) { static unsigned short lengthc[] = { 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 259 }; static unsigned char lengtheb[] = { 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0 }; static unsigned short distc[] = { 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577, 32768 }; static unsigned char disteb[] = { 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13 }; unsigned int bitbuf = 0; int i, j, bitcount = 0; unsigned char *out = NULL; unsigned char ***hash_table = (unsigned char ***)STBIW_MALLOC(_m3dstbiw___ZHASH * sizeof(char **)); if (hash_table == NULL) return NULL; if (quality < 5) quality = 5; _m3dstbiw___sbpush(out, 0x78); _m3dstbiw___sbpush(out, 0x5e); _m3dstbiw___zlib_add(1, 1); _m3dstbiw___zlib_add(1, 2); for (i = 0; i < _m3dstbiw___ZHASH; ++i) hash_table[i] = NULL; i = 0; while (i < data_len - 3) { int h = _m3dstbiw___zhash(data + i) & (_m3dstbiw___ZHASH - 1), best = 3; unsigned char *bestloc = 0; unsigned char **hlist = hash_table[h]; int n = _m3dstbiw___sbcount(hlist); for (j = 0; j < n; ++j) { if (hlist[j] - data > i - 32768) { int d = _m3dstbiw___zlib_countm(hlist[j], data + i, data_len - i); if (d >= best) best = d, bestloc = hlist[j]; } } if (hash_table[h] && _m3dstbiw___sbn(hash_table[h]) == 2 * quality) { STBIW_MEMMOVE(hash_table[h], hash_table[h] + quality, sizeof(hash_table[h][0]) * quality); _m3dstbiw___sbn(hash_table[h]) = quality; } _m3dstbiw___sbpush(hash_table[h], data + i); if (bestloc) { h = _m3dstbiw___zhash(data + i + 1) & (_m3dstbiw___ZHASH - 1); hlist = hash_table[h]; n = _m3dstbiw___sbcount(hlist); for (j = 0; j < n; ++j) { if (hlist[j] - data > i - 32767) { int e = _m3dstbiw___zlib_countm(hlist[j], data + i + 1, data_len - i - 1); if (e > best) { bestloc = NULL; break; } } } } if (bestloc) { int d = (int)(data + i - bestloc); STBIW_ASSERT(d <= 32767 && best <= 258); for (j = 0; best > lengthc[j + 1] - 1; ++j) ; _m3dstbiw___zlib_huff(j + 257); if (lengtheb[j]) _m3dstbiw___zlib_add(best - lengthc[j], lengtheb[j]); for (j = 0; d > distc[j + 1] - 1; ++j) ; _m3dstbiw___zlib_add(_m3dstbiw___zlib_bitrev(j, 5), 5); if (disteb[j]) _m3dstbiw___zlib_add(d - distc[j], disteb[j]); i += best; } else { _m3dstbiw___zlib_huffb(data[i]); ++i; } } for (; i < data_len; ++i) _m3dstbiw___zlib_huffb(data[i]); _m3dstbiw___zlib_huff(256); while (bitcount) _m3dstbiw___zlib_add(0, 1); for (i = 0; i < _m3dstbiw___ZHASH; ++i) (void)_m3dstbiw___sbfree(hash_table[i]); STBIW_FREE(hash_table); { unsigned int s1 = 1, s2 = 0; int blocklen = (int)(data_len % 5552); j = 0; while (j < data_len) { for (i = 0; i < blocklen; ++i) s1 += data[j + i], s2 += s1; s1 %= 65521, s2 %= 65521; j += blocklen; blocklen = 5552; } _m3dstbiw___sbpush(out, STBIW_UCHAR(s2 >> 8)); _m3dstbiw___sbpush(out, STBIW_UCHAR(s2)); _m3dstbiw___sbpush(out, STBIW_UCHAR(s1 >> 8)); _m3dstbiw___sbpush(out, STBIW_UCHAR(s1)); } *out_len = _m3dstbiw___sbn(out); STBIW_MEMMOVE(_m3dstbiw___sbraw(out), out, *out_len); return (unsigned char *)_m3dstbiw___sbraw(out); } #define stbi_zlib_compress _m3dstbi_zlib_compress #else unsigned char *_m3dstbi_zlib_compress(unsigned char *data, int data_len, int *out_len, int quality); #endif #define M3D_CHUNKMAGIC(m, a, b, c, d) ((m)[0] == (a) && (m)[1] == (b) && (m)[2] == (c) && (m)[3] == (d)) #include <locale.h> /* sprintf and strtod cares about number locale */ #include <stdio.h> /* get sprintf */ #ifdef M3D_PROFILING #include <sys/time.h> #endif #if !defined(M3D_NOIMPORTER) /* helper functions for the ASCII parser */ static char *_m3d_findarg(char *s) { while (s && *s && *s != ' ' && *s != '\t' && *s != '\r' && *s != '\n') s++; while (s && *s && (*s == ' ' || *s == '\t')) s++; return s; } static char *_m3d_findnl(char *s) { while (s && *s && *s != '\r' && *s != '\n') s++; if (*s == '\r') s++; if (*s == '\n') s++; return s; } static char *_m3d_gethex(char *s, uint32_t *ret) { if (*s == '#') s++; *ret = 0; for (; *s; s++) { if (*s >= '0' && *s <= '9') { *ret <<= 4; *ret += (uint32_t)(*s - '0'); } else if (*s >= 'a' && *s <= 'f') { *ret <<= 4; *ret += (uint32_t)(*s - 'a' + 10); } else if (*s >= 'A' && *s <= 'F') { *ret <<= 4; *ret += (uint32_t)(*s - 'A' + 10); } else break; } return _m3d_findarg(s); } static char *_m3d_getint(char *s, uint32_t *ret) { char *e = s; if (!s || !*s || *s == '\r' || *s == '\n') return s; for (; *e >= '0' && *e <= '9'; e++) ; *ret = atoi(s); return e; } static char *_m3d_getfloat(char *s, M3D_FLOAT *ret) { char *e = s; if (!s || !*s || *s == '\r' || *s == '\n') return s; for (; *e == '-' || *e == '+' || *e == '.' || (*e >= '0' && *e <= '9') || *e == 'e' || *e == 'E'; e++) ; *ret = (M3D_FLOAT)strtod(s, NULL); return _m3d_findarg(e); } #endif #if !defined(M3D_NODUP) && (!defined(M3D_NOIMPORTER) || defined(M3D_EXPORTER)) /* helper function to create safe strings */ char *_m3d_safestr(char *in, int morelines) { char *out, *o, *i = in; int l; if (!in || !*in) { out = (char *)M3D_MALLOC(1); if (!out) return NULL; out[0] = 0; } else { for (o = in, l = 0; *o && ((morelines & 1) || (*o != '\r' && *o != '\n')) && l < 256; o++, l++) ; out = o = (char *)M3D_MALLOC(l + 1); if (!out) return NULL; while (*i == ' ' || *i == '\t' || *i == '\r' || (morelines && *i == '\n')) i++; for (; *i && (morelines || (*i != '\r' && *i != '\n')); i++) { if (*i == '\r') continue; if (*i == '\n') { if (morelines >= 3 && o > out && *(o - 1) == '\n') break; if (i > in && *(i - 1) == '\n') continue; if (morelines & 1) { if (morelines == 1) *o++ = '\r'; *o++ = '\n'; } else break; } else if (*i == ' ' || *i == '\t') { *o++ = morelines ? ' ' : '_'; } else *o++ = !morelines && (*i == '/' || *i == '\\') ? '_' : *i; } for (; o > out && (*(o - 1) == ' ' || *(o - 1) == '\t' || *(o - 1) == '\r' || *(o - 1) == '\n'); o--) ; *o = 0; out = (char *)M3D_REALLOC(out, (uintptr_t)o - (uintptr_t)out + 1); } return out; } #endif #ifndef M3D_NOIMPORTER /* helper function to load and decode/generate a texture */ M3D_INDEX _m3d_gettx(m3d_t *model, m3dread_t readfilecb, m3dfree_t freecb, char *fn) { unsigned int i, len = 0; unsigned char *buff = NULL; char *fn2; #ifdef STBI__PNG_TYPE unsigned int w, h; stbi__context s; stbi__result_info ri; #endif /* do we have loaded this texture already? */ for (i = 0; i < model->numtexture; i++) if (!strcmp(fn, model->texture[i].name)) return i; /* see if it's inlined in the model */ if (model->inlined) { for (i = 0; i < model->numinlined; i++) if (!strcmp(fn, model->inlined[i].name)) { buff = model->inlined[i].data; len = model->inlined[i].length; freecb = NULL; break; } } /* try to load from external source */ if (!buff && readfilecb) { i = (unsigned int)strlen(fn); if (i < 5 || fn[i - 4] != '.') { fn2 = (char *)M3D_MALLOC(i + 5); if (!fn2) { model->errcode = M3D_ERR_ALLOC; return M3D_UNDEF; } memcpy(fn2, fn, i); memcpy(fn2 + i, ".png", 5); buff = (*readfilecb)(fn2, &len); M3D_FREE(fn2); } if (!buff) { buff = (*readfilecb)(fn, &len); if (!buff) return M3D_UNDEF; } } /* add to textures array */ i = model->numtexture++; model->texture = (m3dtx_t *)M3D_REALLOC(model->texture, model->numtexture * sizeof(m3dtx_t)); if (!model->texture) { if (buff && freecb) (*freecb)(buff); model->errcode = M3D_ERR_ALLOC; return M3D_UNDEF; } model->texture[i].name = fn; model->texture[i].w = model->texture[i].h = 0; model->texture[i].d = NULL; if (buff) { if (buff[0] == 0x89 && buff[1] == 'P' && buff[2] == 'N' && buff[3] == 'G') { #ifdef STBI__PNG_TYPE s.read_from_callbacks = 0; s.img_buffer = s.img_buffer_original = (unsigned char *)buff; s.img_buffer_end = s.img_buffer_original_end = (unsigned char *)buff + len; /* don't use model->texture[i].w directly, it's a uint16_t */ w = h = len = 0; ri.bits_per_channel = 8; model->texture[i].d = (uint8_t *)stbi__png_load(&s, (int *)&w, (int *)&h, (int *)&len, 0, &ri); model->texture[i].w = (uint16_t)w; model->texture[i].h = (uint16_t)h; model->texture[i].f = (uint8_t)len; #endif } else { #ifdef M3D_TX_INTERP if ((model->errcode = M3D_TX_INTERP(fn, buff, len, &model->texture[i])) != M3D_SUCCESS) { M3D_LOG("Unable to generate texture"); M3D_LOG(fn); } #else M3D_LOG("Unimplemented interpreter"); M3D_LOG(fn); #endif } if (freecb) (*freecb)(buff); } if (!model->texture[i].d) model->errcode = M3D_ERR_UNKIMG; return i; } /* helper function to load and generate a procedural surface */ void _m3d_getpr(m3d_t *model, _unused m3dread_t readfilecb, _unused m3dfree_t freecb, _unused char *fn) { #ifdef M3D_PR_INTERP unsigned int i, len = 0; unsigned char *buff = readfilecb ? (*readfilecb)(fn, &len) : NULL; if (!buff && model->inlined) { for (i = 0; i < model->numinlined; i++) if (!strcmp(fn, model->inlined[i].name)) { buff = model->inlined[i].data; len = model->inlined[i].length; freecb = NULL; break; } } if (!buff || !len || (model->errcode = M3D_PR_INTERP(fn, buff, len, model)) != M3D_SUCCESS) { M3D_LOG("Unable to generate procedural surface"); M3D_LOG(fn); model->errcode = M3D_ERR_UNKIMG; } if (freecb && buff) (*freecb)(buff); #else (void)readfilecb; (void)freecb; (void)fn; M3D_LOG("Unimplemented interpreter"); M3D_LOG(fn); model->errcode = M3D_ERR_UNIMPL; #endif } /* helpers to read indices from data stream */ #define M3D_GETSTR(x) \ do { \ offs = 0; \ data = _m3d_getidx(data, model->si_s, &offs); \ x = offs ? ((char *)model->raw + 16 + offs) : NULL; \ } while (0) _inline static unsigned char *_m3d_getidx(unsigned char *data, char type, M3D_INDEX *idx) { switch (type) { case 1: *idx = data[0] > 253 ? (int8_t)data[0] : data[0]; data++; break; case 2: *idx = *((uint16_t *)data) > 65533 ? *((int16_t *)data) : *((uint16_t *)data); data += 2; break; case 4: *idx = *((int32_t *)data); data += 4; break; } return data; } #ifndef M3D_NOANIMATION /* multiply 4 x 4 matrices. Do not use float *r[16] as argument, because some compilers misinterpret that as * 16 pointers each pointing to a float, but we need a single pointer to 16 floats. */ void _m3d_mul(M3D_FLOAT *r, M3D_FLOAT *a, M3D_FLOAT *b) { r[0] = b[0] * a[0] + b[4] * a[1] + b[8] * a[2] + b[12] * a[3]; r[1] = b[1] * a[0] + b[5] * a[1] + b[9] * a[2] + b[13] * a[3]; r[2] = b[2] * a[0] + b[6] * a[1] + b[10] * a[2] + b[14] * a[3]; r[3] = b[3] * a[0] + b[7] * a[1] + b[11] * a[2] + b[15] * a[3]; r[4] = b[0] * a[4] + b[4] * a[5] + b[8] * a[6] + b[12] * a[7]; r[5] = b[1] * a[4] + b[5] * a[5] + b[9] * a[6] + b[13] * a[7]; r[6] = b[2] * a[4] + b[6] * a[5] + b[10] * a[6] + b[14] * a[7]; r[7] = b[3] * a[4] + b[7] * a[5] + b[11] * a[6] + b[15] * a[7]; r[8] = b[0] * a[8] + b[4] * a[9] + b[8] * a[10] + b[12] * a[11]; r[9] = b[1] * a[8] + b[5] * a[9] + b[9] * a[10] + b[13] * a[11]; r[10] = b[2] * a[8] + b[6] * a[9] + b[10] * a[10] + b[14] * a[11]; r[11] = b[3] * a[8] + b[7] * a[9] + b[11] * a[10] + b[15] * a[11]; r[12] = b[0] * a[12] + b[4] * a[13] + b[8] * a[14] + b[12] * a[15]; r[13] = b[1] * a[12] + b[5] * a[13] + b[9] * a[14] + b[13] * a[15]; r[14] = b[2] * a[12] + b[6] * a[13] + b[10] * a[14] + b[14] * a[15]; r[15] = b[3] * a[12] + b[7] * a[13] + b[11] * a[14] + b[15] * a[15]; } /* calculate 4 x 4 matrix inverse */ void _m3d_inv(M3D_FLOAT *m) { M3D_FLOAT r[16]; M3D_FLOAT det = m[0] * m[5] * m[10] * m[15] - m[0] * m[5] * m[11] * m[14] + m[0] * m[6] * m[11] * m[13] - m[0] * m[6] * m[9] * m[15] + m[0] * m[7] * m[9] * m[14] - m[0] * m[7] * m[10] * m[13] - m[1] * m[6] * m[11] * m[12] + m[1] * m[6] * m[8] * m[15] - m[1] * m[7] * m[8] * m[14] + m[1] * m[7] * m[10] * m[12] - m[1] * m[4] * m[10] * m[15] + m[1] * m[4] * m[11] * m[14] + m[2] * m[7] * m[8] * m[13] - m[2] * m[7] * m[9] * m[12] + m[2] * m[4] * m[9] * m[15] - m[2] * m[4] * m[11] * m[13] + m[2] * m[5] * m[11] * m[12] - m[2] * m[5] * m[8] * m[15] - m[3] * m[4] * m[9] * m[14] + m[3] * m[4] * m[10] * m[13] - m[3] * m[5] * m[10] * m[12] + m[3] * m[5] * m[8] * m[14] - m[3] * m[6] * m[8] * m[13] + m[3] * m[6] * m[9] * m[12]; if (det == (M3D_FLOAT)0.0 || det == (M3D_FLOAT)-0.0) det = (M3D_FLOAT)1.0; else det = (M3D_FLOAT)1.0 / det; r[0] = det * (m[5] * (m[10] * m[15] - m[11] * m[14]) + m[6] * (m[11] * m[13] - m[9] * m[15]) + m[7] * (m[9] * m[14] - m[10] * m[13])); r[1] = -det * (m[1] * (m[10] * m[15] - m[11] * m[14]) + m[2] * (m[11] * m[13] - m[9] * m[15]) + m[3] * (m[9] * m[14] - m[10] * m[13])); r[2] = det * (m[1] * (m[6] * m[15] - m[7] * m[14]) + m[2] * (m[7] * m[13] - m[5] * m[15]) + m[3] * (m[5] * m[14] - m[6] * m[13])); r[3] = -det * (m[1] * (m[6] * m[11] - m[7] * m[10]) + m[2] * (m[7] * m[9] - m[5] * m[11]) + m[3] * (m[5] * m[10] - m[6] * m[9])); r[4] = -det * (m[4] * (m[10] * m[15] - m[11] * m[14]) + m[6] * (m[11] * m[12] - m[8] * m[15]) + m[7] * (m[8] * m[14] - m[10] * m[12])); r[5] = det * (m[0] * (m[10] * m[15] - m[11] * m[14]) + m[2] * (m[11] * m[12] - m[8] * m[15]) + m[3] * (m[8] * m[14] - m[10] * m[12])); r[6] = -det * (m[0] * (m[6] * m[15] - m[7] * m[14]) + m[2] * (m[7] * m[12] - m[4] * m[15]) + m[3] * (m[4] * m[14] - m[6] * m[12])); r[7] = det * (m[0] * (m[6] * m[11] - m[7] * m[10]) + m[2] * (m[7] * m[8] - m[4] * m[11]) + m[3] * (m[4] * m[10] - m[6] * m[8])); r[8] = det * (m[4] * (m[9] * m[15] - m[11] * m[13]) + m[5] * (m[11] * m[12] - m[8] * m[15]) + m[7] * (m[8] * m[13] - m[9] * m[12])); r[9] = -det * (m[0] * (m[9] * m[15] - m[11] * m[13]) + m[1] * (m[11] * m[12] - m[8] * m[15]) + m[3] * (m[8] * m[13] - m[9] * m[12])); r[10] = det * (m[0] * (m[5] * m[15] - m[7] * m[13]) + m[1] * (m[7] * m[12] - m[4] * m[15]) + m[3] * (m[4] * m[13] - m[5] * m[12])); r[11] = -det * (m[0] * (m[5] * m[11] - m[7] * m[9]) + m[1] * (m[7] * m[8] - m[4] * m[11]) + m[3] * (m[4] * m[9] - m[5] * m[8])); r[12] = -det * (m[4] * (m[9] * m[14] - m[10] * m[13]) + m[5] * (m[10] * m[12] - m[8] * m[14]) + m[6] * (m[8] * m[13] - m[9] * m[12])); r[13] = det * (m[0] * (m[9] * m[14] - m[10] * m[13]) + m[1] * (m[10] * m[12] - m[8] * m[14]) + m[2] * (m[8] * m[13] - m[9] * m[12])); r[14] = -det * (m[0] * (m[5] * m[14] - m[6] * m[13]) + m[1] * (m[6] * m[12] - m[4] * m[14]) + m[2] * (m[4] * m[13] - m[5] * m[12])); r[15] = det * (m[0] * (m[5] * m[10] - m[6] * m[9]) + m[1] * (m[6] * m[8] - m[4] * m[10]) + m[2] * (m[4] * m[9] - m[5] * m[8])); memcpy(m, &r, sizeof(r)); } /* compose a column major 4 x 4 matrix from vec3 position and vec4 orientation/rotation quaternion */ void _m3d_mat(M3D_FLOAT *r, m3dv_t *p, m3dv_t *q) { if (q->x == (M3D_FLOAT)0.0 && q->y == (M3D_FLOAT)0.0 && q->z >= (M3D_FLOAT)0.7071065 && q->z <= (M3D_FLOAT)0.7071075 && q->w == (M3D_FLOAT)0.0) { r[1] = r[2] = r[4] = r[6] = r[8] = r[9] = (M3D_FLOAT)0.0; r[0] = r[5] = r[10] = (M3D_FLOAT)-1.0; } else { r[0] = 1 - 2 * (q->y * q->y + q->z * q->z); if (r[0] > -M3D_EPSILON && r[0] < M3D_EPSILON) r[0] = (M3D_FLOAT)0.0; r[1] = 2 * (q->x * q->y - q->z * q->w); if (r[1] > -M3D_EPSILON && r[1] < M3D_EPSILON) r[1] = (M3D_FLOAT)0.0; r[2] = 2 * (q->x * q->z + q->y * q->w); if (r[2] > -M3D_EPSILON && r[2] < M3D_EPSILON) r[2] = (M3D_FLOAT)0.0; r[4] = 2 * (q->x * q->y + q->z * q->w); if (r[4] > -M3D_EPSILON && r[4] < M3D_EPSILON) r[4] = (M3D_FLOAT)0.0; r[5] = 1 - 2 * (q->x * q->x + q->z * q->z); if (r[5] > -M3D_EPSILON && r[5] < M3D_EPSILON) r[5] = (M3D_FLOAT)0.0; r[6] = 2 * (q->y * q->z - q->x * q->w); if (r[6] > -M3D_EPSILON && r[6] < M3D_EPSILON) r[6] = (M3D_FLOAT)0.0; r[8] = 2 * (q->x * q->z - q->y * q->w); if (r[8] > -M3D_EPSILON && r[8] < M3D_EPSILON) r[8] = (M3D_FLOAT)0.0; r[9] = 2 * (q->y * q->z + q->x * q->w); if (r[9] > -M3D_EPSILON && r[9] < M3D_EPSILON) r[9] = (M3D_FLOAT)0.0; r[10] = 1 - 2 * (q->x * q->x + q->y * q->y); if (r[10] > -M3D_EPSILON && r[10] < M3D_EPSILON) r[10] = (M3D_FLOAT)0.0; } r[3] = p->x; r[7] = p->y; r[11] = p->z; r[12] = 0; r[13] = 0; r[14] = 0; r[15] = 1; } #endif #if !defined(M3D_NOANIMATION) || !defined(M3D_NONORMALS) /* portable fast inverse square root calculation. returns 1/sqrt(x) */ static M3D_FLOAT _m3d_rsq(M3D_FLOAT x) { #ifdef M3D_DOUBLE return ((M3D_FLOAT)15.0 / (M3D_FLOAT)8.0) + ((M3D_FLOAT)-5.0 / (M3D_FLOAT)4.0) * x + ((M3D_FLOAT)3.0 / (M3D_FLOAT)8.0) * x * x; #else /* <NAME>'s */ float x2 = x * 0.5f; *((uint32_t *)&x) = (0x5f3759df - (*((uint32_t *)&x) >> 1)); return x * (1.5f - (x2 * x * x)); #endif } #endif /** * Function to decode a Model 3D into in-memory format */ m3d_t *m3d_load(unsigned char *data, m3dread_t readfilecb, m3dfree_t freecb, m3d_t *mtllib) { unsigned char *end, *chunk, *buff, weights[8]; unsigned int i, j, k, l, n, am, len = 0, reclen, offs; char *name, *lang; float f; m3d_t *model; M3D_INDEX mi; M3D_FLOAT w; m3dcd_t *cd; m3dtx_t *tx; m3dh_t *h; m3dm_t *m; m3da_t *a; m3di_t *t; #ifndef M3D_NONORMALS char neednorm = 0; m3dv_t *norm = NULL, *v0, *v1, *v2, va, vb; #endif #ifndef M3D_NOANIMATION M3D_FLOAT r[16]; #endif #if !defined(M3D_NOWEIGHTS) || !defined(M3D_NOANIMATION) m3db_t *b; #endif #ifndef M3D_NOWEIGHTS m3ds_t *sk; #endif m3ds_t s; M3D_INDEX bi[M3D_BONEMAXLEVEL + 1], level; const char *ol; char *ptr, *pe, *fn; #ifdef M3D_PROFILING struct timeval tv0, tv1, tvd; gettimeofday(&tv0, NULL); #endif if (!data || (!M3D_CHUNKMAGIC(data, '3', 'D', 'M', 'O') && !M3D_CHUNKMAGIC(data, '3', 'd', 'm', 'o') )) return NULL; model = (m3d_t *)M3D_MALLOC(sizeof(m3d_t)); if (!model) { M3D_LOG("Out of memory"); return NULL; } memset(model, 0, sizeof(m3d_t)); if (mtllib) { model->nummaterial = mtllib->nummaterial; model->material = mtllib->material; model->numtexture = mtllib->numtexture; model->texture = mtllib->texture; model->flags |= M3D_FLG_MTLLIB; } /* ASCII variant? */ if (M3D_CHUNKMAGIC(data, '3', 'd', 'm', 'o')) { model->errcode = M3D_ERR_BADFILE; model->flags |= M3D_FLG_FREESTR; model->raw = (m3dhdr_t *)data; ptr = (char *)data; ol = setlocale(LC_NUMERIC, NULL); setlocale(LC_NUMERIC, "C"); /* parse header. Don't use sscanf, that's incredibly slow */ ptr = _m3d_findarg(ptr); if (!*ptr || *ptr == '\r' || *ptr == '\n') goto asciiend; pe = _m3d_findnl(ptr); model->scale = (float)strtod(ptr, NULL); ptr = pe; if (model->scale <= (M3D_FLOAT)0.0) model->scale = (M3D_FLOAT)1.0; model->name = _m3d_safestr(ptr, 2); ptr = _m3d_findnl(ptr); if (!*ptr) goto asciiend; model->license = _m3d_safestr(ptr, 2); ptr = _m3d_findnl(ptr); if (!*ptr) goto asciiend; model->author = _m3d_safestr(ptr, 2); ptr = _m3d_findnl(ptr); if (!*ptr) goto asciiend; if (*ptr != '\r' && *ptr != '\n') model->desc = _m3d_safestr(ptr, 3); while (*ptr) { while (*ptr && *ptr != '\n') ptr++; ptr++; if (*ptr == '\r') ptr++; if (*ptr == '\n') break; } /* the main chunk reader loop */ while (*ptr) { while (*ptr && (*ptr == '\r' || *ptr == '\n')) ptr++; if (!*ptr || (ptr[0] == 'E' && ptr[1] == 'n' && ptr[2] == 'd')) break; /* make sure there's at least one data row */ pe = ptr; ptr = _m3d_findnl(ptr); if (!*ptr || *ptr == '\r' || *ptr == '\n') goto asciiend; /* Preview chunk */ if (!memcmp(pe, "Preview", 7)) { if (readfilecb) { pe = _m3d_safestr(ptr, 0); if (!pe || !*pe) goto asciiend; model->preview.data = (*readfilecb)(pe, &model->preview.length); M3D_FREE(pe); } while (*ptr && *ptr != '\r' && *ptr != '\n') ptr = _m3d_findnl(ptr); } else /* texture map chunk */ if (!memcmp(pe, "Textmap", 7)) { if (model->tmap) { M3D_LOG("More texture map chunks, should be unique"); goto asciiend; } while (*ptr && *ptr != '\r' && *ptr != '\n') { i = model->numtmap++; model->tmap = (m3dti_t *)M3D_REALLOC(model->tmap, model->numtmap * sizeof(m3dti_t)); if (!model->tmap) goto memerr; ptr = _m3d_getfloat(ptr, &model->tmap[i].u); if (!*ptr || *ptr == '\r' || *ptr == '\n') goto asciiend; _m3d_getfloat(ptr, &model->tmap[i].v); ptr = _m3d_findnl(ptr); } } else /* vertex chunk */ if (!memcmp(pe, "Vertex", 6)) { if (model->vertex) { M3D_LOG("More vertex chunks, should be unique"); goto asciiend; } while (*ptr && *ptr != '\r' && *ptr != '\n') { i = model->numvertex++; model->vertex = (m3dv_t *)M3D_REALLOC(model->vertex, model->numvertex * sizeof(m3dv_t)); if (!model->vertex) goto memerr; memset(&model->vertex[i], 0, sizeof(m3dv_t)); model->vertex[i].skinid = M3D_UNDEF; model->vertex[i].color = 0; model->vertex[i].w = (M3D_FLOAT)1.0; ptr = _m3d_getfloat(ptr, &model->vertex[i].x); if (!*ptr || *ptr == '\r' || *ptr == '\n') goto asciiend; ptr = _m3d_getfloat(ptr, &model->vertex[i].y); if (!*ptr || *ptr == '\r' || *ptr == '\n') goto asciiend; ptr = _m3d_getfloat(ptr, &model->vertex[i].z); if (!*ptr || *ptr == '\r' || *ptr == '\n') goto asciiend; ptr = _m3d_getfloat(ptr, &model->vertex[i].w); if (!*ptr) goto asciiend; if (*ptr == '#') { ptr = _m3d_gethex(ptr, &model->vertex[i].color); if (!*ptr) goto asciiend; } /* parse skin */ memset(&s, 0, sizeof(m3ds_t)); for (j = 0, w = (M3D_FLOAT)0.0; j < M3D_NUMBONE && *ptr && *ptr != '\r' && *ptr != '\n'; j++) { ptr = _m3d_findarg(ptr); if (!*ptr || *ptr == '\r' || *ptr == '\n') goto asciiend; ptr = _m3d_getint(ptr, &k); s.boneid[j] = (M3D_INDEX)k; if (*ptr == ':') { ptr++; ptr = _m3d_getfloat(ptr, &s.weight[j]); w += s.weight[j]; } else if (!j) s.weight[j] = (M3D_FLOAT)1.0; if (!*ptr) goto asciiend; } if (s.boneid[0] != M3D_UNDEF && s.weight[0] > (M3D_FLOAT)0.0) { if (w != (M3D_FLOAT)1.0 && w != (M3D_FLOAT)0.0) for (j = 0; j < M3D_NUMBONE && s.weight[j] > (M3D_FLOAT)0.0; j++) s.weight[j] /= w; k = M3D_NOTDEFINED; if (model->skin) { for (j = 0; j < model->numskin; j++) if (!memcmp(&model->skin[j], &s, sizeof(m3ds_t))) { k = j; break; } } if (k == M3D_NOTDEFINED) { k = model->numskin++; model->skin = (m3ds_t *)M3D_REALLOC(model->skin, model->numskin * sizeof(m3ds_t)); memcpy(&model->skin[k], &s, sizeof(m3ds_t)); } model->vertex[i].skinid = (M3D_INDEX)k; } ptr = _m3d_findnl(ptr); } } else /* Skeleton, bone hierarchy */ if (!memcmp(pe, "Bones", 5)) { if (model->bone) { M3D_LOG("More bones chunks, should be unique"); goto asciiend; } bi[0] = M3D_UNDEF; while (*ptr && *ptr != '\r' && *ptr != '\n') { i = model->numbone++; model->bone = (m3db_t *)M3D_REALLOC(model->bone, model->numbone * sizeof(m3db_t)); if (!model->bone) goto memerr; for (level = 0; *ptr == '/'; ptr++, level++) ; if (level > M3D_BONEMAXLEVEL || !*ptr || *ptr == '\r' || *ptr == '\n') goto asciiend; bi[level + 1] = i; model->bone[i].numweight = 0; model->bone[i].weight = NULL; model->bone[i].parent = bi[level]; ptr = _m3d_getint(ptr, &k); ptr = _m3d_findarg(ptr); if (!*ptr || *ptr == '\r' || *ptr == '\n') goto asciiend; model->bone[i].pos = (M3D_INDEX)k; ptr = _m3d_getint(ptr, &k); ptr = _m3d_findarg(ptr); if (!*ptr || *ptr == '\r' || *ptr == '\n') goto asciiend; model->bone[i].ori = (M3D_INDEX)k; model->vertex[k].skinid = M3D_INDEXMAX; pe = _m3d_safestr(ptr, 0); if (!pe || !*pe) goto asciiend; model->bone[i].name = pe; ptr = _m3d_findnl(ptr); } } else /* material chunk */ if (!memcmp(pe, "Material", 8)) { pe = _m3d_findarg(pe); if (!*pe || *pe == '\r' || *pe == '\n') goto asciiend; pe = _m3d_safestr(pe, 0); if (!pe || !*pe) goto asciiend; for (i = 0; i < model->nummaterial; i++) if (!strcmp(pe, model->material[i].name)) { M3D_LOG("Multiple definitions for material"); M3D_LOG(pe); M3D_FREE(pe); pe = NULL; while (*ptr && *ptr != '\r' && *ptr != '\n') ptr = _m3d_findnl(ptr); break; } if (!pe) continue; i = model->nummaterial++; if (model->flags & M3D_FLG_MTLLIB) { m = model->material; model->material = (m3dm_t *)M3D_MALLOC(model->nummaterial * sizeof(m3dm_t)); if (!model->material) goto memerr; memcpy(model->material, m, (model->nummaterial - 1) * sizeof(m3dm_t)); if (model->texture) { tx = model->texture; model->texture = (m3dtx_t *)M3D_MALLOC(model->numtexture * sizeof(m3dtx_t)); if (!model->texture) goto memerr; memcpy(model->texture, tx, model->numtexture * sizeof(m3dm_t)); } model->flags &= ~M3D_FLG_MTLLIB; } else { model->material = (m3dm_t *)M3D_REALLOC(model->material, model->nummaterial * sizeof(m3dm_t)); if (!model->material) goto memerr; } m = &model->material[i]; m->name = pe; m->numprop = 0; m->prop = NULL; while (*ptr && *ptr != '\r' && *ptr != '\n') { k = n = 256; if (*ptr == 'm' && *(ptr + 1) == 'a' && *(ptr + 2) == 'p' && *(ptr + 3) == '_') { k = m3dpf_map; ptr += 4; } for (j = 0; j < sizeof(m3d_propertytypes) / sizeof(m3d_propertytypes[0]); j++) if (!memcmp(ptr, m3d_propertytypes[j].key, strlen(m3d_propertytypes[j].key))) { n = m3d_propertytypes[j].id; if (k != m3dpf_map) k = m3d_propertytypes[j].format; break; } if (n != 256 && k != 256) { ptr = _m3d_findarg(ptr); if (!*ptr || *ptr == '\r' || *ptr == '\n') goto asciiend; j = m->numprop++; m->prop = (m3dp_t *)M3D_REALLOC(m->prop, m->numprop * sizeof(m3dp_t)); if (!m->prop) goto memerr; m->prop[j].type = n + (k == m3dpf_map && n < 128 ? 128 : 0); switch (k) { case m3dpf_color: ptr = _m3d_gethex(ptr, &m->prop[j].value.color); break; case m3dpf_uint8: case m3dpf_uint16: case m3dpf_uint32: ptr = _m3d_getint(ptr, &m->prop[j].value.num); break; case m3dpf_float: ptr = _m3d_getfloat(ptr, &m->prop[j].value.fnum); break; case m3dpf_map: pe = _m3d_safestr(ptr, 0); if (!pe || !*pe) goto asciiend; m->prop[j].value.textureid = _m3d_gettx(model, readfilecb, freecb, pe); if (model->errcode == M3D_ERR_ALLOC) { M3D_FREE(pe); goto memerr; } /* this error code only returned if readfilecb was specified */ if (m->prop[j].value.textureid == M3D_UNDEF) { M3D_LOG("Texture not found"); M3D_LOG(pe); m->numprop--; } M3D_FREE(pe); break; } } else { M3D_LOG("Unknown material property in"); M3D_LOG(m->name); model->errcode = M3D_ERR_UNKPROP; } ptr = _m3d_findnl(ptr); } if (!m->numprop) model->nummaterial--; } else /* procedural */ if (!memcmp(pe, "Procedural", 10)) { pe = _m3d_safestr(ptr, 0); _m3d_getpr(model, readfilecb, freecb, pe); M3D_FREE(pe); while (*ptr && *ptr != '\r' && *ptr != '\n') ptr = _m3d_findnl(ptr); } else /* mesh */ if (!memcmp(pe, "Mesh", 4)) { mi = M3D_UNDEF; while (*ptr && *ptr != '\r' && *ptr != '\n') { if (*ptr == 'u') { ptr = _m3d_findarg(ptr); if (!*ptr) goto asciiend; mi = M3D_UNDEF; if (*ptr != '\r' && *ptr != '\n') { pe = _m3d_safestr(ptr, 0); if (!pe || !*pe) goto asciiend; for (j = 0; j < model->nummaterial; j++) if (!strcmp(pe, model->material[j].name)) { mi = (M3D_INDEX)j; break; } if (mi == M3D_UNDEF && !(model->flags & M3D_FLG_MTLLIB)) { mi = model->nummaterial++; model->material = (m3dm_t *)M3D_REALLOC(model->material, model->nummaterial * sizeof(m3dm_t)); if (!model->material) goto memerr; model->material[mi].name = pe; model->material[mi].numprop = 1; model->material[mi].prop = NULL; } else M3D_FREE(pe); } } else { i = model->numface++; model->face = (m3df_t *)M3D_REALLOC(model->face, model->numface * sizeof(m3df_t)); if (!model->face) goto memerr; memset(&model->face[i], 255, sizeof(m3df_t)); /* set all index to -1 by default */ model->face[i].materialid = mi; /* hardcoded triangles. */ for (j = 0; j < 3; j++) { /* vertex */ ptr = _m3d_getint(ptr, &k); model->face[i].vertex[j] = (M3D_INDEX)k; if (!*ptr) goto asciiend; if (*ptr == '/') { ptr++; if (*ptr != '/') { /* texcoord */ ptr = _m3d_getint(ptr, &k); model->face[i].texcoord[j] = (M3D_INDEX)k; if (!*ptr) goto asciiend; } if (*ptr == '/') { ptr++; /* normal */ ptr = _m3d_getint(ptr, &k); model->face[i].normal[j] = (M3D_INDEX)k; if (!*ptr) goto asciiend; } } #ifndef M3D_NONORMALS if (model->face[i].normal[j] == M3D_UNDEF) neednorm = 1; #endif ptr = _m3d_findarg(ptr); } } ptr = _m3d_findnl(ptr); } } else /* mathematical shape */ if (!memcmp(pe, "Shape", 5)) { pe = _m3d_findarg(pe); if (!*pe || *pe == '\r' || *pe == '\n') goto asciiend; pe = _m3d_safestr(pe, 0); if (!pe || !*pe) goto asciiend; i = model->numshape++; model->shape = (m3dh_t *)M3D_REALLOC(model->shape, model->numshape * sizeof(m3ds_t)); if (!model->shape) goto memerr; h = &model->shape[i]; h->name = pe; h->group = M3D_UNDEF; h->numcmd = 0; h->cmd = NULL; while (*ptr && *ptr != '\r' && *ptr != '\n') { if (!memcmp(ptr, "group", 5)) { ptr = _m3d_findarg(ptr); ptr = _m3d_getint(ptr, &h->group); ptr = _m3d_findnl(ptr); if (h->group != M3D_UNDEF && h->group >= model->numbone) { M3D_LOG("Unknown bone id as shape group in shape"); M3D_LOG(pe); h->group = M3D_UNDEF; model->errcode = M3D_ERR_SHPE; } continue; } for (cd = NULL, k = 0; k < (unsigned int)(sizeof(m3d_commandtypes) / sizeof(m3d_commandtypes[0])); k++) { j = (unsigned int)strlen(m3d_commandtypes[k].key); if (!memcmp(ptr, m3d_commandtypes[k].key, j) && (ptr[j] == ' ' || ptr[j] == '\r' || ptr[j] == '\n')) { cd = &m3d_commandtypes[k]; break; } } if (cd) { j = h->numcmd++; h->cmd = (m3dc_t *)M3D_REALLOC(h->cmd, h->numcmd * sizeof(m3dc_t)); if (!h->cmd) goto memerr; h->cmd[j].type = k; h->cmd[j].arg = (uint32_t *)M3D_MALLOC(cd->p * sizeof(uint32_t)); if (!h->cmd[j].arg) goto memerr; memset(h->cmd[j].arg, 0, cd->p * sizeof(uint32_t)); for (k = n = 0, l = cd->p; k < l; k++) { ptr = _m3d_findarg(ptr); if (!*ptr) goto asciiend; if (*ptr == '[') { ptr = _m3d_findarg(ptr + 1); if (!*ptr) goto asciiend; } if (*ptr == ']' || *ptr == '\r' || *ptr == '\n') break; switch (cd->a[((k - n) % (cd->p - n)) + n]) { case m3dcp_mi_t: mi = M3D_UNDEF; if (*ptr != '\r' && *ptr != '\n') { pe = _m3d_safestr(ptr, 0); if (!pe || !*pe) goto asciiend; for (n = 0; n < model->nummaterial; n++) if (!strcmp(pe, model->material[n].name)) { mi = (M3D_INDEX)n; break; } if (mi == M3D_UNDEF && !(model->flags & M3D_FLG_MTLLIB)) { mi = model->nummaterial++; model->material = (m3dm_t *)M3D_REALLOC(model->material, model->nummaterial * sizeof(m3dm_t)); if (!model->material) goto memerr; model->material[mi].name = pe; model->material[mi].numprop = 1; model->material[mi].prop = NULL; } else M3D_FREE(pe); } h->cmd[j].arg[k] = mi; break; case m3dcp_vc_t: _m3d_getfloat(ptr, &w); h->cmd[j].arg[k] = *((uint32_t *)&w); break; case m3dcp_va_t: ptr = _m3d_getint(ptr, &h->cmd[j].arg[k]); n = k + 1; l += (h->cmd[j].arg[k] - 1) * (cd->p - k - 1); h->cmd[j].arg = (uint32_t *)M3D_REALLOC(h->cmd[j].arg, l * sizeof(uint32_t)); if (!h->cmd[j].arg) goto memerr; memset(&h->cmd[j].arg[k + 1], 0, (l - k - 1) * sizeof(uint32_t)); break; case m3dcp_qi_t: ptr = _m3d_getint(ptr, &h->cmd[j].arg[k]); model->vertex[h->cmd[i].arg[k]].skinid = M3D_INDEXMAX; break; default: ptr = _m3d_getint(ptr, &h->cmd[j].arg[k]); break; } } } else { M3D_LOG("Unknown shape command in"); M3D_LOG(h->name); model->errcode = M3D_ERR_UNKCMD; } ptr = _m3d_findnl(ptr); } if (!h->numcmd) model->numshape--; } else /* annotation labels */ if (!memcmp(pe, "Labels", 6)) { pe = _m3d_findarg(pe); if (!*pe) goto asciiend; if (*pe == '\r' || *pe == '\n') pe = NULL; else pe = _m3d_safestr(pe, 0); k = 0; fn = NULL; while (*ptr && *ptr != '\r' && *ptr != '\n') { if (*ptr == 'c') { ptr = _m3d_findarg(ptr); if (!*pe || *pe == '\r' || *pe == '\n') goto asciiend; ptr = _m3d_gethex(ptr, &k); } else if (*ptr == 'l') { ptr = _m3d_findarg(ptr); if (!*pe || *pe == '\r' || *pe == '\n') goto asciiend; fn = _m3d_safestr(ptr, 2); } else { i = model->numlabel++; model->label = (m3dl_t *)M3D_REALLOC(model->label, model->numlabel * sizeof(m3dl_t)); if (!model->label) goto memerr; model->label[i].name = pe; model->label[i].lang = fn; model->label[i].color = k; ptr = _m3d_getint(ptr, &j); model->label[i].vertexid = (M3D_INDEX)j; ptr = _m3d_findarg(ptr); if (!*pe || *pe == '\r' || *pe == '\n') goto asciiend; model->label[i].text = _m3d_safestr(ptr, 2); } ptr = _m3d_findnl(ptr); } } else /* action */ if (!memcmp(pe, "Action", 6)) { pe = _m3d_findarg(pe); if (!*pe || *pe == '\r' || *pe == '\n') goto asciiend; pe = _m3d_getint(pe, &k); pe = _m3d_findarg(pe); if (!*pe || *pe == '\r' || *pe == '\n') goto asciiend; pe = _m3d_safestr(pe, 0); if (!pe || !*pe) goto asciiend; i = model->numaction++; model->action = (m3da_t *)M3D_REALLOC(model->action, model->numaction * sizeof(m3da_t)); if (!model->action) goto memerr; a = &model->action[i]; a->name = pe; a->durationmsec = k; /* skip the first frame marker as there's always at least one frame */ a->numframe = 1; a->frame = (m3dfr_t *)M3D_MALLOC(sizeof(m3dfr_t)); if (!a->frame) goto memerr; a->frame[0].msec = 0; a->frame[0].numtransform = 0; a->frame[0].transform = NULL; i = 0; if (*ptr == 'f') ptr = _m3d_findnl(ptr); while (*ptr && *ptr != '\r' && *ptr != '\n') { if (*ptr == 'f') { i = a->numframe++; a->frame = (m3dfr_t *)M3D_REALLOC(a->frame, a->numframe * sizeof(m3dfr_t)); if (!a->frame) goto memerr; ptr = _m3d_findarg(ptr); ptr = _m3d_getint(ptr, &a->frame[i].msec); a->frame[i].numtransform = 0; a->frame[i].transform = NULL; } else { j = a->frame[i].numtransform++; a->frame[i].transform = (m3dtr_t *)M3D_REALLOC(a->frame[i].transform, a->frame[i].numtransform * sizeof(m3dtr_t)); if (!a->frame[i].transform) goto memerr; ptr = _m3d_getint(ptr, &k); ptr = _m3d_findarg(ptr); if (!*ptr || *ptr == '\r' || *ptr == '\n') goto asciiend; a->frame[i].transform[j].boneid = (M3D_INDEX)k; ptr = _m3d_getint(ptr, &k); ptr = _m3d_findarg(ptr); if (!*ptr || *ptr == '\r' || *ptr == '\n') goto asciiend; a->frame[i].transform[j].pos = (M3D_INDEX)k; ptr = _m3d_getint(ptr, &k); if (!*ptr || *ptr == '\r' || *ptr == '\n') goto asciiend; a->frame[i].transform[j].ori = (M3D_INDEX)k; model->vertex[k].skinid = M3D_INDEXMAX; } ptr = _m3d_findnl(ptr); } } else /* inlined assets chunk */ if (!memcmp(pe, "Assets", 6)) { while (*ptr && *ptr != '\r' && *ptr != '\n') { if (readfilecb) { pe = _m3d_safestr(ptr, 2); if (!pe || !*pe) goto asciiend; i = model->numinlined++; model->inlined = (m3di_t *)M3D_REALLOC(model->inlined, model->numinlined * sizeof(m3di_t)); if (!model->inlined) goto memerr; t = &model->inlined[i]; model->inlined[i].data = (*readfilecb)(pe, &model->inlined[i].length); if (model->inlined[i].data) { fn = strrchr(pe, '.'); if (fn && (fn[1] == 'p' || fn[1] == 'P') && (fn[2] == 'n' || fn[2] == 'N') && (fn[3] == 'g' || fn[3] == 'G')) *fn = 0; fn = strrchr(pe, '/'); if (!fn) fn = strrchr(pe, '\\'); if (!fn) fn = pe; else fn++; model->inlined[i].name = _m3d_safestr(fn, 0); } else model->numinlined--; M3D_FREE(pe); } ptr = _m3d_findnl(ptr); } } else /* extra chunks */ if (!memcmp(pe, "Extra", 5)) { pe = _m3d_findarg(pe); if (!*pe || *pe == '\r' || *pe == '\n') goto asciiend; buff = (unsigned char *)_m3d_findnl(ptr); k = ((uint32_t)((uintptr_t)buff - (uintptr_t)ptr) / 3) + 1; i = model->numextra++; model->extra = (m3dchunk_t **)M3D_REALLOC(model->extra, model->numextra * sizeof(m3dchunk_t *)); if (!model->extra) goto memerr; model->extra[i] = (m3dchunk_t *)M3D_MALLOC(k + sizeof(m3dchunk_t)); if (!model->extra[i]) goto memerr; memcpy(&model->extra[i]->magic, pe, 4); model->extra[i]->length = sizeof(m3dchunk_t); pe = (char *)model->extra[i] + sizeof(m3dchunk_t); while (*ptr && *ptr != '\r' && *ptr != '\n') { ptr = _m3d_gethex(ptr, &k); *pe++ = (uint8_t)k; model->extra[i]->length++; } } else goto asciiend; } model->errcode = M3D_SUCCESS; asciiend: setlocale(LC_NUMERIC, ol); goto postprocess; } /* Binary variant */ if (!M3D_CHUNKMAGIC(data + 8, 'H', 'E', 'A', 'D')) { buff = (unsigned char *)stbi_zlib_decode_malloc_guesssize_headerflag((const char *)data + 8, ((m3dchunk_t *)data)->length - 8, 4096, (int *)&len, 1); if (!buff || !len || !M3D_CHUNKMAGIC(buff, 'H', 'E', 'A', 'D')) { if (buff) M3D_FREE(buff); M3D_FREE(model); return NULL; } buff = (unsigned char *)M3D_REALLOC(buff, len); model->flags |= M3D_FLG_FREERAW; /* mark that we have to free the raw buffer */ data = buff; #ifdef M3D_PROFILING gettimeofday(&tv1, NULL); tvd.tv_sec = tv1.tv_sec - tv0.tv_sec; tvd.tv_usec = tv1.tv_usec - tv0.tv_usec; if (tvd.tv_usec < 0) { tvd.tv_sec--; tvd.tv_usec += 1000000L; } printf(" Deflate model %ld.%06ld sec\n", tvd.tv_sec, tvd.tv_usec); memcpy(&tv0, &tv1, sizeof(struct timeval)); #endif } else { len = ((m3dhdr_t *)data)->length; data += 8; } model->raw = (m3dhdr_t *)data; end = data + len; /* parse header */ data += sizeof(m3dhdr_t); M3D_LOG(data); model->name = (char *)data; for (; data < end && *data; data++) { }; data++; model->license = (char *)data; for (; data < end && *data; data++) { }; data++; model->author = (char *)data; for (; data < end && *data; data++) { }; data++; model->desc = (char *)data; chunk = (unsigned char *)model->raw + model->raw->length; model->scale = (M3D_FLOAT)model->raw->scale; if (model->scale <= (M3D_FLOAT)0.0) model->scale = (M3D_FLOAT)1.0; model->vc_s = 1 << ((model->raw->types >> 0) & 3); /* vertex coordinate size */ model->vi_s = 1 << ((model->raw->types >> 2) & 3); /* vertex index size */ model->si_s = 1 << ((model->raw->types >> 4) & 3); /* string offset size */ model->ci_s = 1 << ((model->raw->types >> 6) & 3); /* color index size */ model->ti_s = 1 << ((model->raw->types >> 8) & 3); /* tmap index size */ model->bi_s = 1 << ((model->raw->types >> 10) & 3); /* bone index size */ model->nb_s = 1 << ((model->raw->types >> 12) & 3); /* number of bones per vertex */ model->sk_s = 1 << ((model->raw->types >> 14) & 3); /* skin index size */ model->fc_s = 1 << ((model->raw->types >> 16) & 3); /* frame counter size */ model->hi_s = 1 << ((model->raw->types >> 18) & 3); /* shape index size */ model->fi_s = 1 << ((model->raw->types >> 20) & 3); /* face index size */ if (model->ci_s == 8) model->ci_s = 0; /* optional indices */ if (model->ti_s == 8) model->ti_s = 0; if (model->bi_s == 8) model->bi_s = 0; if (model->sk_s == 8) model->sk_s = 0; if (model->fc_s == 8) model->fc_s = 0; if (model->hi_s == 8) model->hi_s = 0; if (model->fi_s == 8) model->fi_s = 0; /* variable limit checks */ if (sizeof(M3D_FLOAT) == 4 && model->vc_s > 4) { M3D_LOG("Double precision coordinates not supported, truncating to float..."); model->errcode = M3D_ERR_TRUNC; } if (sizeof(M3D_INDEX) == 2 && (model->vi_s > 2 || model->si_s > 2 || model->ci_s > 2 || model->ti_s > 2 || model->bi_s > 2 || model->sk_s > 2 || model->fc_s > 2 || model->hi_s > 2 || model->fi_s > 2)) { M3D_LOG("32 bit indices not supported, unable to load model"); M3D_FREE(model); return NULL; } if (model->vi_s > 4 || model->si_s > 4) { M3D_LOG("Invalid index size, unable to load model"); M3D_FREE(model); return NULL; } if (model->nb_s > M3D_NUMBONE) { M3D_LOG("Model has more bones per vertex than what importer was configured to support"); model->errcode = M3D_ERR_TRUNC; } /* look for inlined assets in advance, material and procedural chunks may need them */ buff = chunk; while (buff < end && !M3D_CHUNKMAGIC(buff, 'O', 'M', 'D', '3')) { data = buff; len = ((m3dchunk_t *)data)->length; buff += len; if (len < sizeof(m3dchunk_t) || buff >= end) { M3D_LOG("Invalid chunk size"); break; } len -= sizeof(m3dchunk_t) + model->si_s; /* inlined assets */ if (M3D_CHUNKMAGIC(data, 'A', 'S', 'E', 'T') && len > 0) { M3D_LOG("Inlined asset"); i = model->numinlined++; model->inlined = (m3di_t *)M3D_REALLOC(model->inlined, model->numinlined * sizeof(m3di_t)); if (!model->inlined) { memerr: M3D_LOG("Out of memory"); model->errcode = M3D_ERR_ALLOC; return model; } data += sizeof(m3dchunk_t); t = &model->inlined[i]; M3D_GETSTR(t->name); M3D_LOG(t->name); t->data = (uint8_t *)data; t->length = len; } } /* parse chunks */ while (chunk < end && !M3D_CHUNKMAGIC(chunk, 'O', 'M', 'D', '3')) { data = chunk; len = ((m3dchunk_t *)chunk)->length; chunk += len; if (len < sizeof(m3dchunk_t) || chunk >= end) { M3D_LOG("Invalid chunk size"); break; } len -= sizeof(m3dchunk_t); /* preview chunk */ if (M3D_CHUNKMAGIC(data, 'P', 'R', 'V', 'W') && len > 0) { model->preview.length = len; model->preview.data = data + sizeof(m3dchunk_t); } else /* color map */ if (M3D_CHUNKMAGIC(data, 'C', 'M', 'A', 'P')) { M3D_LOG("Color map"); if (model->cmap) { M3D_LOG("More color map chunks, should be unique"); model->errcode = M3D_ERR_CMAP; continue; } if (!model->ci_s) { M3D_LOG("Color map chunk, shouldn't be any"); model->errcode = M3D_ERR_CMAP; continue; } model->numcmap = len / sizeof(uint32_t); model->cmap = (uint32_t *)(data + sizeof(m3dchunk_t)); } else /* texture map */ if (M3D_CHUNKMAGIC(data, 'T', 'M', 'A', 'P')) { M3D_LOG("Texture map"); if (model->tmap) { M3D_LOG("More texture map chunks, should be unique"); model->errcode = M3D_ERR_TMAP; continue; } if (!model->ti_s) { M3D_LOG("Texture map chunk, shouldn't be any"); model->errcode = M3D_ERR_TMAP; continue; } reclen = model->vc_s + model->vc_s; model->numtmap = len / reclen; model->tmap = (m3dti_t *)M3D_MALLOC(model->numtmap * sizeof(m3dti_t)); if (!model->tmap) goto memerr; for (i = 0, data += sizeof(m3dchunk_t); data < chunk; i++) { switch (model->vc_s) { case 1: model->tmap[i].u = (M3D_FLOAT)(data[0]) / (M3D_FLOAT)255.0; model->tmap[i].v = (M3D_FLOAT)(data[1]) / (M3D_FLOAT)255.0; break; case 2: model->tmap[i].u = (M3D_FLOAT)(*((int16_t *)(data + 0))) / (M3D_FLOAT)65535.0; model->tmap[i].v = (M3D_FLOAT)(*((int16_t *)(data + 2))) / (M3D_FLOAT)65535.0; break; case 4: model->tmap[i].u = (M3D_FLOAT)(*((float *)(data + 0))); model->tmap[i].v = (M3D_FLOAT)(*((float *)(data + 4))); break; case 8: model->tmap[i].u = (M3D_FLOAT)(*((double *)(data + 0))); model->tmap[i].v = (M3D_FLOAT)(*((double *)(data + 8))); break; } data += reclen; } } else /* vertex list */ if (M3D_CHUNKMAGIC(data, 'V', 'R', 'T', 'S')) { M3D_LOG("Vertex list"); if (model->vertex) { M3D_LOG("More vertex chunks, should be unique"); model->errcode = M3D_ERR_VRTS; continue; } if (model->ci_s && model->ci_s < 4 && !model->cmap) model->errcode = M3D_ERR_CMAP; reclen = model->ci_s + model->sk_s + 4 * model->vc_s; model->numvertex = len / reclen; model->vertex = (m3dv_t *)M3D_MALLOC(model->numvertex * sizeof(m3dv_t)); if (!model->vertex) goto memerr; memset(model->vertex, 0, model->numvertex * sizeof(m3dv_t)); for (i = 0, data += sizeof(m3dchunk_t); data < chunk && i < model->numvertex; i++) { switch (model->vc_s) { case 1: model->vertex[i].x = (M3D_FLOAT)((int8_t)data[0]) / (M3D_FLOAT)127.0; model->vertex[i].y = (M3D_FLOAT)((int8_t)data[1]) / (M3D_FLOAT)127.0; model->vertex[i].z = (M3D_FLOAT)((int8_t)data[2]) / (M3D_FLOAT)127.0; model->vertex[i].w = (M3D_FLOAT)((int8_t)data[3]) / (M3D_FLOAT)127.0; data += 4; break; case 2: model->vertex[i].x = (M3D_FLOAT)(*((int16_t *)(data + 0))) / (M3D_FLOAT)32767.0; model->vertex[i].y = (M3D_FLOAT)(*((int16_t *)(data + 2))) / (M3D_FLOAT)32767.0; model->vertex[i].z = (M3D_FLOAT)(*((int16_t *)(data + 4))) / (M3D_FLOAT)32767.0; model->vertex[i].w = (M3D_FLOAT)(*((int16_t *)(data + 6))) / (M3D_FLOAT)32767.0; data += 8; break; case 4: model->vertex[i].x = (M3D_FLOAT)(*((float *)(data + 0))); model->vertex[i].y = (M3D_FLOAT)(*((float *)(data + 4))); model->vertex[i].z = (M3D_FLOAT)(*((float *)(data + 8))); model->vertex[i].w = (M3D_FLOAT)(*((float *)(data + 12))); data += 16; break; case 8: model->vertex[i].x = (M3D_FLOAT)(*((double *)(data + 0))); model->vertex[i].y = (M3D_FLOAT)(*((double *)(data + 8))); model->vertex[i].z = (M3D_FLOAT)(*((double *)(data + 16))); model->vertex[i].w = (M3D_FLOAT)(*((double *)(data + 24))); data += 32; break; } switch (model->ci_s) { case 1: model->vertex[i].color = model->cmap ? model->cmap[data[0]] : 0; data++; break; case 2: model->vertex[i].color = model->cmap ? model->cmap[*((uint16_t *)data)] : 0; data += 2; break; case 4: model->vertex[i].color = *((uint32_t *)data); data += 4; break; /* case 8: break; */ } model->vertex[i].skinid = M3D_UNDEF; data = _m3d_getidx(data, model->sk_s, &model->vertex[i].skinid); } } else /* skeleton: bone hierarchy and skin */ if (M3D_CHUNKMAGIC(data, 'B', 'O', 'N', 'E')) { M3D_LOG("Skeleton"); if (model->bone) { M3D_LOG("More bone chunks, should be unique"); model->errcode = M3D_ERR_BONE; continue; } if (!model->bi_s) { M3D_LOG("Bone chunk, shouldn't be any"); model->errcode = M3D_ERR_BONE; continue; } if (!model->vertex) { M3D_LOG("No vertex chunk before bones"); model->errcode = M3D_ERR_VRTS; break; } data += sizeof(m3dchunk_t); model->numbone = 0; data = _m3d_getidx(data, model->bi_s, &model->numbone); if (model->numbone) { model->bone = (m3db_t *)M3D_MALLOC(model->numbone * sizeof(m3db_t)); if (!model->bone) goto memerr; } model->numskin = 0; data = _m3d_getidx(data, model->sk_s, &model->numskin); /* read bone hierarchy */ for (i = 0; i < model->numbone; i++) { data = _m3d_getidx(data, model->bi_s, &model->bone[i].parent); M3D_GETSTR(model->bone[i].name); data = _m3d_getidx(data, model->vi_s, &model->bone[i].pos); data = _m3d_getidx(data, model->vi_s, &model->bone[i].ori); model->bone[i].numweight = 0; model->bone[i].weight = NULL; } /* read skin definitions */ if (model->numskin) { model->skin = (m3ds_t *)M3D_MALLOC(model->numskin * sizeof(m3ds_t)); if (!model->skin) goto memerr; for (i = 0; data < chunk && i < model->numskin; i++) { for (j = 0; j < M3D_NUMBONE; j++) { model->skin[i].boneid[j] = M3D_UNDEF; model->skin[i].weight[j] = (M3D_FLOAT)0.0; } memset(&weights, 0, sizeof(weights)); if (model->nb_s == 1) weights[0] = 255; else { memcpy(&weights, data, model->nb_s); data += model->nb_s; } for (j = 0, w = (M3D_FLOAT)0.0; j < (unsigned int)model->nb_s; j++) { if (weights[j]) { if (j >= M3D_NUMBONE) data += model->bi_s; else { model->skin[i].weight[j] = (M3D_FLOAT)(weights[j]) / (M3D_FLOAT)255.0; w += model->skin[i].weight[j]; data = _m3d_getidx(data, model->bi_s, &model->skin[i].boneid[j]); } } } /* this can occur if model has more bones than what the importer is configured to handle */ if (w != (M3D_FLOAT)1.0 && w != (M3D_FLOAT)0.0) { for (j = 0; j < M3D_NUMBONE; j++) model->skin[i].weight[j] /= w; } } } } else /* material */ if (M3D_CHUNKMAGIC(data, 'M', 'T', 'R', 'L')) { data += sizeof(m3dchunk_t); M3D_GETSTR(name); M3D_LOG("Material"); M3D_LOG(name); if (model->ci_s < 4 && !model->numcmap) model->errcode = M3D_ERR_CMAP; for (i = 0; i < model->nummaterial; i++) if (!strcmp(name, model->material[i].name)) { model->errcode = M3D_ERR_MTRL; M3D_LOG("Multiple definitions for material"); M3D_LOG(name); name = NULL; break; } if (name) { i = model->nummaterial++; if (model->flags & M3D_FLG_MTLLIB) { m = model->material; model->material = (m3dm_t *)M3D_MALLOC(model->nummaterial * sizeof(m3dm_t)); if (!model->material) goto memerr; memcpy(model->material, m, (model->nummaterial - 1) * sizeof(m3dm_t)); if (model->texture) { tx = model->texture; model->texture = (m3dtx_t *)M3D_MALLOC(model->numtexture * sizeof(m3dtx_t)); if (!model->texture) goto memerr; memcpy(model->texture, tx, model->numtexture * sizeof(m3dm_t)); } model->flags &= ~M3D_FLG_MTLLIB; } else { model->material = (m3dm_t *)M3D_REALLOC(model->material, model->nummaterial * sizeof(m3dm_t)); if (!model->material) goto memerr; } m = &model->material[i]; m->numprop = 0; m->name = name; m->prop = (m3dp_t *)M3D_MALLOC((len / 2) * sizeof(m3dp_t)); if (!m->prop) goto memerr; while (data < chunk) { i = m->numprop++; m->prop[i].type = *data++; m->prop[i].value.num = 0; if (m->prop[i].type >= 128) k = m3dpf_map; else { for (k = 256, j = 0; j < sizeof(m3d_propertytypes) / sizeof(m3d_propertytypes[0]); j++) if (m->prop[i].type == m3d_propertytypes[j].id) { k = m3d_propertytypes[j].format; break; } } switch (k) { case m3dpf_color: switch (model->ci_s) { case 1: m->prop[i].value.color = model->cmap ? model->cmap[data[0]] : 0; data++; break; case 2: m->prop[i].value.color = model->cmap ? model->cmap[*((uint16_t *)data)] : 0; data += 2; break; case 4: m->prop[i].value.color = *((uint32_t *)data); data += 4; break; } break; case m3dpf_uint8: m->prop[i].value.num = *data++; break; case m3dpf_uint16: m->prop[i].value.num = *((uint16_t *)data); data += 2; break; case m3dpf_uint32: m->prop[i].value.num = *((uint32_t *)data); data += 4; break; case m3dpf_float: m->prop[i].value.fnum = *((float *)data); data += 4; break; case m3dpf_map: M3D_GETSTR(name); m->prop[i].value.textureid = _m3d_gettx(model, readfilecb, freecb, name); if (model->errcode == M3D_ERR_ALLOC) goto memerr; /* this error code only returned if readfilecb was specified */ if (m->prop[i].value.textureid == M3D_UNDEF) { M3D_LOG("Texture not found"); M3D_LOG(m->name); m->numprop--; } break; default: M3D_LOG("Unknown material property in"); M3D_LOG(m->name); model->errcode = M3D_ERR_UNKPROP; data = chunk; break; } } m->prop = (m3dp_t *)M3D_REALLOC(m->prop, m->numprop * sizeof(m3dp_t)); if (!m->prop) goto memerr; } } else /* face */ if (M3D_CHUNKMAGIC(data, 'P', 'R', 'O', 'C')) { /* procedural surface */ M3D_GETSTR(name); M3D_LOG("Procedural surface"); M3D_LOG(name); _m3d_getpr(model, readfilecb, freecb, name); } else if (M3D_CHUNKMAGIC(data, 'M', 'E', 'S', 'H')) { M3D_LOG("Mesh data"); /* mesh */ data += sizeof(m3dchunk_t); mi = M3D_UNDEF; am = model->numface; while (data < chunk) { k = *data++; n = k >> 4; k &= 15; if (!n) { /* use material */ mi = M3D_UNDEF; M3D_GETSTR(name); if (name) { for (j = 0; j < model->nummaterial; j++) if (!strcmp(name, model->material[j].name)) { mi = (M3D_INDEX)j; break; } if (mi == M3D_UNDEF) model->errcode = M3D_ERR_MTRL; } continue; } if (n != 3) { M3D_LOG("Only triangle mesh supported for now"); model->errcode = M3D_ERR_UNKMESH; return model; } i = model->numface++; if (model->numface > am) { am = model->numface + 4095; model->face = (m3df_t *)M3D_REALLOC(model->face, am * sizeof(m3df_t)); if (!model->face) goto memerr; } memset(&model->face[i], 255, sizeof(m3df_t)); /* set all index to -1 by default */ model->face[i].materialid = mi; for (j = 0; j < n; j++) { /* vertex */ data = _m3d_getidx(data, model->vi_s, &model->face[i].vertex[j]); /* texcoord */ if (k & 1) data = _m3d_getidx(data, model->ti_s, &model->face[i].texcoord[j]); /* normal */ if (k & 2) data = _m3d_getidx(data, model->vi_s, &model->face[i].normal[j]); #ifndef M3D_NONORMALS if (model->face[i].normal[j] == M3D_UNDEF) neednorm = 1; #endif } } model->face = (m3df_t *)M3D_REALLOC(model->face, model->numface * sizeof(m3df_t)); } else if (M3D_CHUNKMAGIC(data, 'S', 'H', 'P', 'E')) { /* mathematical shape */ data += sizeof(m3dchunk_t); M3D_GETSTR(name); M3D_LOG("Mathematical Shape"); M3D_LOG(name); i = model->numshape++; model->shape = (m3dh_t *)M3D_REALLOC(model->shape, model->numshape * sizeof(m3dh_t)); if (!model->shape) goto memerr; h = &model->shape[i]; h->numcmd = 0; h->cmd = NULL; h->name = name; h->group = M3D_UNDEF; data = _m3d_getidx(data, model->bi_s, &h->group); if (h->group != M3D_UNDEF && h->group >= model->numbone) { M3D_LOG("Unknown bone id as shape group in shape"); M3D_LOG(name); h->group = M3D_UNDEF; model->errcode = M3D_ERR_SHPE; } while (data < chunk) { i = h->numcmd++; h->cmd = (m3dc_t *)M3D_REALLOC(h->cmd, h->numcmd * sizeof(m3dc_t)); if (!h->cmd) goto memerr; h->cmd[i].type = *data++; if (h->cmd[i].type & 0x80) { h->cmd[i].type &= 0x7F; h->cmd[i].type |= (*data++ << 7); } if (h->cmd[i].type >= (unsigned int)(sizeof(m3d_commandtypes) / sizeof(m3d_commandtypes[0]))) { M3D_LOG("Unknown shape command in"); M3D_LOG(h->name); model->errcode = M3D_ERR_UNKCMD; break; } cd = &m3d_commandtypes[h->cmd[i].type]; h->cmd[i].arg = (uint32_t *)M3D_MALLOC(cd->p * sizeof(uint32_t)); if (!h->cmd[i].arg) goto memerr; memset(h->cmd[i].arg, 0, cd->p * sizeof(uint32_t)); for (k = n = 0, l = cd->p; k < l; k++) switch (cd->a[((k - n) % (cd->p - n)) + n]) { case m3dcp_mi_t: h->cmd[i].arg[k] = M3D_NOTDEFINED; M3D_GETSTR(name); if (name) { for (n = 0; n < model->nummaterial; n++) if (!strcmp(name, model->material[n].name)) { h->cmd[i].arg[k] = n; break; } if (h->cmd[i].arg[k] == M3D_NOTDEFINED) model->errcode = M3D_ERR_MTRL; } break; case m3dcp_vc_t: f = 0.0f; switch (model->vc_s) { case 1: f = (float)((int8_t)data[0]) / 127; break; case 2: f = (float)(*((int16_t *)(data + 0))) / 32767; break; case 4: f = (float)(*((float *)(data + 0))); break; case 8: f = (float)(*((double *)(data + 0))); break; } memcpy(&(h->cmd[i].arg[k]), &f, sizeof(uint32_t)); data += model->vc_s; break; case m3dcp_hi_t: data = _m3d_getidx(data, model->hi_s, &h->cmd[i].arg[k]); break; case m3dcp_fi_t: data = _m3d_getidx(data, model->fi_s, &h->cmd[i].arg[k]); break; case m3dcp_ti_t: data = _m3d_getidx(data, model->ti_s, &h->cmd[i].arg[k]); break; case m3dcp_qi_t: case m3dcp_vi_t: data = _m3d_getidx(data, model->vi_s, &h->cmd[i].arg[k]); break; case m3dcp_i1_t: data = _m3d_getidx(data, 1, &h->cmd[i].arg[k]); break; case m3dcp_i2_t: data = _m3d_getidx(data, 2, &h->cmd[i].arg[k]); break; case m3dcp_i4_t: data = _m3d_getidx(data, 4, &h->cmd[i].arg[k]); break; case m3dcp_va_t: data = _m3d_getidx(data, 4, &h->cmd[i].arg[k]); n = k + 1; l += (h->cmd[i].arg[k] - 1) * (cd->p - k - 1); h->cmd[i].arg = (uint32_t *)M3D_REALLOC(h->cmd[i].arg, l * sizeof(uint32_t)); if (!h->cmd[i].arg) goto memerr; memset(&h->cmd[i].arg[k + 1], 0, (l - k - 1) * sizeof(uint32_t)); break; } } } else /* annotation label list */ if (M3D_CHUNKMAGIC(data, 'L', 'B', 'L', 'S')) { data += sizeof(m3dchunk_t); M3D_GETSTR(name); M3D_GETSTR(lang); M3D_LOG("Label list"); if (name) { M3D_LOG(name); } if (lang) { M3D_LOG(lang); } if (model->ci_s && model->ci_s < 4 && !model->cmap) model->errcode = M3D_ERR_CMAP; k = 0; switch (model->ci_s) { case 1: k = model->cmap ? model->cmap[data[0]] : 0; data++; break; case 2: k = model->cmap ? model->cmap[*((uint16_t *)data)] : 0; data += 2; break; case 4: k = *((uint32_t *)data); data += 4; break; /* case 8: break; */ } reclen = model->vi_s + model->si_s; i = model->numlabel; model->numlabel += len / reclen; model->label = (m3dl_t *)M3D_REALLOC(model->label, model->numlabel * sizeof(m3dl_t)); if (!model->label) goto memerr; memset(&model->label[i], 0, (model->numlabel - i) * sizeof(m3dl_t)); for (; data < chunk && i < model->numlabel; i++) { model->label[i].name = name; model->label[i].lang = lang; model->label[i].color = k; data = _m3d_getidx(data, model->vi_s, &model->label[i].vertexid); M3D_GETSTR(model->label[i].text); } } else /* action */ if (M3D_CHUNKMAGIC(data, 'A', 'C', 'T', 'N')) { M3D_LOG("Action"); i = model->numaction++; model->action = (m3da_t *)M3D_REALLOC(model->action, model->numaction * sizeof(m3da_t)); if (!model->action) goto memerr; a = &model->action[i]; data += sizeof(m3dchunk_t); M3D_GETSTR(a->name); M3D_LOG(a->name); a->numframe = *((uint16_t *)data); data += 2; if (a->numframe < 1) { model->numaction--; } else { a->durationmsec = *((uint32_t *)data); data += 4; a->frame = (m3dfr_t *)M3D_MALLOC(a->numframe * sizeof(m3dfr_t)); if (!a->frame) goto memerr; for (i = 0; data < chunk && i < a->numframe; i++) { a->frame[i].msec = *((uint32_t *)data); data += 4; a->frame[i].numtransform = 0; a->frame[i].transform = NULL; data = _m3d_getidx(data, model->fc_s, &a->frame[i].numtransform); if (a->frame[i].numtransform > 0) { a->frame[i].transform = (m3dtr_t *)M3D_MALLOC(a->frame[i].numtransform * sizeof(m3dtr_t)); for (j = 0; j < a->frame[i].numtransform; j++) { data = _m3d_getidx(data, model->bi_s, &a->frame[i].transform[j].boneid); data = _m3d_getidx(data, model->vi_s, &a->frame[i].transform[j].pos); data = _m3d_getidx(data, model->vi_s, &a->frame[i].transform[j].ori); } } } } } else { i = model->numextra++; model->extra = (m3dchunk_t **)M3D_REALLOC(model->extra, model->numextra * sizeof(m3dchunk_t *)); if (!model->extra) goto memerr; model->extra[i] = (m3dchunk_t *)data; } } /* calculate normals, normalize skin weights, create bone/vertex cross-references and calculate transform matrices */ postprocess: if (model) { M3D_LOG("Post-process"); #ifdef M3D_PROFILING gettimeofday(&tv1, NULL); tvd.tv_sec = tv1.tv_sec - tv0.tv_sec; tvd.tv_usec = tv1.tv_usec - tv0.tv_usec; if (tvd.tv_usec < 0) { tvd.tv_sec--; tvd.tv_usec += 1000000L; } printf(" Parsing chunks %ld.%06ld sec\n", tvd.tv_sec, tvd.tv_usec); #endif #ifndef M3D_NONORMALS if (model->numface && model->face && neednorm) { /* if they are missing, calculate triangle normals into a temporary buffer */ norm = (m3dv_t *)M3D_MALLOC(model->numface * sizeof(m3dv_t)); if (!norm) goto memerr; for (i = 0, n = model->numvertex; i < model->numface; i++) if (model->face[i].normal[0] == M3D_UNDEF) { v0 = &model->vertex[model->face[i].vertex[0]]; v1 = &model->vertex[model->face[i].vertex[1]]; v2 = &model->vertex[model->face[i].vertex[2]]; va.x = v1->x - v0->x; va.y = v1->y - v0->y; va.z = v1->z - v0->z; vb.x = v2->x - v0->x; vb.y = v2->y - v0->y; vb.z = v2->z - v0->z; v0 = &norm[i]; v0->x = (va.y * vb.z) - (va.z * vb.y); v0->y = (va.z * vb.x) - (va.x * vb.z); v0->z = (va.x * vb.y) - (va.y * vb.x); w = _m3d_rsq((v0->x * v0->x) + (v0->y * v0->y) + (v0->z * v0->z)); v0->x *= w; v0->y *= w; v0->z *= w; model->face[i].normal[0] = model->face[i].vertex[0] + n; model->face[i].normal[1] = model->face[i].vertex[1] + n; model->face[i].normal[2] = model->face[i].vertex[2] + n; } /* this is the fast way, we don't care if a normal is repeated in model->vertex */ M3D_LOG("Generating normals"); model->flags |= M3D_FLG_GENNORM; model->numvertex <<= 1; model->vertex = (m3dv_t *)M3D_REALLOC(model->vertex, model->numvertex * sizeof(m3dv_t)); if (!model->vertex) goto memerr; memset(&model->vertex[n], 0, n * sizeof(m3dv_t)); for (i = 0; i < model->numface; i++) for (j = 0; j < 3; j++) { v0 = &model->vertex[model->face[i].vertex[j] + n]; v0->x += norm[i].x; v0->y += norm[i].y; v0->z += norm[i].z; } /* for each vertex, take the average of the temporary normals and use that */ for (i = 0, v0 = &model->vertex[n]; i < n; i++, v0++) { w = _m3d_rsq((v0->x * v0->x) + (v0->y * v0->y) + (v0->z * v0->z)); v0->x *= w; v0->y *= w; v0->z *= w; v0->skinid = M3D_UNDEF; } M3D_FREE(norm); } #endif if (model->numbone && model->bone && model->numskin && model->skin && model->numvertex && model->vertex) { #ifndef M3D_NOWEIGHTS M3D_LOG("Generating weight cross-reference"); for (i = 0; i < model->numvertex; i++) { if (model->vertex[i].skinid < model->numskin) { sk = &model->skin[model->vertex[i].skinid]; w = (M3D_FLOAT)0.0; for (j = 0; j < M3D_NUMBONE && sk->boneid[j] != M3D_UNDEF && sk->weight[j] > (M3D_FLOAT)0.0; j++) w += sk->weight[j]; for (j = 0; j < M3D_NUMBONE && sk->boneid[j] != M3D_UNDEF && sk->weight[j] > (M3D_FLOAT)0.0; j++) { sk->weight[j] /= w; b = &model->bone[sk->boneid[j]]; k = b->numweight++; b->weight = (m3dw_t *)M3D_REALLOC(b->weight, b->numweight * sizeof(m3da_t)); if (!b->weight) goto memerr; b->weight[k].vertexid = i; b->weight[k].weight = sk->weight[j]; } } } #endif #ifndef M3D_NOANIMATION M3D_LOG("Calculating bone transformation matrices"); for (i = 0; i < model->numbone; i++) { b = &model->bone[i]; if (model->bone[i].parent == M3D_UNDEF) { _m3d_mat((M3D_FLOAT *)&b->mat4, &model->vertex[b->pos], &model->vertex[b->ori]); } else { _m3d_mat((M3D_FLOAT *)&r, &model->vertex[b->pos], &model->vertex[b->ori]); _m3d_mul((M3D_FLOAT *)&b->mat4, (M3D_FLOAT *)&model->bone[b->parent].mat4, (M3D_FLOAT *)&r); } } for (i = 0; i < model->numbone; i++) _m3d_inv((M3D_FLOAT *)&model->bone[i].mat4); #endif } #ifdef M3D_PROFILING gettimeofday(&tv0, NULL); tvd.tv_sec = tv0.tv_sec - tv1.tv_sec; tvd.tv_usec = tv0.tv_usec - tv1.tv_usec; if (tvd.tv_usec < 0) { tvd.tv_sec--; tvd.tv_usec += 1000000L; } printf(" Post-process %ld.%06ld sec\n", tvd.tv_sec, tvd.tv_usec); #endif } return model; } /** * Calculates skeletons for animation frames, returns a working copy (should be freed after use) */ m3dtr_t *m3d_frame(m3d_t *model, M3D_INDEX actionid, M3D_INDEX frameid, m3dtr_t *skeleton) { unsigned int i; M3D_INDEX s = frameid; m3dfr_t *fr; if (!model || !model->numbone || !model->bone || (actionid != M3D_UNDEF && (!model->action || actionid >= model->numaction || frameid >= model->action[actionid].numframe))) { model->errcode = M3D_ERR_UNKFRAME; return skeleton; } model->errcode = M3D_SUCCESS; if (!skeleton) { skeleton = (m3dtr_t *)M3D_MALLOC(model->numbone * sizeof(m3dtr_t)); if (!skeleton) { model->errcode = M3D_ERR_ALLOC; return NULL; } goto gen; } if (actionid == M3D_UNDEF || !frameid) { gen: s = 0; for (i = 0; i < model->numbone; i++) { skeleton[i].boneid = i; skeleton[i].pos = model->bone[i].pos; skeleton[i].ori = model->bone[i].ori; } } if (actionid < model->numaction && (frameid || !model->action[actionid].frame[0].msec)) { for (; s <= frameid; s++) { fr = &model->action[actionid].frame[s]; for (i = 0; i < fr->numtransform; i++) { skeleton[fr->transform[i].boneid].pos = fr->transform[i].pos; skeleton[fr->transform[i].boneid].ori = fr->transform[i].ori; } } } return skeleton; } #ifndef M3D_NOANIMATION /** * Returns interpolated animation-pose, a working copy (should be freed after use) */ m3db_t *m3d_pose(m3d_t *model, M3D_INDEX actionid, uint32_t msec) { unsigned int i, j, l; M3D_FLOAT r[16], t, c, d, s; m3db_t *ret; m3dv_t *v, *p, *f; m3dtr_t *tmp; m3dfr_t *fr; if (!model || !model->numbone || !model->bone) { model->errcode = M3D_ERR_UNKFRAME; return NULL; } ret = (m3db_t *)M3D_MALLOC(model->numbone * sizeof(m3db_t)); if (!ret) { model->errcode = M3D_ERR_ALLOC; return NULL; } memcpy(ret, model->bone, model->numbone * sizeof(m3db_t)); for (i = 0; i < model->numbone; i++) _m3d_inv((M3D_FLOAT *)&ret[i].mat4); if (!model->action || actionid >= model->numaction) { model->errcode = M3D_ERR_UNKFRAME; return ret; } msec %= model->action[actionid].durationmsec; model->errcode = M3D_SUCCESS; fr = &model->action[actionid].frame[0]; for (j = l = 0; j < model->action[actionid].numframe && model->action[actionid].frame[j].msec <= msec; j++) { fr = &model->action[actionid].frame[j]; l = fr->msec; for (i = 0; i < fr->numtransform; i++) { ret[fr->transform[i].boneid].pos = fr->transform[i].pos; ret[fr->transform[i].boneid].ori = fr->transform[i].ori; } } if (l != msec) { model->vertex = (m3dv_t *)M3D_REALLOC(model->vertex, (model->numvertex + 2 * model->numbone) * sizeof(m3dv_t)); if (!model->vertex) { free(ret); model->errcode = M3D_ERR_ALLOC; return NULL; } tmp = (m3dtr_t *)M3D_MALLOC(model->numbone * sizeof(m3dtr_t)); if (tmp) { for (i = 0; i < model->numbone; i++) { tmp[i].pos = ret[i].pos; tmp[i].ori = ret[i].ori; } fr = &model->action[actionid].frame[j % model->action[actionid].numframe]; t = l >= fr->msec ? (M3D_FLOAT)1.0 : (M3D_FLOAT)(msec - l) / (M3D_FLOAT)(fr->msec - l); for (i = 0; i < fr->numtransform; i++) { tmp[fr->transform[i].boneid].pos = fr->transform[i].pos; tmp[fr->transform[i].boneid].ori = fr->transform[i].ori; } for (i = 0, j = model->numvertex; i < model->numbone; i++) { /* interpolation of position */ if (ret[i].pos != tmp[i].pos) { p = &model->vertex[ret[i].pos]; f = &model->vertex[tmp[i].pos]; v = &model->vertex[j]; v->x = p->x + t * (f->x - p->x); v->y = p->y + t * (f->y - p->y); v->z = p->z + t * (f->z - p->z); ret[i].pos = j++; } /* interpolation of orientation */ if (ret[i].ori != tmp[i].ori) { p = &model->vertex[ret[i].ori]; f = &model->vertex[tmp[i].ori]; v = &model->vertex[j]; d = p->w * f->w + p->x * f->x + p->y * f->y + p->z * f->z; if (d < 0) { d = -d; s = (M3D_FLOAT)-1.0; } else s = (M3D_FLOAT)1.0; #if 0 /* don't use SLERP, requires two more variables, libm linkage and it is slow (but nice) */ a = (M3D_FLOAT)1.0 - t; b = t; if(d < (M3D_FLOAT)0.999999) { c = acosf(d); b = 1 / sinf(c); a = sinf(a * c) * b; b *= sinf(t * c) * s; } v->x = p->x * a + f->x * b; v->y = p->y * a + f->y * b; v->z = p->z * a + f->z * b; v->w = p->w * a + f->w * b; #else /* approximated NLERP, original approximation by <NAME>, heavily optimized by me */ c = t - (M3D_FLOAT)0.5; t += t * c * (t - (M3D_FLOAT)1.0) * (((M3D_FLOAT)1.0904 + d * ((M3D_FLOAT)-3.2452 + d * ((M3D_FLOAT)3.55645 - d * (M3D_FLOAT)1.43519))) * c * c + ((M3D_FLOAT)0.848013 + d * ((M3D_FLOAT)-1.06021 + d * (M3D_FLOAT)0.215638))); v->x = p->x + t * (s * f->x - p->x); v->y = p->y + t * (s * f->y - p->y); v->z = p->z + t * (s * f->z - p->z); v->w = p->w + t * (s * f->w - p->w); d = _m3d_rsq(v->w * v->w + v->x * v->x + v->y * v->y + v->z * v->z); v->x *= d; v->y *= d; v->z *= d; v->w *= d; #endif ret[i].ori = j++; } } M3D_FREE(tmp); } } for (i = 0; i < model->numbone; i++) { if (ret[i].parent == M3D_UNDEF) { _m3d_mat((M3D_FLOAT *)&ret[i].mat4, &model->vertex[ret[i].pos], &model->vertex[ret[i].ori]); } else { _m3d_mat((M3D_FLOAT *)&r, &model->vertex[ret[i].pos], &model->vertex[ret[i].ori]); _m3d_mul((M3D_FLOAT *)&ret[i].mat4, (M3D_FLOAT *)&ret[ret[i].parent].mat4, (M3D_FLOAT *)&r); } } return ret; } #endif /* M3D_NOANIMATION */ #endif /* M3D_IMPLEMENTATION */ #if !defined(M3D_NODUP) && (!defined(M3D_NOIMPORTER) || defined(M3D_EXPORTER)) /** * Free the in-memory model */ void m3d_free(m3d_t *model) { unsigned int i, j; if (!model) return; /* if model imported from ASCII, we have to free all strings as well */ if (model->flags & M3D_FLG_FREESTR) { if (model->name) M3D_FREE(model->name); if (model->license) M3D_FREE(model->license); if (model->author) M3D_FREE(model->author); if (model->desc) M3D_FREE(model->desc); if (model->bone) for (i = 0; i < model->numbone; i++) if (model->bone[i].name) M3D_FREE(model->bone[i].name); if (model->shape) for (i = 0; i < model->numshape; i++) if (model->shape[i].name) M3D_FREE(model->shape[i].name); if (model->material) for (i = 0; i < model->nummaterial; i++) if (model->material[i].name) M3D_FREE(model->material[i].name); if (model->action) for (i = 0; i < model->numaction; i++) if (model->action[i].name) M3D_FREE(model->action[i].name); if (model->texture) for (i = 0; i < model->numtexture; i++) if (model->texture[i].name) M3D_FREE(model->texture[i].name); if (model->inlined) for (i = 0; i < model->numinlined; i++) { if (model->inlined[i].name) M3D_FREE(model->inlined[i].name); if (model->inlined[i].data) M3D_FREE(model->inlined[i].data); } if (model->extra) for (i = 0; i < model->numextra; i++) if (model->extra[i]) M3D_FREE(model->extra[i]); if (model->label) for (i = 0; i < model->numlabel; i++) { if (model->label[i].name) { for (j = i + 1; j < model->numlabel; j++) if (model->label[j].name == model->label[i].name) model->label[j].name = NULL; M3D_FREE(model->label[i].name); } if (model->label[i].lang) { for (j = i + 1; j < model->numlabel; j++) if (model->label[j].lang == model->label[i].lang) model->label[j].lang = NULL; M3D_FREE(model->label[i].lang); } if (model->label[i].text) M3D_FREE(model->label[i].text); } if (model->preview.data) M3D_FREE(model->preview.data); } if (model->flags & M3D_FLG_FREERAW) M3D_FREE(model->raw); if (model->tmap) M3D_FREE(model->tmap); if (model->bone) { for (i = 0; i < model->numbone; i++) if (model->bone[i].weight) M3D_FREE(model->bone[i].weight); M3D_FREE(model->bone); } if (model->skin) M3D_FREE(model->skin); if (model->vertex) M3D_FREE(model->vertex); if (model->face) M3D_FREE(model->face); if (model->shape) { for (i = 0; i < model->numshape; i++) { if (model->shape[i].cmd) { for (j = 0; j < model->shape[i].numcmd; j++) if (model->shape[i].cmd[j].arg) M3D_FREE(model->shape[i].cmd[j].arg); M3D_FREE(model->shape[i].cmd); } } M3D_FREE(model->shape); } if (model->material && !(model->flags & M3D_FLG_MTLLIB)) { for (i = 0; i < model->nummaterial; i++) if (model->material[i].prop) M3D_FREE(model->material[i].prop); M3D_FREE(model->material); } if (model->texture) { for (i = 0; i < model->numtexture; i++) if (model->texture[i].d) M3D_FREE(model->texture[i].d); M3D_FREE(model->texture); } if (model->action) { for (i = 0; i < model->numaction; i++) { if (model->action[i].frame) { for (j = 0; j < model->action[i].numframe; j++) if (model->action[i].frame[j].transform) M3D_FREE(model->action[i].frame[j].transform); M3D_FREE(model->action[i].frame); } } M3D_FREE(model->action); } if (model->label) M3D_FREE(model->label); if (model->inlined) M3D_FREE(model->inlined); if (model->extra) M3D_FREE(model->extra); free(model); } #endif #ifdef M3D_EXPORTER typedef struct { char *str; uint32_t offs; } m3dstr_t; typedef struct { m3dti_t data; M3D_INDEX oldidx; M3D_INDEX newidx; } m3dtisave_t; typedef struct { m3dv_t data; M3D_INDEX oldidx; M3D_INDEX newidx; unsigned char norm; } m3dvsave_t; typedef struct { m3ds_t data; M3D_INDEX oldidx; M3D_INDEX newidx; } m3dssave_t; typedef struct { m3df_t data; int group; uint8_t opacity; } m3dfsave_t; /* create unique list of strings */ static m3dstr_t *_m3d_addstr(m3dstr_t *str, uint32_t *numstr, char *s) { uint32_t i; if (!s || !*s) return str; if (str) { for (i = 0; i < *numstr; i++) if (str[i].str == s || !strcmp(str[i].str, s)) return str; } str = (m3dstr_t *)M3D_REALLOC(str, ((*numstr) + 1) * sizeof(m3dstr_t)); str[*numstr].str = s; str[*numstr].offs = 0; (*numstr)++; return str; } /* add strings to header */ m3dhdr_t *_m3d_addhdr(m3dhdr_t *h, m3dstr_t *s) { int i; char *safe = _m3d_safestr(s->str, 0); i = (int)strlen(safe); h = (m3dhdr_t *)M3D_REALLOC(h, h->length + i + 1); if (!h) { M3D_FREE(safe); return NULL; } memcpy((uint8_t *)h + h->length, safe, i + 1); s->offs = h->length - 16; h->length += i + 1; M3D_FREE(safe); return h; } /* return offset of string */ static uint32_t _m3d_stridx(m3dstr_t *str, uint32_t numstr, char *s) { uint32_t i; char *safe; if (!s || !*s) return 0; if (str) { safe = _m3d_safestr(s, 0); if (!safe) return 0; if (!*safe) { free(safe); return 0; } for (i = 0; i < numstr; i++) if (!strcmp(str[i].str, s)) { free(safe); return str[i].offs; } free(safe); } return 0; } /* compare to faces by their material */ static int _m3d_facecmp(const void *a, const void *b) { const m3dfsave_t *A = (const m3dfsave_t *)a, *B = (const m3dfsave_t *)b; return A->group != B->group ? A->group - B->group : (A->opacity != B->opacity ? (int)B->opacity - (int)A->opacity : (int)A->data.materialid - (int)B->data.materialid); } /* compare face groups */ static int _m3d_grpcmp(const void *a, const void *b) { return *((uint32_t *)a) - *((uint32_t *)b); } /* compare UVs */ static int _m3d_ticmp(const void *a, const void *b) { return memcmp(a, b, sizeof(m3dti_t)); } /* compare skin groups */ static int _m3d_skincmp(const void *a, const void *b) { return memcmp(a, b, sizeof(m3ds_t)); } /* compare vertices */ static int _m3d_vrtxcmp(const void *a, const void *b) { int c = memcmp(a, b, 3 * sizeof(M3D_FLOAT)); if (c) return c; c = ((m3dvsave_t *)a)->norm - ((m3dvsave_t *)b)->norm; if (c) return c; return memcmp(a, b, sizeof(m3dv_t)); } /* compare labels */ static _inline int _m3d_strcmp(char *a, char *b) { if (a == NULL && b != NULL) return -1; if (a != NULL && b == NULL) return 1; if (a == NULL && b == NULL) return 0; return strcmp(a, b); } static int _m3d_lblcmp(const void *a, const void *b) { const m3dl_t *A = (const m3dl_t *)a, *B = (const m3dl_t *)b; int c = _m3d_strcmp(A->lang, B->lang); if (!c) c = _m3d_strcmp(A->name, B->name); if (!c) c = _m3d_strcmp(A->text, B->text); return c; } /* compare two colors by HSV value */ _inline static int _m3d_cmapcmp(const void *a, const void *b) { uint8_t *A = (uint8_t *)a, *B = (uint8_t *)b; _register int m, vA, vB; /* get HSV value for A */ m = A[2] < A[1] ? A[2] : A[1]; if (A[0] < m) m = A[0]; vA = A[2] > A[1] ? A[2] : A[1]; if (A[0] > vA) vA = A[0]; /* get HSV value for B */ m = B[2] < B[1] ? B[2] : B[1]; if (B[0] < m) m = B[0]; vB = B[2] > B[1] ? B[2] : B[1]; if (B[0] > vB) vB = B[0]; return vA - vB; } /* create sorted list of colors */ static uint32_t *_m3d_addcmap(uint32_t *cmap, uint32_t *numcmap, uint32_t color) { uint32_t i; if (cmap) { for (i = 0; i < *numcmap; i++) if (cmap[i] == color) return cmap; } cmap = (uint32_t *)M3D_REALLOC(cmap, ((*numcmap) + 1) * sizeof(uint32_t)); for (i = 0; i < *numcmap && _m3d_cmapcmp(&color, &cmap[i]) > 0; i++) ; if (i < *numcmap) memmove(&cmap[i + 1], &cmap[i], ((*numcmap) - i) * sizeof(uint32_t)); cmap[i] = color; (*numcmap)++; return cmap; } /* look up a color and return its index */ static uint32_t _m3d_cmapidx(uint32_t *cmap, uint32_t numcmap, uint32_t color) { uint32_t i; if (numcmap >= 65536) return color; for (i = 0; i < numcmap; i++) if (cmap[i] == color) return i; return 0; } /* add index to output */ static unsigned char *_m3d_addidx(unsigned char *out, char type, uint32_t idx) { switch (type) { case 1: *out++ = (uint8_t)(idx); break; case 2: *((uint16_t *)out) = (uint16_t)(idx); out += 2; break; case 4: *((uint32_t *)out) = (uint32_t)(idx); out += 4; break; /* case 0: case 8: break; */ } return out; } /* round a vertex position */ static void _m3d_round(int quality, m3dv_t *src, m3dv_t *dst) { _register int t; /* copy additional attributes */ if (src != dst) memcpy(dst, src, sizeof(m3dv_t)); /* round according to quality */ switch (quality) { case M3D_EXP_INT8: t = (int)(src->x * 127 + (src->x >= 0 ? (M3D_FLOAT)0.5 : (M3D_FLOAT)-0.5)); dst->x = (M3D_FLOAT)t / (M3D_FLOAT)127.0; t = (int)(src->y * 127 + (src->y >= 0 ? (M3D_FLOAT)0.5 : (M3D_FLOAT)-0.5)); dst->y = (M3D_FLOAT)t / (M3D_FLOAT)127.0; t = (int)(src->z * 127 + (src->z >= 0 ? (M3D_FLOAT)0.5 : (M3D_FLOAT)-0.5)); dst->z = (M3D_FLOAT)t / (M3D_FLOAT)127.0; t = (int)(src->w * 127 + (src->w >= 0 ? (M3D_FLOAT)0.5 : (M3D_FLOAT)-0.5)); dst->w = (M3D_FLOAT)t / (M3D_FLOAT)127.0; break; case M3D_EXP_INT16: t = (int)(src->x * 32767 + (src->x >= 0 ? (M3D_FLOAT)0.5 : (M3D_FLOAT)-0.5)); dst->x = (M3D_FLOAT)t / (M3D_FLOAT)32767.0; t = (int)(src->y * 32767 + (src->y >= 0 ? (M3D_FLOAT)0.5 : (M3D_FLOAT)-0.5)); dst->y = (M3D_FLOAT)t / (M3D_FLOAT)32767.0; t = (int)(src->z * 32767 + (src->z >= 0 ? (M3D_FLOAT)0.5 : (M3D_FLOAT)-0.5)); dst->z = (M3D_FLOAT)t / (M3D_FLOAT)32767.0; t = (int)(src->w * 32767 + (src->w >= 0 ? (M3D_FLOAT)0.5 : (M3D_FLOAT)-0.5)); dst->w = (M3D_FLOAT)t / (M3D_FLOAT)32767.0; break; } if (dst->x == (M3D_FLOAT)-0.0) dst->x = (M3D_FLOAT)0.0; if (dst->y == (M3D_FLOAT)-0.0) dst->y = (M3D_FLOAT)0.0; if (dst->z == (M3D_FLOAT)-0.0) dst->z = (M3D_FLOAT)0.0; if (dst->w == (M3D_FLOAT)-0.0) dst->w = (M3D_FLOAT)0.0; } /* add a bone to ascii output */ static char *_m3d_prtbone(char *ptr, m3db_t *bone, M3D_INDEX numbone, M3D_INDEX parent, uint32_t level, M3D_INDEX *vrtxidx) { uint32_t i, j; char *sn; if (level > M3D_BONEMAXLEVEL || !bone) return ptr; for (i = 0; i < numbone; i++) { if (bone[i].parent == parent) { for (j = 0; j < level; j++) *ptr++ = '/'; sn = _m3d_safestr(bone[i].name, 0); ptr += sprintf(ptr, "%d %d %s\r\n", vrtxidx[bone[i].pos], vrtxidx[bone[i].ori], sn); M3D_FREE(sn); ptr = _m3d_prtbone(ptr, bone, numbone, i, level + 1, vrtxidx); } } return ptr; } /** * Function to encode an in-memory model into on storage Model 3D format */ unsigned char *m3d_save(m3d_t *model, int quality, int flags, unsigned int *size) { const char *ol; char *ptr; char vc_s, vi_s, si_s, ci_s, ti_s, bi_s, nb_s, sk_s, fc_s, hi_s, fi_s; char *sn = NULL, *sl = NULL, *sa = NULL, *sd = NULL; unsigned char *out = NULL, *z = NULL, weights[M3D_NUMBONE], *norm = NULL; unsigned int i = 0, j = 0, k = 0, l = 0, n = 0, len = 0, chunklen = 0, *length = NULL; M3D_FLOAT scale = (M3D_FLOAT)0.0, min_x, max_x, min_y, max_y, min_z, max_z; M3D_INDEX last, *vrtxidx = NULL, *mtrlidx = NULL, *tmapidx = NULL, *skinidx = NULL; uint32_t idx, numcmap = 0, *cmap = NULL, numvrtx = 0, maxvrtx = 0, numtmap = 0, maxtmap = 0, numproc = 0; uint32_t numskin = 0, maxskin = 0, numstr = 0, maxt = 0, maxbone = 0, numgrp = 0, maxgrp = 0, *grpidx = NULL; uint8_t *opa = nullptr; m3dcd_t *cd; m3dc_t *cmd; m3dstr_t *str = NULL; m3dvsave_t *vrtx = NULL, vertex; m3dtisave_t *tmap = NULL, tcoord; m3dssave_t *skin = NULL, sk; m3dfsave_t *face = NULL; m3dhdr_t *h = NULL; m3dm_t *m; m3da_t *a; if (!model) { if (size) *size = 0; return NULL; } model->errcode = M3D_SUCCESS; if (flags & M3D_EXP_ASCII) quality = M3D_EXP_DOUBLE; vrtxidx = (M3D_INDEX *)M3D_MALLOC(model->numvertex * sizeof(M3D_INDEX)); if (!vrtxidx) goto memerr; memset(vrtxidx, 255, model->numvertex * sizeof(M3D_INDEX)); if (model->numvertex && !(flags & M3D_EXP_NONORMAL)) { norm = (unsigned char *)M3D_MALLOC(model->numvertex * sizeof(unsigned char)); if (!norm) goto memerr; memset(norm, 0, model->numvertex * sizeof(unsigned char)); } if (model->nummaterial && !(flags & M3D_EXP_NOMATERIAL)) { mtrlidx = (M3D_INDEX *)M3D_MALLOC(model->nummaterial * sizeof(M3D_INDEX)); if (!mtrlidx) goto memerr; memset(mtrlidx, 255, model->nummaterial * sizeof(M3D_INDEX)); opa = (uint8_t *)M3D_MALLOC(model->nummaterial * 2 * sizeof(M3D_INDEX)); if (!opa) goto memerr; memset(opa, 255, model->nummaterial * 2 * sizeof(M3D_INDEX)); } if (model->numtmap && !(flags & M3D_EXP_NOTXTCRD)) { tmapidx = (M3D_INDEX *)M3D_MALLOC(model->numtmap * sizeof(M3D_INDEX)); if (!tmapidx) goto memerr; memset(tmapidx, 255, model->numtmap * sizeof(M3D_INDEX)); } /** collect array elements that are actually referenced **/ if (!(flags & M3D_EXP_NOFACE)) { /* face */ if (model->numface && model->face) { M3D_LOG("Processing mesh face"); face = (m3dfsave_t *)M3D_MALLOC(model->numface * sizeof(m3dfsave_t)); if (!face) goto memerr; for (i = 0; i < model->numface; i++) { memcpy(&face[i].data, &model->face[i], sizeof(m3df_t)); face[i].group = 0; face[i].opacity = 255; if (!(flags & M3D_EXP_NOMATERIAL) && model->face[i].materialid < model->nummaterial) { if (model->material[model->face[i].materialid].numprop) { mtrlidx[model->face[i].materialid] = 0; if (opa[model->face[i].materialid * 2]) { m = &model->material[model->face[i].materialid]; for (j = 0; j < m->numprop; j++) if (m->prop[j].type == m3dp_Kd) { opa[model->face[i].materialid * 2 + 1] = ((uint8_t *)&m->prop[j].value.color)[3]; break; } for (j = 0; j < m->numprop; j++) if (m->prop[j].type == m3dp_d) { opa[model->face[i].materialid * 2 + 1] = (uint8_t)(m->prop[j].value.fnum * 255); break; } opa[model->face[i].materialid * 2] = 0; } face[i].opacity = opa[model->face[i].materialid * 2 + 1]; } else face[i].data.materialid = M3D_UNDEF; } for (j = 0; j < 3; j++) { k = model->face[i].vertex[j]; if (k < model->numvertex) vrtxidx[k] = 0; if (!(flags & M3D_EXP_NOCMAP)) { cmap = _m3d_addcmap(cmap, &numcmap, model->vertex[k].color); if (!cmap) goto memerr; } k = model->face[i].normal[j]; if (k < model->numvertex && !(flags & M3D_EXP_NONORMAL)) { vrtxidx[k] = 0; norm[k] = 1; } k = model->face[i].texcoord[j]; if (k < model->numtmap && !(flags & M3D_EXP_NOTXTCRD)) tmapidx[k] = 0; } /* convert from CW to CCW */ if (flags & M3D_EXP_IDOSUCK) { j = face[i].data.vertex[1]; face[i].data.vertex[1] = face[i].data.vertex[2]; face[i].data.vertex[2] = face[i].data.vertex[1]; j = face[i].data.normal[1]; face[i].data.normal[1] = face[i].data.normal[2]; face[i].data.normal[2] = face[i].data.normal[1]; j = face[i].data.texcoord[1]; face[i].data.texcoord[1] = face[i].data.texcoord[2]; face[i].data.texcoord[2] = face[i].data.texcoord[1]; } } } if (model->numshape && model->shape) { M3D_LOG("Processing shape face"); for (i = 0; i < model->numshape; i++) { if (!model->shape[i].numcmd) continue; str = _m3d_addstr(str, &numstr, model->shape[i].name); if (!str) goto memerr; for (j = 0; j < model->shape[i].numcmd; j++) { cmd = &model->shape[i].cmd[j]; if (cmd->type >= (unsigned int)(sizeof(m3d_commandtypes) / sizeof(m3d_commandtypes[0])) || !cmd->arg) continue; if (cmd->type == m3dc_mesh) { if (numgrp + 2 < maxgrp) { maxgrp += 1024; grpidx = (uint32_t *)realloc(grpidx, maxgrp * sizeof(uint32_t)); if (!grpidx) goto memerr; if (!numgrp) { grpidx[0] = 0; grpidx[1] = model->numface; numgrp += 2; } } grpidx[numgrp + 0] = cmd->arg[0]; grpidx[numgrp + 1] = cmd->arg[0] + cmd->arg[1]; numgrp += 2; } cd = &m3d_commandtypes[cmd->type]; for (k = n = 0, l = cd->p; k < l; k++) switch (cd->a[((k - n) % (cd->p - n)) + n]) { case m3dcp_mi_t: if (!(flags & M3D_EXP_NOMATERIAL) && cmd->arg[k] < model->nummaterial) mtrlidx[cmd->arg[k]] = 0; break; case m3dcp_ti_t: if (!(flags & M3D_EXP_NOTXTCRD) && cmd->arg[k] < model->numtmap) tmapidx[cmd->arg[k]] = 0; break; case m3dcp_qi_t: case m3dcp_vi_t: if (cmd->arg[k] < model->numvertex) vrtxidx[cmd->arg[k]] = 0; break; case m3dcp_va_t: n = k + 1; l += (cmd->arg[k] - 1) * (cd->p - k - 1); break; } } } } if (model->numface && face) { if (numgrp && grpidx) { qsort(grpidx, numgrp, sizeof(uint32_t), _m3d_grpcmp); for (i = j = 0; i < model->numface && j < numgrp; i++) { while (j < numgrp && grpidx[j] < i) j++; face[i].group = j; } } qsort(face, model->numface, sizeof(m3dfsave_t), _m3d_facecmp); } if (grpidx) { M3D_FREE(grpidx); grpidx = NULL; } if (model->numlabel && model->label) { M3D_LOG("Processing annotation labels"); for (i = 0; i < model->numlabel; i++) { str = _m3d_addstr(str, &numstr, model->label[i].name); str = _m3d_addstr(str, &numstr, model->label[i].lang); str = _m3d_addstr(str, &numstr, model->label[i].text); if (!(flags & M3D_EXP_NOCMAP)) { cmap = _m3d_addcmap(cmap, &numcmap, model->label[i].color); if (!cmap) goto memerr; } if (model->label[i].vertexid < model->numvertex) vrtxidx[model->label[i].vertexid] = 0; } qsort(model->label, model->numlabel, sizeof(m3dl_t), _m3d_lblcmp); } } else if (!(flags & M3D_EXP_NOMATERIAL)) { /* without a face, simply add all materials, because it can be an mtllib */ for (i = 0; i < model->nummaterial; i++) mtrlidx[i] = i; } /* bind-pose skeleton */ if (model->numbone && model->bone && !(flags & M3D_EXP_NOBONE)) { M3D_LOG("Processing bones"); for (i = 0; i < model->numbone; i++) { str = _m3d_addstr(str, &numstr, model->bone[i].name); if (!str) goto memerr; k = model->bone[i].pos; if (k < model->numvertex) vrtxidx[k] = 0; k = model->bone[i].ori; if (k < model->numvertex) vrtxidx[k] = 0; } } /* actions, animated skeleton poses */ if (model->numaction && model->action && !(flags & M3D_EXP_NOACTION)) { M3D_LOG("Processing action list"); for (j = 0; j < model->numaction; j++) { a = &model->action[j]; str = _m3d_addstr(str, &numstr, a->name); if (!str) goto memerr; if (a->numframe > 65535) a->numframe = 65535; for (i = 0; i < a->numframe; i++) { for (l = 0; l < a->frame[i].numtransform; l++) { k = a->frame[i].transform[l].pos; if (k < model->numvertex) vrtxidx[k] = 0; k = a->frame[i].transform[l].ori; if (k < model->numvertex) vrtxidx[k] = 0; } if (l > maxt) maxt = l; } } } /* add colors to color map and texture names to string table */ if (!(flags & M3D_EXP_NOMATERIAL)) { M3D_LOG("Processing materials"); for (i = k = 0; i < model->nummaterial; i++) { if (mtrlidx[i] == M3D_UNDEF || !model->material[i].numprop) continue; mtrlidx[i] = k++; m = &model->material[i]; str = _m3d_addstr(str, &numstr, m->name); if (!str) goto memerr; if (m->prop) for (j = 0; j < m->numprop; j++) { if (!(flags & M3D_EXP_NOCMAP) && m->prop[j].type < 128) { for (l = 0; l < sizeof(m3d_propertytypes) / sizeof(m3d_propertytypes[0]); l++) { if (m->prop[j].type == m3d_propertytypes[l].id && m3d_propertytypes[l].format == m3dpf_color) { ((uint8_t *)&m->prop[j].value.color)[3] = opa[i * 2 + 1]; cmap = _m3d_addcmap(cmap, &numcmap, m->prop[j].value.color); if (!cmap) goto memerr; break; } } } if (m->prop[j].type >= 128 && m->prop[j].value.textureid < model->numtexture && model->texture[m->prop[j].value.textureid].name) { str = _m3d_addstr(str, &numstr, model->texture[m->prop[j].value.textureid].name); if (!str) goto memerr; } } } } /* if there's only one black color, don't store it */ if (numcmap == 1 && cmap && !cmap[0]) numcmap = 0; /** compress lists **/ if (model->numtmap && !(flags & M3D_EXP_NOTXTCRD)) { M3D_LOG("Compressing tmap"); tmap = (m3dtisave_t *)M3D_MALLOC(model->numtmap * sizeof(m3dtisave_t)); if (!tmap) goto memerr; for (i = 0; i < model->numtmap; i++) { if (tmapidx[i] == M3D_UNDEF) continue; switch (quality) { case M3D_EXP_INT8: l = (unsigned int)(model->tmap[i].u * 255); tcoord.data.u = (M3D_FLOAT)l / (M3D_FLOAT)255.0; l = (unsigned int)(model->tmap[i].v * 255); tcoord.data.v = (M3D_FLOAT)l / (M3D_FLOAT)255.0; break; case M3D_EXP_INT16: l = (unsigned int)(model->tmap[i].u * 65535); tcoord.data.u = (M3D_FLOAT)l / (M3D_FLOAT)65535.0; l = (unsigned int)(model->tmap[i].v * 65535); tcoord.data.v = (M3D_FLOAT)l / (M3D_FLOAT)65535.0; break; default: tcoord.data.u = model->tmap[i].u; tcoord.data.v = model->tmap[i].v; break; } if (flags & M3D_EXP_FLIPTXTCRD) tcoord.data.v = (M3D_FLOAT)1.0 - tcoord.data.v; tcoord.oldidx = i; memcpy(&tmap[numtmap++], &tcoord, sizeof(m3dtisave_t)); } if (numtmap) { qsort(tmap, numtmap, sizeof(m3dtisave_t), _m3d_ticmp); memcpy(&tcoord.data, &tmap[0], sizeof(m3dti_t)); for (i = 0; i < numtmap; i++) { if (memcmp(&tcoord.data, &tmap[i].data, sizeof(m3dti_t))) { memcpy(&tcoord.data, &tmap[i].data, sizeof(m3dti_t)); maxtmap++; } tmap[i].newidx = maxtmap; tmapidx[tmap[i].oldidx] = maxtmap; } maxtmap++; } } if (model->numskin && model->skin && !(flags & M3D_EXP_NOBONE)) { M3D_LOG("Compressing skin"); skinidx = (M3D_INDEX *)M3D_MALLOC(model->numskin * sizeof(M3D_INDEX)); if (!skinidx) goto memerr; skin = (m3dssave_t *)M3D_MALLOC(model->numskin * sizeof(m3dssave_t)); if (!skin) goto memerr; memset(skinidx, 255, model->numskin * sizeof(M3D_INDEX)); for (i = 0; i < model->numvertex; i++) { if (vrtxidx[i] != M3D_UNDEF && model->vertex[i].skinid < model->numskin) skinidx[model->vertex[i].skinid] = 0; } for (i = 0; i < model->numskin; i++) { if (skinidx[i] == M3D_UNDEF) continue; memset(&sk, 0, sizeof(m3dssave_t)); for (j = 0, min_x = (M3D_FLOAT)0.0; j < M3D_NUMBONE && model->skin[i].boneid[j] != M3D_UNDEF && model->skin[i].weight[j] > (M3D_FLOAT)0.0; j++) { sk.data.boneid[j] = model->skin[i].boneid[j]; sk.data.weight[j] = model->skin[i].weight[j]; min_x += sk.data.weight[j]; } if (j > maxbone) maxbone = j; if (min_x != (M3D_FLOAT)1.0 && min_x != (M3D_FLOAT)0.0) for (j = 0; j < M3D_NUMBONE && sk.data.weight[j] > (M3D_FLOAT)0.0; j++) sk.data.weight[j] /= min_x; sk.oldidx = i; memcpy(&skin[numskin++], &sk, sizeof(m3dssave_t)); } if (numskin) { qsort(skin, numskin, sizeof(m3dssave_t), _m3d_skincmp); memcpy(&sk.data, &skin[0].data, sizeof(m3ds_t)); for (i = 0; i < numskin; i++) { if (memcmp(&sk.data, &skin[i].data, sizeof(m3ds_t))) { memcpy(&sk.data, &skin[i].data, sizeof(m3ds_t)); maxskin++; } skin[i].newidx = maxskin; skinidx[skin[i].oldidx] = maxskin; } maxskin++; } } M3D_LOG("Compressing vertex list"); min_x = min_y = min_z = (M3D_FLOAT)1e10; max_x = max_y = max_z = (M3D_FLOAT)-1e10; if (vrtxidx) { vrtx = (m3dvsave_t *)M3D_MALLOC(model->numvertex * sizeof(m3dvsave_t)); if (!vrtx) goto memerr; for (i = numvrtx = 0; i < model->numvertex; i++) { if (vrtxidx[i] == M3D_UNDEF) continue; _m3d_round(quality, &model->vertex[i], &vertex.data); vertex.norm = norm ? norm[i] : 0; if (vertex.data.skinid != M3D_INDEXMAX && !vertex.norm) { vertex.data.skinid = vertex.data.skinid != M3D_UNDEF && skinidx ? skinidx[vertex.data.skinid] : M3D_UNDEF; if (vertex.data.x > max_x) max_x = vertex.data.x; if (vertex.data.x < min_x) min_x = vertex.data.x; if (vertex.data.y > max_y) max_y = vertex.data.y; if (vertex.data.y < min_y) min_y = vertex.data.y; if (vertex.data.z > max_z) max_z = vertex.data.z; if (vertex.data.z < min_z) min_z = vertex.data.z; } #ifdef M3D_VERTEXTYPE vertex.data.type = 0; #endif vertex.oldidx = i; memcpy(&vrtx[numvrtx++], &vertex, sizeof(m3dvsave_t)); } if (numvrtx) { qsort(vrtx, numvrtx, sizeof(m3dvsave_t), _m3d_vrtxcmp); memcpy(&vertex.data, &vrtx[0].data, sizeof(m3dv_t)); for (i = 0; i < numvrtx; i++) { if (memcmp(&vertex.data, &vrtx[i].data, vrtx[i].norm ? 3 * sizeof(M3D_FLOAT) : sizeof(m3dv_t))) { memcpy(&vertex.data, &vrtx[i].data, sizeof(m3dv_t)); maxvrtx++; } vrtx[i].newidx = maxvrtx; vrtxidx[vrtx[i].oldidx] = maxvrtx; } maxvrtx++; } } if (skinidx) { M3D_FREE(skinidx); skinidx = NULL; } if (norm) { M3D_FREE(norm); norm = NULL; } /* normalize to bounding cube */ if (numvrtx && !(flags & M3D_EXP_NORECALC)) { M3D_LOG("Normalizing coordinates"); if (min_x < (M3D_FLOAT)0.0) min_x = -min_x; if (max_x < (M3D_FLOAT)0.0) max_x = -max_x; if (min_y < (M3D_FLOAT)0.0) min_y = -min_y; if (max_y < (M3D_FLOAT)0.0) max_y = -max_y; if (min_z < (M3D_FLOAT)0.0) min_z = -min_z; if (max_z < (M3D_FLOAT)0.0) max_z = -max_z; scale = min_x; if (max_x > scale) scale = max_x; if (min_y > scale) scale = min_y; if (max_y > scale) scale = max_y; if (min_z > scale) scale = min_z; if (max_z > scale) scale = max_z; if (scale == (M3D_FLOAT)0.0) scale = (M3D_FLOAT)1.0; if (scale != (M3D_FLOAT)1.0) { for (i = 0; i < numvrtx; i++) { if (vrtx[i].data.skinid == M3D_INDEXMAX) continue; vrtx[i].data.x /= scale; vrtx[i].data.y /= scale; vrtx[i].data.z /= scale; } } } if (model->scale > (M3D_FLOAT)0.0) scale = model->scale; if (scale <= (M3D_FLOAT)0.0) scale = (M3D_FLOAT)1.0; /* meta info */ sn = _m3d_safestr(model->name && *model->name ? model->name : (char *)"(noname)", 2); sl = _m3d_safestr(model->license ? model->license : (char *)"MIT", 2); sa = _m3d_safestr(model->author ? model->author : getenv("LOGNAME"), 2); if (!sn || !sl || !sa) { memerr: if (vrtxidx) M3D_FREE(vrtxidx); if (mtrlidx) M3D_FREE(mtrlidx); if (tmapidx) M3D_FREE(tmapidx); if (skinidx) M3D_FREE(skinidx); if (grpidx) M3D_FREE(grpidx); if (norm) M3D_FREE(norm); if (face) M3D_FREE(face); if (cmap) M3D_FREE(cmap); if (tmap) M3D_FREE(tmap); if (skin) M3D_FREE(skin); if (str) M3D_FREE(str); if (vrtx) M3D_FREE(vrtx); if (sn) M3D_FREE(sn); if (sl) M3D_FREE(sl); if (sa) M3D_FREE(sa); if (sd) M3D_FREE(sd); if (out) M3D_FREE(out); if (h) M3D_FREE(h); M3D_LOG("Out of memory"); model->errcode = M3D_ERR_ALLOC; return NULL; } M3D_LOG("Serializing model"); if (flags & M3D_EXP_ASCII) { /* use CRLF to make model creators on Win happy... */ sd = _m3d_safestr(model->desc, 1); if (!sd) goto memerr; ol = setlocale(LC_NUMERIC, NULL); setlocale(LC_NUMERIC, "C"); /* header */ len = 64 + (unsigned int)(strlen(sn) + strlen(sl) + strlen(sa) + strlen(sd)); out = (unsigned char *)M3D_MALLOC(len); if (!out) { setlocale(LC_NUMERIC, ol); goto memerr; } ptr = (char *)out; ptr += sprintf(ptr, "3dmodel %g\r\n%s\r\n%s\r\n%s\r\n%s\r\n\r\n", scale, sn, sl, sa, sd); M3D_FREE(sl); M3D_FREE(sa); M3D_FREE(sd); sl = sa = sd = NULL; /* preview chunk */ if (model->preview.data && model->preview.length) { sl = _m3d_safestr(sn, 0); if (sl) { ptr -= (uintptr_t)out; len = (unsigned int)((uintptr_t)ptr + (uintptr_t)20); out = (unsigned char *)M3D_REALLOC(out, len); ptr += (uintptr_t)out; if (!out) { setlocale(LC_NUMERIC, ol); goto memerr; } ptr += sprintf(ptr, "Preview\r\n%s.png\r\n\r\n", sl); M3D_FREE(sl); sl = NULL; } } M3D_FREE(sn); sn = NULL; /* texture map */ if (numtmap && tmap && !(flags & M3D_EXP_NOTXTCRD) && !(flags & M3D_EXP_NOFACE)) { ptr -= (uintptr_t)out; len = (unsigned int)((uintptr_t)ptr + (uintptr_t)(maxtmap * 32) + (uintptr_t)12); out = (unsigned char *)M3D_REALLOC(out, len); ptr += (uintptr_t)out; if (!out) { setlocale(LC_NUMERIC, ol); goto memerr; } ptr += sprintf(ptr, "Textmap\r\n"); last = M3D_UNDEF; for (i = 0; i < numtmap; i++) { if (tmap[i].newidx == last) continue; last = tmap[i].newidx; ptr += sprintf(ptr, "%g %g\r\n", tmap[i].data.u, tmap[i].data.v); } ptr += sprintf(ptr, "\r\n"); } /* vertex chunk */ if (numvrtx && vrtx && !(flags & M3D_EXP_NOFACE)) { ptr -= (uintptr_t)out; len = (unsigned int)((uintptr_t)ptr + (uintptr_t)(maxvrtx * 128) + (uintptr_t)10); out = (unsigned char *)M3D_REALLOC(out, len); ptr += (uintptr_t)out; if (!out) { setlocale(LC_NUMERIC, ol); goto memerr; } ptr += sprintf(ptr, "Vertex\r\n"); last = M3D_UNDEF; for (i = 0; i < numvrtx; i++) { if (vrtx[i].newidx == last) continue; last = vrtx[i].newidx; ptr += sprintf(ptr, "%g %g %g %g", vrtx[i].data.x, vrtx[i].data.y, vrtx[i].data.z, vrtx[i].data.w); if (!(flags & M3D_EXP_NOCMAP) && vrtx[i].data.color) ptr += sprintf(ptr, " #%08x", vrtx[i].data.color); if (!(flags & M3D_EXP_NOBONE) && model->numbone && maxskin && vrtx[i].data.skinid < M3D_INDEXMAX) { if (skin[vrtx[i].data.skinid].data.weight[0] == (M3D_FLOAT)1.0) ptr += sprintf(ptr, " %d", skin[vrtx[i].data.skinid].data.boneid[0]); else for (j = 0; j < M3D_NUMBONE && skin[vrtx[i].data.skinid].data.boneid[j] != M3D_UNDEF && skin[vrtx[i].data.skinid].data.weight[j] > (M3D_FLOAT)0.0; j++) ptr += sprintf(ptr, " %d:%g", skin[vrtx[i].data.skinid].data.boneid[j], skin[vrtx[i].data.skinid].data.weight[j]); } ptr += sprintf(ptr, "\r\n"); } ptr += sprintf(ptr, "\r\n"); } /* bones chunk */ if (model->numbone && model->bone && !(flags & M3D_EXP_NOBONE)) { ptr -= (uintptr_t)out; len = (unsigned int)((uintptr_t)ptr + (uintptr_t)9); for (i = 0; i < model->numbone; i++) { len += (unsigned int)strlen(model->bone[i].name) + 128; } out = (unsigned char *)M3D_REALLOC(out, len); ptr += (uintptr_t)out; if (!out) { setlocale(LC_NUMERIC, ol); goto memerr; } ptr += sprintf(ptr, "Bones\r\n"); ptr = _m3d_prtbone(ptr, model->bone, model->numbone, M3D_UNDEF, 0, vrtxidx); ptr += sprintf(ptr, "\r\n"); } /* materials */ if (model->nummaterial && !(flags & M3D_EXP_NOMATERIAL)) { for (j = 0; j < model->nummaterial; j++) { if (mtrlidx[j] == M3D_UNDEF || !model->material[j].numprop || !model->material[j].prop) continue; m = &model->material[j]; sn = _m3d_safestr(m->name, 0); if (!sn) { setlocale(LC_NUMERIC, ol); goto memerr; } ptr -= (uintptr_t)out; len = (unsigned int)((uintptr_t)ptr + (uintptr_t)strlen(sn) + (uintptr_t)12); for (i = 0; i < m->numprop; i++) { if (m->prop[i].type < 128) len += 32; else if (m->prop[i].value.textureid < model->numtexture && model->texture[m->prop[i].value.textureid].name) len += (unsigned int)strlen(model->texture[m->prop[i].value.textureid].name) + 16; } out = (unsigned char *)M3D_REALLOC(out, len); ptr += (uintptr_t)out; if (!out) { setlocale(LC_NUMERIC, ol); goto memerr; } ptr += sprintf(ptr, "Material %s\r\n", sn); M3D_FREE(sn); sn = NULL; for (i = 0; i < m->numprop; i++) { k = 256; if (m->prop[i].type >= 128) { for (l = 0; l < sizeof(m3d_propertytypes) / sizeof(m3d_propertytypes[0]); l++) if (m->prop[i].type == m3d_propertytypes[l].id) { sn = m3d_propertytypes[l].key; break; } if (!sn) for (l = 0; l < sizeof(m3d_propertytypes) / sizeof(m3d_propertytypes[0]); l++) if (m->prop[i].type - 128 == m3d_propertytypes[l].id) { sn = m3d_propertytypes[l].key; break; } k = sn ? m3dpf_map : 256; } else { for (l = 0; l < sizeof(m3d_propertytypes) / sizeof(m3d_propertytypes[0]); l++) if (m->prop[i].type == m3d_propertytypes[l].id) { sn = m3d_propertytypes[l].key; k = m3d_propertytypes[l].format; break; } } switch (k) { case m3dpf_color: ptr += sprintf(ptr, "%s #%08x\r\n", sn, m->prop[i].value.color); break; case m3dpf_uint8: case m3dpf_uint16: case m3dpf_uint32: ptr += sprintf(ptr, "%s %d\r\n", sn, m->prop[i].value.num); break; case m3dpf_float: ptr += sprintf(ptr, "%s %g\r\n", sn, m->prop[i].value.fnum); break; case m3dpf_map: if (m->prop[i].value.textureid < model->numtexture && model->texture[m->prop[i].value.textureid].name) { sl = _m3d_safestr(model->texture[m->prop[i].value.textureid].name, 0); if (!sl) { setlocale(LC_NUMERIC, ol); goto memerr; } if (*sl) ptr += sprintf(ptr, "map_%s %s\r\n", sn, sl); M3D_FREE(sn); M3D_FREE(sl); sl = NULL; } break; } sn = NULL; } ptr += sprintf(ptr, "\r\n"); } } /* procedural face */ if (model->numinlined && model->inlined && !(flags & M3D_EXP_NOFACE)) { /* all inlined assets which are not textures should be procedural surfaces */ for (j = 0; j < model->numinlined; j++) { if (!model->inlined[j].name || !*model->inlined[j].name || !model->inlined[j].length || !model->inlined[j].data || (model->inlined[j].data[1] == 'P' && model->inlined[j].data[2] == 'N' && model->inlined[j].data[3] == 'G')) continue; for (i = k = 0; i < model->numtexture; i++) { if (!strcmp(model->inlined[j].name, model->texture[i].name)) { k = 1; break; } } if (k) continue; sn = _m3d_safestr(model->inlined[j].name, 0); if (!sn) { setlocale(LC_NUMERIC, ol); goto memerr; } ptr -= (uintptr_t)out; len = (unsigned int)((uintptr_t)ptr + (uintptr_t)strlen(sn) + (uintptr_t)18); out = (unsigned char *)M3D_REALLOC(out, len); ptr += (uintptr_t)out; if (!out) { setlocale(LC_NUMERIC, ol); goto memerr; } ptr += sprintf(ptr, "Procedural\r\n%s\r\n\r\n", sn); M3D_FREE(sn); sn = NULL; } } /* mesh face */ if (model->numface && face && !(flags & M3D_EXP_NOFACE)) { ptr -= (uintptr_t)out; len = (unsigned int)((uintptr_t)ptr + (uintptr_t)(model->numface * 128) + (uintptr_t)6); last = M3D_UNDEF; if (!(flags & M3D_EXP_NOMATERIAL)) for (i = 0; i < model->numface; i++) { j = face[i].data.materialid < model->nummaterial ? face[i].data.materialid : M3D_UNDEF; if (j != last) { last = j; if (last < model->nummaterial) len += (unsigned int)strlen(model->material[last].name); len += 6; } } out = (unsigned char *)M3D_REALLOC(out, len); ptr += (uintptr_t)out; if (!out) { setlocale(LC_NUMERIC, ol); goto memerr; } ptr += sprintf(ptr, "Mesh\r\n"); last = M3D_UNDEF; for (i = 0; i < model->numface; i++) { j = face[i].data.materialid < model->nummaterial ? face[i].data.materialid : M3D_UNDEF; if (!(flags & M3D_EXP_NOMATERIAL) && j != last) { last = j; if (last < model->nummaterial) { sn = _m3d_safestr(model->material[last].name, 0); if (!sn) { setlocale(LC_NUMERIC, ol); goto memerr; } ptr += sprintf(ptr, "use %s\r\n", sn); M3D_FREE(sn); sn = NULL; } else ptr += sprintf(ptr, "use\r\n"); } /* hardcoded triangles. Should be repeated as many times as the number of edges in polygon */ for (j = 0; j < 3; j++) { ptr += sprintf(ptr, "%s%d", j ? " " : "", vrtxidx[face[i].data.vertex[j]]); k = M3D_NOTDEFINED; if (!(flags & M3D_EXP_NOTXTCRD) && (face[i].data.texcoord[j] != M3D_UNDEF) && (tmapidx[face[i].data.texcoord[j]] != M3D_UNDEF)) { k = tmapidx[face[i].data.texcoord[j]]; ptr += sprintf(ptr, "/%d", k); } if (!(flags & M3D_EXP_NONORMAL) && (face[i].data.normal[j] != M3D_UNDEF)) ptr += sprintf(ptr, "%s/%d", k == M3D_NOTDEFINED ? "/" : "", vrtxidx[face[i].data.normal[j]]); } ptr += sprintf(ptr, "\r\n"); } ptr += sprintf(ptr, "\r\n"); } /* mathematical shapes face */ if (model->numshape && (!(flags & M3D_EXP_NOFACE))) { for (j = 0; j < model->numshape; j++) { sn = _m3d_safestr(model->shape[j].name, 0); if (!sn) { setlocale(LC_NUMERIC, ol); goto memerr; } ptr -= (uintptr_t)out; len = (unsigned int)((uintptr_t)ptr + (uintptr_t)strlen(sn) + (uintptr_t)33); out = (unsigned char *)M3D_REALLOC(out, len); ptr += (uintptr_t)out; if (!out) { setlocale(LC_NUMERIC, ol); goto memerr; } ptr += sprintf(ptr, "Shape %s\r\n", sn); M3D_FREE(sn); sn = NULL; if (model->shape[j].group != M3D_UNDEF && !(flags & M3D_EXP_NOBONE)) ptr += sprintf(ptr, "group %d\r\n", model->shape[j].group); for (i = 0; i < model->shape[j].numcmd; i++) { cmd = &model->shape[j].cmd[i]; if (cmd->type >= (unsigned int)(sizeof(m3d_commandtypes) / sizeof(m3d_commandtypes[0])) || !cmd->arg) continue; cd = &m3d_commandtypes[cmd->type]; ptr -= (uintptr_t)out; len = (unsigned int)((uintptr_t)ptr + (uintptr_t)strlen(cd->key) + (uintptr_t)3); for (k = 0; k < cd->p; k++) switch (cd->a[k]) { case m3dcp_mi_t: if (cmd->arg[k] != M3D_NOTDEFINED) { len += (unsigned int)strlen(model->material[cmd->arg[k]].name) + 1; } break; case m3dcp_va_t: len += cmd->arg[k] * (cd->p - k - 1) * 16; k = cd->p; break; default: len += 16; break; } out = (unsigned char *)M3D_REALLOC(out, len); ptr += (uintptr_t)out; if (!out) { setlocale(LC_NUMERIC, ol); goto memerr; } ptr += sprintf(ptr, "%s", cd->key); for (k = n = 0, l = cd->p; k < l; k++) { switch (cd->a[((k - n) % (cd->p - n)) + n]) { case m3dcp_mi_t: if (cmd->arg[k] != M3D_NOTDEFINED) { sn = _m3d_safestr(model->material[cmd->arg[k]].name, 0); if (!sn) { setlocale(LC_NUMERIC, ol); goto memerr; } ptr += sprintf(ptr, " %s", sn); M3D_FREE(sn); sn = NULL; } break; case m3dcp_vc_t: ptr += sprintf(ptr, " %g", *((float *)&cmd->arg[k])); break; case m3dcp_va_t: ptr += sprintf(ptr, " %d[", cmd->arg[k]); n = k + 1; l += (cmd->arg[k] - 1) * (cd->p - k - 1); break; default: ptr += sprintf(ptr, " %d", cmd->arg[k]); break; } } ptr += sprintf(ptr, "%s\r\n", l > cd->p ? " ]" : ""); } ptr += sprintf(ptr, "\r\n"); } } /* annotation labels */ if (model->numlabel && model->label && !(flags & M3D_EXP_NOFACE)) { for (i = 0, j = 3, length = NULL; i < model->numlabel; i++) { if (model->label[i].name) j += (unsigned int)strlen(model->label[i].name); if (model->label[i].lang) j += (unsigned int)strlen(model->label[i].lang); if (model->label[i].text) j += (unsigned int)strlen(model->label[i].text); j += 40; } ptr -= (uintptr_t)out; len = (unsigned int)((uintptr_t)ptr + (uintptr_t)j); out = (unsigned char *)M3D_REALLOC(out, len); ptr += (uintptr_t)out; if (!out) { setlocale(LC_NUMERIC, ol); goto memerr; } for (i = 0; i < model->numlabel; i++) { if (!i || _m3d_strcmp(sl, model->label[i].lang) || _m3d_strcmp(sn, model->label[i].name)) { sl = model->label[i].lang; sn = model->label[i].name; sd = _m3d_safestr(sn, 0); if (!sd) { setlocale(LC_NUMERIC, ol); sn = sl = NULL; goto memerr; } if (i) ptr += sprintf(ptr, "\r\n"); ptr += sprintf(ptr, "Labels %s\r\n", sd); M3D_FREE(sd); sd = NULL; if (model->label[i].color) ptr += sprintf(ptr, "color #0x%08x\r\n", model->label[i].color); if (sl && *sl) { sd = _m3d_safestr(sl, 0); if (!sd) { setlocale(LC_NUMERIC, ol); sn = sl = NULL; goto memerr; } ptr += sprintf(ptr, "lang %s\r\n", sd); M3D_FREE(sd); sd = NULL; } } sd = _m3d_safestr(model->label[i].text, 2); if (!sd) { setlocale(LC_NUMERIC, ol); sn = sl = NULL; goto memerr; } ptr += sprintf(ptr, "%d %s\r\n", model->label[i].vertexid, sd); M3D_FREE(sd); sd = NULL; } ptr += sprintf(ptr, "\r\n"); sn = sl = NULL; } /* actions */ if (model->numaction && model->action && !(flags & M3D_EXP_NOACTION)) { for (j = 0; j < model->numaction; j++) { a = &model->action[j]; sn = _m3d_safestr(a->name, 0); if (!sn) { setlocale(LC_NUMERIC, ol); goto memerr; } ptr -= (uintptr_t)out; len = (unsigned int)((uintptr_t)ptr + (uintptr_t)strlen(sn) + (uintptr_t)48); for (i = 0; i < a->numframe; i++) len += a->frame[i].numtransform * 128 + 8; out = (unsigned char *)M3D_REALLOC(out, len); ptr += (uintptr_t)out; if (!out) { setlocale(LC_NUMERIC, ol); goto memerr; } ptr += sprintf(ptr, "Action %d %s\r\n", a->durationmsec, sn); M3D_FREE(sn); sn = NULL; for (i = 0; i < a->numframe; i++) { ptr += sprintf(ptr, "frame %d\r\n", a->frame[i].msec); for (k = 0; k < a->frame[i].numtransform; k++) { ptr += sprintf(ptr, "%d %d %d\r\n", a->frame[i].transform[k].boneid, vrtxidx[a->frame[i].transform[k].pos], vrtxidx[a->frame[i].transform[k].ori]); } } ptr += sprintf(ptr, "\r\n"); } } /* inlined assets */ if (model->numinlined && model->inlined) { for (i = j = 0; i < model->numinlined; i++) if (model->inlined[i].name) j += (unsigned int)strlen(model->inlined[i].name) + 6; if (j > 0) { ptr -= (uintptr_t)out; len = (unsigned int)((uintptr_t)ptr + (uintptr_t)j + (uintptr_t)16); out = (unsigned char *)M3D_REALLOC(out, len); ptr += (uintptr_t)out; if (!out) { setlocale(LC_NUMERIC, ol); goto memerr; } ptr += sprintf(ptr, "Assets\r\n"); for (i = 0; i < model->numinlined; i++) if (model->inlined[i].name) ptr += sprintf(ptr, "%s%s\r\n", model->inlined[i].name, strrchr(model->inlined[i].name, '.') ? "" : ".png"); ptr += sprintf(ptr, "\r\n"); } } /* extra info */ if (model->numextra && (flags & M3D_EXP_EXTRA)) { for (i = 0; i < model->numextra; i++) { if (model->extra[i]->length < 9) continue; ptr -= (uintptr_t)out; len = (unsigned int)((uintptr_t)ptr + (uintptr_t)17 + (uintptr_t)(model->extra[i]->length * 3)); out = (unsigned char *)M3D_REALLOC(out, len); ptr += (uintptr_t)out; if (!out) { setlocale(LC_NUMERIC, ol); goto memerr; } ptr += sprintf(ptr, "Extra %c%c%c%c\r\n", model->extra[i]->magic[0] > ' ' ? model->extra[i]->magic[0] : '_', model->extra[i]->magic[1] > ' ' ? model->extra[i]->magic[1] : '_', model->extra[i]->magic[2] > ' ' ? model->extra[i]->magic[2] : '_', model->extra[i]->magic[3] > ' ' ? model->extra[i]->magic[3] : '_'); for (j = 0; j < model->extra[i]->length; j++) ptr += sprintf(ptr, "%02x ", *((unsigned char *)model->extra + sizeof(m3dchunk_t) + j)); ptr--; ptr += sprintf(ptr, "\r\n\r\n"); } } setlocale(LC_NUMERIC, ol); len = (unsigned int)((uintptr_t)ptr - (uintptr_t)out); out = (unsigned char *)M3D_REALLOC(out, len + 1); if (!out) goto memerr; out[len] = 0; } else { /* strictly only use LF (newline) in binary */ sd = _m3d_safestr(model->desc, 3); if (!sd) goto memerr; /* header */ h = (m3dhdr_t *)M3D_MALLOC(sizeof(m3dhdr_t) + strlen(sn) + strlen(sl) + strlen(sa) + strlen(sd) + 4); if (!h) goto memerr; memcpy((uint8_t *)h, "HEAD", 4); h->length = sizeof(m3dhdr_t); h->scale = scale; i = (unsigned int)strlen(sn); memcpy((uint8_t *)h + h->length, sn, i + 1); h->length += i + 1; M3D_FREE(sn); i = (unsigned int)strlen(sl); memcpy((uint8_t *)h + h->length, sl, i + 1); h->length += i + 1; M3D_FREE(sl); i = (unsigned int)strlen(sa); memcpy((uint8_t *)h + h->length, sa, i + 1); h->length += i + 1; M3D_FREE(sa); i = (unsigned int)strlen(sd); memcpy((uint8_t *)h + h->length, sd, i + 1); h->length += i + 1; M3D_FREE(sd); sn = sl = sa = sd = NULL; if (model->inlined) for (i = 0; i < model->numinlined; i++) { if (model->inlined[i].name && *model->inlined[i].name && model->inlined[i].length > 0) { str = _m3d_addstr(str, &numstr, model->inlined[i].name); if (!str) goto memerr; } } if (str) for (i = 0; i < numstr; i++) { h = _m3d_addhdr(h, &str[i]); if (!h) goto memerr; } vc_s = quality == M3D_EXP_INT8 ? 1 : (quality == M3D_EXP_INT16 ? 2 : (quality == M3D_EXP_DOUBLE ? 8 : 4)); vi_s = maxvrtx < 254 ? 1 : (maxvrtx < 65534 ? 2 : 4); si_s = h->length - 16 < 254 ? 1 : (h->length - 16 < 65534 ? 2 : 4); ci_s = !numcmap || !cmap ? 0 : (numcmap < 254 ? 1 : (numcmap < 65534 ? 2 : 4)); ti_s = !maxtmap || !tmap ? 0 : (maxtmap < 254 ? 1 : (maxtmap < 65534 ? 2 : 4)); bi_s = !model->numbone || !model->bone || (flags & M3D_EXP_NOBONE) ? 0 : (model->numbone < 254 ? 1 : (model->numbone < 65534 ? 2 : 4)); nb_s = maxbone < 2 ? 1 : (maxbone == 2 ? 2 : (maxbone <= 4 ? 4 : 8)); sk_s = !bi_s || !maxskin || !skin ? 0 : (maxskin < 254 ? 1 : (maxskin < 65534 ? 2 : 4)); fc_s = maxt < 254 ? 1 : (maxt < 65534 ? 2 : 4); hi_s = !model->numshape || !model->shape || (flags & M3D_EXP_NOFACE) ? 0 : (model->numshape < 254 ? 1 : (model->numshape < 65534 ? 2 : 4)); fi_s = !model->numface || !model->face || (flags & M3D_EXP_NOFACE) ? 0 : (model->numface < 254 ? 1 : (model->numface < 65534 ? 2 : 4)); h->types = (vc_s == 8 ? (3 << 0) : (vc_s == 2 ? (1 << 0) : (vc_s == 1 ? (0 << 0) : (2 << 0)))) | (vi_s == 2 ? (1 << 2) : (vi_s == 1 ? (0 << 2) : (2 << 2))) | (si_s == 2 ? (1 << 4) : (si_s == 1 ? (0 << 4) : (2 << 4))) | (ci_s == 2 ? (1 << 6) : (ci_s == 1 ? (0 << 6) : (ci_s == 4 ? (2 << 6) : (3 << 6)))) | (ti_s == 2 ? (1 << 8) : (ti_s == 1 ? (0 << 8) : (ti_s == 4 ? (2 << 8) : (3 << 8)))) | (bi_s == 2 ? (1 << 10) : (bi_s == 1 ? (0 << 10) : (bi_s == 4 ? (2 << 10) : (3 << 10)))) | (nb_s == 2 ? (1 << 12) : (nb_s == 1 ? (0 << 12) : (2 << 12))) | (sk_s == 2 ? (1 << 14) : (sk_s == 1 ? (0 << 14) : (sk_s == 4 ? (2 << 14) : (3 << 14)))) | (fc_s == 2 ? (1 << 16) : (fc_s == 1 ? (0 << 16) : (2 << 16))) | (hi_s == 2 ? (1 << 18) : (hi_s == 1 ? (0 << 18) : (hi_s == 4 ? (2 << 18) : (3 << 18)))) | (fi_s == 2 ? (1 << 20) : (fi_s == 1 ? (0 << 20) : (fi_s == 4 ? (2 << 20) : (3 << 20)))); len = h->length; /* preview image chunk, must be the first if exists */ if (model->preview.data && model->preview.length) { chunklen = 8 + model->preview.length; h = (m3dhdr_t *)M3D_REALLOC(h, len + chunklen); if (!h) goto memerr; memcpy((uint8_t *)h + len, "PRVW", 4); *((uint32_t *)((uint8_t *)h + len + 4)) = chunklen; memcpy((uint8_t *)h + len + 8, model->preview.data, model->preview.length); len += chunklen; } /* color map */ if (numcmap && cmap && ci_s < 4 && !(flags & M3D_EXP_NOCMAP)) { chunklen = 8 + numcmap * sizeof(uint32_t); h = (m3dhdr_t *)M3D_REALLOC(h, len + chunklen); if (!h) goto memerr; memcpy((uint8_t *)h + len, "CMAP", 4); *((uint32_t *)((uint8_t *)h + len + 4)) = chunklen; memcpy((uint8_t *)h + len + 8, cmap, chunklen - 8); len += chunklen; } else numcmap = 0; /* texture map */ if (numtmap && tmap && !(flags & M3D_EXP_NOTXTCRD) && !(flags & M3D_EXP_NOFACE)) { chunklen = 8 + maxtmap * vc_s * 2; h = (m3dhdr_t *)M3D_REALLOC(h, len + chunklen); if (!h) goto memerr; memcpy((uint8_t *)h + len, "TMAP", 4); length = (uint32_t *)((uint8_t *)h + len + 4); out = (uint8_t *)h + len + 8; last = M3D_UNDEF; for (i = 0; i < numtmap; i++) { if (tmap[i].newidx == last) continue; last = tmap[i].newidx; switch (vc_s) { case 1: *out++ = (uint8_t)(tmap[i].data.u * 255); *out++ = (uint8_t)(tmap[i].data.v * 255); break; case 2: *((uint16_t *)out) = (uint16_t)(tmap[i].data.u * 65535); out += 2; *((uint16_t *)out) = (uint16_t)(tmap[i].data.v * 65535); out += 2; break; case 4: *((float *)out) = tmap[i].data.u; out += 4; *((float *)out) = tmap[i].data.v; out += 4; break; case 8: *((double *)out) = tmap[i].data.u; out += 8; *((double *)out) = tmap[i].data.v; out += 8; break; } } *length = (uint32_t)((uintptr_t)out - (uintptr_t)((uint8_t *)h + len)); out = NULL; len += *length; } /* vertex */ if (numvrtx && vrtx) { chunklen = 8 + maxvrtx * (ci_s + sk_s + 4 * vc_s); h = (m3dhdr_t *)M3D_REALLOC(h, len + chunklen); if (!h) goto memerr; memcpy((uint8_t *)h + len, "VRTS", 4); length = (uint32_t *)((uint8_t *)h + len + 4); out = (uint8_t *)h + len + 8; last = M3D_UNDEF; for (i = 0; i < numvrtx; i++) { if (vrtx[i].newidx == last) continue; last = vrtx[i].newidx; switch (vc_s) { case 1: *out++ = (int8_t)(vrtx[i].data.x * 127); *out++ = (int8_t)(vrtx[i].data.y * 127); *out++ = (int8_t)(vrtx[i].data.z * 127); *out++ = (int8_t)(vrtx[i].data.w * 127); break; case 2: *((int16_t *)out) = (int16_t)(vrtx[i].data.x * 32767); out += 2; *((int16_t *)out) = (int16_t)(vrtx[i].data.y * 32767); out += 2; *((int16_t *)out) = (int16_t)(vrtx[i].data.z * 32767); out += 2; *((int16_t *)out) = (int16_t)(vrtx[i].data.w * 32767); out += 2; break; case 4: memcpy(out, &vrtx[i].data.x, sizeof(float)); out += 4; memcpy(out, &vrtx[i].data.y, sizeof(float)); out += 4; memcpy(out, &vrtx[i].data.z, sizeof(float)); out += 4; memcpy(out, &vrtx[i].data.w, sizeof(float)); out += 4; break; case 8: *((double *)out) = vrtx[i].data.x; out += 8; *((double *)out) = vrtx[i].data.y; out += 8; *((double *)out) = vrtx[i].data.z; out += 8; *((double *)out) = vrtx[i].data.w; out += 8; break; } idx = _m3d_cmapidx(cmap, numcmap, vrtx[i].data.color); switch (ci_s) { case 1: *out++ = (uint8_t)(idx); break; case 2: *((uint16_t *)out) = (uint16_t)(idx); out += 2; break; case 4: *((uint32_t *)out) = vrtx[i].data.color; out += 4; break; } out = _m3d_addidx(out, sk_s, vrtx[i].data.skinid); } uint32_t v = (uint32_t)((uintptr_t)out - (uintptr_t)((uint8_t *)h + len)); memcpy(length, &v, sizeof(uint32_t)); //*length = (uint32_t)((uintptr_t)out - (uintptr_t)((uint8_t *)h + len)); out = NULL; len += v; } /* bones chunk */ if (model->numbone && model->bone && !(flags & M3D_EXP_NOBONE)) { i = 8 + bi_s + sk_s + model->numbone * (bi_s + si_s + 2 * vi_s); chunklen = i + numskin * nb_s * (bi_s + 1); h = (m3dhdr_t *)M3D_REALLOC(h, len + chunklen); if (!h) goto memerr; memcpy((uint8_t *)h + len, "BONE", 4); length = (uint32_t *)((uint8_t *)h + len + 4); out = (uint8_t *)h + len + 8; out = _m3d_addidx(out, bi_s, model->numbone); out = _m3d_addidx(out, sk_s, maxskin); for (i = 0; i < model->numbone; i++) { out = _m3d_addidx(out, bi_s, model->bone[i].parent); out = _m3d_addidx(out, si_s, _m3d_stridx(str, numstr, model->bone[i].name)); out = _m3d_addidx(out, vi_s, vrtxidx[model->bone[i].pos]); out = _m3d_addidx(out, vi_s, vrtxidx[model->bone[i].ori]); } if (numskin && skin && sk_s) { last = M3D_UNDEF; for (i = 0; i < numskin; i++) { if (skin[i].newidx == last) continue; last = skin[i].newidx; memset(&weights, 0, nb_s); for (j = 0; j < (uint32_t)nb_s && skin[i].data.boneid[j] != M3D_UNDEF && skin[i].data.weight[j] > (M3D_FLOAT)0.0; j++) weights[j] = (uint8_t)(skin[i].data.weight[j] * 255); switch (nb_s) { case 1: weights[0] = 255; break; case 2: *((uint16_t *)out) = *((uint16_t *)&weights[0]); out += 2; break; case 4: *((uint32_t *)out) = *((uint32_t *)&weights[0]); out += 4; break; case 8: *((uint64_t *)out) = *((uint64_t *)&weights[0]); out += 8; break; } for (j = 0; j < (uint32_t)nb_s && skin[i].data.boneid[j] != M3D_UNDEF && weights[j]; j++) { out = _m3d_addidx(out, bi_s, skin[i].data.boneid[j]); *length += bi_s; } } } *length = (uint32_t)((uintptr_t)out - (uintptr_t)((uint8_t *)h + len)); out = NULL; len += *length; } /* materials */ if (model->nummaterial && !(flags & M3D_EXP_NOMATERIAL)) { for (j = 0; j < model->nummaterial; j++) { if (mtrlidx[j] == M3D_UNDEF || !model->material[j].numprop || !model->material[j].prop) continue; m = &model->material[j]; chunklen = 12 + si_s + m->numprop * 5; h = (m3dhdr_t *)M3D_REALLOC(h, len + chunklen); if (!h) goto memerr; memcpy((uint8_t *)h + len, "MTRL", 4); length = (uint32_t *)((uint8_t *)h + len + 4); out = (uint8_t *)h + len + 8; out = _m3d_addidx(out, si_s, _m3d_stridx(str, numstr, m->name)); for (i = 0; i < m->numprop; i++) { if (m->prop[i].type >= 128) { if (m->prop[i].value.textureid >= model->numtexture || !model->texture[m->prop[i].value.textureid].name) continue; k = m3dpf_map; } else { for (k = 256, l = 0; l < sizeof(m3d_propertytypes) / sizeof(m3d_propertytypes[0]); l++) if (m->prop[i].type == m3d_propertytypes[l].id) { k = m3d_propertytypes[l].format; break; } } if (k == 256) continue; *out++ = m->prop[i].type; switch (k) { case m3dpf_color: if (!(flags & M3D_EXP_NOCMAP)) { idx = _m3d_cmapidx(cmap, numcmap, m->prop[i].value.color); switch (ci_s) { case 1: *out++ = (uint8_t)(idx); break; case 2: *((uint16_t *)out) = (uint16_t)(idx); out += 2; break; case 4: *((uint32_t *)out) = (uint32_t)(m->prop[i].value.color); out += 4; break; } } else out--; break; case m3dpf_uint8: *out++ = (uint8_t)m->prop[i].value.num; break; case m3dpf_uint16: *((uint16_t *)out) = (uint16_t)m->prop[i].value.num; out += 2; break; case m3dpf_uint32: *((uint32_t *)out) = m->prop[i].value.num; out += 4; break; case m3dpf_float: *((float *)out) = m->prop[i].value.fnum; out += 4; break; case m3dpf_map: idx = _m3d_stridx(str, numstr, model->texture[m->prop[i].value.textureid].name); out = _m3d_addidx(out, si_s, idx); break; } } *length = (uint32_t)((uintptr_t)out - (uintptr_t)((uint8_t *)h + len)); len += *length; out = NULL; } } /* procedural face */ if (model->numinlined && model->inlined && !(flags & M3D_EXP_NOFACE)) { /* all inlined assets which are not textures should be procedural surfaces */ for (j = 0; j < model->numinlined; j++) { if (!model->inlined[j].name || !model->inlined[j].name[0] || model->inlined[j].length < 4 || !model->inlined[j].data || (model->inlined[j].data[1] == 'P' && model->inlined[j].data[2] == 'N' && model->inlined[j].data[3] == 'G')) continue; for (i = k = 0; i < model->numtexture; i++) { if (!strcmp(model->inlined[j].name, model->texture[i].name)) { k = 1; break; } } if (k) continue; numproc++; chunklen = 8 + si_s; h = (m3dhdr_t *)M3D_REALLOC(h, len + chunklen); if (!h) goto memerr; memcpy((uint8_t *)h + len, "PROC", 4); *((uint32_t *)((uint8_t *)h + len + 4)) = chunklen; out = (uint8_t *)h + len + 8; out = _m3d_addidx(out, si_s, _m3d_stridx(str, numstr, model->inlined[j].name)); out = NULL; len += chunklen; } } /* mesh face */ if (model->numface && face && !(flags & M3D_EXP_NOFACE)) { chunklen = 8 + si_s + model->numface * (6 * vi_s + 3 * ti_s + si_s + 1); h = (m3dhdr_t *)M3D_REALLOC(h, len + chunklen); if (!h) goto memerr; memcpy((uint8_t *)h + len, "MESH", 4); length = (uint32_t *)((uint8_t *)h + len + 4); out = (uint8_t *)h + len + 8; last = M3D_UNDEF; for (i = 0; i < model->numface; i++) { if (!(flags & M3D_EXP_NOMATERIAL) && face[i].data.materialid != last) { last = face[i].data.materialid; idx = last < model->nummaterial ? _m3d_stridx(str, numstr, model->material[last].name) : 0; *out++ = 0; out = _m3d_addidx(out, si_s, idx); } /* hardcoded triangles. */ k = (3 << 4) | (((flags & M3D_EXP_NOTXTCRD) || !ti_s || face[i].data.texcoord[0] == M3D_UNDEF || face[i].data.texcoord[1] == M3D_UNDEF || face[i].data.texcoord[2] == M3D_UNDEF) ? 0 : 1) | (((flags & M3D_EXP_NONORMAL) || face[i].data.normal[0] == M3D_UNDEF || face[i].data.normal[1] == M3D_UNDEF || face[i].data.normal[2] == M3D_UNDEF) ? 0 : 2); *out++ = (uint8_t)k; for (j = 0; j < 3; j++) { out = _m3d_addidx(out, vi_s, vrtxidx[face[i].data.vertex[j]]); if (k & 1) out = _m3d_addidx(out, ti_s, tmapidx[face[i].data.texcoord[j]]); if (k & 2) out = _m3d_addidx(out, vi_s, vrtxidx[face[i].data.normal[j]]); } } uint32_t v = (uint32_t)((uintptr_t)out - (uintptr_t)((uint8_t *)h + len)); memcpy(length, &v, sizeof(uint32_t)); len += v; out = NULL; } /* mathematical shapes face */ if (model->numshape && model->shape && !(flags & M3D_EXP_NOFACE)) { for (j = 0; j < model->numshape; j++) { chunklen = 12 + si_s + model->shape[j].numcmd * (M3D_CMDMAXARG + 1) * 4; h = (m3dhdr_t *)M3D_REALLOC(h, len + chunklen); if (!h) goto memerr; memcpy((uint8_t *)h + len, "SHPE", 4); length = (uint32_t *)((uint8_t *)h + len + 4); out = (uint8_t *)h + len + 8; out = _m3d_addidx(out, si_s, _m3d_stridx(str, numstr, model->shape[j].name)); out = _m3d_addidx(out, bi_s, model->shape[j].group); for (i = 0; i < model->shape[j].numcmd; i++) { cmd = &model->shape[j].cmd[i]; if (cmd->type >= (unsigned int)(sizeof(m3d_commandtypes) / sizeof(m3d_commandtypes[0])) || !cmd->arg) continue; cd = &m3d_commandtypes[cmd->type]; *out++ = (cmd->type & 0x7F) | (cmd->type > 127 ? 0x80 : 0); if (cmd->type > 127) *out++ = (cmd->type >> 7) & 0xff; for (k = n = 0, l = cd->p; k < l; k++) { switch (cd->a[((k - n) % (cd->p - n)) + n]) { case m3dcp_mi_t: out = _m3d_addidx(out, si_s, cmd->arg[k] < model->nummaterial ? _m3d_stridx(str, numstr, model->material[cmd->arg[k]].name) : 0); break; case m3dcp_vc_t: min_x = *((float *)&cmd->arg[k]); switch (vc_s) { case 1: *out++ = (int8_t)(min_x * 127); break; case 2: *((int16_t *)out) = (int16_t)(min_x * 32767); out += 2; break; case 4: *((float *)out) = min_x; out += 4; break; case 8: *((double *)out) = min_x; out += 8; break; } break; case m3dcp_hi_t: out = _m3d_addidx(out, hi_s, cmd->arg[k]); break; case m3dcp_fi_t: out = _m3d_addidx(out, fi_s, cmd->arg[k]); break; case m3dcp_ti_t: out = _m3d_addidx(out, ti_s, cmd->arg[k]); break; case m3dcp_qi_t: case m3dcp_vi_t: out = _m3d_addidx(out, vi_s, cmd->arg[k]); break; case m3dcp_i1_t: out = _m3d_addidx(out, 1, cmd->arg[k]); break; case m3dcp_i2_t: out = _m3d_addidx(out, 2, cmd->arg[k]); break; case m3dcp_i4_t: out = _m3d_addidx(out, 4, cmd->arg[k]); break; case m3dcp_va_t: out = _m3d_addidx(out, 4, cmd->arg[k]); n = k + 1; l += (cmd->arg[k] - 1) * (cd->p - k - 1); break; } } } uint32_t v = (uint32_t)((uintptr_t)out - (uintptr_t)((uint8_t *)h + len)); memcpy( length, &v, sizeof(uint32_t)); len += v; out = NULL; } } /* annotation labels */ if (model->numlabel && model->label) { for (i = 0, length = NULL; i < model->numlabel; i++) { if (!i || _m3d_strcmp(sl, model->label[i].lang) || _m3d_strcmp(sn, model->label[i].name)) { sl = model->label[i].lang; sn = model->label[i].name; if (length) { *length = (uint32_t)((uintptr_t)out - (uintptr_t)((uint8_t *)h + len)); len += *length; } chunklen = 8 + 2 * si_s + ci_s + model->numlabel * (vi_s + si_s); h = (m3dhdr_t *)M3D_REALLOC(h, len + chunklen); if (!h) { sn = NULL; sl = NULL; goto memerr; } memcpy((uint8_t *)h + len, "LBLS", 4); length = (uint32_t *)((uint8_t *)h + len + 4); out = (uint8_t *)h + len + 8; out = _m3d_addidx(out, si_s, _m3d_stridx(str, numstr, model->label[l].name)); out = _m3d_addidx(out, si_s, _m3d_stridx(str, numstr, model->label[l].lang)); idx = _m3d_cmapidx(cmap, numcmap, model->label[i].color); switch (ci_s) { case 1: *out++ = (uint8_t)(idx); break; case 2: *((uint16_t *)out) = (uint16_t)(idx); out += 2; break; case 4: *((uint32_t *)out) = model->label[i].color; out += 4; break; } } out = _m3d_addidx(out, vi_s, vrtxidx[model->label[i].vertexid]); out = _m3d_addidx(out, si_s, _m3d_stridx(str, numstr, model->label[l].text)); } if (length) { uint32_t v = (uint32_t)((uintptr_t)out - (uintptr_t)((uint8_t *)h + len)); memcpy( length, &v, sizeof(uint32_t)); len += v; } out = NULL; sn = sl = NULL; } /* actions */ if (model->numaction && model->action && model->numbone && model->bone && !(flags & M3D_EXP_NOACTION)) { for (j = 0; j < model->numaction; j++) { a = &model->action[j]; chunklen = 14 + si_s + a->numframe * (4 + fc_s + maxt * (bi_s + 2 * vi_s)); h = (m3dhdr_t *)M3D_REALLOC(h, len + chunklen); if (!h) goto memerr; memcpy((uint8_t *)h + len, "ACTN", 4); length = (uint32_t *)((uint8_t *)h + len + 4); out = (uint8_t *)h + len + 8; out = _m3d_addidx(out, si_s, _m3d_stridx(str, numstr, a->name)); *((uint16_t *)out) = (uint16_t)(a->numframe); out += 2; *((uint32_t *)out) = (uint32_t)(a->durationmsec); out += 4; for (i = 0; i < a->numframe; i++) { *((uint32_t *)out) = (uint32_t)(a->frame[i].msec); out += 4; out = _m3d_addidx(out, fc_s, a->frame[i].numtransform); for (k = 0; k < a->frame[i].numtransform; k++) { out = _m3d_addidx(out, bi_s, a->frame[i].transform[k].boneid); out = _m3d_addidx(out, vi_s, vrtxidx[a->frame[i].transform[k].pos]); out = _m3d_addidx(out, vi_s, vrtxidx[a->frame[i].transform[k].ori]); } } uint32_t v = (uint32_t)((uintptr_t)out - (uintptr_t)((uint8_t *)h + len)); memcpy( length, &v, sizeof(uint32_t)); len += v; out = NULL; } } /* inlined assets */ if (model->numinlined && model->inlined && (numproc || (flags & M3D_EXP_INLINE))) { for (j = 0; j < model->numinlined; j++) { if (!model->inlined[j].name || !model->inlined[j].name[0] || model->inlined[j].length < 4 || !model->inlined[j].data) continue; if (!(flags & M3D_EXP_INLINE)) { if (model->inlined[j].data[1] == 'P' && model->inlined[j].data[2] == 'N' && model->inlined[j].data[3] == 'G') continue; for (i = k = 0; i < model->numtexture; i++) { if (!strcmp(model->inlined[j].name, model->texture[i].name)) { k = 1; break; } } if (k) continue; } chunklen = 8 + si_s + model->inlined[j].length; h = (m3dhdr_t *)M3D_REALLOC(h, len + chunklen); if (!h) goto memerr; memcpy((uint8_t *)h + len, "ASET", 4); *((uint32_t *)((uint8_t *)h + len + 4)) = chunklen; out = (uint8_t *)h + len + 8; out = _m3d_addidx(out, si_s, _m3d_stridx(str, numstr, model->inlined[j].name)); memcpy(out, model->inlined[j].data, model->inlined[j].length); out = NULL; len += chunklen; } } /* extra chunks */ if (model->numextra && model->extra && (flags & M3D_EXP_EXTRA)) { for (j = 0; j < model->numextra; j++) { if (!model->extra[j] || model->extra[j]->length < 8) continue; chunklen = model->extra[j]->length; h = (m3dhdr_t *)M3D_REALLOC(h, len + chunklen); if (!h) goto memerr; memcpy((uint8_t *)h + len, model->extra[j], chunklen); len += chunklen; } } /* add end chunk */ h = (m3dhdr_t *)M3D_REALLOC(h, len + 4); if (!h) goto memerr; memcpy((uint8_t *)h + len, "OMD3", 4); len += 4; /* zlib compress */ if (!(flags & M3D_EXP_NOZLIB)) { M3D_LOG("Deflating chunks"); z = stbi_zlib_compress((unsigned char *)h, len, (int *)&l, 9); if (z && l > 0 && l < len) { len = l; M3D_FREE(h); h = (m3dhdr_t *)z; } } /* add file header at the beginning */ len += 8; out = (unsigned char *)M3D_MALLOC(len); if (!out) goto memerr; memcpy(out, "3DMO", 4); *((uint32_t *)(out + 4)) = len; memcpy(out + 8, h, len - 8); } if (size) *size = out ? len : 0; if (vrtxidx) M3D_FREE(vrtxidx); if (mtrlidx) M3D_FREE(mtrlidx); if (tmapidx) M3D_FREE(tmapidx); if (skinidx) M3D_FREE(skinidx); if (norm) M3D_FREE(norm); if (face) M3D_FREE(face); if (cmap) M3D_FREE(cmap); if (tmap) M3D_FREE(tmap); if (skin) M3D_FREE(skin); if (str) M3D_FREE(str); if (vrtx) M3D_FREE(vrtx); if (h) M3D_FREE(h); return out; } #endif #endif /* M3D_IMPLEMENTATION */ #ifdef __cplusplus } #ifdef M3D_CPPWRAPPER #include <memory> #include <string> #include <vector> /*** C++ wrapper class ***/ namespace M3D { #ifdef M3D_IMPLEMENTATION class Model { public: m3d_t *model; public: Model() { this->model = (m3d_t *)malloc(sizeof(m3d_t)); memset(this->model, 0, sizeof(m3d_t)); } Model(_unused const std::string &data, _unused m3dread_t ReadFileCB, _unused m3dfree_t FreeCB, _unused M3D::Model mtllib) { #ifndef M3D_NOIMPORTER this->model = m3d_load((unsigned char *)data.data(), ReadFileCB, FreeCB, mtllib.model); #else Model(); #endif } Model(_unused const std::vector<unsigned char> data, _unused m3dread_t ReadFileCB, _unused m3dfree_t FreeCB, _unused M3D::Model mtllib) { #ifndef M3D_NOIMPORTER this->model = m3d_load((unsigned char *)&data[0], ReadFileCB, FreeCB, mtllib.model); #else Model(); #endif } Model(_unused const unsigned char *data, _unused m3dread_t ReadFileCB, _unused m3dfree_t FreeCB, _unused M3D::Model mtllib) { #ifndef M3D_NOIMPORTER this->model = m3d_load((unsigned char *)data, ReadFileCB, FreeCB, mtllib.model); #else Model(); #endif } ~Model() { m3d_free(this->model); } public: m3d_t *getCStruct() { return this->model; } std::string getName() { return std::string(this->model->name); } void setName(std::string name) { this->model->name = (char *)name.c_str(); } std::string getLicense() { return std::string(this->model->license); } void setLicense(std::string license) { this->model->license = (char *)license.c_str(); } std::string getAuthor() { return std::string(this->model->author); } void setAuthor(std::string author) { this->model->author = (char *)author.c_str(); } std::string getDescription() { return std::string(this->model->desc); } void setDescription(std::string desc) { this->model->desc = (char *)desc.c_str(); } float getScale() { return this->model->scale; } void setScale(float scale) { this->model->scale = scale; } std::vector<unsigned char> getPreview() { return this->model->preview.data ? std::vector<unsigned char>(this->model->preview.data, this->model->preview.data + this->model->preview.length) : std::vector<unsigned char>(); } std::vector<uint32_t> getColorMap() { return this->model->cmap ? std::vector<uint32_t>(this->model->cmap, this->model->cmap + this->model->numcmap) : std::vector<uint32_t>(); } std::vector<m3dti_t> getTextureMap() { return this->model->tmap ? std::vector<m3dti_t>(this->model->tmap, this->model->tmap + this->model->numtmap) : std::vector<m3dti_t>(); } std::vector<m3dtx_t> getTextures() { return this->model->texture ? std::vector<m3dtx_t>(this->model->texture, this->model->texture + this->model->numtexture) : std::vector<m3dtx_t>(); } std::string getTextureName(int idx) { return idx >= 0 && (unsigned int)idx < this->model->numtexture ? std::string(this->model->texture[idx].name) : nullptr; } std::vector<m3db_t> getBones() { return this->model->bone ? std::vector<m3db_t>(this->model->bone, this->model->bone + this->model->numbone) : std::vector<m3db_t>(); } std::string getBoneName(int idx) { return idx >= 0 && (unsigned int)idx < this->model->numbone ? std::string(this->model->bone[idx].name) : nullptr; } std::vector<m3dm_t> getMaterials() { return this->model->material ? std::vector<m3dm_t>(this->model->material, this->model->material + this->model->nummaterial) : std::vector<m3dm_t>(); } std::string getMaterialName(int idx) { return idx >= 0 && (unsigned int)idx < this->model->nummaterial ? std::string(this->model->material[idx].name) : nullptr; } int getMaterialPropertyInt(int idx, int type) { if (idx < 0 || (unsigned int)idx >= this->model->nummaterial || type < 0 || type >= 127 || !this->model->material[idx].prop) return -1; for (int i = 0; i < this->model->material[idx].numprop; i++) { if (this->model->material[idx].prop[i].type == type) return this->model->material[idx].prop[i].value.num; } return -1; } uint32_t getMaterialPropertyColor(int idx, int type) { return this->getMaterialPropertyInt(idx, type); } float getMaterialPropertyFloat(int idx, int type) { if (idx < 0 || (unsigned int)idx >= this->model->nummaterial || type < 0 || type >= 127 || !this->model->material[idx].prop) return -1.0f; for (int i = 0; i < this->model->material[idx].numprop; i++) { if (this->model->material[idx].prop[i].type == type) return this->model->material[idx].prop[i].value.fnum; } return -1.0f; } m3dtx_t *getMaterialPropertyMap(int idx, int type) { if (idx < 0 || (unsigned int)idx >= this->model->nummaterial || type < 128 || type > 255 || !this->model->material[idx].prop) return nullptr; for (int i = 0; i < this->model->material[idx].numprop; i++) { if (this->model->material[idx].prop[i].type == type) return this->model->material[idx].prop[i].value.textureid < this->model->numtexture ? &this->model->texture[this->model->material[idx].prop[i].value.textureid] : nullptr; } return nullptr; } std::vector<m3dv_t> getVertices() { return this->model->vertex ? std::vector<m3dv_t>(this->model->vertex, this->model->vertex + this->model->numvertex) : std::vector<m3dv_t>(); } std::vector<m3df_t> getFace() { return this->model->face ? std::vector<m3df_t>(this->model->face, this->model->face + this->model->numface) : std::vector<m3df_t>(); } std::vector<m3dh_t> getShape() { return this->model->shape ? std::vector<m3dh_t>(this->model->shape, this->model->shape + this->model->numshape) : std::vector<m3dh_t>(); } std::string getShapeName(int idx) { return idx >= 0 && (unsigned int)idx < this->model->numshape && this->model->shape[idx].name && this->model->shape[idx].name[0] ? std::string(this->model->shape[idx].name) : nullptr; } unsigned int getShapeGroup(int idx) { return idx >= 0 && (unsigned int)idx < this->model->numshape ? this->model->shape[idx].group : 0xFFFFFFFF; } std::vector<m3dc_t> getShapeCommands(int idx) { return idx >= 0 && (unsigned int)idx < this->model->numshape && this->model->shape[idx].cmd ? std::vector<m3dc_t>(this->model->shape[idx].cmd, this->model->shape[idx].cmd + this->model->shape[idx].numcmd) : std::vector<m3dc_t>(); } std::vector<m3dl_t> getAnnotationLabels() { return this->model->label ? std::vector<m3dl_t>(this->model->label, this->model->label + this->model->numlabel) : std::vector<m3dl_t>(); } std::vector<m3ds_t> getSkin() { return this->model->skin ? std::vector<m3ds_t>(this->model->skin, this->model->skin + this->model->numskin) : std::vector<m3ds_t>(); } std::vector<m3da_t> getActions() { return this->model->action ? std::vector<m3da_t>(this->model->action, this->model->action + this->model->numaction) : std::vector<m3da_t>(); } std::string getActionName(int aidx) { return aidx >= 0 && (unsigned int)aidx < this->model->numaction ? std::string(this->model->action[aidx].name) : nullptr; } unsigned int getActionDuration(int aidx) { return aidx >= 0 && (unsigned int)aidx < this->model->numaction ? this->model->action[aidx].durationmsec : 0; } std::vector<m3dfr_t> getActionFrames(int aidx) { return aidx >= 0 && (unsigned int)aidx < this->model->numaction ? std::vector<m3dfr_t>(this->model->action[aidx].frame, this->model->action[aidx].frame + this->model->action[aidx].numframe) : std::vector<m3dfr_t>(); } unsigned int getActionFrameTimestamp(int aidx, int fidx) { return aidx >= 0 && (unsigned int)aidx < this->model->numaction ? (fidx >= 0 && (unsigned int)fidx < this->model->action[aidx].numframe ? this->model->action[aidx].frame[fidx].msec : 0) : 0; } std::vector<m3dtr_t> getActionFrameTransforms(int aidx, int fidx) { return aidx >= 0 && (unsigned int)aidx < this->model->numaction ? ( fidx >= 0 && (unsigned int)fidx < this->model->action[aidx].numframe ? std::vector<m3dtr_t>(this->model->action[aidx].frame[fidx].transform, this->model->action[aidx].frame[fidx].transform + this->model->action[aidx].frame[fidx].numtransform) : std::vector<m3dtr_t>()) : std::vector<m3dtr_t>(); } std::vector<m3dtr_t> getActionFrame(int aidx, int fidx, std::vector<m3dtr_t> skeleton) { m3dtr_t *pose = m3d_frame(this->model, (unsigned int)aidx, (unsigned int)fidx, skeleton.size() ? &skeleton[0] : nullptr); return std::vector<m3dtr_t>(pose, pose + this->model->numbone); } std::vector<m3db_t> getActionPose(int aidx, unsigned int msec) { m3db_t *pose = m3d_pose(this->model, (unsigned int)aidx, (unsigned int)msec); return std::vector<m3db_t>(pose, pose + this->model->numbone); } std::vector<m3di_t> getInlinedAssets() { return this->model->inlined ? std::vector<m3di_t>(this->model->inlined, this->model->inlined + this->model->numinlined) : std::vector<m3di_t>(); } std::vector<std::unique_ptr<m3dchunk_t>> getExtras() { return this->model->extra ? std::vector<std::unique_ptr<m3dchunk_t>>(this->model->extra, this->model->extra + this->model->numextra) : std::vector<std::unique_ptr<m3dchunk_t>>(); } std::vector<unsigned char> Save(_unused int quality, _unused int flags) { #ifdef M3D_EXPORTER unsigned int size; unsigned char *ptr = m3d_save(this->model, quality, flags, &size); return ptr && size ? std::vector<unsigned char>(ptr, ptr + size) : std::vector<unsigned char>(); #else return std::vector<unsigned char>(); #endif } }; #else class Model { public: m3d_t *model; public: Model(const std::string &data, m3dread_t ReadFileCB, m3dfree_t FreeCB); Model(const std::vector<unsigned char> data, m3dread_t ReadFileCB, m3dfree_t FreeCB); Model(const unsigned char *data, m3dread_t ReadFileCB, m3dfree_t FreeCB); Model(); ~Model(); public: m3d_t *getCStruct(); std::string getName(); void setName(std::string name); std::string getLicense(); void setLicense(std::string license); std::string getAuthor(); void setAuthor(std::string author); std::string getDescription(); void setDescription(std::string desc); float getScale(); void setScale(float scale); std::vector<unsigned char> getPreview(); std::vector<uint32_t> getColorMap(); std::vector<m3dti_t> getTextureMap(); std::vector<m3dtx_t> getTextures(); std::string getTextureName(int idx); std::vector<m3db_t> getBones(); std::string getBoneName(int idx); std::vector<m3dm_t> getMaterials(); std::string getMaterialName(int idx); int getMaterialPropertyInt(int idx, int type); uint32_t getMaterialPropertyColor(int idx, int type); float getMaterialPropertyFloat(int idx, int type); m3dtx_t *getMaterialPropertyMap(int idx, int type); std::vector<m3dv_t> getVertices(); std::vector<m3df_t> getFace(); std::vector<m3dh_t> getShape(); std::string getShapeName(int idx); unsigned int getShapeGroup(int idx); std::vector<m3dc_t> getShapeCommands(int idx); std::vector<m3dl_t> getAnnotationLabels(); std::vector<m3ds_t> getSkin(); std::vector<m3da_t> getActions(); std::string getActionName(int aidx); unsigned int getActionDuration(int aidx); std::vector<m3dfr_t> getActionFrames(int aidx); unsigned int getActionFrameTimestamp(int aidx, int fidx); std::vector<m3dtr_t> getActionFrameTransforms(int aidx, int fidx); std::vector<m3dtr_t> getActionFrame(int aidx, int fidx, std::vector<m3dtr_t> skeleton); std::vector<m3db_t> getActionPose(int aidx, unsigned int msec); std::vector<m3di_t> getInlinedAssets(); std::vector<std::unique_ptr<m3dchunk_t>> getExtras(); std::vector<unsigned char> Save(int quality, int flags); }; #endif /* impl */ } // namespace M3D #endif /* M3D_CPPWRAPPER */ #if _MSC_VER > 1920 && !defined(__clang__) # pragma warning(pop) #endif /* _MSC_VER */ #endif /* __cplusplus */ #endif
132,588
526
<filename>open-metadata-implementation/adapters/open-connectors/governance-daemon-connectors/security-officer-connectors/security-officer-tag-connector/src/main/java/org/odpi/openmetadata/openconnector/governancedarmonconnectors/securityofficerconnectors/securitytagconnector/SecurityTagConnectorProvider.java /* SPDX-License-Identifier: Apache-2.0 */ /* Copyright Contributors to the ODPi Egeria project. */ package org.odpi.openmetadata.openconnector.governancedarmonconnectors.securityofficerconnectors.securitytagconnector; import org.odpi.openmetadata.frameworks.connectors.ConnectorProviderBase; import org.odpi.openmetadata.frameworks.connectors.properties.beans.ConnectorType; public class SecurityTagConnectorProvider extends ConnectorProviderBase { static final String connectorTypeGUID = "810169fb-2eb4-8dcf-20f5-52896a072003"; static final String connectorTypeName = "Security Tag Server Connector"; static final String connectorTypeDescription = "Connector supports storing of the open metadata cohort registry in a file."; /** * Constructor used to initialize the ConnectorProviderBase with the Java class name of the specific * registry store implementation. */ public SecurityTagConnectorProvider() { Class connectorClass = SecurityTagConnector.class; super.setConnectorClassName(connectorClass.getName()); ConnectorType connectorType = new ConnectorType(); connectorType.setType(ConnectorType.getConnectorTypeType()); connectorType.setGUID(connectorTypeGUID); connectorType.setQualifiedName(connectorTypeName); connectorType.setDisplayName(connectorTypeName); connectorType.setDescription(connectorTypeDescription); connectorType.setConnectorProviderClassName(this.getClass().getName()); super.connectorTypeBean = connectorType; } }
558
940
/* * timer.cpp - Time Manager emulation * * Basilisk II (C) 1997-2008 <NAME> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* * SEE ALSO * Inside Macintosh: Processes, chapter 3 "Time Manager" * Technote 1063: "Inside Macintosh: Processes: Time Manager Addenda" */ #include <stdio.h> #include "sysdeps.h" #include "cpu_emulation.h" #include "main.h" #include "macos_util.h" #include "timer.h" #define DEBUG 0 #include "debug.h" // Set this to 1 to enable TMQueue management (doesn't work) #define TM_QUEUE 0 // Definitions for Time Manager enum { // TMTask struct tmAddr = 6, tmCount = 10, tmWakeUp = 14, tmReserved = 18 }; // Array of additional info for each installed TMTask struct TMDesc { uint32 task; // Mac address of associated TMTask tm_time_t wakeup; // Time this task is scheduled for execution bool in_use; // Flag: descriptor in use }; const int NUM_DESCS = 64; // Maximum number of descriptors static TMDesc desc[NUM_DESCS]; /* * Allocate descriptor for given TMTask in list */ static int alloc_desc(uint32 tm) { // Search for first free descriptor for (int i=0; i<NUM_DESCS; i++) if (!desc[i].in_use) { desc[i].task = tm; desc[i].in_use = true; return i; } return -1; } /* * Free descriptor in list */ inline static void free_desc(int i) { desc[i].in_use = false; } /* * Find descriptor associated with given TMTask */ inline static int find_desc(uint32 tm) { for (int i=0; i<NUM_DESCS; i++) if (desc[i].in_use && desc[i].task == tm) return i; return -1; } /* * Enqueue task in Time Manager queue */ static void enqueue_tm(uint32 tm) { #if TM_QUEUE uint32 tm_var = ReadMacInt32(0xb30); WriteMacInt32(tm + qLink, ReadMacInt32(tm_var)); WriteMacInt32(tm_var, tm); #endif } /* * Remove task from Time Manager queue */ static void dequeue_tm(uint32 tm) { #if TM_QUEUE uint32 p = ReadMacInt32(0xb30); while (p) { uint32 next = ReadMacInt32(p + qLink); if (next == tm) { WriteMacInt32(p + qLink, ReadMacInt32(next + qLink)); return; } } #endif } /* * Initialize Time Manager */ void TimerInit(void) { // Mark all descriptors as inactive for (int i=0; i<NUM_DESCS; i++) free_desc(i); } /* * Exit Time Manager */ void TimerExit(void) { } /* * Emulator reset, remove all timer tasks */ void TimerReset(void) { // Mark all descriptors as inactive for (int i=0; i<NUM_DESCS; i++) free_desc(i); } /* * Insert timer task */ int16 InsTime(uint32 tm, uint16 trap) { D(bug("InsTime %08lx, trap %04x\n", tm, trap)); WriteMacInt16(tm + qType, ReadMacInt16(tm + qType) & 0x1fff | (trap << 4) & 0x6000); if (find_desc(tm) >= 0) printf("WARNING: InsTime(): Task re-inserted\n"); else { int i = alloc_desc(tm); if (i < 0) printf("FATAL: InsTime(): No free Time Manager descriptor\n"); } return 0; } /* * Remove timer task */ int16 RmvTime(uint32 tm) { D(bug("RmvTime %08lx\n", tm)); // Find descriptor int i = find_desc(tm); if (i < 0) { printf("WARNING: RmvTime(%08x): Descriptor not found\n", tm); return 0; } // Task active? if (ReadMacInt16(tm + qType) & 0x8000) { // Yes, make task inactive and remove it from the Time Manager queue WriteMacInt16(tm + qType, ReadMacInt16(tm + qType) & 0x7fff); dequeue_tm(tm); // Compute remaining time tm_time_t remaining, current; timer_current_time(current); timer_sub_time(remaining, desc[i].wakeup, current); WriteMacInt32(tm + tmCount, timer_host2mac_time(remaining)); } else WriteMacInt32(tm + tmCount, 0); D(bug(" tmCount %d\n", ReadMacInt32(tm + tmCount))); // Free descriptor free_desc(i); return 0; } /* * Start timer task */ int16 PrimeTime(uint32 tm, int32 time) { D(bug("PrimeTime %08x, time %d\n", tm, time)); // Find descriptor int i = find_desc(tm); if (i < 0) { printf("FATAL: PrimeTime(): Descriptor not found\n"); return 0; } // Extended task? if (ReadMacInt16(tm + qType) & 0x4000) { // Convert delay time tm_time_t delay; timer_mac2host_time(delay, time); // Yes, tmWakeUp set? if (ReadMacInt32(tm + tmWakeUp)) { //!! PrimeTime(0) means continue previous delay // (save wakeup time in RmvTime?) if (time == 0) printf("WARNING: Unsupported PrimeTime(0)\n"); // Yes, calculate wakeup time relative to last scheduled time tm_time_t wakeup; timer_add_time(wakeup, desc[i].wakeup, delay); desc[i].wakeup = wakeup; } else { // No, calculate wakeup time relative to current time tm_time_t now; timer_current_time(now); timer_add_time(desc[i].wakeup, now, delay); } // Set tmWakeUp to indicate that task was scheduled WriteMacInt32(tm + tmWakeUp, 0x12345678); } else { // Not extended task, calculate wakeup time relative to current time tm_time_t delay; timer_mac2host_time(delay, time); timer_current_time(desc[i].wakeup); timer_add_time(desc[i].wakeup, desc[i].wakeup, delay); } // Make task active and enqueue it in the Time Manager queue WriteMacInt16(tm + qType, ReadMacInt16(tm + qType) | 0x8000); enqueue_tm(tm); return 0; } /* * Timer interrupt function (executed as part of 60Hz interrupt) */ void TimerInterrupt(void) { // Look for active TMTasks that have expired tm_time_t now; timer_current_time(now); for (int i=0; i<NUM_DESCS; i++) if (desc[i].in_use) { uint32 tm = desc[i].task; if ((ReadMacInt16(tm + qType) & 0x8000) && timer_cmp_time(desc[i].wakeup, now) < 0) { // Found one, mark as inactive and remove it from the Time Manager queue WriteMacInt16(tm + qType, ReadMacInt16(tm + qType) & 0x7fff); dequeue_tm(tm); // Call timer function uint32 addr = ReadMacInt32(tm + tmAddr); if (addr) { D(bug("Calling TimeTask %08lx, addr %08lx\n", tm, addr)); M68kRegisters r; r.a[0] = addr; r.a[1] = tm; Execute68k(addr, &r); } } } }
2,592
335
{ "word": "Vav", "definitions": [ "The sixth letter of the Hebrew alphabet." ], "parts-of-speech": "Noun" }
60
892
{ "schema_version": "1.2.0", "id": "GHSA-53cv-6j2x-jm64", "modified": "2022-05-13T01:51:04Z", "published": "2022-05-13T01:51:04Z", "aliases": [ "CVE-2018-20422" ], "details": "Discuz! DiscuzX 3.4, when WeChat login is enabled, allows remote attackers to bypass authentication by leveraging a non-empty #wechat#common_member_wechatmp to gain login access to an account via a plugin.php ac=wxregister request (the attacker does not have control over which account will be accessed).", "severity": [ { "type": "CVSS_V3", "score": "CVSS:3.0/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H" } ], "affected": [ ], "references": [ { "type": "ADVISORY", "url": "https://nvd.nist.gov/vuln/detail/CVE-2018-20422" }, { "type": "WEB", "url": "https://gitee.com/ComsenzDiscuz/DiscuzX/issues/IPRUI" } ], "database_specific": { "cwe_ids": [ "CWE-287" ], "severity": "HIGH", "github_reviewed": false } }
458
14,668
<filename>chrome/browser/ash/system_extensions/system_extensions_status_or.h // Copyright 2021 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CHROME_BROWSER_ASH_SYSTEM_EXTENSIONS_SYSTEM_EXTENSIONS_STATUS_OR_H_ #define CHROME_BROWSER_ASH_SYSTEM_EXTENSIONS_SYSTEM_EXTENSIONS_STATUS_OR_H_ #include "third_party/abseil-cpp/absl/types/variant.h" // SystemExtensionsStatusOr is a union of an status enum class and an object. // This class either holds an object in a usable state, or a status code // explaining why `T` is not present. This class is typically the return value // of a function which may fail. // // An SystemExtensionsStatusOr can never hold an "OK" status, instead, the // presence of `T` indicates success. Instead of checking for a `kOk` value, use // the `ok()` member function. // // There is nothing SystemExtensions specific about this class so if needed // this can be moved to //base. template <typename S, typename T> class SystemExtensionsStatusOr { public: // Constructs a new `SystemExtensionsStatusOr` with an `S::kUnknown` status. // This constructor is marked 'explicit' to prevent usages in return values // such as 'return {};'. explicit SystemExtensionsStatusOr() // NOLINT : status_or_value_(S::kUnknown) {} // All of these are implicit, so that one may just return `S` or `T`. SystemExtensionsStatusOr(S status) : status_or_value_(status) {} // NOLINT SystemExtensionsStatusOr(T value) // NOLINT : status_or_value_(std::move(value)) {} SystemExtensionsStatusOr(SystemExtensionsStatusOr&&) = default; SystemExtensionsStatusOr& operator=(SystemExtensionsStatusOr&&) = default; ~SystemExtensionsStatusOr() = default; bool ok() const { return absl::holds_alternative<T>(status_or_value_); } // Returns the status code when the status is not kOk. Crashes if the // status is kOk. S status() { CHECK(!ok()); return absl::get<S>(status_or_value_); } // Returns `T` if ok() is true. CHECKs otherwise. const T& value() const& { CHECK(ok()); return absl::get<T>(status_or_value_); } // Returns the `T` if ok() is true. CHECKs otherwise. T&& value() && { CHECK(ok()); return std::move(absl::get<T>(status_or_value_)); } private: absl::variant<S, T> status_or_value_; }; #endif // CHROME_BROWSER_ASH_SYSTEM_EXTENSIONS_SYSTEM_EXTENSIONS_STATUS_OR_H_
851
7,320
<gh_stars>1000+ /* * Copyright 2016 Google, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import com.google.classyshark.Shark; import java.io.File; public class Main { public static void main(String[] args) { File apk = new File("/Users/bfarber/Desktop/Scenarios/4 APKs/" + "com.google.samples.apps.iosched-333.apk"); Shark shark = Shark.with(apk); System.out.println( shark.getGeneratedClass("com.bumptech.glide.request.target.BaseTarget")); System.out.println(shark.getAllClassNames()); System.out.println(shark.getManifest()); System.out.println(shark.getAllMethods()); System.out.println("\n\n\n\nAll Classes " + shark.getAllClassNames().size() + "\nAll Methods " + shark.getAllMethods().size()); } }
463
573
<gh_stars>100-1000 // Copyright 2015, VIXL authors // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // // * Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright notice, // this list of conditions and the following disclaimer in the documentation // and/or other materials provided with the distribution. // * Neither the name of ARM Limited nor the names of its contributors may be // used to endorse or promote products derived from this software without // specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS CONTRIBUTORS "AS IS" AND // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // --------------------------------------------------------------------- // This file is auto generated using tools/generate_simulator_traces.py. // // PLEASE DO NOT EDIT. // --------------------------------------------------------------------- #ifndef VIXL_ASSEMBLER_COND_RD_RN_OPERAND_RM_SHIFT_AMOUNT_1TO32_SBCS_T32_H_ #define VIXL_ASSEMBLER_COND_RD_RN_OPERAND_RM_SHIFT_AMOUNT_1TO32_SBCS_T32_H_ const byte kInstruction_sbcs_al_r11_r13_r10_ASR_9[] = { 0x7d, 0xeb, 0x6a, 0x2b // sbcs al r11 r13 r10 ASR 9 }; const byte kInstruction_sbcs_al_r7_r5_r2_ASR_2[] = { 0x75, 0xeb, 0xa2, 0x07 // sbcs al r7 r5 r2 ASR 2 }; const byte kInstruction_sbcs_al_r5_r2_r11_LSR_5[] = { 0x72, 0xeb, 0x5b, 0x15 // sbcs al r5 r2 r11 LSR 5 }; const byte kInstruction_sbcs_al_r14_r6_r10_LSR_32[] = { 0x76, 0xeb, 0x1a, 0x0e // sbcs al r14 r6 r10 LSR 32 }; const byte kInstruction_sbcs_al_r9_r6_r3_LSR_13[] = { 0x76, 0xeb, 0x53, 0x39 // sbcs al r9 r6 r3 LSR 13 }; const byte kInstruction_sbcs_al_r14_r4_r6_LSR_31[] = { 0x74, 0xeb, 0xd6, 0x7e // sbcs al r14 r4 r6 LSR 31 }; const byte kInstruction_sbcs_al_r2_r1_r7_LSR_14[] = { 0x71, 0xeb, 0x97, 0x32 // sbcs al r2 r1 r7 LSR 14 }; const byte kInstruction_sbcs_al_r2_r9_r12_LSR_24[] = { 0x79, 0xeb, 0x1c, 0x62 // sbcs al r2 r9 r12 LSR 24 }; const byte kInstruction_sbcs_al_r10_r12_r4_ASR_2[] = { 0x7c, 0xeb, 0xa4, 0x0a // sbcs al r10 r12 r4 ASR 2 }; const byte kInstruction_sbcs_al_r6_r10_r0_LSR_8[] = { 0x7a, 0xeb, 0x10, 0x26 // sbcs al r6 r10 r0 LSR 8 }; const byte kInstruction_sbcs_al_r12_r11_r4_ASR_7[] = { 0x7b, 0xeb, 0xe4, 0x1c // sbcs al r12 r11 r4 ASR 7 }; const byte kInstruction_sbcs_al_r9_r4_r8_ASR_27[] = { 0x74, 0xeb, 0xe8, 0x69 // sbcs al r9 r4 r8 ASR 27 }; const byte kInstruction_sbcs_al_r2_r10_r11_ASR_1[] = { 0x7a, 0xeb, 0x6b, 0x02 // sbcs al r2 r10 r11 ASR 1 }; const byte kInstruction_sbcs_al_r0_r2_r9_ASR_24[] = { 0x72, 0xeb, 0x29, 0x60 // sbcs al r0 r2 r9 ASR 24 }; const byte kInstruction_sbcs_al_r11_r6_r14_ASR_31[] = { 0x76, 0xeb, 0xee, 0x7b // sbcs al r11 r6 r14 ASR 31 }; const byte kInstruction_sbcs_al_r2_r14_r14_ASR_18[] = { 0x7e, 0xeb, 0xae, 0x42 // sbcs al r2 r14 r14 ASR 18 }; const byte kInstruction_sbcs_al_r5_r7_r1_ASR_2[] = { 0x77, 0xeb, 0xa1, 0x05 // sbcs al r5 r7 r1 ASR 2 }; const byte kInstruction_sbcs_al_r1_r14_r7_LSR_18[] = { 0x7e, 0xeb, 0x97, 0x41 // sbcs al r1 r14 r7 LSR 18 }; const byte kInstruction_sbcs_al_r7_r7_r1_ASR_4[] = { 0x77, 0xeb, 0x21, 0x17 // sbcs al r7 r7 r1 ASR 4 }; const byte kInstruction_sbcs_al_r14_r5_r12_LSR_1[] = { 0x75, 0xeb, 0x5c, 0x0e // sbcs al r14 r5 r12 LSR 1 }; const byte kInstruction_sbcs_al_r2_r11_r10_ASR_23[] = { 0x7b, 0xeb, 0xea, 0x52 // sbcs al r2 r11 r10 ASR 23 }; const byte kInstruction_sbcs_al_r5_r0_r10_ASR_3[] = { 0x70, 0xeb, 0xea, 0x05 // sbcs al r5 r0 r10 ASR 3 }; const byte kInstruction_sbcs_al_r9_r13_r9_ASR_6[] = { 0x7d, 0xeb, 0xa9, 0x19 // sbcs al r9 r13 r9 ASR 6 }; const byte kInstruction_sbcs_al_r6_r10_r13_ASR_24[] = { 0x7a, 0xeb, 0x2d, 0x66 // sbcs al r6 r10 r13 ASR 24 }; const byte kInstruction_sbcs_al_r9_r3_r14_LSR_30[] = { 0x73, 0xeb, 0x9e, 0x79 // sbcs al r9 r3 r14 LSR 30 }; const byte kInstruction_sbcs_al_r11_r14_r11_LSR_24[] = { 0x7e, 0xeb, 0x1b, 0x6b // sbcs al r11 r14 r11 LSR 24 }; const byte kInstruction_sbcs_al_r11_r3_r4_ASR_7[] = { 0x73, 0xeb, 0xe4, 0x1b // sbcs al r11 r3 r4 ASR 7 }; const byte kInstruction_sbcs_al_r14_r13_r10_ASR_1[] = { 0x7d, 0xeb, 0x6a, 0x0e // sbcs al r14 r13 r10 ASR 1 }; const byte kInstruction_sbcs_al_r0_r9_r0_LSR_2[] = { 0x79, 0xeb, 0x90, 0x00 // sbcs al r0 r9 r0 LSR 2 }; const byte kInstruction_sbcs_al_r2_r1_r7_ASR_15[] = { 0x71, 0xeb, 0xe7, 0x32 // sbcs al r2 r1 r7 ASR 15 }; const byte kInstruction_sbcs_al_r8_r14_r5_LSR_27[] = { 0x7e, 0xeb, 0xd5, 0x68 // sbcs al r8 r14 r5 LSR 27 }; const byte kInstruction_sbcs_al_r9_r14_r13_ASR_21[] = { 0x7e, 0xeb, 0x6d, 0x59 // sbcs al r9 r14 r13 ASR 21 }; const byte kInstruction_sbcs_al_r11_r14_r14_ASR_3[] = { 0x7e, 0xeb, 0xee, 0x0b // sbcs al r11 r14 r14 ASR 3 }; const byte kInstruction_sbcs_al_r6_r3_r6_LSR_23[] = { 0x73, 0xeb, 0xd6, 0x56 // sbcs al r6 r3 r6 LSR 23 }; const byte kInstruction_sbcs_al_r14_r8_r11_LSR_6[] = { 0x78, 0xeb, 0x9b, 0x1e // sbcs al r14 r8 r11 LSR 6 }; const byte kInstruction_sbcs_al_r5_r3_r3_LSR_8[] = { 0x73, 0xeb, 0x13, 0x25 // sbcs al r5 r3 r3 LSR 8 }; const byte kInstruction_sbcs_al_r12_r6_r1_LSR_6[] = { 0x76, 0xeb, 0x91, 0x1c // sbcs al r12 r6 r1 LSR 6 }; const byte kInstruction_sbcs_al_r5_r0_r9_LSR_30[] = { 0x70, 0xeb, 0x99, 0x75 // sbcs al r5 r0 r9 LSR 30 }; const byte kInstruction_sbcs_al_r4_r9_r3_ASR_17[] = { 0x79, 0xeb, 0x63, 0x44 // sbcs al r4 r9 r3 ASR 17 }; const byte kInstruction_sbcs_al_r12_r2_r4_ASR_20[] = { 0x72, 0xeb, 0x24, 0x5c // sbcs al r12 r2 r4 ASR 20 }; const byte kInstruction_sbcs_al_r2_r9_r13_ASR_25[] = { 0x79, 0xeb, 0x6d, 0x62 // sbcs al r2 r9 r13 ASR 25 }; const byte kInstruction_sbcs_al_r11_r5_r12_LSR_10[] = { 0x75, 0xeb, 0x9c, 0x2b // sbcs al r11 r5 r12 LSR 10 }; const byte kInstruction_sbcs_al_r4_r13_r12_LSR_22[] = { 0x7d, 0xeb, 0x9c, 0x54 // sbcs al r4 r13 r12 LSR 22 }; const byte kInstruction_sbcs_al_r2_r4_r6_LSR_11[] = { 0x74, 0xeb, 0xd6, 0x22 // sbcs al r2 r4 r6 LSR 11 }; const byte kInstruction_sbcs_al_r8_r4_r1_LSR_22[] = { 0x74, 0xeb, 0x91, 0x58 // sbcs al r8 r4 r1 LSR 22 }; const byte kInstruction_sbcs_al_r6_r12_r10_LSR_31[] = { 0x7c, 0xeb, 0xda, 0x76 // sbcs al r6 r12 r10 LSR 31 }; const byte kInstruction_sbcs_al_r10_r0_r2_ASR_7[] = { 0x70, 0xeb, 0xe2, 0x1a // sbcs al r10 r0 r2 ASR 7 }; const byte kInstruction_sbcs_al_r14_r6_r13_ASR_21[] = { 0x76, 0xeb, 0x6d, 0x5e // sbcs al r14 r6 r13 ASR 21 }; const byte kInstruction_sbcs_al_r7_r14_r13_LSR_4[] = { 0x7e, 0xeb, 0x1d, 0x17 // sbcs al r7 r14 r13 LSR 4 }; const byte kInstruction_sbcs_al_r1_r10_r12_ASR_2[] = { 0x7a, 0xeb, 0xac, 0x01 // sbcs al r1 r10 r12 ASR 2 }; const byte kInstruction_sbcs_al_r0_r2_r10_LSR_7[] = { 0x72, 0xeb, 0xda, 0x10 // sbcs al r0 r2 r10 LSR 7 }; const byte kInstruction_sbcs_al_r0_r1_r11_LSR_17[] = { 0x71, 0xeb, 0x5b, 0x40 // sbcs al r0 r1 r11 LSR 17 }; const byte kInstruction_sbcs_al_r4_r13_r2_ASR_25[] = { 0x7d, 0xeb, 0x62, 0x64 // sbcs al r4 r13 r2 ASR 25 }; const byte kInstruction_sbcs_al_r1_r4_r14_LSR_7[] = { 0x74, 0xeb, 0xde, 0x11 // sbcs al r1 r4 r14 LSR 7 }; const byte kInstruction_sbcs_al_r5_r8_r4_ASR_19[] = { 0x78, 0xeb, 0xe4, 0x45 // sbcs al r5 r8 r4 ASR 19 }; const byte kInstruction_sbcs_al_r4_r3_r8_ASR_12[] = { 0x73, 0xeb, 0x28, 0x34 // sbcs al r4 r3 r8 ASR 12 }; const byte kInstruction_sbcs_al_r2_r4_r13_ASR_12[] = { 0x74, 0xeb, 0x2d, 0x32 // sbcs al r2 r4 r13 ASR 12 }; const byte kInstruction_sbcs_al_r8_r9_r2_LSR_20[] = { 0x79, 0xeb, 0x12, 0x58 // sbcs al r8 r9 r2 LSR 20 }; const byte kInstruction_sbcs_al_r10_r6_r3_ASR_21[] = { 0x76, 0xeb, 0x63, 0x5a // sbcs al r10 r6 r3 ASR 21 }; const byte kInstruction_sbcs_al_r2_r7_r7_ASR_3[] = { 0x77, 0xeb, 0xe7, 0x02 // sbcs al r2 r7 r7 ASR 3 }; const byte kInstruction_sbcs_al_r8_r7_r7_LSR_19[] = { 0x77, 0xeb, 0xd7, 0x48 // sbcs al r8 r7 r7 LSR 19 }; const byte kInstruction_sbcs_al_r7_r9_r4_LSR_3[] = { 0x79, 0xeb, 0xd4, 0x07 // sbcs al r7 r9 r4 LSR 3 }; const byte kInstruction_sbcs_al_r1_r7_r3_ASR_2[] = { 0x77, 0xeb, 0xa3, 0x01 // sbcs al r1 r7 r3 ASR 2 }; const byte kInstruction_sbcs_al_r1_r2_r3_ASR_5[] = { 0x72, 0xeb, 0x63, 0x11 // sbcs al r1 r2 r3 ASR 5 }; const byte kInstruction_sbcs_al_r12_r4_r1_ASR_5[] = { 0x74, 0xeb, 0x61, 0x1c // sbcs al r12 r4 r1 ASR 5 }; const byte kInstruction_sbcs_al_r4_r2_r10_ASR_1[] = { 0x72, 0xeb, 0x6a, 0x04 // sbcs al r4 r2 r10 ASR 1 }; const byte kInstruction_sbcs_al_r10_r5_r11_LSR_3[] = { 0x75, 0xeb, 0xdb, 0x0a // sbcs al r10 r5 r11 LSR 3 }; const byte kInstruction_sbcs_al_r5_r9_r1_ASR_8[] = { 0x79, 0xeb, 0x21, 0x25 // sbcs al r5 r9 r1 ASR 8 }; const byte kInstruction_sbcs_al_r6_r11_r3_LSR_28[] = { 0x7b, 0xeb, 0x13, 0x76 // sbcs al r6 r11 r3 LSR 28 }; const byte kInstruction_sbcs_al_r9_r13_r6_LSR_22[] = { 0x7d, 0xeb, 0x96, 0x59 // sbcs al r9 r13 r6 LSR 22 }; const byte kInstruction_sbcs_al_r10_r13_r1_LSR_30[] = { 0x7d, 0xeb, 0x91, 0x7a // sbcs al r10 r13 r1 LSR 30 }; const byte kInstruction_sbcs_al_r9_r1_r4_ASR_26[] = { 0x71, 0xeb, 0xa4, 0x69 // sbcs al r9 r1 r4 ASR 26 }; const byte kInstruction_sbcs_al_r4_r4_r4_ASR_21[] = { 0x74, 0xeb, 0x64, 0x54 // sbcs al r4 r4 r4 ASR 21 }; const byte kInstruction_sbcs_al_r9_r5_r11_ASR_19[] = { 0x75, 0xeb, 0xeb, 0x49 // sbcs al r9 r5 r11 ASR 19 }; const byte kInstruction_sbcs_al_r8_r11_r5_LSR_30[] = { 0x7b, 0xeb, 0x95, 0x78 // sbcs al r8 r11 r5 LSR 30 }; const byte kInstruction_sbcs_al_r4_r10_r4_LSR_23[] = { 0x7a, 0xeb, 0xd4, 0x54 // sbcs al r4 r10 r4 LSR 23 }; const byte kInstruction_sbcs_al_r7_r6_r2_LSR_32[] = { 0x76, 0xeb, 0x12, 0x07 // sbcs al r7 r6 r2 LSR 32 }; const byte kInstruction_sbcs_al_r4_r14_r12_LSR_7[] = { 0x7e, 0xeb, 0xdc, 0x14 // sbcs al r4 r14 r12 LSR 7 }; const byte kInstruction_sbcs_al_r5_r2_r9_LSR_7[] = { 0x72, 0xeb, 0xd9, 0x15 // sbcs al r5 r2 r9 LSR 7 }; const byte kInstruction_sbcs_al_r2_r14_r1_ASR_6[] = { 0x7e, 0xeb, 0xa1, 0x12 // sbcs al r2 r14 r1 ASR 6 }; const byte kInstruction_sbcs_al_r14_r13_r11_LSR_12[] = { 0x7d, 0xeb, 0x1b, 0x3e // sbcs al r14 r13 r11 LSR 12 }; const byte kInstruction_sbcs_al_r8_r8_r6_ASR_5[] = { 0x78, 0xeb, 0x66, 0x18 // sbcs al r8 r8 r6 ASR 5 }; const byte kInstruction_sbcs_al_r14_r10_r12_LSR_13[] = { 0x7a, 0xeb, 0x5c, 0x3e // sbcs al r14 r10 r12 LSR 13 }; const byte kInstruction_sbcs_al_r3_r6_r7_LSR_31[] = { 0x76, 0xeb, 0xd7, 0x73 // sbcs al r3 r6 r7 LSR 31 }; const byte kInstruction_sbcs_al_r8_r1_r9_ASR_2[] = { 0x71, 0xeb, 0xa9, 0x08 // sbcs al r8 r1 r9 ASR 2 }; const byte kInstruction_sbcs_al_r9_r12_r12_ASR_21[] = { 0x7c, 0xeb, 0x6c, 0x59 // sbcs al r9 r12 r12 ASR 21 }; const byte kInstruction_sbcs_al_r13_r4_r12_LSR_14[] = { 0x74, 0xeb, 0x9c, 0x3d // sbcs al r13 r4 r12 LSR 14 }; const byte kInstruction_sbcs_al_r2_r11_r12_LSR_18[] = { 0x7b, 0xeb, 0x9c, 0x42 // sbcs al r2 r11 r12 LSR 18 }; const byte kInstruction_sbcs_al_r9_r3_r0_ASR_31[] = { 0x73, 0xeb, 0xe0, 0x79 // sbcs al r9 r3 r0 ASR 31 }; const byte kInstruction_sbcs_al_r13_r6_r12_LSR_6[] = { 0x76, 0xeb, 0x9c, 0x1d // sbcs al r13 r6 r12 LSR 6 }; const byte kInstruction_sbcs_al_r1_r1_r7_LSR_3[] = { 0x71, 0xeb, 0xd7, 0x01 // sbcs al r1 r1 r7 LSR 3 }; const byte kInstruction_sbcs_al_r0_r13_r9_ASR_1[] = { 0x7d, 0xeb, 0x69, 0x00 // sbcs al r0 r13 r9 ASR 1 }; const byte kInstruction_sbcs_al_r2_r1_r3_LSR_12[] = { 0x71, 0xeb, 0x13, 0x32 // sbcs al r2 r1 r3 LSR 12 }; const byte kInstruction_sbcs_al_r12_r6_r10_ASR_1[] = { 0x76, 0xeb, 0x6a, 0x0c // sbcs al r12 r6 r10 ASR 1 }; const byte kInstruction_sbcs_al_r12_r4_r3_ASR_4[] = { 0x74, 0xeb, 0x23, 0x1c // sbcs al r12 r4 r3 ASR 4 }; const byte kInstruction_sbcs_al_r7_r0_r5_LSR_25[] = { 0x70, 0xeb, 0x55, 0x67 // sbcs al r7 r0 r5 LSR 25 }; const byte kInstruction_sbcs_al_r4_r5_r12_LSR_20[] = { 0x75, 0xeb, 0x1c, 0x54 // sbcs al r4 r5 r12 LSR 20 }; const byte kInstruction_sbcs_al_r3_r5_r11_LSR_24[] = { 0x75, 0xeb, 0x1b, 0x63 // sbcs al r3 r5 r11 LSR 24 }; const byte kInstruction_sbcs_al_r5_r8_r10_LSR_25[] = { 0x78, 0xeb, 0x5a, 0x65 // sbcs al r5 r8 r10 LSR 25 }; const byte kInstruction_sbcs_al_r11_r9_r12_LSR_24[] = { 0x79, 0xeb, 0x1c, 0x6b // sbcs al r11 r9 r12 LSR 24 }; const byte kInstruction_sbcs_al_r13_r11_r13_LSR_20[] = { 0x7b, 0xeb, 0x1d, 0x5d // sbcs al r13 r11 r13 LSR 20 }; const byte kInstruction_sbcs_al_r12_r4_r3_ASR_32[] = { 0x74, 0xeb, 0x23, 0x0c // sbcs al r12 r4 r3 ASR 32 }; const byte kInstruction_sbcs_al_r3_r6_r11_ASR_13[] = { 0x76, 0xeb, 0x6b, 0x33 // sbcs al r3 r6 r11 ASR 13 }; const byte kInstruction_sbcs_al_r13_r9_r7_LSR_27[] = { 0x79, 0xeb, 0xd7, 0x6d // sbcs al r13 r9 r7 LSR 27 }; const byte kInstruction_sbcs_al_r13_r9_r6_LSR_24[] = { 0x79, 0xeb, 0x16, 0x6d // sbcs al r13 r9 r6 LSR 24 }; const byte kInstruction_sbcs_al_r6_r13_r3_ASR_1[] = { 0x7d, 0xeb, 0x63, 0x06 // sbcs al r6 r13 r3 ASR 1 }; const byte kInstruction_sbcs_al_r8_r7_r14_ASR_27[] = { 0x77, 0xeb, 0xee, 0x68 // sbcs al r8 r7 r14 ASR 27 }; const byte kInstruction_sbcs_al_r8_r8_r8_LSR_29[] = { 0x78, 0xeb, 0x58, 0x78 // sbcs al r8 r8 r8 LSR 29 }; const byte kInstruction_sbcs_al_r1_r13_r4_ASR_26[] = { 0x7d, 0xeb, 0xa4, 0x61 // sbcs al r1 r13 r4 ASR 26 }; const byte kInstruction_sbcs_al_r3_r2_r10_LSR_16[] = { 0x72, 0xeb, 0x1a, 0x43 // sbcs al r3 r2 r10 LSR 16 }; const byte kInstruction_sbcs_al_r2_r11_r9_ASR_29[] = { 0x7b, 0xeb, 0x69, 0x72 // sbcs al r2 r11 r9 ASR 29 }; const byte kInstruction_sbcs_al_r12_r9_r8_LSR_7[] = { 0x79, 0xeb, 0xd8, 0x1c // sbcs al r12 r9 r8 LSR 7 }; const byte kInstruction_sbcs_al_r6_r2_r0_LSR_4[] = { 0x72, 0xeb, 0x10, 0x16 // sbcs al r6 r2 r0 LSR 4 }; const byte kInstruction_sbcs_al_r12_r2_r11_LSR_8[] = { 0x72, 0xeb, 0x1b, 0x2c // sbcs al r12 r2 r11 LSR 8 }; const byte kInstruction_sbcs_al_r0_r10_r12_LSR_5[] = { 0x7a, 0xeb, 0x5c, 0x10 // sbcs al r0 r10 r12 LSR 5 }; const byte kInstruction_sbcs_al_r2_r2_r2_ASR_4[] = { 0x72, 0xeb, 0x22, 0x12 // sbcs al r2 r2 r2 ASR 4 }; const byte kInstruction_sbcs_al_r4_r13_r11_LSR_15[] = { 0x7d, 0xeb, 0xdb, 0x34 // sbcs al r4 r13 r11 LSR 15 }; const byte kInstruction_sbcs_al_r4_r2_r13_ASR_4[] = { 0x72, 0xeb, 0x2d, 0x14 // sbcs al r4 r2 r13 ASR 4 }; const byte kInstruction_sbcs_al_r4_r4_r7_LSR_30[] = { 0x74, 0xeb, 0x97, 0x74 // sbcs al r4 r4 r7 LSR 30 }; const byte kInstruction_sbcs_al_r4_r8_r10_LSR_14[] = { 0x78, 0xeb, 0x9a, 0x34 // sbcs al r4 r8 r10 LSR 14 }; const byte kInstruction_sbcs_al_r14_r8_r11_ASR_16[] = { 0x78, 0xeb, 0x2b, 0x4e // sbcs al r14 r8 r11 ASR 16 }; const byte kInstruction_sbcs_al_r0_r8_r1_LSR_25[] = { 0x78, 0xeb, 0x51, 0x60 // sbcs al r0 r8 r1 LSR 25 }; const byte kInstruction_sbcs_al_r14_r13_r14_ASR_3[] = { 0x7d, 0xeb, 0xee, 0x0e // sbcs al r14 r13 r14 ASR 3 }; const byte kInstruction_sbcs_al_r13_r8_r13_ASR_31[] = { 0x78, 0xeb, 0xed, 0x7d // sbcs al r13 r8 r13 ASR 31 }; const byte kInstruction_sbcs_al_r9_r6_r1_LSR_28[] = { 0x76, 0xeb, 0x11, 0x79 // sbcs al r9 r6 r1 LSR 28 }; const byte kInstruction_sbcs_al_r4_r14_r1_ASR_9[] = { 0x7e, 0xeb, 0x61, 0x24 // sbcs al r4 r14 r1 ASR 9 }; const byte kInstruction_sbcs_al_r8_r0_r14_LSR_7[] = { 0x70, 0xeb, 0xde, 0x18 // sbcs al r8 r0 r14 LSR 7 }; const byte kInstruction_sbcs_al_r8_r8_r12_ASR_14[] = { 0x78, 0xeb, 0xac, 0x38 // sbcs al r8 r8 r12 ASR 14 }; const byte kInstruction_sbcs_al_r9_r14_r12_ASR_19[] = { 0x7e, 0xeb, 0xec, 0x49 // sbcs al r9 r14 r12 ASR 19 }; const byte kInstruction_sbcs_al_r4_r14_r11_ASR_25[] = { 0x7e, 0xeb, 0x6b, 0x64 // sbcs al r4 r14 r11 ASR 25 }; const byte kInstruction_sbcs_al_r1_r0_r9_ASR_13[] = { 0x70, 0xeb, 0x69, 0x31 // sbcs al r1 r0 r9 ASR 13 }; const byte kInstruction_sbcs_al_r8_r13_r9_LSR_4[] = { 0x7d, 0xeb, 0x19, 0x18 // sbcs al r8 r13 r9 LSR 4 }; const byte kInstruction_sbcs_al_r2_r4_r4_LSR_3[] = { 0x74, 0xeb, 0xd4, 0x02 // sbcs al r2 r4 r4 LSR 3 }; const byte kInstruction_sbcs_al_r14_r13_r3_LSR_8[] = { 0x7d, 0xeb, 0x13, 0x2e // sbcs al r14 r13 r3 LSR 8 }; const byte kInstruction_sbcs_al_r11_r6_r3_LSR_10[] = { 0x76, 0xeb, 0x93, 0x2b // sbcs al r11 r6 r3 LSR 10 }; const byte kInstruction_sbcs_al_r13_r8_r4_ASR_31[] = { 0x78, 0xeb, 0xe4, 0x7d // sbcs al r13 r8 r4 ASR 31 }; const byte kInstruction_sbcs_al_r8_r11_r0_LSR_13[] = { 0x7b, 0xeb, 0x50, 0x38 // sbcs al r8 r11 r0 LSR 13 }; const byte kInstruction_sbcs_al_r10_r5_r10_ASR_19[] = { 0x75, 0xeb, 0xea, 0x4a // sbcs al r10 r5 r10 ASR 19 }; const byte kInstruction_sbcs_al_r13_r4_r5_ASR_2[] = { 0x74, 0xeb, 0xa5, 0x0d // sbcs al r13 r4 r5 ASR 2 }; const byte kInstruction_sbcs_al_r8_r4_r10_LSR_3[] = { 0x74, 0xeb, 0xda, 0x08 // sbcs al r8 r4 r10 LSR 3 }; const byte kInstruction_sbcs_al_r13_r7_r3_LSR_6[] = { 0x77, 0xeb, 0x93, 0x1d // sbcs al r13 r7 r3 LSR 6 }; const byte kInstruction_sbcs_al_r6_r1_r8_LSR_1[] = { 0x71, 0xeb, 0x58, 0x06 // sbcs al r6 r1 r8 LSR 1 }; const byte kInstruction_sbcs_al_r5_r13_r9_LSR_31[] = { 0x7d, 0xeb, 0xd9, 0x75 // sbcs al r5 r13 r9 LSR 31 }; const byte kInstruction_sbcs_al_r11_r8_r0_ASR_19[] = { 0x78, 0xeb, 0xe0, 0x4b // sbcs al r11 r8 r0 ASR 19 }; const byte kInstruction_sbcs_al_r14_r6_r8_LSR_25[] = { 0x76, 0xeb, 0x58, 0x6e // sbcs al r14 r6 r8 LSR 25 }; const byte kInstruction_sbcs_al_r10_r6_r7_ASR_28[] = { 0x76, 0xeb, 0x27, 0x7a // sbcs al r10 r6 r7 ASR 28 }; const byte kInstruction_sbcs_al_r5_r2_r9_LSR_12[] = { 0x72, 0xeb, 0x19, 0x35 // sbcs al r5 r2 r9 LSR 12 }; const byte kInstruction_sbcs_al_r1_r2_r6_ASR_18[] = { 0x72, 0xeb, 0xa6, 0x41 // sbcs al r1 r2 r6 ASR 18 }; const byte kInstruction_sbcs_al_r10_r13_r11_ASR_14[] = { 0x7d, 0xeb, 0xab, 0x3a // sbcs al r10 r13 r11 ASR 14 }; const byte kInstruction_sbcs_al_r6_r8_r8_LSR_14[] = { 0x78, 0xeb, 0x98, 0x36 // sbcs al r6 r8 r8 LSR 14 }; const byte kInstruction_sbcs_al_r7_r14_r11_ASR_18[] = { 0x7e, 0xeb, 0xab, 0x47 // sbcs al r7 r14 r11 ASR 18 }; const byte kInstruction_sbcs_al_r3_r11_r2_LSR_13[] = { 0x7b, 0xeb, 0x52, 0x33 // sbcs al r3 r11 r2 LSR 13 }; const byte kInstruction_sbcs_al_r14_r7_r6_ASR_10[] = { 0x77, 0xeb, 0xa6, 0x2e // sbcs al r14 r7 r6 ASR 10 }; const byte kInstruction_sbcs_al_r6_r5_r7_ASR_12[] = { 0x75, 0xeb, 0x27, 0x36 // sbcs al r6 r5 r7 ASR 12 }; const byte kInstruction_sbcs_al_r5_r2_r9_ASR_13[] = { 0x72, 0xeb, 0x69, 0x35 // sbcs al r5 r2 r9 ASR 13 }; const byte kInstruction_sbcs_al_r12_r13_r3_LSR_14[] = { 0x7d, 0xeb, 0x93, 0x3c // sbcs al r12 r13 r3 LSR 14 }; const byte kInstruction_sbcs_al_r10_r4_r0_ASR_23[] = { 0x74, 0xeb, 0xe0, 0x5a // sbcs al r10 r4 r0 ASR 23 }; const byte kInstruction_sbcs_al_r10_r12_r2_LSR_18[] = { 0x7c, 0xeb, 0x92, 0x4a // sbcs al r10 r12 r2 LSR 18 }; const byte kInstruction_sbcs_al_r4_r10_r14_ASR_18[] = { 0x7a, 0xeb, 0xae, 0x44 // sbcs al r4 r10 r14 ASR 18 }; const byte kInstruction_sbcs_al_r13_r0_r1_LSR_7[] = { 0x70, 0xeb, 0xd1, 0x1d // sbcs al r13 r0 r1 LSR 7 }; const byte kInstruction_sbcs_al_r3_r3_r13_LSR_16[] = { 0x73, 0xeb, 0x1d, 0x43 // sbcs al r3 r3 r13 LSR 16 }; const byte kInstruction_sbcs_al_r7_r4_r4_ASR_19[] = { 0x74, 0xeb, 0xe4, 0x47 // sbcs al r7 r4 r4 ASR 19 }; const byte kInstruction_sbcs_al_r6_r7_r4_ASR_13[] = { 0x77, 0xeb, 0x64, 0x36 // sbcs al r6 r7 r4 ASR 13 }; const byte kInstruction_sbcs_al_r8_r10_r11_LSR_14[] = { 0x7a, 0xeb, 0x9b, 0x38 // sbcs al r8 r10 r11 LSR 14 }; const byte kInstruction_sbcs_al_r0_r0_r1_ASR_32[] = { 0x70, 0xeb, 0x21, 0x00 // sbcs al r0 r0 r1 ASR 32 }; const byte kInstruction_sbcs_al_r10_r12_r0_LSR_17[] = { 0x7c, 0xeb, 0x50, 0x4a // sbcs al r10 r12 r0 LSR 17 }; const byte kInstruction_sbcs_al_r2_r5_r12_ASR_8[] = { 0x75, 0xeb, 0x2c, 0x22 // sbcs al r2 r5 r12 ASR 8 }; const byte kInstruction_sbcs_al_r4_r3_r11_LSR_1[] = { 0x73, 0xeb, 0x5b, 0x04 // sbcs al r4 r3 r11 LSR 1 }; const byte kInstruction_sbcs_al_r12_r13_r12_LSR_22[] = { 0x7d, 0xeb, 0x9c, 0x5c // sbcs al r12 r13 r12 LSR 22 }; const byte kInstruction_sbcs_al_r8_r13_r11_LSR_12[] = { 0x7d, 0xeb, 0x1b, 0x38 // sbcs al r8 r13 r11 LSR 12 }; const byte kInstruction_sbcs_al_r9_r11_r3_LSR_27[] = { 0x7b, 0xeb, 0xd3, 0x69 // sbcs al r9 r11 r3 LSR 27 }; const byte kInstruction_sbcs_al_r8_r9_r10_ASR_21[] = { 0x79, 0xeb, 0x6a, 0x58 // sbcs al r8 r9 r10 ASR 21 }; const byte kInstruction_sbcs_al_r10_r3_r0_LSR_8[] = { 0x73, 0xeb, 0x10, 0x2a // sbcs al r10 r3 r0 LSR 8 }; const byte kInstruction_sbcs_al_r9_r2_r6_LSR_32[] = { 0x72, 0xeb, 0x16, 0x09 // sbcs al r9 r2 r6 LSR 32 }; const byte kInstruction_sbcs_al_r9_r0_r9_ASR_24[] = { 0x70, 0xeb, 0x29, 0x69 // sbcs al r9 r0 r9 ASR 24 }; const byte kInstruction_sbcs_al_r0_r10_r7_LSR_7[] = { 0x7a, 0xeb, 0xd7, 0x10 // sbcs al r0 r10 r7 LSR 7 }; const byte kInstruction_sbcs_al_r7_r11_r12_LSR_14[] = { 0x7b, 0xeb, 0x9c, 0x37 // sbcs al r7 r11 r12 LSR 14 }; const byte kInstruction_sbcs_al_r12_r10_r13_ASR_29[] = { 0x7a, 0xeb, 0x6d, 0x7c // sbcs al r12 r10 r13 ASR 29 }; const byte kInstruction_sbcs_al_r2_r14_r3_LSR_5[] = { 0x7e, 0xeb, 0x53, 0x12 // sbcs al r2 r14 r3 LSR 5 }; const byte kInstruction_sbcs_al_r14_r3_r12_ASR_19[] = { 0x73, 0xeb, 0xec, 0x4e // sbcs al r14 r3 r12 ASR 19 }; const byte kInstruction_sbcs_al_r12_r12_r11_ASR_31[] = { 0x7c, 0xeb, 0xeb, 0x7c // sbcs al r12 r12 r11 ASR 31 }; const byte kInstruction_sbcs_al_r0_r3_r2_ASR_4[] = { 0x73, 0xeb, 0x22, 0x10 // sbcs al r0 r3 r2 ASR 4 }; const byte kInstruction_sbcs_al_r13_r2_r11_ASR_9[] = { 0x72, 0xeb, 0x6b, 0x2d // sbcs al r13 r2 r11 ASR 9 }; const byte kInstruction_sbcs_al_r12_r14_r9_LSR_13[] = { 0x7e, 0xeb, 0x59, 0x3c // sbcs al r12 r14 r9 LSR 13 }; const byte kInstruction_sbcs_al_r14_r3_r3_ASR_28[] = { 0x73, 0xeb, 0x23, 0x7e // sbcs al r14 r3 r3 ASR 28 }; const byte kInstruction_sbcs_al_r12_r5_r12_LSR_19[] = { 0x75, 0xeb, 0xdc, 0x4c // sbcs al r12 r5 r12 LSR 19 }; const byte kInstruction_sbcs_al_r9_r13_r1_LSR_14[] = { 0x7d, 0xeb, 0x91, 0x39 // sbcs al r9 r13 r1 LSR 14 }; const byte kInstruction_sbcs_al_r5_r3_r1_LSR_11[] = { 0x73, 0xeb, 0xd1, 0x25 // sbcs al r5 r3 r1 LSR 11 }; const byte kInstruction_sbcs_al_r0_r14_r5_ASR_22[] = { 0x7e, 0xeb, 0xa5, 0x50 // sbcs al r0 r14 r5 ASR 22 }; const byte kInstruction_sbcs_al_r8_r9_r8_ASR_12[] = { 0x79, 0xeb, 0x28, 0x38 // sbcs al r8 r9 r8 ASR 12 }; const byte kInstruction_sbcs_al_r9_r0_r13_LSR_15[] = { 0x70, 0xeb, 0xdd, 0x39 // sbcs al r9 r0 r13 LSR 15 }; const byte kInstruction_sbcs_al_r9_r5_r14_ASR_9[] = { 0x75, 0xeb, 0x6e, 0x29 // sbcs al r9 r5 r14 ASR 9 }; const byte kInstruction_sbcs_al_r9_r13_r13_LSR_16[] = { 0x7d, 0xeb, 0x1d, 0x49 // sbcs al r9 r13 r13 LSR 16 }; const byte kInstruction_sbcs_al_r7_r0_r8_ASR_17[] = { 0x70, 0xeb, 0x68, 0x47 // sbcs al r7 r0 r8 ASR 17 }; const byte kInstruction_sbcs_al_r10_r13_r14_ASR_30[] = { 0x7d, 0xeb, 0xae, 0x7a // sbcs al r10 r13 r14 ASR 30 }; const byte kInstruction_sbcs_al_r7_r10_r4_LSR_8[] = { 0x7a, 0xeb, 0x14, 0x27 // sbcs al r7 r10 r4 LSR 8 }; const byte kInstruction_sbcs_al_r10_r5_r1_ASR_2[] = { 0x75, 0xeb, 0xa1, 0x0a // sbcs al r10 r5 r1 ASR 2 }; const byte kInstruction_sbcs_al_r4_r10_r2_LSR_10[] = { 0x7a, 0xeb, 0x92, 0x24 // sbcs al r4 r10 r2 LSR 10 }; const byte kInstruction_sbcs_al_r3_r5_r0_LSR_22[] = { 0x75, 0xeb, 0x90, 0x53 // sbcs al r3 r5 r0 LSR 22 }; const byte kInstruction_sbcs_al_r13_r11_r12_LSR_22[] = { 0x7b, 0xeb, 0x9c, 0x5d // sbcs al r13 r11 r12 LSR 22 }; const byte kInstruction_sbcs_al_r0_r8_r6_LSR_6[] = { 0x78, 0xeb, 0x96, 0x10 // sbcs al r0 r8 r6 LSR 6 }; const byte kInstruction_sbcs_al_r13_r4_r1_LSR_30[] = { 0x74, 0xeb, 0x91, 0x7d // sbcs al r13 r4 r1 LSR 30 }; const byte kInstruction_sbcs_al_r13_r9_r12_ASR_20[] = { 0x79, 0xeb, 0x2c, 0x5d // sbcs al r13 r9 r12 ASR 20 }; const byte kInstruction_sbcs_al_r0_r5_r10_ASR_2[] = { 0x75, 0xeb, 0xaa, 0x00 // sbcs al r0 r5 r10 ASR 2 }; const byte kInstruction_sbcs_al_r10_r4_r0_ASR_13[] = { 0x74, 0xeb, 0x60, 0x3a // sbcs al r10 r4 r0 ASR 13 }; const byte kInstruction_sbcs_al_r12_r3_r0_LSR_16[] = { 0x73, 0xeb, 0x10, 0x4c // sbcs al r12 r3 r0 LSR 16 }; const byte kInstruction_sbcs_al_r7_r11_r14_ASR_25[] = { 0x7b, 0xeb, 0x6e, 0x67 // sbcs al r7 r11 r14 ASR 25 }; const byte kInstruction_sbcs_al_r8_r9_r12_ASR_31[] = { 0x79, 0xeb, 0xec, 0x78 // sbcs al r8 r9 r12 ASR 31 }; const byte kInstruction_sbcs_al_r14_r11_r8_LSR_26[] = { 0x7b, 0xeb, 0x98, 0x6e // sbcs al r14 r11 r8 LSR 26 }; const byte kInstruction_sbcs_al_r8_r3_r6_ASR_31[] = { 0x73, 0xeb, 0xe6, 0x78 // sbcs al r8 r3 r6 ASR 31 }; const byte kInstruction_sbcs_al_r10_r4_r5_ASR_9[] = { 0x74, 0xeb, 0x65, 0x2a // sbcs al r10 r4 r5 ASR 9 }; const byte kInstruction_sbcs_al_r9_r4_r6_LSR_31[] = { 0x74, 0xeb, 0xd6, 0x79 // sbcs al r9 r4 r6 LSR 31 }; const byte kInstruction_sbcs_al_r12_r6_r12_LSR_32[] = { 0x76, 0xeb, 0x1c, 0x0c // sbcs al r12 r6 r12 LSR 32 }; const byte kInstruction_sbcs_al_r5_r8_r9_LSR_15[] = { 0x78, 0xeb, 0xd9, 0x35 // sbcs al r5 r8 r9 LSR 15 }; const byte kInstruction_sbcs_al_r1_r7_r0_LSR_4[] = { 0x77, 0xeb, 0x10, 0x11 // sbcs al r1 r7 r0 LSR 4 }; const byte kInstruction_sbcs_al_r14_r5_r3_LSR_11[] = { 0x75, 0xeb, 0xd3, 0x2e // sbcs al r14 r5 r3 LSR 11 }; const byte kInstruction_sbcs_al_r0_r5_r11_ASR_2[] = { 0x75, 0xeb, 0xab, 0x00 // sbcs al r0 r5 r11 ASR 2 }; const byte kInstruction_sbcs_al_r11_r13_r7_ASR_4[] = { 0x7d, 0xeb, 0x27, 0x1b // sbcs al r11 r13 r7 ASR 4 }; const byte kInstruction_sbcs_al_r8_r13_r12_LSR_7[] = { 0x7d, 0xeb, 0xdc, 0x18 // sbcs al r8 r13 r12 LSR 7 }; const byte kInstruction_sbcs_al_r2_r11_r2_ASR_28[] = { 0x7b, 0xeb, 0x22, 0x72 // sbcs al r2 r11 r2 ASR 28 }; const byte kInstruction_sbcs_al_r9_r14_r11_LSR_14[] = { 0x7e, 0xeb, 0x9b, 0x39 // sbcs al r9 r14 r11 LSR 14 }; const byte kInstruction_sbcs_al_r5_r12_r4_ASR_24[] = { 0x7c, 0xeb, 0x24, 0x65 // sbcs al r5 r12 r4 ASR 24 }; const byte kInstruction_sbcs_al_r9_r13_r3_LSR_19[] = { 0x7d, 0xeb, 0xd3, 0x49 // sbcs al r9 r13 r3 LSR 19 }; const byte kInstruction_sbcs_al_r6_r3_r3_ASR_25[] = { 0x73, 0xeb, 0x63, 0x66 // sbcs al r6 r3 r3 ASR 25 }; const byte kInstruction_sbcs_al_r13_r6_r6_LSR_16[] = { 0x76, 0xeb, 0x16, 0x4d // sbcs al r13 r6 r6 LSR 16 }; const byte kInstruction_sbcs_al_r0_r9_r5_ASR_30[] = { 0x79, 0xeb, 0xa5, 0x70 // sbcs al r0 r9 r5 ASR 30 }; const byte kInstruction_sbcs_al_r9_r9_r0_LSR_5[] = { 0x79, 0xeb, 0x50, 0x19 // sbcs al r9 r9 r0 LSR 5 }; const byte kInstruction_sbcs_al_r0_r5_r14_LSR_12[] = { 0x75, 0xeb, 0x1e, 0x30 // sbcs al r0 r5 r14 LSR 12 }; const byte kInstruction_sbcs_al_r14_r12_r7_ASR_7[] = { 0x7c, 0xeb, 0xe7, 0x1e // sbcs al r14 r12 r7 ASR 7 }; const byte kInstruction_sbcs_al_r8_r13_r6_ASR_27[] = { 0x7d, 0xeb, 0xe6, 0x68 // sbcs al r8 r13 r6 ASR 27 }; const byte kInstruction_sbcs_al_r12_r6_r13_LSR_24[] = { 0x76, 0xeb, 0x1d, 0x6c // sbcs al r12 r6 r13 LSR 24 }; const byte kInstruction_sbcs_al_r7_r10_r6_ASR_32[] = { 0x7a, 0xeb, 0x26, 0x07 // sbcs al r7 r10 r6 ASR 32 }; const byte kInstruction_sbcs_al_r6_r12_r13_ASR_8[] = { 0x7c, 0xeb, 0x2d, 0x26 // sbcs al r6 r12 r13 ASR 8 }; const byte kInstruction_sbcs_al_r13_r0_r8_LSR_19[] = { 0x70, 0xeb, 0xd8, 0x4d // sbcs al r13 r0 r8 LSR 19 }; const byte kInstruction_sbcs_al_r10_r9_r10_LSR_20[] = { 0x79, 0xeb, 0x1a, 0x5a // sbcs al r10 r9 r10 LSR 20 }; const byte kInstruction_sbcs_al_r5_r7_r2_LSR_25[] = { 0x77, 0xeb, 0x52, 0x65 // sbcs al r5 r7 r2 LSR 25 }; const byte kInstruction_sbcs_al_r2_r6_r0_LSR_15[] = { 0x76, 0xeb, 0xd0, 0x32 // sbcs al r2 r6 r0 LSR 15 }; const byte kInstruction_sbcs_al_r12_r6_r8_LSR_21[] = { 0x76, 0xeb, 0x58, 0x5c // sbcs al r12 r6 r8 LSR 21 }; const byte kInstruction_sbcs_al_r14_r13_r2_LSR_29[] = { 0x7d, 0xeb, 0x52, 0x7e // sbcs al r14 r13 r2 LSR 29 }; const byte kInstruction_sbcs_al_r1_r13_r0_LSR_21[] = { 0x7d, 0xeb, 0x50, 0x51 // sbcs al r1 r13 r0 LSR 21 }; const byte kInstruction_sbcs_al_r6_r7_r8_ASR_13[] = { 0x77, 0xeb, 0x68, 0x36 // sbcs al r6 r7 r8 ASR 13 }; const byte kInstruction_sbcs_al_r13_r2_r10_ASR_8[] = { 0x72, 0xeb, 0x2a, 0x2d // sbcs al r13 r2 r10 ASR 8 }; const byte kInstruction_sbcs_al_r5_r13_r7_LSR_2[] = { 0x7d, 0xeb, 0x97, 0x05 // sbcs al r5 r13 r7 LSR 2 }; const byte kInstruction_sbcs_al_r0_r3_r2_LSR_17[] = { 0x73, 0xeb, 0x52, 0x40 // sbcs al r0 r3 r2 LSR 17 }; const byte kInstruction_sbcs_al_r1_r8_r9_LSR_3[] = { 0x78, 0xeb, 0xd9, 0x01 // sbcs al r1 r8 r9 LSR 3 }; const byte kInstruction_sbcs_al_r11_r3_r1_LSR_29[] = { 0x73, 0xeb, 0x51, 0x7b // sbcs al r11 r3 r1 LSR 29 }; const byte kInstruction_sbcs_al_r2_r2_r11_LSR_17[] = { 0x72, 0xeb, 0x5b, 0x42 // sbcs al r2 r2 r11 LSR 17 }; const byte kInstruction_sbcs_al_r7_r14_r11_LSR_22[] = { 0x7e, 0xeb, 0x9b, 0x57 // sbcs al r7 r14 r11 LSR 22 }; const byte kInstruction_sbcs_al_r8_r7_r14_LSR_17[] = { 0x77, 0xeb, 0x5e, 0x48 // sbcs al r8 r7 r14 LSR 17 }; const byte kInstruction_sbcs_al_r14_r2_r7_ASR_32[] = { 0x72, 0xeb, 0x27, 0x0e // sbcs al r14 r2 r7 ASR 32 }; const byte kInstruction_sbcs_al_r0_r6_r9_ASR_13[] = { 0x76, 0xeb, 0x69, 0x30 // sbcs al r0 r6 r9 ASR 13 }; const byte kInstruction_sbcs_al_r3_r5_r4_ASR_24[] = { 0x75, 0xeb, 0x24, 0x63 // sbcs al r3 r5 r4 ASR 24 }; const byte kInstruction_sbcs_al_r10_r10_r6_ASR_1[] = { 0x7a, 0xeb, 0x66, 0x0a // sbcs al r10 r10 r6 ASR 1 }; const byte kInstruction_sbcs_al_r8_r9_r4_ASR_5[] = { 0x79, 0xeb, 0x64, 0x18 // sbcs al r8 r9 r4 ASR 5 }; const byte kInstruction_sbcs_al_r3_r0_r6_LSR_25[] = { 0x70, 0xeb, 0x56, 0x63 // sbcs al r3 r0 r6 LSR 25 }; const byte kInstruction_sbcs_al_r12_r7_r12_ASR_11[] = { 0x77, 0xeb, 0xec, 0x2c // sbcs al r12 r7 r12 ASR 11 }; const byte kInstruction_sbcs_al_r10_r9_r7_ASR_2[] = { 0x79, 0xeb, 0xa7, 0x0a // sbcs al r10 r9 r7 ASR 2 }; const byte kInstruction_sbcs_al_r13_r13_r5_ASR_2[] = { 0x7d, 0xeb, 0xa5, 0x0d // sbcs al r13 r13 r5 ASR 2 }; const byte kInstruction_sbcs_al_r11_r3_r2_ASR_5[] = { 0x73, 0xeb, 0x62, 0x1b // sbcs al r11 r3 r2 ASR 5 }; const byte kInstruction_sbcs_al_r0_r8_r8_ASR_10[] = { 0x78, 0xeb, 0xa8, 0x20 // sbcs al r0 r8 r8 ASR 10 }; const byte kInstruction_sbcs_al_r10_r12_r12_ASR_19[] = { 0x7c, 0xeb, 0xec, 0x4a // sbcs al r10 r12 r12 ASR 19 }; const byte kInstruction_sbcs_al_r2_r6_r0_LSR_10[] = { 0x76, 0xeb, 0x90, 0x22 // sbcs al r2 r6 r0 LSR 10 }; const byte kInstruction_sbcs_al_r11_r8_r8_ASR_15[] = { 0x78, 0xeb, 0xe8, 0x3b // sbcs al r11 r8 r8 ASR 15 }; const byte kInstruction_sbcs_al_r14_r14_r1_LSR_14[] = { 0x7e, 0xeb, 0x91, 0x3e // sbcs al r14 r14 r1 LSR 14 }; const byte kInstruction_sbcs_al_r9_r8_r12_ASR_21[] = { 0x78, 0xeb, 0x6c, 0x59 // sbcs al r9 r8 r12 ASR 21 }; const byte kInstruction_sbcs_al_r14_r14_r12_ASR_9[] = { 0x7e, 0xeb, 0x6c, 0x2e // sbcs al r14 r14 r12 ASR 9 }; const byte kInstruction_sbcs_al_r0_r0_r3_ASR_22[] = { 0x70, 0xeb, 0xa3, 0x50 // sbcs al r0 r0 r3 ASR 22 }; const byte kInstruction_sbcs_al_r9_r7_r13_LSR_16[] = { 0x77, 0xeb, 0x1d, 0x49 // sbcs al r9 r7 r13 LSR 16 }; const byte kInstruction_sbcs_al_r8_r1_r5_LSR_28[] = { 0x71, 0xeb, 0x15, 0x78 // sbcs al r8 r1 r5 LSR 28 }; const byte kInstruction_sbcs_al_r0_r2_r11_LSR_21[] = { 0x72, 0xeb, 0x5b, 0x50 // sbcs al r0 r2 r11 LSR 21 }; const byte kInstruction_sbcs_al_r5_r12_r8_LSR_25[] = { 0x7c, 0xeb, 0x58, 0x65 // sbcs al r5 r12 r8 LSR 25 }; const byte kInstruction_sbcs_al_r9_r5_r6_ASR_5[] = { 0x75, 0xeb, 0x66, 0x19 // sbcs al r9 r5 r6 ASR 5 }; const byte kInstruction_sbcs_al_r0_r0_r7_ASR_13[] = { 0x70, 0xeb, 0x67, 0x30 // sbcs al r0 r0 r7 ASR 13 }; const byte kInstruction_sbcs_al_r2_r10_r7_ASR_10[] = { 0x7a, 0xeb, 0xa7, 0x22 // sbcs al r2 r10 r7 ASR 10 }; const byte kInstruction_sbcs_al_r13_r8_r14_ASR_32[] = { 0x78, 0xeb, 0x2e, 0x0d // sbcs al r13 r8 r14 ASR 32 }; const byte kInstruction_sbcs_al_r3_r2_r9_ASR_30[] = { 0x72, 0xeb, 0xa9, 0x73 // sbcs al r3 r2 r9 ASR 30 }; const byte kInstruction_sbcs_al_r11_r0_r14_ASR_6[] = { 0x70, 0xeb, 0xae, 0x1b // sbcs al r11 r0 r14 ASR 6 }; const byte kInstruction_sbcs_al_r13_r10_r2_ASR_18[] = { 0x7a, 0xeb, 0xa2, 0x4d // sbcs al r13 r10 r2 ASR 18 }; const byte kInstruction_sbcs_al_r8_r13_r1_ASR_18[] = { 0x7d, 0xeb, 0xa1, 0x48 // sbcs al r8 r13 r1 ASR 18 }; const byte kInstruction_sbcs_al_r10_r4_r3_LSR_19[] = { 0x74, 0xeb, 0xd3, 0x4a // sbcs al r10 r4 r3 LSR 19 }; const byte kInstruction_sbcs_al_r2_r2_r9_ASR_15[] = { 0x72, 0xeb, 0xe9, 0x32 // sbcs al r2 r2 r9 ASR 15 }; const byte kInstruction_sbcs_al_r6_r4_r8_LSR_28[] = { 0x74, 0xeb, 0x18, 0x76 // sbcs al r6 r4 r8 LSR 28 }; const byte kInstruction_sbcs_al_r14_r9_r6_LSR_27[] = { 0x79, 0xeb, 0xd6, 0x6e // sbcs al r14 r9 r6 LSR 27 }; const byte kInstruction_sbcs_al_r3_r14_r8_LSR_18[] = { 0x7e, 0xeb, 0x98, 0x43 // sbcs al r3 r14 r8 LSR 18 }; const byte kInstruction_sbcs_al_r4_r1_r14_LSR_2[] = { 0x71, 0xeb, 0x9e, 0x04 // sbcs al r4 r1 r14 LSR 2 }; const byte kInstruction_sbcs_al_r13_r9_r6_ASR_16[] = { 0x79, 0xeb, 0x26, 0x4d // sbcs al r13 r9 r6 ASR 16 }; const byte kInstruction_sbcs_al_r4_r1_r9_ASR_29[] = { 0x71, 0xeb, 0x69, 0x74 // sbcs al r4 r1 r9 ASR 29 }; const byte kInstruction_sbcs_al_r4_r3_r2_LSR_23[] = { 0x73, 0xeb, 0xd2, 0x54 // sbcs al r4 r3 r2 LSR 23 }; const byte kInstruction_sbcs_al_r11_r8_r0_LSR_19[] = { 0x78, 0xeb, 0xd0, 0x4b // sbcs al r11 r8 r0 LSR 19 }; const byte kInstruction_sbcs_al_r6_r10_r4_ASR_29[] = { 0x7a, 0xeb, 0x64, 0x76 // sbcs al r6 r10 r4 ASR 29 }; const byte kInstruction_sbcs_al_r8_r2_r5_ASR_25[] = { 0x72, 0xeb, 0x65, 0x68 // sbcs al r8 r2 r5 ASR 25 }; const byte kInstruction_sbcs_al_r3_r10_r14_LSR_25[] = { 0x7a, 0xeb, 0x5e, 0x63 // sbcs al r3 r10 r14 LSR 25 }; const byte kInstruction_sbcs_al_r4_r9_r0_LSR_32[] = { 0x79, 0xeb, 0x10, 0x04 // sbcs al r4 r9 r0 LSR 32 }; const byte kInstruction_sbcs_al_r14_r10_r1_ASR_8[] = { 0x7a, 0xeb, 0x21, 0x2e // sbcs al r14 r10 r1 ASR 8 }; const byte kInstruction_sbcs_al_r10_r10_r1_LSR_4[] = { 0x7a, 0xeb, 0x11, 0x1a // sbcs al r10 r10 r1 LSR 4 }; const byte kInstruction_sbcs_al_r10_r2_r9_ASR_23[] = { 0x72, 0xeb, 0xe9, 0x5a // sbcs al r10 r2 r9 ASR 23 }; const byte kInstruction_sbcs_al_r12_r2_r7_LSR_30[] = { 0x72, 0xeb, 0x97, 0x7c // sbcs al r12 r2 r7 LSR 30 }; const byte kInstruction_sbcs_al_r13_r4_r9_ASR_20[] = { 0x74, 0xeb, 0x29, 0x5d // sbcs al r13 r4 r9 ASR 20 }; const byte kInstruction_sbcs_al_r12_r13_r2_LSR_29[] = { 0x7d, 0xeb, 0x52, 0x7c // sbcs al r12 r13 r2 LSR 29 }; const byte kInstruction_sbcs_al_r14_r8_r13_ASR_12[] = { 0x78, 0xeb, 0x2d, 0x3e // sbcs al r14 r8 r13 ASR 12 }; const byte kInstruction_sbcs_al_r11_r14_r11_ASR_18[] = { 0x7e, 0xeb, 0xab, 0x4b // sbcs al r11 r14 r11 ASR 18 }; const byte kInstruction_sbcs_al_r11_r10_r1_LSR_3[] = { 0x7a, 0xeb, 0xd1, 0x0b // sbcs al r11 r10 r1 LSR 3 }; const byte kInstruction_sbcs_al_r6_r2_r0_LSR_27[] = { 0x72, 0xeb, 0xd0, 0x66 // sbcs al r6 r2 r0 LSR 27 }; const byte kInstruction_sbcs_al_r13_r6_r12_ASR_6[] = { 0x76, 0xeb, 0xac, 0x1d // sbcs al r13 r6 r12 ASR 6 }; const byte kInstruction_sbcs_al_r9_r2_r3_ASR_21[] = { 0x72, 0xeb, 0x63, 0x59 // sbcs al r9 r2 r3 ASR 21 }; const byte kInstruction_sbcs_al_r2_r9_r4_LSR_16[] = { 0x79, 0xeb, 0x14, 0x42 // sbcs al r2 r9 r4 LSR 16 }; const byte kInstruction_sbcs_al_r10_r13_r10_ASR_23[] = { 0x7d, 0xeb, 0xea, 0x5a // sbcs al r10 r13 r10 ASR 23 }; const byte kInstruction_sbcs_al_r8_r13_r10_LSR_20[] = { 0x7d, 0xeb, 0x1a, 0x58 // sbcs al r8 r13 r10 LSR 20 }; const byte kInstruction_sbcs_al_r0_r7_r7_ASR_17[] = { 0x77, 0xeb, 0x67, 0x40 // sbcs al r0 r7 r7 ASR 17 }; const byte kInstruction_sbcs_al_r2_r5_r9_ASR_24[] = { 0x75, 0xeb, 0x29, 0x62 // sbcs al r2 r5 r9 ASR 24 }; const byte kInstruction_sbcs_al_r1_r9_r7_ASR_16[] = { 0x79, 0xeb, 0x27, 0x41 // sbcs al r1 r9 r7 ASR 16 }; const byte kInstruction_sbcs_al_r4_r1_r7_LSR_26[] = { 0x71, 0xeb, 0x97, 0x64 // sbcs al r4 r1 r7 LSR 26 }; const byte kInstruction_sbcs_al_r6_r4_r10_LSR_26[] = { 0x74, 0xeb, 0x9a, 0x66 // sbcs al r6 r4 r10 LSR 26 }; const byte kInstruction_sbcs_al_r9_r5_r7_ASR_1[] = { 0x75, 0xeb, 0x67, 0x09 // sbcs al r9 r5 r7 ASR 1 }; const byte kInstruction_sbcs_al_r5_r3_r5_LSR_8[] = { 0x73, 0xeb, 0x15, 0x25 // sbcs al r5 r3 r5 LSR 8 }; const byte kInstruction_sbcs_al_r7_r6_r8_LSR_28[] = { 0x76, 0xeb, 0x18, 0x77 // sbcs al r7 r6 r8 LSR 28 }; const byte kInstruction_sbcs_al_r3_r5_r12_ASR_23[] = { 0x75, 0xeb, 0xec, 0x53 // sbcs al r3 r5 r12 ASR 23 }; const byte kInstruction_sbcs_al_r3_r14_r9_LSR_28[] = { 0x7e, 0xeb, 0x19, 0x73 // sbcs al r3 r14 r9 LSR 28 }; const byte kInstruction_sbcs_al_r14_r5_r3_LSR_21[] = { 0x75, 0xeb, 0x53, 0x5e // sbcs al r14 r5 r3 LSR 21 }; const byte kInstruction_sbcs_al_r11_r0_r13_LSR_23[] = { 0x70, 0xeb, 0xdd, 0x5b // sbcs al r11 r0 r13 LSR 23 }; const byte kInstruction_sbcs_al_r13_r13_r7_LSR_15[] = { 0x7d, 0xeb, 0xd7, 0x3d // sbcs al r13 r13 r7 LSR 15 }; const byte kInstruction_sbcs_al_r6_r10_r8_LSR_24[] = { 0x7a, 0xeb, 0x18, 0x66 // sbcs al r6 r10 r8 LSR 24 }; const byte kInstruction_sbcs_al_r8_r11_r11_ASR_28[] = { 0x7b, 0xeb, 0x2b, 0x78 // sbcs al r8 r11 r11 ASR 28 }; const byte kInstruction_sbcs_al_r9_r1_r1_LSR_26[] = { 0x71, 0xeb, 0x91, 0x69 // sbcs al r9 r1 r1 LSR 26 }; const byte kInstruction_sbcs_al_r2_r4_r14_LSR_2[] = { 0x74, 0xeb, 0x9e, 0x02 // sbcs al r2 r4 r14 LSR 2 }; const byte kInstruction_sbcs_al_r4_r7_r2_ASR_19[] = { 0x77, 0xeb, 0xe2, 0x44 // sbcs al r4 r7 r2 ASR 19 }; const byte kInstruction_sbcs_al_r9_r1_r7_ASR_23[] = { 0x71, 0xeb, 0xe7, 0x59 // sbcs al r9 r1 r7 ASR 23 }; const byte kInstruction_sbcs_al_r4_r7_r11_ASR_7[] = { 0x77, 0xeb, 0xeb, 0x14 // sbcs al r4 r7 r11 ASR 7 }; const byte kInstruction_sbcs_al_r7_r9_r5_ASR_32[] = { 0x79, 0xeb, 0x25, 0x07 // sbcs al r7 r9 r5 ASR 32 }; const byte kInstruction_sbcs_al_r14_r6_r6_ASR_11[] = { 0x76, 0xeb, 0xe6, 0x2e // sbcs al r14 r6 r6 ASR 11 }; const byte kInstruction_sbcs_al_r14_r5_r14_ASR_32[] = { 0x75, 0xeb, 0x2e, 0x0e // sbcs al r14 r5 r14 ASR 32 }; const byte kInstruction_sbcs_al_r9_r2_r13_LSR_15[] = { 0x72, 0xeb, 0xdd, 0x39 // sbcs al r9 r2 r13 LSR 15 }; const byte kInstruction_sbcs_al_r13_r8_r3_LSR_15[] = { 0x78, 0xeb, 0xd3, 0x3d // sbcs al r13 r8 r3 LSR 15 }; const byte kInstruction_sbcs_al_r14_r0_r2_ASR_10[] = { 0x70, 0xeb, 0xa2, 0x2e // sbcs al r14 r0 r2 ASR 10 }; const byte kInstruction_sbcs_al_r9_r6_r5_LSR_3[] = { 0x76, 0xeb, 0xd5, 0x09 // sbcs al r9 r6 r5 LSR 3 }; const byte kInstruction_sbcs_al_r11_r10_r12_LSR_13[] = { 0x7a, 0xeb, 0x5c, 0x3b // sbcs al r11 r10 r12 LSR 13 }; const byte kInstruction_sbcs_al_r7_r11_r9_LSR_11[] = { 0x7b, 0xeb, 0xd9, 0x27 // sbcs al r7 r11 r9 LSR 11 }; const byte kInstruction_sbcs_al_r3_r9_r9_ASR_10[] = { 0x79, 0xeb, 0xa9, 0x23 // sbcs al r3 r9 r9 ASR 10 }; const byte kInstruction_sbcs_al_r12_r14_r3_LSR_25[] = { 0x7e, 0xeb, 0x53, 0x6c // sbcs al r12 r14 r3 LSR 25 }; const byte kInstruction_sbcs_al_r13_r1_r11_ASR_7[] = { 0x71, 0xeb, 0xeb, 0x1d // sbcs al r13 r1 r11 ASR 7 }; const byte kInstruction_sbcs_al_r12_r9_r5_ASR_2[] = { 0x79, 0xeb, 0xa5, 0x0c // sbcs al r12 r9 r5 ASR 2 }; const byte kInstruction_sbcs_al_r6_r13_r7_ASR_12[] = { 0x7d, 0xeb, 0x27, 0x36 // sbcs al r6 r13 r7 ASR 12 }; const byte kInstruction_sbcs_al_r5_r1_r5_LSR_16[] = { 0x71, 0xeb, 0x15, 0x45 // sbcs al r5 r1 r5 LSR 16 }; const byte kInstruction_sbcs_al_r0_r11_r13_LSR_22[] = { 0x7b, 0xeb, 0x9d, 0x50 // sbcs al r0 r11 r13 LSR 22 }; const byte kInstruction_sbcs_al_r7_r8_r1_ASR_25[] = { 0x78, 0xeb, 0x61, 0x67 // sbcs al r7 r8 r1 ASR 25 }; const byte kInstruction_sbcs_al_r2_r13_r9_LSR_11[] = { 0x7d, 0xeb, 0xd9, 0x22 // sbcs al r2 r13 r9 LSR 11 }; const byte kInstruction_sbcs_al_r4_r9_r11_ASR_17[] = { 0x79, 0xeb, 0x6b, 0x44 // sbcs al r4 r9 r11 ASR 17 }; const byte kInstruction_sbcs_al_r6_r0_r4_ASR_13[] = { 0x70, 0xeb, 0x64, 0x36 // sbcs al r6 r0 r4 ASR 13 }; const byte kInstruction_sbcs_al_r9_r0_r14_LSR_23[] = { 0x70, 0xeb, 0xde, 0x59 // sbcs al r9 r0 r14 LSR 23 }; const byte kInstruction_sbcs_al_r14_r11_r5_ASR_17[] = { 0x7b, 0xeb, 0x65, 0x4e // sbcs al r14 r11 r5 ASR 17 }; const byte kInstruction_sbcs_al_r6_r14_r13_ASR_4[] = { 0x7e, 0xeb, 0x2d, 0x16 // sbcs al r6 r14 r13 ASR 4 }; const byte kInstruction_sbcs_al_r14_r12_r7_ASR_31[] = { 0x7c, 0xeb, 0xe7, 0x7e // sbcs al r14 r12 r7 ASR 31 }; const byte kInstruction_sbcs_al_r11_r10_r12_ASR_1[] = { 0x7a, 0xeb, 0x6c, 0x0b // sbcs al r11 r10 r12 ASR 1 }; const byte kInstruction_sbcs_al_r14_r11_r12_ASR_25[] = { 0x7b, 0xeb, 0x6c, 0x6e // sbcs al r14 r11 r12 ASR 25 }; const byte kInstruction_sbcs_al_r2_r13_r1_ASR_1[] = { 0x7d, 0xeb, 0x61, 0x02 // sbcs al r2 r13 r1 ASR 1 }; const byte kInstruction_sbcs_al_r9_r2_r3_LSR_29[] = { 0x72, 0xeb, 0x53, 0x79 // sbcs al r9 r2 r3 LSR 29 }; const byte kInstruction_sbcs_al_r1_r7_r6_ASR_20[] = { 0x77, 0xeb, 0x26, 0x51 // sbcs al r1 r7 r6 ASR 20 }; const byte kInstruction_sbcs_al_r9_r13_r3_LSR_2[] = { 0x7d, 0xeb, 0x93, 0x09 // sbcs al r9 r13 r3 LSR 2 }; const byte kInstruction_sbcs_al_r8_r12_r5_ASR_24[] = { 0x7c, 0xeb, 0x25, 0x68 // sbcs al r8 r12 r5 ASR 24 }; const byte kInstruction_sbcs_al_r12_r5_r14_LSR_1[] = { 0x75, 0xeb, 0x5e, 0x0c // sbcs al r12 r5 r14 LSR 1 }; const byte kInstruction_sbcs_al_r13_r4_r9_ASR_30[] = { 0x74, 0xeb, 0xa9, 0x7d // sbcs al r13 r4 r9 ASR 30 }; const byte kInstruction_sbcs_al_r12_r2_r11_ASR_28[] = { 0x72, 0xeb, 0x2b, 0x7c // sbcs al r12 r2 r11 ASR 28 }; const byte kInstruction_sbcs_al_r8_r2_r11_LSR_26[] = { 0x72, 0xeb, 0x9b, 0x68 // sbcs al r8 r2 r11 LSR 26 }; const byte kInstruction_sbcs_al_r0_r0_r2_ASR_21[] = { 0x70, 0xeb, 0x62, 0x50 // sbcs al r0 r0 r2 ASR 21 }; const byte kInstruction_sbcs_al_r7_r10_r14_LSR_22[] = { 0x7a, 0xeb, 0x9e, 0x57 // sbcs al r7 r10 r14 LSR 22 }; const byte kInstruction_sbcs_al_r3_r1_r4_ASR_18[] = { 0x71, 0xeb, 0xa4, 0x43 // sbcs al r3 r1 r4 ASR 18 }; const byte kInstruction_sbcs_al_r8_r14_r3_ASR_32[] = { 0x7e, 0xeb, 0x23, 0x08 // sbcs al r8 r14 r3 ASR 32 }; const byte kInstruction_sbcs_al_r4_r9_r8_ASR_4[] = { 0x79, 0xeb, 0x28, 0x14 // sbcs al r4 r9 r8 ASR 4 }; const byte kInstruction_sbcs_al_r7_r2_r4_ASR_14[] = { 0x72, 0xeb, 0xa4, 0x37 // sbcs al r7 r2 r4 ASR 14 }; const byte kInstruction_sbcs_al_r12_r1_r9_ASR_9[] = { 0x71, 0xeb, 0x69, 0x2c // sbcs al r12 r1 r9 ASR 9 }; const byte kInstruction_sbcs_al_r3_r5_r0_ASR_11[] = { 0x75, 0xeb, 0xe0, 0x23 // sbcs al r3 r5 r0 ASR 11 }; const byte kInstruction_sbcs_al_r14_r9_r0_LSR_10[] = { 0x79, 0xeb, 0x90, 0x2e // sbcs al r14 r9 r0 LSR 10 }; const byte kInstruction_sbcs_al_r14_r13_r6_ASR_27[] = { 0x7d, 0xeb, 0xe6, 0x6e // sbcs al r14 r13 r6 ASR 27 }; const byte kInstruction_sbcs_al_r13_r8_r1_LSR_27[] = { 0x78, 0xeb, 0xd1, 0x6d // sbcs al r13 r8 r1 LSR 27 }; const byte kInstruction_sbcs_al_r7_r0_r7_LSR_31[] = { 0x70, 0xeb, 0xd7, 0x77 // sbcs al r7 r0 r7 LSR 31 }; const byte kInstruction_sbcs_al_r5_r8_r7_ASR_27[] = { 0x78, 0xeb, 0xe7, 0x65 // sbcs al r5 r8 r7 ASR 27 }; const byte kInstruction_sbcs_al_r12_r3_r10_ASR_24[] = { 0x73, 0xeb, 0x2a, 0x6c // sbcs al r12 r3 r10 ASR 24 }; const byte kInstruction_sbcs_al_r14_r14_r5_LSR_20[] = { 0x7e, 0xeb, 0x15, 0x5e // sbcs al r14 r14 r5 LSR 20 }; const byte kInstruction_sbcs_al_r0_r12_r7_LSR_32[] = { 0x7c, 0xeb, 0x17, 0x00 // sbcs al r0 r12 r7 LSR 32 }; const byte kInstruction_sbcs_al_r2_r3_r6_ASR_17[] = { 0x73, 0xeb, 0x66, 0x42 // sbcs al r2 r3 r6 ASR 17 }; const byte kInstruction_sbcs_al_r11_r8_r13_ASR_27[] = { 0x78, 0xeb, 0xed, 0x6b // sbcs al r11 r8 r13 ASR 27 }; const byte kInstruction_sbcs_al_r13_r12_r4_LSR_24[] = { 0x7c, 0xeb, 0x14, 0x6d // sbcs al r13 r12 r4 LSR 24 }; const byte kInstruction_sbcs_al_r3_r3_r0_ASR_26[] = { 0x73, 0xeb, 0xa0, 0x63 // sbcs al r3 r3 r0 ASR 26 }; const byte kInstruction_sbcs_al_r10_r0_r5_ASR_26[] = { 0x70, 0xeb, 0xa5, 0x6a // sbcs al r10 r0 r5 ASR 26 }; const byte kInstruction_sbcs_al_r5_r9_r7_LSR_6[] = { 0x79, 0xeb, 0x97, 0x15 // sbcs al r5 r9 r7 LSR 6 }; const byte kInstruction_sbcs_al_r12_r4_r9_ASR_8[] = { 0x74, 0xeb, 0x29, 0x2c // sbcs al r12 r4 r9 ASR 8 }; const byte kInstruction_sbcs_al_r4_r0_r13_LSR_16[] = { 0x70, 0xeb, 0x1d, 0x44 // sbcs al r4 r0 r13 LSR 16 }; const byte kInstruction_sbcs_al_r11_r2_r2_LSR_6[] = { 0x72, 0xeb, 0x92, 0x1b // sbcs al r11 r2 r2 LSR 6 }; const byte kInstruction_sbcs_al_r12_r4_r3_ASR_11[] = { 0x74, 0xeb, 0xe3, 0x2c // sbcs al r12 r4 r3 ASR 11 }; const byte kInstruction_sbcs_al_r0_r10_r12_ASR_22[] = { 0x7a, 0xeb, 0xac, 0x50 // sbcs al r0 r10 r12 ASR 22 }; const byte kInstruction_sbcs_al_r12_r2_r12_LSR_16[] = { 0x72, 0xeb, 0x1c, 0x4c // sbcs al r12 r2 r12 LSR 16 }; const byte kInstruction_sbcs_al_r2_r2_r8_ASR_14[] = { 0x72, 0xeb, 0xa8, 0x32 // sbcs al r2 r2 r8 ASR 14 }; const byte kInstruction_sbcs_al_r9_r1_r3_LSR_2[] = { 0x71, 0xeb, 0x93, 0x09 // sbcs al r9 r1 r3 LSR 2 }; const byte kInstruction_sbcs_al_r7_r0_r6_ASR_15[] = { 0x70, 0xeb, 0xe6, 0x37 // sbcs al r7 r0 r6 ASR 15 }; const byte kInstruction_sbcs_al_r11_r2_r12_LSR_17[] = { 0x72, 0xeb, 0x5c, 0x4b // sbcs al r11 r2 r12 LSR 17 }; const byte kInstruction_sbcs_al_r3_r7_r7_ASR_19[] = { 0x77, 0xeb, 0xe7, 0x43 // sbcs al r3 r7 r7 ASR 19 }; const byte kInstruction_sbcs_al_r9_r13_r1_LSR_29[] = { 0x7d, 0xeb, 0x51, 0x79 // sbcs al r9 r13 r1 LSR 29 }; const byte kInstruction_sbcs_al_r1_r0_r2_LSR_2[] = { 0x70, 0xeb, 0x92, 0x01 // sbcs al r1 r0 r2 LSR 2 }; const byte kInstruction_sbcs_al_r14_r10_r2_ASR_12[] = { 0x7a, 0xeb, 0x22, 0x3e // sbcs al r14 r10 r2 ASR 12 }; const byte kInstruction_sbcs_al_r7_r14_r11_ASR_27[] = { 0x7e, 0xeb, 0xeb, 0x67 // sbcs al r7 r14 r11 ASR 27 }; const byte kInstruction_sbcs_al_r9_r8_r13_ASR_17[] = { 0x78, 0xeb, 0x6d, 0x49 // sbcs al r9 r8 r13 ASR 17 }; const byte kInstruction_sbcs_al_r6_r14_r8_LSR_11[] = { 0x7e, 0xeb, 0xd8, 0x26 // sbcs al r6 r14 r8 LSR 11 }; const byte kInstruction_sbcs_al_r5_r3_r9_ASR_31[] = { 0x73, 0xeb, 0xe9, 0x75 // sbcs al r5 r3 r9 ASR 31 }; const byte kInstruction_sbcs_al_r5_r4_r1_ASR_29[] = { 0x74, 0xeb, 0x61, 0x75 // sbcs al r5 r4 r1 ASR 29 }; const byte kInstruction_sbcs_al_r6_r5_r10_ASR_25[] = { 0x75, 0xeb, 0x6a, 0x66 // sbcs al r6 r5 r10 ASR 25 }; const byte kInstruction_sbcs_al_r1_r8_r14_ASR_32[] = { 0x78, 0xeb, 0x2e, 0x01 // sbcs al r1 r8 r14 ASR 32 }; const byte kInstruction_sbcs_al_r0_r3_r5_ASR_4[] = { 0x73, 0xeb, 0x25, 0x10 // sbcs al r0 r3 r5 ASR 4 }; const byte kInstruction_sbcs_al_r8_r6_r1_ASR_5[] = { 0x76, 0xeb, 0x61, 0x18 // sbcs al r8 r6 r1 ASR 5 }; const byte kInstruction_sbcs_al_r14_r9_r14_ASR_25[] = { 0x79, 0xeb, 0x6e, 0x6e // sbcs al r14 r9 r14 ASR 25 }; const byte kInstruction_sbcs_al_r2_r10_r0_ASR_18[] = { 0x7a, 0xeb, 0xa0, 0x42 // sbcs al r2 r10 r0 ASR 18 }; const byte kInstruction_sbcs_al_r12_r14_r0_LSR_23[] = { 0x7e, 0xeb, 0xd0, 0x5c // sbcs al r12 r14 r0 LSR 23 }; const byte kInstruction_sbcs_al_r5_r13_r14_LSR_25[] = { 0x7d, 0xeb, 0x5e, 0x65 // sbcs al r5 r13 r14 LSR 25 }; const byte kInstruction_sbcs_al_r13_r11_r10_ASR_18[] = { 0x7b, 0xeb, 0xaa, 0x4d // sbcs al r13 r11 r10 ASR 18 }; const byte kInstruction_sbcs_al_r13_r9_r4_LSR_22[] = { 0x79, 0xeb, 0x94, 0x5d // sbcs al r13 r9 r4 LSR 22 }; const byte kInstruction_sbcs_al_r10_r12_r5_LSR_12[] = { 0x7c, 0xeb, 0x15, 0x3a // sbcs al r10 r12 r5 LSR 12 }; const byte kInstruction_sbcs_al_r0_r1_r2_ASR_28[] = { 0x71, 0xeb, 0x22, 0x70 // sbcs al r0 r1 r2 ASR 28 }; const byte kInstruction_sbcs_al_r13_r5_r5_LSR_4[] = { 0x75, 0xeb, 0x15, 0x1d // sbcs al r13 r5 r5 LSR 4 }; const byte kInstruction_sbcs_al_r1_r3_r10_LSR_18[] = { 0x73, 0xeb, 0x9a, 0x41 // sbcs al r1 r3 r10 LSR 18 }; const byte kInstruction_sbcs_al_r2_r6_r4_LSR_4[] = { 0x76, 0xeb, 0x14, 0x12 // sbcs al r2 r6 r4 LSR 4 }; const byte kInstruction_sbcs_al_r0_r3_r10_LSR_4[] = { 0x73, 0xeb, 0x1a, 0x10 // sbcs al r0 r3 r10 LSR 4 }; const byte kInstruction_sbcs_al_r14_r2_r8_LSR_30[] = { 0x72, 0xeb, 0x98, 0x7e // sbcs al r14 r2 r8 LSR 30 }; const byte kInstruction_sbcs_al_r10_r12_r10_ASR_18[] = { 0x7c, 0xeb, 0xaa, 0x4a // sbcs al r10 r12 r10 ASR 18 }; const byte kInstruction_sbcs_al_r13_r4_r2_LSR_31[] = { 0x74, 0xeb, 0xd2, 0x7d // sbcs al r13 r4 r2 LSR 31 }; const byte kInstruction_sbcs_al_r10_r11_r14_LSR_5[] = { 0x7b, 0xeb, 0x5e, 0x1a // sbcs al r10 r11 r14 LSR 5 }; const byte kInstruction_sbcs_al_r3_r1_r6_ASR_8[] = { 0x71, 0xeb, 0x26, 0x23 // sbcs al r3 r1 r6 ASR 8 }; const byte kInstruction_sbcs_al_r7_r14_r2_ASR_10[] = { 0x7e, 0xeb, 0xa2, 0x27 // sbcs al r7 r14 r2 ASR 10 }; const byte kInstruction_sbcs_al_r8_r10_r8_ASR_8[] = { 0x7a, 0xeb, 0x28, 0x28 // sbcs al r8 r10 r8 ASR 8 }; const byte kInstruction_sbcs_al_r7_r10_r4_ASR_21[] = { 0x7a, 0xeb, 0x64, 0x57 // sbcs al r7 r10 r4 ASR 21 }; const byte kInstruction_sbcs_al_r6_r3_r3_ASR_6[] = { 0x73, 0xeb, 0xa3, 0x16 // sbcs al r6 r3 r3 ASR 6 }; const byte kInstruction_sbcs_al_r1_r8_r6_ASR_20[] = { 0x78, 0xeb, 0x26, 0x51 // sbcs al r1 r8 r6 ASR 20 }; const byte kInstruction_sbcs_al_r14_r6_r0_LSR_12[] = { 0x76, 0xeb, 0x10, 0x3e // sbcs al r14 r6 r0 LSR 12 }; const byte kInstruction_sbcs_al_r8_r1_r14_LSR_19[] = { 0x71, 0xeb, 0xde, 0x48 // sbcs al r8 r1 r14 LSR 19 }; const byte kInstruction_sbcs_al_r6_r7_r8_LSR_22[] = { 0x77, 0xeb, 0x98, 0x56 // sbcs al r6 r7 r8 LSR 22 }; const byte kInstruction_sbcs_al_r9_r0_r11_LSR_8[] = { 0x70, 0xeb, 0x1b, 0x29 // sbcs al r9 r0 r11 LSR 8 }; const byte kInstruction_sbcs_al_r10_r3_r2_LSR_6[] = { 0x73, 0xeb, 0x92, 0x1a // sbcs al r10 r3 r2 LSR 6 }; const byte kInstruction_sbcs_al_r2_r14_r0_ASR_12[] = { 0x7e, 0xeb, 0x20, 0x32 // sbcs al r2 r14 r0 ASR 12 }; const byte kInstruction_sbcs_al_r6_r3_r5_LSR_22[] = { 0x73, 0xeb, 0x95, 0x56 // sbcs al r6 r3 r5 LSR 22 }; const byte kInstruction_sbcs_al_r2_r13_r9_LSR_12[] = { 0x7d, 0xeb, 0x19, 0x32 // sbcs al r2 r13 r9 LSR 12 }; const byte kInstruction_sbcs_al_r14_r5_r2_LSR_5[] = { 0x75, 0xeb, 0x52, 0x1e // sbcs al r14 r5 r2 LSR 5 }; const byte kInstruction_sbcs_al_r4_r10_r12_LSR_32[] = { 0x7a, 0xeb, 0x1c, 0x04 // sbcs al r4 r10 r12 LSR 32 }; const byte kInstruction_sbcs_al_r1_r12_r2_ASR_1[] = { 0x7c, 0xeb, 0x62, 0x01 // sbcs al r1 r12 r2 ASR 1 }; const byte kInstruction_sbcs_al_r7_r11_r3_ASR_27[] = { 0x7b, 0xeb, 0xe3, 0x67 // sbcs al r7 r11 r3 ASR 27 }; const byte kInstruction_sbcs_al_r3_r2_r2_ASR_29[] = { 0x72, 0xeb, 0x62, 0x73 // sbcs al r3 r2 r2 ASR 29 }; const byte kInstruction_sbcs_al_r12_r2_r10_ASR_13[] = { 0x72, 0xeb, 0x6a, 0x3c // sbcs al r12 r2 r10 ASR 13 }; const byte kInstruction_sbcs_al_r3_r2_r3_ASR_19[] = { 0x72, 0xeb, 0xe3, 0x43 // sbcs al r3 r2 r3 ASR 19 }; const byte kInstruction_sbcs_al_r3_r12_r8_ASR_14[] = { 0x7c, 0xeb, 0xa8, 0x33 // sbcs al r3 r12 r8 ASR 14 }; const byte kInstruction_sbcs_al_r14_r13_r9_LSR_28[] = { 0x7d, 0xeb, 0x19, 0x7e // sbcs al r14 r13 r9 LSR 28 }; const byte kInstruction_sbcs_al_r6_r12_r7_ASR_32[] = { 0x7c, 0xeb, 0x27, 0x06 // sbcs al r6 r12 r7 ASR 32 }; const byte kInstruction_sbcs_al_r11_r11_r12_ASR_9[] = { 0x7b, 0xeb, 0x6c, 0x2b // sbcs al r11 r11 r12 ASR 9 }; const byte kInstruction_sbcs_al_r9_r11_r4_ASR_21[] = { 0x7b, 0xeb, 0x64, 0x59 // sbcs al r9 r11 r4 ASR 21 }; const byte kInstruction_sbcs_al_r6_r9_r3_LSR_30[] = { 0x79, 0xeb, 0x93, 0x76 // sbcs al r6 r9 r3 LSR 30 }; const byte kInstruction_sbcs_al_r6_r0_r8_ASR_22[] = { 0x70, 0xeb, 0xa8, 0x56 // sbcs al r6 r0 r8 ASR 22 }; const byte kInstruction_sbcs_al_r5_r9_r11_ASR_27[] = { 0x79, 0xeb, 0xeb, 0x65 // sbcs al r5 r9 r11 ASR 27 }; const byte kInstruction_sbcs_al_r4_r10_r6_LSR_2[] = { 0x7a, 0xeb, 0x96, 0x04 // sbcs al r4 r10 r6 LSR 2 }; const byte kInstruction_sbcs_al_r10_r14_r11_ASR_20[] = { 0x7e, 0xeb, 0x2b, 0x5a // sbcs al r10 r14 r11 ASR 20 }; const byte kInstruction_sbcs_al_r8_r13_r11_LSR_13[] = { 0x7d, 0xeb, 0x5b, 0x38 // sbcs al r8 r13 r11 LSR 13 }; const byte kInstruction_sbcs_al_r7_r12_r13_LSR_11[] = { 0x7c, 0xeb, 0xdd, 0x27 // sbcs al r7 r12 r13 LSR 11 }; const byte kInstruction_sbcs_al_r14_r6_r14_ASR_21[] = { 0x76, 0xeb, 0x6e, 0x5e // sbcs al r14 r6 r14 ASR 21 }; const byte kInstruction_sbcs_al_r2_r2_r7_LSR_25[] = { 0x72, 0xeb, 0x57, 0x62 // sbcs al r2 r2 r7 LSR 25 }; const byte kInstruction_sbcs_al_r0_r11_r5_LSR_5[] = { 0x7b, 0xeb, 0x55, 0x10 // sbcs al r0 r11 r5 LSR 5 }; const byte kInstruction_sbcs_al_r1_r5_r14_LSR_19[] = { 0x75, 0xeb, 0xde, 0x41 // sbcs al r1 r5 r14 LSR 19 }; const byte kInstruction_sbcs_al_r4_r14_r13_LSR_27[] = { 0x7e, 0xeb, 0xdd, 0x64 // sbcs al r4 r14 r13 LSR 27 }; const byte kInstruction_sbcs_al_r13_r2_r3_ASR_24[] = { 0x72, 0xeb, 0x23, 0x6d // sbcs al r13 r2 r3 ASR 24 }; const byte kInstruction_sbcs_al_r11_r1_r9_ASR_12[] = { 0x71, 0xeb, 0x29, 0x3b // sbcs al r11 r1 r9 ASR 12 }; const byte kInstruction_sbcs_al_r2_r7_r13_LSR_10[] = { 0x77, 0xeb, 0x9d, 0x22 // sbcs al r2 r7 r13 LSR 10 }; const byte kInstruction_sbcs_al_r4_r13_r0_ASR_3[] = { 0x7d, 0xeb, 0xe0, 0x04 // sbcs al r4 r13 r0 ASR 3 }; const byte kInstruction_sbcs_al_r7_r1_r3_ASR_23[] = { 0x71, 0xeb, 0xe3, 0x57 // sbcs al r7 r1 r3 ASR 23 }; const byte kInstruction_sbcs_al_r10_r13_r3_ASR_20[] = { 0x7d, 0xeb, 0x23, 0x5a // sbcs al r10 r13 r3 ASR 20 }; const byte kInstruction_sbcs_al_r7_r13_r9_LSR_8[] = { 0x7d, 0xeb, 0x19, 0x27 // sbcs al r7 r13 r9 LSR 8 }; const byte kInstruction_sbcs_al_r14_r14_r3_LSR_21[] = { 0x7e, 0xeb, 0x53, 0x5e // sbcs al r14 r14 r3 LSR 21 }; const byte kInstruction_sbcs_al_r4_r14_r2_ASR_32[] = { 0x7e, 0xeb, 0x22, 0x04 // sbcs al r4 r14 r2 ASR 32 }; const byte kInstruction_sbcs_al_r1_r4_r3_LSR_10[] = { 0x74, 0xeb, 0x93, 0x21 // sbcs al r1 r4 r3 LSR 10 }; const byte kInstruction_sbcs_al_r11_r10_r9_LSR_16[] = { 0x7a, 0xeb, 0x19, 0x4b // sbcs al r11 r10 r9 LSR 16 }; const byte kInstruction_sbcs_al_r9_r8_r4_LSR_5[] = { 0x78, 0xeb, 0x54, 0x19 // sbcs al r9 r8 r4 LSR 5 }; const byte kInstruction_sbcs_al_r11_r8_r11_ASR_7[] = { 0x78, 0xeb, 0xeb, 0x1b // sbcs al r11 r8 r11 ASR 7 }; const byte kInstruction_sbcs_al_r3_r7_r2_ASR_20[] = { 0x77, 0xeb, 0x22, 0x53 // sbcs al r3 r7 r2 ASR 20 }; const byte kInstruction_sbcs_al_r9_r10_r0_ASR_1[] = { 0x7a, 0xeb, 0x60, 0x09 // sbcs al r9 r10 r0 ASR 1 }; const byte kInstruction_sbcs_al_r0_r12_r10_ASR_21[] = { 0x7c, 0xeb, 0x6a, 0x50 // sbcs al r0 r12 r10 ASR 21 }; const byte kInstruction_sbcs_al_r11_r4_r2_ASR_32[] = { 0x74, 0xeb, 0x22, 0x0b // sbcs al r11 r4 r2 ASR 32 }; const byte kInstruction_sbcs_al_r5_r0_r2_LSR_15[] = { 0x70, 0xeb, 0xd2, 0x35 // sbcs al r5 r0 r2 LSR 15 }; const byte kInstruction_sbcs_al_r8_r10_r7_ASR_14[] = { 0x7a, 0xeb, 0xa7, 0x38 // sbcs al r8 r10 r7 ASR 14 }; const byte kInstruction_sbcs_al_r14_r5_r3_LSR_18[] = { 0x75, 0xeb, 0x93, 0x4e // sbcs al r14 r5 r3 LSR 18 }; const byte kInstruction_sbcs_al_r2_r8_r6_ASR_6[] = { 0x78, 0xeb, 0xa6, 0x12 // sbcs al r2 r8 r6 ASR 6 }; const byte kInstruction_sbcs_al_r3_r0_r4_LSR_23[] = { 0x70, 0xeb, 0xd4, 0x53 // sbcs al r3 r0 r4 LSR 23 }; const byte kInstruction_sbcs_al_r3_r7_r0_LSR_13[] = { 0x77, 0xeb, 0x50, 0x33 // sbcs al r3 r7 r0 LSR 13 }; const byte kInstruction_sbcs_al_r3_r4_r10_ASR_28[] = { 0x74, 0xeb, 0x2a, 0x73 // sbcs al r3 r4 r10 ASR 28 }; const byte kInstruction_sbcs_al_r3_r4_r1_ASR_6[] = { 0x74, 0xeb, 0xa1, 0x13 // sbcs al r3 r4 r1 ASR 6 }; const byte kInstruction_sbcs_al_r0_r3_r8_ASR_18[] = { 0x73, 0xeb, 0xa8, 0x40 // sbcs al r0 r3 r8 ASR 18 }; const byte kInstruction_sbcs_al_r5_r6_r13_LSR_2[] = { 0x76, 0xeb, 0x9d, 0x05 // sbcs al r5 r6 r13 LSR 2 }; const byte kInstruction_sbcs_al_r10_r11_r14_LSR_2[] = { 0x7b, 0xeb, 0x9e, 0x0a // sbcs al r10 r11 r14 LSR 2 }; const byte kInstruction_sbcs_al_r10_r6_r6_ASR_17[] = { 0x76, 0xeb, 0x66, 0x4a // sbcs al r10 r6 r6 ASR 17 }; const byte kInstruction_sbcs_al_r5_r2_r3_ASR_3[] = { 0x72, 0xeb, 0xe3, 0x05 // sbcs al r5 r2 r3 ASR 3 }; const byte kInstruction_sbcs_al_r14_r14_r1_LSR_19[] = { 0x7e, 0xeb, 0xd1, 0x4e // sbcs al r14 r14 r1 LSR 19 }; const byte kInstruction_sbcs_al_r8_r4_r7_LSR_6[] = { 0x74, 0xeb, 0x97, 0x18 // sbcs al r8 r4 r7 LSR 6 }; const byte kInstruction_sbcs_al_r12_r0_r8_LSR_29[] = { 0x70, 0xeb, 0x58, 0x7c // sbcs al r12 r0 r8 LSR 29 }; const byte kInstruction_sbcs_al_r9_r0_r1_ASR_29[] = { 0x70, 0xeb, 0x61, 0x79 // sbcs al r9 r0 r1 ASR 29 }; const byte kInstruction_sbcs_al_r7_r13_r9_ASR_10[] = { 0x7d, 0xeb, 0xa9, 0x27 // sbcs al r7 r13 r9 ASR 10 }; const byte kInstruction_sbcs_al_r9_r10_r1_ASR_26[] = { 0x7a, 0xeb, 0xa1, 0x69 // sbcs al r9 r10 r1 ASR 26 }; const byte kInstruction_sbcs_al_r1_r11_r10_ASR_30[] = { 0x7b, 0xeb, 0xaa, 0x71 // sbcs al r1 r11 r10 ASR 30 }; const byte kInstruction_sbcs_al_r3_r14_r6_LSR_11[] = { 0x7e, 0xeb, 0xd6, 0x23 // sbcs al r3 r14 r6 LSR 11 }; const TestResult kReferencesbcs[] = { { ARRAY_SIZE(kInstruction_sbcs_al_r11_r13_r10_ASR_9), kInstruction_sbcs_al_r11_r13_r10_ASR_9, }, { ARRAY_SIZE(kInstruction_sbcs_al_r7_r5_r2_ASR_2), kInstruction_sbcs_al_r7_r5_r2_ASR_2, }, { ARRAY_SIZE(kInstruction_sbcs_al_r5_r2_r11_LSR_5), kInstruction_sbcs_al_r5_r2_r11_LSR_5, }, { ARRAY_SIZE(kInstruction_sbcs_al_r14_r6_r10_LSR_32), kInstruction_sbcs_al_r14_r6_r10_LSR_32, }, { ARRAY_SIZE(kInstruction_sbcs_al_r9_r6_r3_LSR_13), kInstruction_sbcs_al_r9_r6_r3_LSR_13, }, { ARRAY_SIZE(kInstruction_sbcs_al_r14_r4_r6_LSR_31), kInstruction_sbcs_al_r14_r4_r6_LSR_31, }, { ARRAY_SIZE(kInstruction_sbcs_al_r2_r1_r7_LSR_14), kInstruction_sbcs_al_r2_r1_r7_LSR_14, }, { ARRAY_SIZE(kInstruction_sbcs_al_r2_r9_r12_LSR_24), kInstruction_sbcs_al_r2_r9_r12_LSR_24, }, { ARRAY_SIZE(kInstruction_sbcs_al_r10_r12_r4_ASR_2), kInstruction_sbcs_al_r10_r12_r4_ASR_2, }, { ARRAY_SIZE(kInstruction_sbcs_al_r6_r10_r0_LSR_8), kInstruction_sbcs_al_r6_r10_r0_LSR_8, }, { ARRAY_SIZE(kInstruction_sbcs_al_r12_r11_r4_ASR_7), kInstruction_sbcs_al_r12_r11_r4_ASR_7, }, { ARRAY_SIZE(kInstruction_sbcs_al_r9_r4_r8_ASR_27), kInstruction_sbcs_al_r9_r4_r8_ASR_27, }, { ARRAY_SIZE(kInstruction_sbcs_al_r2_r10_r11_ASR_1), kInstruction_sbcs_al_r2_r10_r11_ASR_1, }, { ARRAY_SIZE(kInstruction_sbcs_al_r0_r2_r9_ASR_24), kInstruction_sbcs_al_r0_r2_r9_ASR_24, }, { ARRAY_SIZE(kInstruction_sbcs_al_r11_r6_r14_ASR_31), kInstruction_sbcs_al_r11_r6_r14_ASR_31, }, { ARRAY_SIZE(kInstruction_sbcs_al_r2_r14_r14_ASR_18), kInstruction_sbcs_al_r2_r14_r14_ASR_18, }, { ARRAY_SIZE(kInstruction_sbcs_al_r5_r7_r1_ASR_2), kInstruction_sbcs_al_r5_r7_r1_ASR_2, }, { ARRAY_SIZE(kInstruction_sbcs_al_r1_r14_r7_LSR_18), kInstruction_sbcs_al_r1_r14_r7_LSR_18, }, { ARRAY_SIZE(kInstruction_sbcs_al_r7_r7_r1_ASR_4), kInstruction_sbcs_al_r7_r7_r1_ASR_4, }, { ARRAY_SIZE(kInstruction_sbcs_al_r14_r5_r12_LSR_1), kInstruction_sbcs_al_r14_r5_r12_LSR_1, }, { ARRAY_SIZE(kInstruction_sbcs_al_r2_r11_r10_ASR_23), kInstruction_sbcs_al_r2_r11_r10_ASR_23, }, { ARRAY_SIZE(kInstruction_sbcs_al_r5_r0_r10_ASR_3), kInstruction_sbcs_al_r5_r0_r10_ASR_3, }, { ARRAY_SIZE(kInstruction_sbcs_al_r9_r13_r9_ASR_6), kInstruction_sbcs_al_r9_r13_r9_ASR_6, }, { ARRAY_SIZE(kInstruction_sbcs_al_r6_r10_r13_ASR_24), kInstruction_sbcs_al_r6_r10_r13_ASR_24, }, { ARRAY_SIZE(kInstruction_sbcs_al_r9_r3_r14_LSR_30), kInstruction_sbcs_al_r9_r3_r14_LSR_30, }, { ARRAY_SIZE(kInstruction_sbcs_al_r11_r14_r11_LSR_24), kInstruction_sbcs_al_r11_r14_r11_LSR_24, }, { ARRAY_SIZE(kInstruction_sbcs_al_r11_r3_r4_ASR_7), kInstruction_sbcs_al_r11_r3_r4_ASR_7, }, { ARRAY_SIZE(kInstruction_sbcs_al_r14_r13_r10_ASR_1), kInstruction_sbcs_al_r14_r13_r10_ASR_1, }, { ARRAY_SIZE(kInstruction_sbcs_al_r0_r9_r0_LSR_2), kInstruction_sbcs_al_r0_r9_r0_LSR_2, }, { ARRAY_SIZE(kInstruction_sbcs_al_r2_r1_r7_ASR_15), kInstruction_sbcs_al_r2_r1_r7_ASR_15, }, { ARRAY_SIZE(kInstruction_sbcs_al_r8_r14_r5_LSR_27), kInstruction_sbcs_al_r8_r14_r5_LSR_27, }, { ARRAY_SIZE(kInstruction_sbcs_al_r9_r14_r13_ASR_21), kInstruction_sbcs_al_r9_r14_r13_ASR_21, }, { ARRAY_SIZE(kInstruction_sbcs_al_r11_r14_r14_ASR_3), kInstruction_sbcs_al_r11_r14_r14_ASR_3, }, { ARRAY_SIZE(kInstruction_sbcs_al_r6_r3_r6_LSR_23), kInstruction_sbcs_al_r6_r3_r6_LSR_23, }, { ARRAY_SIZE(kInstruction_sbcs_al_r14_r8_r11_LSR_6), kInstruction_sbcs_al_r14_r8_r11_LSR_6, }, { ARRAY_SIZE(kInstruction_sbcs_al_r5_r3_r3_LSR_8), kInstruction_sbcs_al_r5_r3_r3_LSR_8, }, { ARRAY_SIZE(kInstruction_sbcs_al_r12_r6_r1_LSR_6), kInstruction_sbcs_al_r12_r6_r1_LSR_6, }, { ARRAY_SIZE(kInstruction_sbcs_al_r5_r0_r9_LSR_30), kInstruction_sbcs_al_r5_r0_r9_LSR_30, }, { ARRAY_SIZE(kInstruction_sbcs_al_r4_r9_r3_ASR_17), kInstruction_sbcs_al_r4_r9_r3_ASR_17, }, { ARRAY_SIZE(kInstruction_sbcs_al_r12_r2_r4_ASR_20), kInstruction_sbcs_al_r12_r2_r4_ASR_20, }, { ARRAY_SIZE(kInstruction_sbcs_al_r2_r9_r13_ASR_25), kInstruction_sbcs_al_r2_r9_r13_ASR_25, }, { ARRAY_SIZE(kInstruction_sbcs_al_r11_r5_r12_LSR_10), kInstruction_sbcs_al_r11_r5_r12_LSR_10, }, { ARRAY_SIZE(kInstruction_sbcs_al_r4_r13_r12_LSR_22), kInstruction_sbcs_al_r4_r13_r12_LSR_22, }, { ARRAY_SIZE(kInstruction_sbcs_al_r2_r4_r6_LSR_11), kInstruction_sbcs_al_r2_r4_r6_LSR_11, }, { ARRAY_SIZE(kInstruction_sbcs_al_r8_r4_r1_LSR_22), kInstruction_sbcs_al_r8_r4_r1_LSR_22, }, { ARRAY_SIZE(kInstruction_sbcs_al_r6_r12_r10_LSR_31), kInstruction_sbcs_al_r6_r12_r10_LSR_31, }, { ARRAY_SIZE(kInstruction_sbcs_al_r10_r0_r2_ASR_7), kInstruction_sbcs_al_r10_r0_r2_ASR_7, }, { ARRAY_SIZE(kInstruction_sbcs_al_r14_r6_r13_ASR_21), kInstruction_sbcs_al_r14_r6_r13_ASR_21, }, { ARRAY_SIZE(kInstruction_sbcs_al_r7_r14_r13_LSR_4), kInstruction_sbcs_al_r7_r14_r13_LSR_4, }, { ARRAY_SIZE(kInstruction_sbcs_al_r1_r10_r12_ASR_2), kInstruction_sbcs_al_r1_r10_r12_ASR_2, }, { ARRAY_SIZE(kInstruction_sbcs_al_r0_r2_r10_LSR_7), kInstruction_sbcs_al_r0_r2_r10_LSR_7, }, { ARRAY_SIZE(kInstruction_sbcs_al_r0_r1_r11_LSR_17), kInstruction_sbcs_al_r0_r1_r11_LSR_17, }, { ARRAY_SIZE(kInstruction_sbcs_al_r4_r13_r2_ASR_25), kInstruction_sbcs_al_r4_r13_r2_ASR_25, }, { ARRAY_SIZE(kInstruction_sbcs_al_r1_r4_r14_LSR_7), kInstruction_sbcs_al_r1_r4_r14_LSR_7, }, { ARRAY_SIZE(kInstruction_sbcs_al_r5_r8_r4_ASR_19), kInstruction_sbcs_al_r5_r8_r4_ASR_19, }, { ARRAY_SIZE(kInstruction_sbcs_al_r4_r3_r8_ASR_12), kInstruction_sbcs_al_r4_r3_r8_ASR_12, }, { ARRAY_SIZE(kInstruction_sbcs_al_r2_r4_r13_ASR_12), kInstruction_sbcs_al_r2_r4_r13_ASR_12, }, { ARRAY_SIZE(kInstruction_sbcs_al_r8_r9_r2_LSR_20), kInstruction_sbcs_al_r8_r9_r2_LSR_20, }, { ARRAY_SIZE(kInstruction_sbcs_al_r10_r6_r3_ASR_21), kInstruction_sbcs_al_r10_r6_r3_ASR_21, }, { ARRAY_SIZE(kInstruction_sbcs_al_r2_r7_r7_ASR_3), kInstruction_sbcs_al_r2_r7_r7_ASR_3, }, { ARRAY_SIZE(kInstruction_sbcs_al_r8_r7_r7_LSR_19), kInstruction_sbcs_al_r8_r7_r7_LSR_19, }, { ARRAY_SIZE(kInstruction_sbcs_al_r7_r9_r4_LSR_3), kInstruction_sbcs_al_r7_r9_r4_LSR_3, }, { ARRAY_SIZE(kInstruction_sbcs_al_r1_r7_r3_ASR_2), kInstruction_sbcs_al_r1_r7_r3_ASR_2, }, { ARRAY_SIZE(kInstruction_sbcs_al_r1_r2_r3_ASR_5), kInstruction_sbcs_al_r1_r2_r3_ASR_5, }, { ARRAY_SIZE(kInstruction_sbcs_al_r12_r4_r1_ASR_5), kInstruction_sbcs_al_r12_r4_r1_ASR_5, }, { ARRAY_SIZE(kInstruction_sbcs_al_r4_r2_r10_ASR_1), kInstruction_sbcs_al_r4_r2_r10_ASR_1, }, { ARRAY_SIZE(kInstruction_sbcs_al_r10_r5_r11_LSR_3), kInstruction_sbcs_al_r10_r5_r11_LSR_3, }, { ARRAY_SIZE(kInstruction_sbcs_al_r5_r9_r1_ASR_8), kInstruction_sbcs_al_r5_r9_r1_ASR_8, }, { ARRAY_SIZE(kInstruction_sbcs_al_r6_r11_r3_LSR_28), kInstruction_sbcs_al_r6_r11_r3_LSR_28, }, { ARRAY_SIZE(kInstruction_sbcs_al_r9_r13_r6_LSR_22), kInstruction_sbcs_al_r9_r13_r6_LSR_22, }, { ARRAY_SIZE(kInstruction_sbcs_al_r10_r13_r1_LSR_30), kInstruction_sbcs_al_r10_r13_r1_LSR_30, }, { ARRAY_SIZE(kInstruction_sbcs_al_r9_r1_r4_ASR_26), kInstruction_sbcs_al_r9_r1_r4_ASR_26, }, { ARRAY_SIZE(kInstruction_sbcs_al_r4_r4_r4_ASR_21), kInstruction_sbcs_al_r4_r4_r4_ASR_21, }, { ARRAY_SIZE(kInstruction_sbcs_al_r9_r5_r11_ASR_19), kInstruction_sbcs_al_r9_r5_r11_ASR_19, }, { ARRAY_SIZE(kInstruction_sbcs_al_r8_r11_r5_LSR_30), kInstruction_sbcs_al_r8_r11_r5_LSR_30, }, { ARRAY_SIZE(kInstruction_sbcs_al_r4_r10_r4_LSR_23), kInstruction_sbcs_al_r4_r10_r4_LSR_23, }, { ARRAY_SIZE(kInstruction_sbcs_al_r7_r6_r2_LSR_32), kInstruction_sbcs_al_r7_r6_r2_LSR_32, }, { ARRAY_SIZE(kInstruction_sbcs_al_r4_r14_r12_LSR_7), kInstruction_sbcs_al_r4_r14_r12_LSR_7, }, { ARRAY_SIZE(kInstruction_sbcs_al_r5_r2_r9_LSR_7), kInstruction_sbcs_al_r5_r2_r9_LSR_7, }, { ARRAY_SIZE(kInstruction_sbcs_al_r2_r14_r1_ASR_6), kInstruction_sbcs_al_r2_r14_r1_ASR_6, }, { ARRAY_SIZE(kInstruction_sbcs_al_r14_r13_r11_LSR_12), kInstruction_sbcs_al_r14_r13_r11_LSR_12, }, { ARRAY_SIZE(kInstruction_sbcs_al_r8_r8_r6_ASR_5), kInstruction_sbcs_al_r8_r8_r6_ASR_5, }, { ARRAY_SIZE(kInstruction_sbcs_al_r14_r10_r12_LSR_13), kInstruction_sbcs_al_r14_r10_r12_LSR_13, }, { ARRAY_SIZE(kInstruction_sbcs_al_r3_r6_r7_LSR_31), kInstruction_sbcs_al_r3_r6_r7_LSR_31, }, { ARRAY_SIZE(kInstruction_sbcs_al_r8_r1_r9_ASR_2), kInstruction_sbcs_al_r8_r1_r9_ASR_2, }, { ARRAY_SIZE(kInstruction_sbcs_al_r9_r12_r12_ASR_21), kInstruction_sbcs_al_r9_r12_r12_ASR_21, }, { ARRAY_SIZE(kInstruction_sbcs_al_r13_r4_r12_LSR_14), kInstruction_sbcs_al_r13_r4_r12_LSR_14, }, { ARRAY_SIZE(kInstruction_sbcs_al_r2_r11_r12_LSR_18), kInstruction_sbcs_al_r2_r11_r12_LSR_18, }, { ARRAY_SIZE(kInstruction_sbcs_al_r9_r3_r0_ASR_31), kInstruction_sbcs_al_r9_r3_r0_ASR_31, }, { ARRAY_SIZE(kInstruction_sbcs_al_r13_r6_r12_LSR_6), kInstruction_sbcs_al_r13_r6_r12_LSR_6, }, { ARRAY_SIZE(kInstruction_sbcs_al_r1_r1_r7_LSR_3), kInstruction_sbcs_al_r1_r1_r7_LSR_3, }, { ARRAY_SIZE(kInstruction_sbcs_al_r0_r13_r9_ASR_1), kInstruction_sbcs_al_r0_r13_r9_ASR_1, }, { ARRAY_SIZE(kInstruction_sbcs_al_r2_r1_r3_LSR_12), kInstruction_sbcs_al_r2_r1_r3_LSR_12, }, { ARRAY_SIZE(kInstruction_sbcs_al_r12_r6_r10_ASR_1), kInstruction_sbcs_al_r12_r6_r10_ASR_1, }, { ARRAY_SIZE(kInstruction_sbcs_al_r12_r4_r3_ASR_4), kInstruction_sbcs_al_r12_r4_r3_ASR_4, }, { ARRAY_SIZE(kInstruction_sbcs_al_r7_r0_r5_LSR_25), kInstruction_sbcs_al_r7_r0_r5_LSR_25, }, { ARRAY_SIZE(kInstruction_sbcs_al_r4_r5_r12_LSR_20), kInstruction_sbcs_al_r4_r5_r12_LSR_20, }, { ARRAY_SIZE(kInstruction_sbcs_al_r3_r5_r11_LSR_24), kInstruction_sbcs_al_r3_r5_r11_LSR_24, }, { ARRAY_SIZE(kInstruction_sbcs_al_r5_r8_r10_LSR_25), kInstruction_sbcs_al_r5_r8_r10_LSR_25, }, { ARRAY_SIZE(kInstruction_sbcs_al_r11_r9_r12_LSR_24), kInstruction_sbcs_al_r11_r9_r12_LSR_24, }, { ARRAY_SIZE(kInstruction_sbcs_al_r13_r11_r13_LSR_20), kInstruction_sbcs_al_r13_r11_r13_LSR_20, }, { ARRAY_SIZE(kInstruction_sbcs_al_r12_r4_r3_ASR_32), kInstruction_sbcs_al_r12_r4_r3_ASR_32, }, { ARRAY_SIZE(kInstruction_sbcs_al_r3_r6_r11_ASR_13), kInstruction_sbcs_al_r3_r6_r11_ASR_13, }, { ARRAY_SIZE(kInstruction_sbcs_al_r13_r9_r7_LSR_27), kInstruction_sbcs_al_r13_r9_r7_LSR_27, }, { ARRAY_SIZE(kInstruction_sbcs_al_r13_r9_r6_LSR_24), kInstruction_sbcs_al_r13_r9_r6_LSR_24, }, { ARRAY_SIZE(kInstruction_sbcs_al_r6_r13_r3_ASR_1), kInstruction_sbcs_al_r6_r13_r3_ASR_1, }, { ARRAY_SIZE(kInstruction_sbcs_al_r8_r7_r14_ASR_27), kInstruction_sbcs_al_r8_r7_r14_ASR_27, }, { ARRAY_SIZE(kInstruction_sbcs_al_r8_r8_r8_LSR_29), kInstruction_sbcs_al_r8_r8_r8_LSR_29, }, { ARRAY_SIZE(kInstruction_sbcs_al_r1_r13_r4_ASR_26), kInstruction_sbcs_al_r1_r13_r4_ASR_26, }, { ARRAY_SIZE(kInstruction_sbcs_al_r3_r2_r10_LSR_16), kInstruction_sbcs_al_r3_r2_r10_LSR_16, }, { ARRAY_SIZE(kInstruction_sbcs_al_r2_r11_r9_ASR_29), kInstruction_sbcs_al_r2_r11_r9_ASR_29, }, { ARRAY_SIZE(kInstruction_sbcs_al_r12_r9_r8_LSR_7), kInstruction_sbcs_al_r12_r9_r8_LSR_7, }, { ARRAY_SIZE(kInstruction_sbcs_al_r6_r2_r0_LSR_4), kInstruction_sbcs_al_r6_r2_r0_LSR_4, }, { ARRAY_SIZE(kInstruction_sbcs_al_r12_r2_r11_LSR_8), kInstruction_sbcs_al_r12_r2_r11_LSR_8, }, { ARRAY_SIZE(kInstruction_sbcs_al_r0_r10_r12_LSR_5), kInstruction_sbcs_al_r0_r10_r12_LSR_5, }, { ARRAY_SIZE(kInstruction_sbcs_al_r2_r2_r2_ASR_4), kInstruction_sbcs_al_r2_r2_r2_ASR_4, }, { ARRAY_SIZE(kInstruction_sbcs_al_r4_r13_r11_LSR_15), kInstruction_sbcs_al_r4_r13_r11_LSR_15, }, { ARRAY_SIZE(kInstruction_sbcs_al_r4_r2_r13_ASR_4), kInstruction_sbcs_al_r4_r2_r13_ASR_4, }, { ARRAY_SIZE(kInstruction_sbcs_al_r4_r4_r7_LSR_30), kInstruction_sbcs_al_r4_r4_r7_LSR_30, }, { ARRAY_SIZE(kInstruction_sbcs_al_r4_r8_r10_LSR_14), kInstruction_sbcs_al_r4_r8_r10_LSR_14, }, { ARRAY_SIZE(kInstruction_sbcs_al_r14_r8_r11_ASR_16), kInstruction_sbcs_al_r14_r8_r11_ASR_16, }, { ARRAY_SIZE(kInstruction_sbcs_al_r0_r8_r1_LSR_25), kInstruction_sbcs_al_r0_r8_r1_LSR_25, }, { ARRAY_SIZE(kInstruction_sbcs_al_r14_r13_r14_ASR_3), kInstruction_sbcs_al_r14_r13_r14_ASR_3, }, { ARRAY_SIZE(kInstruction_sbcs_al_r13_r8_r13_ASR_31), kInstruction_sbcs_al_r13_r8_r13_ASR_31, }, { ARRAY_SIZE(kInstruction_sbcs_al_r9_r6_r1_LSR_28), kInstruction_sbcs_al_r9_r6_r1_LSR_28, }, { ARRAY_SIZE(kInstruction_sbcs_al_r4_r14_r1_ASR_9), kInstruction_sbcs_al_r4_r14_r1_ASR_9, }, { ARRAY_SIZE(kInstruction_sbcs_al_r8_r0_r14_LSR_7), kInstruction_sbcs_al_r8_r0_r14_LSR_7, }, { ARRAY_SIZE(kInstruction_sbcs_al_r8_r8_r12_ASR_14), kInstruction_sbcs_al_r8_r8_r12_ASR_14, }, { ARRAY_SIZE(kInstruction_sbcs_al_r9_r14_r12_ASR_19), kInstruction_sbcs_al_r9_r14_r12_ASR_19, }, { ARRAY_SIZE(kInstruction_sbcs_al_r4_r14_r11_ASR_25), kInstruction_sbcs_al_r4_r14_r11_ASR_25, }, { ARRAY_SIZE(kInstruction_sbcs_al_r1_r0_r9_ASR_13), kInstruction_sbcs_al_r1_r0_r9_ASR_13, }, { ARRAY_SIZE(kInstruction_sbcs_al_r8_r13_r9_LSR_4), kInstruction_sbcs_al_r8_r13_r9_LSR_4, }, { ARRAY_SIZE(kInstruction_sbcs_al_r2_r4_r4_LSR_3), kInstruction_sbcs_al_r2_r4_r4_LSR_3, }, { ARRAY_SIZE(kInstruction_sbcs_al_r14_r13_r3_LSR_8), kInstruction_sbcs_al_r14_r13_r3_LSR_8, }, { ARRAY_SIZE(kInstruction_sbcs_al_r11_r6_r3_LSR_10), kInstruction_sbcs_al_r11_r6_r3_LSR_10, }, { ARRAY_SIZE(kInstruction_sbcs_al_r13_r8_r4_ASR_31), kInstruction_sbcs_al_r13_r8_r4_ASR_31, }, { ARRAY_SIZE(kInstruction_sbcs_al_r8_r11_r0_LSR_13), kInstruction_sbcs_al_r8_r11_r0_LSR_13, }, { ARRAY_SIZE(kInstruction_sbcs_al_r10_r5_r10_ASR_19), kInstruction_sbcs_al_r10_r5_r10_ASR_19, }, { ARRAY_SIZE(kInstruction_sbcs_al_r13_r4_r5_ASR_2), kInstruction_sbcs_al_r13_r4_r5_ASR_2, }, { ARRAY_SIZE(kInstruction_sbcs_al_r8_r4_r10_LSR_3), kInstruction_sbcs_al_r8_r4_r10_LSR_3, }, { ARRAY_SIZE(kInstruction_sbcs_al_r13_r7_r3_LSR_6), kInstruction_sbcs_al_r13_r7_r3_LSR_6, }, { ARRAY_SIZE(kInstruction_sbcs_al_r6_r1_r8_LSR_1), kInstruction_sbcs_al_r6_r1_r8_LSR_1, }, { ARRAY_SIZE(kInstruction_sbcs_al_r5_r13_r9_LSR_31), kInstruction_sbcs_al_r5_r13_r9_LSR_31, }, { ARRAY_SIZE(kInstruction_sbcs_al_r11_r8_r0_ASR_19), kInstruction_sbcs_al_r11_r8_r0_ASR_19, }, { ARRAY_SIZE(kInstruction_sbcs_al_r14_r6_r8_LSR_25), kInstruction_sbcs_al_r14_r6_r8_LSR_25, }, { ARRAY_SIZE(kInstruction_sbcs_al_r10_r6_r7_ASR_28), kInstruction_sbcs_al_r10_r6_r7_ASR_28, }, { ARRAY_SIZE(kInstruction_sbcs_al_r5_r2_r9_LSR_12), kInstruction_sbcs_al_r5_r2_r9_LSR_12, }, { ARRAY_SIZE(kInstruction_sbcs_al_r1_r2_r6_ASR_18), kInstruction_sbcs_al_r1_r2_r6_ASR_18, }, { ARRAY_SIZE(kInstruction_sbcs_al_r10_r13_r11_ASR_14), kInstruction_sbcs_al_r10_r13_r11_ASR_14, }, { ARRAY_SIZE(kInstruction_sbcs_al_r6_r8_r8_LSR_14), kInstruction_sbcs_al_r6_r8_r8_LSR_14, }, { ARRAY_SIZE(kInstruction_sbcs_al_r7_r14_r11_ASR_18), kInstruction_sbcs_al_r7_r14_r11_ASR_18, }, { ARRAY_SIZE(kInstruction_sbcs_al_r3_r11_r2_LSR_13), kInstruction_sbcs_al_r3_r11_r2_LSR_13, }, { ARRAY_SIZE(kInstruction_sbcs_al_r14_r7_r6_ASR_10), kInstruction_sbcs_al_r14_r7_r6_ASR_10, }, { ARRAY_SIZE(kInstruction_sbcs_al_r6_r5_r7_ASR_12), kInstruction_sbcs_al_r6_r5_r7_ASR_12, }, { ARRAY_SIZE(kInstruction_sbcs_al_r5_r2_r9_ASR_13), kInstruction_sbcs_al_r5_r2_r9_ASR_13, }, { ARRAY_SIZE(kInstruction_sbcs_al_r12_r13_r3_LSR_14), kInstruction_sbcs_al_r12_r13_r3_LSR_14, }, { ARRAY_SIZE(kInstruction_sbcs_al_r10_r4_r0_ASR_23), kInstruction_sbcs_al_r10_r4_r0_ASR_23, }, { ARRAY_SIZE(kInstruction_sbcs_al_r10_r12_r2_LSR_18), kInstruction_sbcs_al_r10_r12_r2_LSR_18, }, { ARRAY_SIZE(kInstruction_sbcs_al_r4_r10_r14_ASR_18), kInstruction_sbcs_al_r4_r10_r14_ASR_18, }, { ARRAY_SIZE(kInstruction_sbcs_al_r13_r0_r1_LSR_7), kInstruction_sbcs_al_r13_r0_r1_LSR_7, }, { ARRAY_SIZE(kInstruction_sbcs_al_r3_r3_r13_LSR_16), kInstruction_sbcs_al_r3_r3_r13_LSR_16, }, { ARRAY_SIZE(kInstruction_sbcs_al_r7_r4_r4_ASR_19), kInstruction_sbcs_al_r7_r4_r4_ASR_19, }, { ARRAY_SIZE(kInstruction_sbcs_al_r6_r7_r4_ASR_13), kInstruction_sbcs_al_r6_r7_r4_ASR_13, }, { ARRAY_SIZE(kInstruction_sbcs_al_r8_r10_r11_LSR_14), kInstruction_sbcs_al_r8_r10_r11_LSR_14, }, { ARRAY_SIZE(kInstruction_sbcs_al_r0_r0_r1_ASR_32), kInstruction_sbcs_al_r0_r0_r1_ASR_32, }, { ARRAY_SIZE(kInstruction_sbcs_al_r10_r12_r0_LSR_17), kInstruction_sbcs_al_r10_r12_r0_LSR_17, }, { ARRAY_SIZE(kInstruction_sbcs_al_r2_r5_r12_ASR_8), kInstruction_sbcs_al_r2_r5_r12_ASR_8, }, { ARRAY_SIZE(kInstruction_sbcs_al_r4_r3_r11_LSR_1), kInstruction_sbcs_al_r4_r3_r11_LSR_1, }, { ARRAY_SIZE(kInstruction_sbcs_al_r12_r13_r12_LSR_22), kInstruction_sbcs_al_r12_r13_r12_LSR_22, }, { ARRAY_SIZE(kInstruction_sbcs_al_r8_r13_r11_LSR_12), kInstruction_sbcs_al_r8_r13_r11_LSR_12, }, { ARRAY_SIZE(kInstruction_sbcs_al_r9_r11_r3_LSR_27), kInstruction_sbcs_al_r9_r11_r3_LSR_27, }, { ARRAY_SIZE(kInstruction_sbcs_al_r8_r9_r10_ASR_21), kInstruction_sbcs_al_r8_r9_r10_ASR_21, }, { ARRAY_SIZE(kInstruction_sbcs_al_r10_r3_r0_LSR_8), kInstruction_sbcs_al_r10_r3_r0_LSR_8, }, { ARRAY_SIZE(kInstruction_sbcs_al_r9_r2_r6_LSR_32), kInstruction_sbcs_al_r9_r2_r6_LSR_32, }, { ARRAY_SIZE(kInstruction_sbcs_al_r9_r0_r9_ASR_24), kInstruction_sbcs_al_r9_r0_r9_ASR_24, }, { ARRAY_SIZE(kInstruction_sbcs_al_r0_r10_r7_LSR_7), kInstruction_sbcs_al_r0_r10_r7_LSR_7, }, { ARRAY_SIZE(kInstruction_sbcs_al_r7_r11_r12_LSR_14), kInstruction_sbcs_al_r7_r11_r12_LSR_14, }, { ARRAY_SIZE(kInstruction_sbcs_al_r12_r10_r13_ASR_29), kInstruction_sbcs_al_r12_r10_r13_ASR_29, }, { ARRAY_SIZE(kInstruction_sbcs_al_r2_r14_r3_LSR_5), kInstruction_sbcs_al_r2_r14_r3_LSR_5, }, { ARRAY_SIZE(kInstruction_sbcs_al_r14_r3_r12_ASR_19), kInstruction_sbcs_al_r14_r3_r12_ASR_19, }, { ARRAY_SIZE(kInstruction_sbcs_al_r12_r12_r11_ASR_31), kInstruction_sbcs_al_r12_r12_r11_ASR_31, }, { ARRAY_SIZE(kInstruction_sbcs_al_r0_r3_r2_ASR_4), kInstruction_sbcs_al_r0_r3_r2_ASR_4, }, { ARRAY_SIZE(kInstruction_sbcs_al_r13_r2_r11_ASR_9), kInstruction_sbcs_al_r13_r2_r11_ASR_9, }, { ARRAY_SIZE(kInstruction_sbcs_al_r12_r14_r9_LSR_13), kInstruction_sbcs_al_r12_r14_r9_LSR_13, }, { ARRAY_SIZE(kInstruction_sbcs_al_r14_r3_r3_ASR_28), kInstruction_sbcs_al_r14_r3_r3_ASR_28, }, { ARRAY_SIZE(kInstruction_sbcs_al_r12_r5_r12_LSR_19), kInstruction_sbcs_al_r12_r5_r12_LSR_19, }, { ARRAY_SIZE(kInstruction_sbcs_al_r9_r13_r1_LSR_14), kInstruction_sbcs_al_r9_r13_r1_LSR_14, }, { ARRAY_SIZE(kInstruction_sbcs_al_r5_r3_r1_LSR_11), kInstruction_sbcs_al_r5_r3_r1_LSR_11, }, { ARRAY_SIZE(kInstruction_sbcs_al_r0_r14_r5_ASR_22), kInstruction_sbcs_al_r0_r14_r5_ASR_22, }, { ARRAY_SIZE(kInstruction_sbcs_al_r8_r9_r8_ASR_12), kInstruction_sbcs_al_r8_r9_r8_ASR_12, }, { ARRAY_SIZE(kInstruction_sbcs_al_r9_r0_r13_LSR_15), kInstruction_sbcs_al_r9_r0_r13_LSR_15, }, { ARRAY_SIZE(kInstruction_sbcs_al_r9_r5_r14_ASR_9), kInstruction_sbcs_al_r9_r5_r14_ASR_9, }, { ARRAY_SIZE(kInstruction_sbcs_al_r9_r13_r13_LSR_16), kInstruction_sbcs_al_r9_r13_r13_LSR_16, }, { ARRAY_SIZE(kInstruction_sbcs_al_r7_r0_r8_ASR_17), kInstruction_sbcs_al_r7_r0_r8_ASR_17, }, { ARRAY_SIZE(kInstruction_sbcs_al_r10_r13_r14_ASR_30), kInstruction_sbcs_al_r10_r13_r14_ASR_30, }, { ARRAY_SIZE(kInstruction_sbcs_al_r7_r10_r4_LSR_8), kInstruction_sbcs_al_r7_r10_r4_LSR_8, }, { ARRAY_SIZE(kInstruction_sbcs_al_r10_r5_r1_ASR_2), kInstruction_sbcs_al_r10_r5_r1_ASR_2, }, { ARRAY_SIZE(kInstruction_sbcs_al_r4_r10_r2_LSR_10), kInstruction_sbcs_al_r4_r10_r2_LSR_10, }, { ARRAY_SIZE(kInstruction_sbcs_al_r3_r5_r0_LSR_22), kInstruction_sbcs_al_r3_r5_r0_LSR_22, }, { ARRAY_SIZE(kInstruction_sbcs_al_r13_r11_r12_LSR_22), kInstruction_sbcs_al_r13_r11_r12_LSR_22, }, { ARRAY_SIZE(kInstruction_sbcs_al_r0_r8_r6_LSR_6), kInstruction_sbcs_al_r0_r8_r6_LSR_6, }, { ARRAY_SIZE(kInstruction_sbcs_al_r13_r4_r1_LSR_30), kInstruction_sbcs_al_r13_r4_r1_LSR_30, }, { ARRAY_SIZE(kInstruction_sbcs_al_r13_r9_r12_ASR_20), kInstruction_sbcs_al_r13_r9_r12_ASR_20, }, { ARRAY_SIZE(kInstruction_sbcs_al_r0_r5_r10_ASR_2), kInstruction_sbcs_al_r0_r5_r10_ASR_2, }, { ARRAY_SIZE(kInstruction_sbcs_al_r10_r4_r0_ASR_13), kInstruction_sbcs_al_r10_r4_r0_ASR_13, }, { ARRAY_SIZE(kInstruction_sbcs_al_r12_r3_r0_LSR_16), kInstruction_sbcs_al_r12_r3_r0_LSR_16, }, { ARRAY_SIZE(kInstruction_sbcs_al_r7_r11_r14_ASR_25), kInstruction_sbcs_al_r7_r11_r14_ASR_25, }, { ARRAY_SIZE(kInstruction_sbcs_al_r8_r9_r12_ASR_31), kInstruction_sbcs_al_r8_r9_r12_ASR_31, }, { ARRAY_SIZE(kInstruction_sbcs_al_r14_r11_r8_LSR_26), kInstruction_sbcs_al_r14_r11_r8_LSR_26, }, { ARRAY_SIZE(kInstruction_sbcs_al_r8_r3_r6_ASR_31), kInstruction_sbcs_al_r8_r3_r6_ASR_31, }, { ARRAY_SIZE(kInstruction_sbcs_al_r10_r4_r5_ASR_9), kInstruction_sbcs_al_r10_r4_r5_ASR_9, }, { ARRAY_SIZE(kInstruction_sbcs_al_r9_r4_r6_LSR_31), kInstruction_sbcs_al_r9_r4_r6_LSR_31, }, { ARRAY_SIZE(kInstruction_sbcs_al_r12_r6_r12_LSR_32), kInstruction_sbcs_al_r12_r6_r12_LSR_32, }, { ARRAY_SIZE(kInstruction_sbcs_al_r5_r8_r9_LSR_15), kInstruction_sbcs_al_r5_r8_r9_LSR_15, }, { ARRAY_SIZE(kInstruction_sbcs_al_r1_r7_r0_LSR_4), kInstruction_sbcs_al_r1_r7_r0_LSR_4, }, { ARRAY_SIZE(kInstruction_sbcs_al_r14_r5_r3_LSR_11), kInstruction_sbcs_al_r14_r5_r3_LSR_11, }, { ARRAY_SIZE(kInstruction_sbcs_al_r0_r5_r11_ASR_2), kInstruction_sbcs_al_r0_r5_r11_ASR_2, }, { ARRAY_SIZE(kInstruction_sbcs_al_r11_r13_r7_ASR_4), kInstruction_sbcs_al_r11_r13_r7_ASR_4, }, { ARRAY_SIZE(kInstruction_sbcs_al_r8_r13_r12_LSR_7), kInstruction_sbcs_al_r8_r13_r12_LSR_7, }, { ARRAY_SIZE(kInstruction_sbcs_al_r2_r11_r2_ASR_28), kInstruction_sbcs_al_r2_r11_r2_ASR_28, }, { ARRAY_SIZE(kInstruction_sbcs_al_r9_r14_r11_LSR_14), kInstruction_sbcs_al_r9_r14_r11_LSR_14, }, { ARRAY_SIZE(kInstruction_sbcs_al_r5_r12_r4_ASR_24), kInstruction_sbcs_al_r5_r12_r4_ASR_24, }, { ARRAY_SIZE(kInstruction_sbcs_al_r9_r13_r3_LSR_19), kInstruction_sbcs_al_r9_r13_r3_LSR_19, }, { ARRAY_SIZE(kInstruction_sbcs_al_r6_r3_r3_ASR_25), kInstruction_sbcs_al_r6_r3_r3_ASR_25, }, { ARRAY_SIZE(kInstruction_sbcs_al_r13_r6_r6_LSR_16), kInstruction_sbcs_al_r13_r6_r6_LSR_16, }, { ARRAY_SIZE(kInstruction_sbcs_al_r0_r9_r5_ASR_30), kInstruction_sbcs_al_r0_r9_r5_ASR_30, }, { ARRAY_SIZE(kInstruction_sbcs_al_r9_r9_r0_LSR_5), kInstruction_sbcs_al_r9_r9_r0_LSR_5, }, { ARRAY_SIZE(kInstruction_sbcs_al_r0_r5_r14_LSR_12), kInstruction_sbcs_al_r0_r5_r14_LSR_12, }, { ARRAY_SIZE(kInstruction_sbcs_al_r14_r12_r7_ASR_7), kInstruction_sbcs_al_r14_r12_r7_ASR_7, }, { ARRAY_SIZE(kInstruction_sbcs_al_r8_r13_r6_ASR_27), kInstruction_sbcs_al_r8_r13_r6_ASR_27, }, { ARRAY_SIZE(kInstruction_sbcs_al_r12_r6_r13_LSR_24), kInstruction_sbcs_al_r12_r6_r13_LSR_24, }, { ARRAY_SIZE(kInstruction_sbcs_al_r7_r10_r6_ASR_32), kInstruction_sbcs_al_r7_r10_r6_ASR_32, }, { ARRAY_SIZE(kInstruction_sbcs_al_r6_r12_r13_ASR_8), kInstruction_sbcs_al_r6_r12_r13_ASR_8, }, { ARRAY_SIZE(kInstruction_sbcs_al_r13_r0_r8_LSR_19), kInstruction_sbcs_al_r13_r0_r8_LSR_19, }, { ARRAY_SIZE(kInstruction_sbcs_al_r10_r9_r10_LSR_20), kInstruction_sbcs_al_r10_r9_r10_LSR_20, }, { ARRAY_SIZE(kInstruction_sbcs_al_r5_r7_r2_LSR_25), kInstruction_sbcs_al_r5_r7_r2_LSR_25, }, { ARRAY_SIZE(kInstruction_sbcs_al_r2_r6_r0_LSR_15), kInstruction_sbcs_al_r2_r6_r0_LSR_15, }, { ARRAY_SIZE(kInstruction_sbcs_al_r12_r6_r8_LSR_21), kInstruction_sbcs_al_r12_r6_r8_LSR_21, }, { ARRAY_SIZE(kInstruction_sbcs_al_r14_r13_r2_LSR_29), kInstruction_sbcs_al_r14_r13_r2_LSR_29, }, { ARRAY_SIZE(kInstruction_sbcs_al_r1_r13_r0_LSR_21), kInstruction_sbcs_al_r1_r13_r0_LSR_21, }, { ARRAY_SIZE(kInstruction_sbcs_al_r6_r7_r8_ASR_13), kInstruction_sbcs_al_r6_r7_r8_ASR_13, }, { ARRAY_SIZE(kInstruction_sbcs_al_r13_r2_r10_ASR_8), kInstruction_sbcs_al_r13_r2_r10_ASR_8, }, { ARRAY_SIZE(kInstruction_sbcs_al_r5_r13_r7_LSR_2), kInstruction_sbcs_al_r5_r13_r7_LSR_2, }, { ARRAY_SIZE(kInstruction_sbcs_al_r0_r3_r2_LSR_17), kInstruction_sbcs_al_r0_r3_r2_LSR_17, }, { ARRAY_SIZE(kInstruction_sbcs_al_r1_r8_r9_LSR_3), kInstruction_sbcs_al_r1_r8_r9_LSR_3, }, { ARRAY_SIZE(kInstruction_sbcs_al_r11_r3_r1_LSR_29), kInstruction_sbcs_al_r11_r3_r1_LSR_29, }, { ARRAY_SIZE(kInstruction_sbcs_al_r2_r2_r11_LSR_17), kInstruction_sbcs_al_r2_r2_r11_LSR_17, }, { ARRAY_SIZE(kInstruction_sbcs_al_r7_r14_r11_LSR_22), kInstruction_sbcs_al_r7_r14_r11_LSR_22, }, { ARRAY_SIZE(kInstruction_sbcs_al_r8_r7_r14_LSR_17), kInstruction_sbcs_al_r8_r7_r14_LSR_17, }, { ARRAY_SIZE(kInstruction_sbcs_al_r14_r2_r7_ASR_32), kInstruction_sbcs_al_r14_r2_r7_ASR_32, }, { ARRAY_SIZE(kInstruction_sbcs_al_r0_r6_r9_ASR_13), kInstruction_sbcs_al_r0_r6_r9_ASR_13, }, { ARRAY_SIZE(kInstruction_sbcs_al_r3_r5_r4_ASR_24), kInstruction_sbcs_al_r3_r5_r4_ASR_24, }, { ARRAY_SIZE(kInstruction_sbcs_al_r10_r10_r6_ASR_1), kInstruction_sbcs_al_r10_r10_r6_ASR_1, }, { ARRAY_SIZE(kInstruction_sbcs_al_r8_r9_r4_ASR_5), kInstruction_sbcs_al_r8_r9_r4_ASR_5, }, { ARRAY_SIZE(kInstruction_sbcs_al_r3_r0_r6_LSR_25), kInstruction_sbcs_al_r3_r0_r6_LSR_25, }, { ARRAY_SIZE(kInstruction_sbcs_al_r12_r7_r12_ASR_11), kInstruction_sbcs_al_r12_r7_r12_ASR_11, }, { ARRAY_SIZE(kInstruction_sbcs_al_r10_r9_r7_ASR_2), kInstruction_sbcs_al_r10_r9_r7_ASR_2, }, { ARRAY_SIZE(kInstruction_sbcs_al_r13_r13_r5_ASR_2), kInstruction_sbcs_al_r13_r13_r5_ASR_2, }, { ARRAY_SIZE(kInstruction_sbcs_al_r11_r3_r2_ASR_5), kInstruction_sbcs_al_r11_r3_r2_ASR_5, }, { ARRAY_SIZE(kInstruction_sbcs_al_r0_r8_r8_ASR_10), kInstruction_sbcs_al_r0_r8_r8_ASR_10, }, { ARRAY_SIZE(kInstruction_sbcs_al_r10_r12_r12_ASR_19), kInstruction_sbcs_al_r10_r12_r12_ASR_19, }, { ARRAY_SIZE(kInstruction_sbcs_al_r2_r6_r0_LSR_10), kInstruction_sbcs_al_r2_r6_r0_LSR_10, }, { ARRAY_SIZE(kInstruction_sbcs_al_r11_r8_r8_ASR_15), kInstruction_sbcs_al_r11_r8_r8_ASR_15, }, { ARRAY_SIZE(kInstruction_sbcs_al_r14_r14_r1_LSR_14), kInstruction_sbcs_al_r14_r14_r1_LSR_14, }, { ARRAY_SIZE(kInstruction_sbcs_al_r9_r8_r12_ASR_21), kInstruction_sbcs_al_r9_r8_r12_ASR_21, }, { ARRAY_SIZE(kInstruction_sbcs_al_r14_r14_r12_ASR_9), kInstruction_sbcs_al_r14_r14_r12_ASR_9, }, { ARRAY_SIZE(kInstruction_sbcs_al_r0_r0_r3_ASR_22), kInstruction_sbcs_al_r0_r0_r3_ASR_22, }, { ARRAY_SIZE(kInstruction_sbcs_al_r9_r7_r13_LSR_16), kInstruction_sbcs_al_r9_r7_r13_LSR_16, }, { ARRAY_SIZE(kInstruction_sbcs_al_r8_r1_r5_LSR_28), kInstruction_sbcs_al_r8_r1_r5_LSR_28, }, { ARRAY_SIZE(kInstruction_sbcs_al_r0_r2_r11_LSR_21), kInstruction_sbcs_al_r0_r2_r11_LSR_21, }, { ARRAY_SIZE(kInstruction_sbcs_al_r5_r12_r8_LSR_25), kInstruction_sbcs_al_r5_r12_r8_LSR_25, }, { ARRAY_SIZE(kInstruction_sbcs_al_r9_r5_r6_ASR_5), kInstruction_sbcs_al_r9_r5_r6_ASR_5, }, { ARRAY_SIZE(kInstruction_sbcs_al_r0_r0_r7_ASR_13), kInstruction_sbcs_al_r0_r0_r7_ASR_13, }, { ARRAY_SIZE(kInstruction_sbcs_al_r2_r10_r7_ASR_10), kInstruction_sbcs_al_r2_r10_r7_ASR_10, }, { ARRAY_SIZE(kInstruction_sbcs_al_r13_r8_r14_ASR_32), kInstruction_sbcs_al_r13_r8_r14_ASR_32, }, { ARRAY_SIZE(kInstruction_sbcs_al_r3_r2_r9_ASR_30), kInstruction_sbcs_al_r3_r2_r9_ASR_30, }, { ARRAY_SIZE(kInstruction_sbcs_al_r11_r0_r14_ASR_6), kInstruction_sbcs_al_r11_r0_r14_ASR_6, }, { ARRAY_SIZE(kInstruction_sbcs_al_r13_r10_r2_ASR_18), kInstruction_sbcs_al_r13_r10_r2_ASR_18, }, { ARRAY_SIZE(kInstruction_sbcs_al_r8_r13_r1_ASR_18), kInstruction_sbcs_al_r8_r13_r1_ASR_18, }, { ARRAY_SIZE(kInstruction_sbcs_al_r10_r4_r3_LSR_19), kInstruction_sbcs_al_r10_r4_r3_LSR_19, }, { ARRAY_SIZE(kInstruction_sbcs_al_r2_r2_r9_ASR_15), kInstruction_sbcs_al_r2_r2_r9_ASR_15, }, { ARRAY_SIZE(kInstruction_sbcs_al_r6_r4_r8_LSR_28), kInstruction_sbcs_al_r6_r4_r8_LSR_28, }, { ARRAY_SIZE(kInstruction_sbcs_al_r14_r9_r6_LSR_27), kInstruction_sbcs_al_r14_r9_r6_LSR_27, }, { ARRAY_SIZE(kInstruction_sbcs_al_r3_r14_r8_LSR_18), kInstruction_sbcs_al_r3_r14_r8_LSR_18, }, { ARRAY_SIZE(kInstruction_sbcs_al_r4_r1_r14_LSR_2), kInstruction_sbcs_al_r4_r1_r14_LSR_2, }, { ARRAY_SIZE(kInstruction_sbcs_al_r13_r9_r6_ASR_16), kInstruction_sbcs_al_r13_r9_r6_ASR_16, }, { ARRAY_SIZE(kInstruction_sbcs_al_r4_r1_r9_ASR_29), kInstruction_sbcs_al_r4_r1_r9_ASR_29, }, { ARRAY_SIZE(kInstruction_sbcs_al_r4_r3_r2_LSR_23), kInstruction_sbcs_al_r4_r3_r2_LSR_23, }, { ARRAY_SIZE(kInstruction_sbcs_al_r11_r8_r0_LSR_19), kInstruction_sbcs_al_r11_r8_r0_LSR_19, }, { ARRAY_SIZE(kInstruction_sbcs_al_r6_r10_r4_ASR_29), kInstruction_sbcs_al_r6_r10_r4_ASR_29, }, { ARRAY_SIZE(kInstruction_sbcs_al_r8_r2_r5_ASR_25), kInstruction_sbcs_al_r8_r2_r5_ASR_25, }, { ARRAY_SIZE(kInstruction_sbcs_al_r3_r10_r14_LSR_25), kInstruction_sbcs_al_r3_r10_r14_LSR_25, }, { ARRAY_SIZE(kInstruction_sbcs_al_r4_r9_r0_LSR_32), kInstruction_sbcs_al_r4_r9_r0_LSR_32, }, { ARRAY_SIZE(kInstruction_sbcs_al_r14_r10_r1_ASR_8), kInstruction_sbcs_al_r14_r10_r1_ASR_8, }, { ARRAY_SIZE(kInstruction_sbcs_al_r10_r10_r1_LSR_4), kInstruction_sbcs_al_r10_r10_r1_LSR_4, }, { ARRAY_SIZE(kInstruction_sbcs_al_r10_r2_r9_ASR_23), kInstruction_sbcs_al_r10_r2_r9_ASR_23, }, { ARRAY_SIZE(kInstruction_sbcs_al_r12_r2_r7_LSR_30), kInstruction_sbcs_al_r12_r2_r7_LSR_30, }, { ARRAY_SIZE(kInstruction_sbcs_al_r13_r4_r9_ASR_20), kInstruction_sbcs_al_r13_r4_r9_ASR_20, }, { ARRAY_SIZE(kInstruction_sbcs_al_r12_r13_r2_LSR_29), kInstruction_sbcs_al_r12_r13_r2_LSR_29, }, { ARRAY_SIZE(kInstruction_sbcs_al_r14_r8_r13_ASR_12), kInstruction_sbcs_al_r14_r8_r13_ASR_12, }, { ARRAY_SIZE(kInstruction_sbcs_al_r11_r14_r11_ASR_18), kInstruction_sbcs_al_r11_r14_r11_ASR_18, }, { ARRAY_SIZE(kInstruction_sbcs_al_r11_r10_r1_LSR_3), kInstruction_sbcs_al_r11_r10_r1_LSR_3, }, { ARRAY_SIZE(kInstruction_sbcs_al_r6_r2_r0_LSR_27), kInstruction_sbcs_al_r6_r2_r0_LSR_27, }, { ARRAY_SIZE(kInstruction_sbcs_al_r13_r6_r12_ASR_6), kInstruction_sbcs_al_r13_r6_r12_ASR_6, }, { ARRAY_SIZE(kInstruction_sbcs_al_r9_r2_r3_ASR_21), kInstruction_sbcs_al_r9_r2_r3_ASR_21, }, { ARRAY_SIZE(kInstruction_sbcs_al_r2_r9_r4_LSR_16), kInstruction_sbcs_al_r2_r9_r4_LSR_16, }, { ARRAY_SIZE(kInstruction_sbcs_al_r10_r13_r10_ASR_23), kInstruction_sbcs_al_r10_r13_r10_ASR_23, }, { ARRAY_SIZE(kInstruction_sbcs_al_r8_r13_r10_LSR_20), kInstruction_sbcs_al_r8_r13_r10_LSR_20, }, { ARRAY_SIZE(kInstruction_sbcs_al_r0_r7_r7_ASR_17), kInstruction_sbcs_al_r0_r7_r7_ASR_17, }, { ARRAY_SIZE(kInstruction_sbcs_al_r2_r5_r9_ASR_24), kInstruction_sbcs_al_r2_r5_r9_ASR_24, }, { ARRAY_SIZE(kInstruction_sbcs_al_r1_r9_r7_ASR_16), kInstruction_sbcs_al_r1_r9_r7_ASR_16, }, { ARRAY_SIZE(kInstruction_sbcs_al_r4_r1_r7_LSR_26), kInstruction_sbcs_al_r4_r1_r7_LSR_26, }, { ARRAY_SIZE(kInstruction_sbcs_al_r6_r4_r10_LSR_26), kInstruction_sbcs_al_r6_r4_r10_LSR_26, }, { ARRAY_SIZE(kInstruction_sbcs_al_r9_r5_r7_ASR_1), kInstruction_sbcs_al_r9_r5_r7_ASR_1, }, { ARRAY_SIZE(kInstruction_sbcs_al_r5_r3_r5_LSR_8), kInstruction_sbcs_al_r5_r3_r5_LSR_8, }, { ARRAY_SIZE(kInstruction_sbcs_al_r7_r6_r8_LSR_28), kInstruction_sbcs_al_r7_r6_r8_LSR_28, }, { ARRAY_SIZE(kInstruction_sbcs_al_r3_r5_r12_ASR_23), kInstruction_sbcs_al_r3_r5_r12_ASR_23, }, { ARRAY_SIZE(kInstruction_sbcs_al_r3_r14_r9_LSR_28), kInstruction_sbcs_al_r3_r14_r9_LSR_28, }, { ARRAY_SIZE(kInstruction_sbcs_al_r14_r5_r3_LSR_21), kInstruction_sbcs_al_r14_r5_r3_LSR_21, }, { ARRAY_SIZE(kInstruction_sbcs_al_r11_r0_r13_LSR_23), kInstruction_sbcs_al_r11_r0_r13_LSR_23, }, { ARRAY_SIZE(kInstruction_sbcs_al_r13_r13_r7_LSR_15), kInstruction_sbcs_al_r13_r13_r7_LSR_15, }, { ARRAY_SIZE(kInstruction_sbcs_al_r6_r10_r8_LSR_24), kInstruction_sbcs_al_r6_r10_r8_LSR_24, }, { ARRAY_SIZE(kInstruction_sbcs_al_r8_r11_r11_ASR_28), kInstruction_sbcs_al_r8_r11_r11_ASR_28, }, { ARRAY_SIZE(kInstruction_sbcs_al_r9_r1_r1_LSR_26), kInstruction_sbcs_al_r9_r1_r1_LSR_26, }, { ARRAY_SIZE(kInstruction_sbcs_al_r2_r4_r14_LSR_2), kInstruction_sbcs_al_r2_r4_r14_LSR_2, }, { ARRAY_SIZE(kInstruction_sbcs_al_r4_r7_r2_ASR_19), kInstruction_sbcs_al_r4_r7_r2_ASR_19, }, { ARRAY_SIZE(kInstruction_sbcs_al_r9_r1_r7_ASR_23), kInstruction_sbcs_al_r9_r1_r7_ASR_23, }, { ARRAY_SIZE(kInstruction_sbcs_al_r4_r7_r11_ASR_7), kInstruction_sbcs_al_r4_r7_r11_ASR_7, }, { ARRAY_SIZE(kInstruction_sbcs_al_r7_r9_r5_ASR_32), kInstruction_sbcs_al_r7_r9_r5_ASR_32, }, { ARRAY_SIZE(kInstruction_sbcs_al_r14_r6_r6_ASR_11), kInstruction_sbcs_al_r14_r6_r6_ASR_11, }, { ARRAY_SIZE(kInstruction_sbcs_al_r14_r5_r14_ASR_32), kInstruction_sbcs_al_r14_r5_r14_ASR_32, }, { ARRAY_SIZE(kInstruction_sbcs_al_r9_r2_r13_LSR_15), kInstruction_sbcs_al_r9_r2_r13_LSR_15, }, { ARRAY_SIZE(kInstruction_sbcs_al_r13_r8_r3_LSR_15), kInstruction_sbcs_al_r13_r8_r3_LSR_15, }, { ARRAY_SIZE(kInstruction_sbcs_al_r14_r0_r2_ASR_10), kInstruction_sbcs_al_r14_r0_r2_ASR_10, }, { ARRAY_SIZE(kInstruction_sbcs_al_r9_r6_r5_LSR_3), kInstruction_sbcs_al_r9_r6_r5_LSR_3, }, { ARRAY_SIZE(kInstruction_sbcs_al_r11_r10_r12_LSR_13), kInstruction_sbcs_al_r11_r10_r12_LSR_13, }, { ARRAY_SIZE(kInstruction_sbcs_al_r7_r11_r9_LSR_11), kInstruction_sbcs_al_r7_r11_r9_LSR_11, }, { ARRAY_SIZE(kInstruction_sbcs_al_r3_r9_r9_ASR_10), kInstruction_sbcs_al_r3_r9_r9_ASR_10, }, { ARRAY_SIZE(kInstruction_sbcs_al_r12_r14_r3_LSR_25), kInstruction_sbcs_al_r12_r14_r3_LSR_25, }, { ARRAY_SIZE(kInstruction_sbcs_al_r13_r1_r11_ASR_7), kInstruction_sbcs_al_r13_r1_r11_ASR_7, }, { ARRAY_SIZE(kInstruction_sbcs_al_r12_r9_r5_ASR_2), kInstruction_sbcs_al_r12_r9_r5_ASR_2, }, { ARRAY_SIZE(kInstruction_sbcs_al_r6_r13_r7_ASR_12), kInstruction_sbcs_al_r6_r13_r7_ASR_12, }, { ARRAY_SIZE(kInstruction_sbcs_al_r5_r1_r5_LSR_16), kInstruction_sbcs_al_r5_r1_r5_LSR_16, }, { ARRAY_SIZE(kInstruction_sbcs_al_r0_r11_r13_LSR_22), kInstruction_sbcs_al_r0_r11_r13_LSR_22, }, { ARRAY_SIZE(kInstruction_sbcs_al_r7_r8_r1_ASR_25), kInstruction_sbcs_al_r7_r8_r1_ASR_25, }, { ARRAY_SIZE(kInstruction_sbcs_al_r2_r13_r9_LSR_11), kInstruction_sbcs_al_r2_r13_r9_LSR_11, }, { ARRAY_SIZE(kInstruction_sbcs_al_r4_r9_r11_ASR_17), kInstruction_sbcs_al_r4_r9_r11_ASR_17, }, { ARRAY_SIZE(kInstruction_sbcs_al_r6_r0_r4_ASR_13), kInstruction_sbcs_al_r6_r0_r4_ASR_13, }, { ARRAY_SIZE(kInstruction_sbcs_al_r9_r0_r14_LSR_23), kInstruction_sbcs_al_r9_r0_r14_LSR_23, }, { ARRAY_SIZE(kInstruction_sbcs_al_r14_r11_r5_ASR_17), kInstruction_sbcs_al_r14_r11_r5_ASR_17, }, { ARRAY_SIZE(kInstruction_sbcs_al_r6_r14_r13_ASR_4), kInstruction_sbcs_al_r6_r14_r13_ASR_4, }, { ARRAY_SIZE(kInstruction_sbcs_al_r14_r12_r7_ASR_31), kInstruction_sbcs_al_r14_r12_r7_ASR_31, }, { ARRAY_SIZE(kInstruction_sbcs_al_r11_r10_r12_ASR_1), kInstruction_sbcs_al_r11_r10_r12_ASR_1, }, { ARRAY_SIZE(kInstruction_sbcs_al_r14_r11_r12_ASR_25), kInstruction_sbcs_al_r14_r11_r12_ASR_25, }, { ARRAY_SIZE(kInstruction_sbcs_al_r2_r13_r1_ASR_1), kInstruction_sbcs_al_r2_r13_r1_ASR_1, }, { ARRAY_SIZE(kInstruction_sbcs_al_r9_r2_r3_LSR_29), kInstruction_sbcs_al_r9_r2_r3_LSR_29, }, { ARRAY_SIZE(kInstruction_sbcs_al_r1_r7_r6_ASR_20), kInstruction_sbcs_al_r1_r7_r6_ASR_20, }, { ARRAY_SIZE(kInstruction_sbcs_al_r9_r13_r3_LSR_2), kInstruction_sbcs_al_r9_r13_r3_LSR_2, }, { ARRAY_SIZE(kInstruction_sbcs_al_r8_r12_r5_ASR_24), kInstruction_sbcs_al_r8_r12_r5_ASR_24, }, { ARRAY_SIZE(kInstruction_sbcs_al_r12_r5_r14_LSR_1), kInstruction_sbcs_al_r12_r5_r14_LSR_1, }, { ARRAY_SIZE(kInstruction_sbcs_al_r13_r4_r9_ASR_30), kInstruction_sbcs_al_r13_r4_r9_ASR_30, }, { ARRAY_SIZE(kInstruction_sbcs_al_r12_r2_r11_ASR_28), kInstruction_sbcs_al_r12_r2_r11_ASR_28, }, { ARRAY_SIZE(kInstruction_sbcs_al_r8_r2_r11_LSR_26), kInstruction_sbcs_al_r8_r2_r11_LSR_26, }, { ARRAY_SIZE(kInstruction_sbcs_al_r0_r0_r2_ASR_21), kInstruction_sbcs_al_r0_r0_r2_ASR_21, }, { ARRAY_SIZE(kInstruction_sbcs_al_r7_r10_r14_LSR_22), kInstruction_sbcs_al_r7_r10_r14_LSR_22, }, { ARRAY_SIZE(kInstruction_sbcs_al_r3_r1_r4_ASR_18), kInstruction_sbcs_al_r3_r1_r4_ASR_18, }, { ARRAY_SIZE(kInstruction_sbcs_al_r8_r14_r3_ASR_32), kInstruction_sbcs_al_r8_r14_r3_ASR_32, }, { ARRAY_SIZE(kInstruction_sbcs_al_r4_r9_r8_ASR_4), kInstruction_sbcs_al_r4_r9_r8_ASR_4, }, { ARRAY_SIZE(kInstruction_sbcs_al_r7_r2_r4_ASR_14), kInstruction_sbcs_al_r7_r2_r4_ASR_14, }, { ARRAY_SIZE(kInstruction_sbcs_al_r12_r1_r9_ASR_9), kInstruction_sbcs_al_r12_r1_r9_ASR_9, }, { ARRAY_SIZE(kInstruction_sbcs_al_r3_r5_r0_ASR_11), kInstruction_sbcs_al_r3_r5_r0_ASR_11, }, { ARRAY_SIZE(kInstruction_sbcs_al_r14_r9_r0_LSR_10), kInstruction_sbcs_al_r14_r9_r0_LSR_10, }, { ARRAY_SIZE(kInstruction_sbcs_al_r14_r13_r6_ASR_27), kInstruction_sbcs_al_r14_r13_r6_ASR_27, }, { ARRAY_SIZE(kInstruction_sbcs_al_r13_r8_r1_LSR_27), kInstruction_sbcs_al_r13_r8_r1_LSR_27, }, { ARRAY_SIZE(kInstruction_sbcs_al_r7_r0_r7_LSR_31), kInstruction_sbcs_al_r7_r0_r7_LSR_31, }, { ARRAY_SIZE(kInstruction_sbcs_al_r5_r8_r7_ASR_27), kInstruction_sbcs_al_r5_r8_r7_ASR_27, }, { ARRAY_SIZE(kInstruction_sbcs_al_r12_r3_r10_ASR_24), kInstruction_sbcs_al_r12_r3_r10_ASR_24, }, { ARRAY_SIZE(kInstruction_sbcs_al_r14_r14_r5_LSR_20), kInstruction_sbcs_al_r14_r14_r5_LSR_20, }, { ARRAY_SIZE(kInstruction_sbcs_al_r0_r12_r7_LSR_32), kInstruction_sbcs_al_r0_r12_r7_LSR_32, }, { ARRAY_SIZE(kInstruction_sbcs_al_r2_r3_r6_ASR_17), kInstruction_sbcs_al_r2_r3_r6_ASR_17, }, { ARRAY_SIZE(kInstruction_sbcs_al_r11_r8_r13_ASR_27), kInstruction_sbcs_al_r11_r8_r13_ASR_27, }, { ARRAY_SIZE(kInstruction_sbcs_al_r13_r12_r4_LSR_24), kInstruction_sbcs_al_r13_r12_r4_LSR_24, }, { ARRAY_SIZE(kInstruction_sbcs_al_r3_r3_r0_ASR_26), kInstruction_sbcs_al_r3_r3_r0_ASR_26, }, { ARRAY_SIZE(kInstruction_sbcs_al_r10_r0_r5_ASR_26), kInstruction_sbcs_al_r10_r0_r5_ASR_26, }, { ARRAY_SIZE(kInstruction_sbcs_al_r5_r9_r7_LSR_6), kInstruction_sbcs_al_r5_r9_r7_LSR_6, }, { ARRAY_SIZE(kInstruction_sbcs_al_r12_r4_r9_ASR_8), kInstruction_sbcs_al_r12_r4_r9_ASR_8, }, { ARRAY_SIZE(kInstruction_sbcs_al_r4_r0_r13_LSR_16), kInstruction_sbcs_al_r4_r0_r13_LSR_16, }, { ARRAY_SIZE(kInstruction_sbcs_al_r11_r2_r2_LSR_6), kInstruction_sbcs_al_r11_r2_r2_LSR_6, }, { ARRAY_SIZE(kInstruction_sbcs_al_r12_r4_r3_ASR_11), kInstruction_sbcs_al_r12_r4_r3_ASR_11, }, { ARRAY_SIZE(kInstruction_sbcs_al_r0_r10_r12_ASR_22), kInstruction_sbcs_al_r0_r10_r12_ASR_22, }, { ARRAY_SIZE(kInstruction_sbcs_al_r12_r2_r12_LSR_16), kInstruction_sbcs_al_r12_r2_r12_LSR_16, }, { ARRAY_SIZE(kInstruction_sbcs_al_r2_r2_r8_ASR_14), kInstruction_sbcs_al_r2_r2_r8_ASR_14, }, { ARRAY_SIZE(kInstruction_sbcs_al_r9_r1_r3_LSR_2), kInstruction_sbcs_al_r9_r1_r3_LSR_2, }, { ARRAY_SIZE(kInstruction_sbcs_al_r7_r0_r6_ASR_15), kInstruction_sbcs_al_r7_r0_r6_ASR_15, }, { ARRAY_SIZE(kInstruction_sbcs_al_r11_r2_r12_LSR_17), kInstruction_sbcs_al_r11_r2_r12_LSR_17, }, { ARRAY_SIZE(kInstruction_sbcs_al_r3_r7_r7_ASR_19), kInstruction_sbcs_al_r3_r7_r7_ASR_19, }, { ARRAY_SIZE(kInstruction_sbcs_al_r9_r13_r1_LSR_29), kInstruction_sbcs_al_r9_r13_r1_LSR_29, }, { ARRAY_SIZE(kInstruction_sbcs_al_r1_r0_r2_LSR_2), kInstruction_sbcs_al_r1_r0_r2_LSR_2, }, { ARRAY_SIZE(kInstruction_sbcs_al_r14_r10_r2_ASR_12), kInstruction_sbcs_al_r14_r10_r2_ASR_12, }, { ARRAY_SIZE(kInstruction_sbcs_al_r7_r14_r11_ASR_27), kInstruction_sbcs_al_r7_r14_r11_ASR_27, }, { ARRAY_SIZE(kInstruction_sbcs_al_r9_r8_r13_ASR_17), kInstruction_sbcs_al_r9_r8_r13_ASR_17, }, { ARRAY_SIZE(kInstruction_sbcs_al_r6_r14_r8_LSR_11), kInstruction_sbcs_al_r6_r14_r8_LSR_11, }, { ARRAY_SIZE(kInstruction_sbcs_al_r5_r3_r9_ASR_31), kInstruction_sbcs_al_r5_r3_r9_ASR_31, }, { ARRAY_SIZE(kInstruction_sbcs_al_r5_r4_r1_ASR_29), kInstruction_sbcs_al_r5_r4_r1_ASR_29, }, { ARRAY_SIZE(kInstruction_sbcs_al_r6_r5_r10_ASR_25), kInstruction_sbcs_al_r6_r5_r10_ASR_25, }, { ARRAY_SIZE(kInstruction_sbcs_al_r1_r8_r14_ASR_32), kInstruction_sbcs_al_r1_r8_r14_ASR_32, }, { ARRAY_SIZE(kInstruction_sbcs_al_r0_r3_r5_ASR_4), kInstruction_sbcs_al_r0_r3_r5_ASR_4, }, { ARRAY_SIZE(kInstruction_sbcs_al_r8_r6_r1_ASR_5), kInstruction_sbcs_al_r8_r6_r1_ASR_5, }, { ARRAY_SIZE(kInstruction_sbcs_al_r14_r9_r14_ASR_25), kInstruction_sbcs_al_r14_r9_r14_ASR_25, }, { ARRAY_SIZE(kInstruction_sbcs_al_r2_r10_r0_ASR_18), kInstruction_sbcs_al_r2_r10_r0_ASR_18, }, { ARRAY_SIZE(kInstruction_sbcs_al_r12_r14_r0_LSR_23), kInstruction_sbcs_al_r12_r14_r0_LSR_23, }, { ARRAY_SIZE(kInstruction_sbcs_al_r5_r13_r14_LSR_25), kInstruction_sbcs_al_r5_r13_r14_LSR_25, }, { ARRAY_SIZE(kInstruction_sbcs_al_r13_r11_r10_ASR_18), kInstruction_sbcs_al_r13_r11_r10_ASR_18, }, { ARRAY_SIZE(kInstruction_sbcs_al_r13_r9_r4_LSR_22), kInstruction_sbcs_al_r13_r9_r4_LSR_22, }, { ARRAY_SIZE(kInstruction_sbcs_al_r10_r12_r5_LSR_12), kInstruction_sbcs_al_r10_r12_r5_LSR_12, }, { ARRAY_SIZE(kInstruction_sbcs_al_r0_r1_r2_ASR_28), kInstruction_sbcs_al_r0_r1_r2_ASR_28, }, { ARRAY_SIZE(kInstruction_sbcs_al_r13_r5_r5_LSR_4), kInstruction_sbcs_al_r13_r5_r5_LSR_4, }, { ARRAY_SIZE(kInstruction_sbcs_al_r1_r3_r10_LSR_18), kInstruction_sbcs_al_r1_r3_r10_LSR_18, }, { ARRAY_SIZE(kInstruction_sbcs_al_r2_r6_r4_LSR_4), kInstruction_sbcs_al_r2_r6_r4_LSR_4, }, { ARRAY_SIZE(kInstruction_sbcs_al_r0_r3_r10_LSR_4), kInstruction_sbcs_al_r0_r3_r10_LSR_4, }, { ARRAY_SIZE(kInstruction_sbcs_al_r14_r2_r8_LSR_30), kInstruction_sbcs_al_r14_r2_r8_LSR_30, }, { ARRAY_SIZE(kInstruction_sbcs_al_r10_r12_r10_ASR_18), kInstruction_sbcs_al_r10_r12_r10_ASR_18, }, { ARRAY_SIZE(kInstruction_sbcs_al_r13_r4_r2_LSR_31), kInstruction_sbcs_al_r13_r4_r2_LSR_31, }, { ARRAY_SIZE(kInstruction_sbcs_al_r10_r11_r14_LSR_5), kInstruction_sbcs_al_r10_r11_r14_LSR_5, }, { ARRAY_SIZE(kInstruction_sbcs_al_r3_r1_r6_ASR_8), kInstruction_sbcs_al_r3_r1_r6_ASR_8, }, { ARRAY_SIZE(kInstruction_sbcs_al_r7_r14_r2_ASR_10), kInstruction_sbcs_al_r7_r14_r2_ASR_10, }, { ARRAY_SIZE(kInstruction_sbcs_al_r8_r10_r8_ASR_8), kInstruction_sbcs_al_r8_r10_r8_ASR_8, }, { ARRAY_SIZE(kInstruction_sbcs_al_r7_r10_r4_ASR_21), kInstruction_sbcs_al_r7_r10_r4_ASR_21, }, { ARRAY_SIZE(kInstruction_sbcs_al_r6_r3_r3_ASR_6), kInstruction_sbcs_al_r6_r3_r3_ASR_6, }, { ARRAY_SIZE(kInstruction_sbcs_al_r1_r8_r6_ASR_20), kInstruction_sbcs_al_r1_r8_r6_ASR_20, }, { ARRAY_SIZE(kInstruction_sbcs_al_r14_r6_r0_LSR_12), kInstruction_sbcs_al_r14_r6_r0_LSR_12, }, { ARRAY_SIZE(kInstruction_sbcs_al_r8_r1_r14_LSR_19), kInstruction_sbcs_al_r8_r1_r14_LSR_19, }, { ARRAY_SIZE(kInstruction_sbcs_al_r6_r7_r8_LSR_22), kInstruction_sbcs_al_r6_r7_r8_LSR_22, }, { ARRAY_SIZE(kInstruction_sbcs_al_r9_r0_r11_LSR_8), kInstruction_sbcs_al_r9_r0_r11_LSR_8, }, { ARRAY_SIZE(kInstruction_sbcs_al_r10_r3_r2_LSR_6), kInstruction_sbcs_al_r10_r3_r2_LSR_6, }, { ARRAY_SIZE(kInstruction_sbcs_al_r2_r14_r0_ASR_12), kInstruction_sbcs_al_r2_r14_r0_ASR_12, }, { ARRAY_SIZE(kInstruction_sbcs_al_r6_r3_r5_LSR_22), kInstruction_sbcs_al_r6_r3_r5_LSR_22, }, { ARRAY_SIZE(kInstruction_sbcs_al_r2_r13_r9_LSR_12), kInstruction_sbcs_al_r2_r13_r9_LSR_12, }, { ARRAY_SIZE(kInstruction_sbcs_al_r14_r5_r2_LSR_5), kInstruction_sbcs_al_r14_r5_r2_LSR_5, }, { ARRAY_SIZE(kInstruction_sbcs_al_r4_r10_r12_LSR_32), kInstruction_sbcs_al_r4_r10_r12_LSR_32, }, { ARRAY_SIZE(kInstruction_sbcs_al_r1_r12_r2_ASR_1), kInstruction_sbcs_al_r1_r12_r2_ASR_1, }, { ARRAY_SIZE(kInstruction_sbcs_al_r7_r11_r3_ASR_27), kInstruction_sbcs_al_r7_r11_r3_ASR_27, }, { ARRAY_SIZE(kInstruction_sbcs_al_r3_r2_r2_ASR_29), kInstruction_sbcs_al_r3_r2_r2_ASR_29, }, { ARRAY_SIZE(kInstruction_sbcs_al_r12_r2_r10_ASR_13), kInstruction_sbcs_al_r12_r2_r10_ASR_13, }, { ARRAY_SIZE(kInstruction_sbcs_al_r3_r2_r3_ASR_19), kInstruction_sbcs_al_r3_r2_r3_ASR_19, }, { ARRAY_SIZE(kInstruction_sbcs_al_r3_r12_r8_ASR_14), kInstruction_sbcs_al_r3_r12_r8_ASR_14, }, { ARRAY_SIZE(kInstruction_sbcs_al_r14_r13_r9_LSR_28), kInstruction_sbcs_al_r14_r13_r9_LSR_28, }, { ARRAY_SIZE(kInstruction_sbcs_al_r6_r12_r7_ASR_32), kInstruction_sbcs_al_r6_r12_r7_ASR_32, }, { ARRAY_SIZE(kInstruction_sbcs_al_r11_r11_r12_ASR_9), kInstruction_sbcs_al_r11_r11_r12_ASR_9, }, { ARRAY_SIZE(kInstruction_sbcs_al_r9_r11_r4_ASR_21), kInstruction_sbcs_al_r9_r11_r4_ASR_21, }, { ARRAY_SIZE(kInstruction_sbcs_al_r6_r9_r3_LSR_30), kInstruction_sbcs_al_r6_r9_r3_LSR_30, }, { ARRAY_SIZE(kInstruction_sbcs_al_r6_r0_r8_ASR_22), kInstruction_sbcs_al_r6_r0_r8_ASR_22, }, { ARRAY_SIZE(kInstruction_sbcs_al_r5_r9_r11_ASR_27), kInstruction_sbcs_al_r5_r9_r11_ASR_27, }, { ARRAY_SIZE(kInstruction_sbcs_al_r4_r10_r6_LSR_2), kInstruction_sbcs_al_r4_r10_r6_LSR_2, }, { ARRAY_SIZE(kInstruction_sbcs_al_r10_r14_r11_ASR_20), kInstruction_sbcs_al_r10_r14_r11_ASR_20, }, { ARRAY_SIZE(kInstruction_sbcs_al_r8_r13_r11_LSR_13), kInstruction_sbcs_al_r8_r13_r11_LSR_13, }, { ARRAY_SIZE(kInstruction_sbcs_al_r7_r12_r13_LSR_11), kInstruction_sbcs_al_r7_r12_r13_LSR_11, }, { ARRAY_SIZE(kInstruction_sbcs_al_r14_r6_r14_ASR_21), kInstruction_sbcs_al_r14_r6_r14_ASR_21, }, { ARRAY_SIZE(kInstruction_sbcs_al_r2_r2_r7_LSR_25), kInstruction_sbcs_al_r2_r2_r7_LSR_25, }, { ARRAY_SIZE(kInstruction_sbcs_al_r0_r11_r5_LSR_5), kInstruction_sbcs_al_r0_r11_r5_LSR_5, }, { ARRAY_SIZE(kInstruction_sbcs_al_r1_r5_r14_LSR_19), kInstruction_sbcs_al_r1_r5_r14_LSR_19, }, { ARRAY_SIZE(kInstruction_sbcs_al_r4_r14_r13_LSR_27), kInstruction_sbcs_al_r4_r14_r13_LSR_27, }, { ARRAY_SIZE(kInstruction_sbcs_al_r13_r2_r3_ASR_24), kInstruction_sbcs_al_r13_r2_r3_ASR_24, }, { ARRAY_SIZE(kInstruction_sbcs_al_r11_r1_r9_ASR_12), kInstruction_sbcs_al_r11_r1_r9_ASR_12, }, { ARRAY_SIZE(kInstruction_sbcs_al_r2_r7_r13_LSR_10), kInstruction_sbcs_al_r2_r7_r13_LSR_10, }, { ARRAY_SIZE(kInstruction_sbcs_al_r4_r13_r0_ASR_3), kInstruction_sbcs_al_r4_r13_r0_ASR_3, }, { ARRAY_SIZE(kInstruction_sbcs_al_r7_r1_r3_ASR_23), kInstruction_sbcs_al_r7_r1_r3_ASR_23, }, { ARRAY_SIZE(kInstruction_sbcs_al_r10_r13_r3_ASR_20), kInstruction_sbcs_al_r10_r13_r3_ASR_20, }, { ARRAY_SIZE(kInstruction_sbcs_al_r7_r13_r9_LSR_8), kInstruction_sbcs_al_r7_r13_r9_LSR_8, }, { ARRAY_SIZE(kInstruction_sbcs_al_r14_r14_r3_LSR_21), kInstruction_sbcs_al_r14_r14_r3_LSR_21, }, { ARRAY_SIZE(kInstruction_sbcs_al_r4_r14_r2_ASR_32), kInstruction_sbcs_al_r4_r14_r2_ASR_32, }, { ARRAY_SIZE(kInstruction_sbcs_al_r1_r4_r3_LSR_10), kInstruction_sbcs_al_r1_r4_r3_LSR_10, }, { ARRAY_SIZE(kInstruction_sbcs_al_r11_r10_r9_LSR_16), kInstruction_sbcs_al_r11_r10_r9_LSR_16, }, { ARRAY_SIZE(kInstruction_sbcs_al_r9_r8_r4_LSR_5), kInstruction_sbcs_al_r9_r8_r4_LSR_5, }, { ARRAY_SIZE(kInstruction_sbcs_al_r11_r8_r11_ASR_7), kInstruction_sbcs_al_r11_r8_r11_ASR_7, }, { ARRAY_SIZE(kInstruction_sbcs_al_r3_r7_r2_ASR_20), kInstruction_sbcs_al_r3_r7_r2_ASR_20, }, { ARRAY_SIZE(kInstruction_sbcs_al_r9_r10_r0_ASR_1), kInstruction_sbcs_al_r9_r10_r0_ASR_1, }, { ARRAY_SIZE(kInstruction_sbcs_al_r0_r12_r10_ASR_21), kInstruction_sbcs_al_r0_r12_r10_ASR_21, }, { ARRAY_SIZE(kInstruction_sbcs_al_r11_r4_r2_ASR_32), kInstruction_sbcs_al_r11_r4_r2_ASR_32, }, { ARRAY_SIZE(kInstruction_sbcs_al_r5_r0_r2_LSR_15), kInstruction_sbcs_al_r5_r0_r2_LSR_15, }, { ARRAY_SIZE(kInstruction_sbcs_al_r8_r10_r7_ASR_14), kInstruction_sbcs_al_r8_r10_r7_ASR_14, }, { ARRAY_SIZE(kInstruction_sbcs_al_r14_r5_r3_LSR_18), kInstruction_sbcs_al_r14_r5_r3_LSR_18, }, { ARRAY_SIZE(kInstruction_sbcs_al_r2_r8_r6_ASR_6), kInstruction_sbcs_al_r2_r8_r6_ASR_6, }, { ARRAY_SIZE(kInstruction_sbcs_al_r3_r0_r4_LSR_23), kInstruction_sbcs_al_r3_r0_r4_LSR_23, }, { ARRAY_SIZE(kInstruction_sbcs_al_r3_r7_r0_LSR_13), kInstruction_sbcs_al_r3_r7_r0_LSR_13, }, { ARRAY_SIZE(kInstruction_sbcs_al_r3_r4_r10_ASR_28), kInstruction_sbcs_al_r3_r4_r10_ASR_28, }, { ARRAY_SIZE(kInstruction_sbcs_al_r3_r4_r1_ASR_6), kInstruction_sbcs_al_r3_r4_r1_ASR_6, }, { ARRAY_SIZE(kInstruction_sbcs_al_r0_r3_r8_ASR_18), kInstruction_sbcs_al_r0_r3_r8_ASR_18, }, { ARRAY_SIZE(kInstruction_sbcs_al_r5_r6_r13_LSR_2), kInstruction_sbcs_al_r5_r6_r13_LSR_2, }, { ARRAY_SIZE(kInstruction_sbcs_al_r10_r11_r14_LSR_2), kInstruction_sbcs_al_r10_r11_r14_LSR_2, }, { ARRAY_SIZE(kInstruction_sbcs_al_r10_r6_r6_ASR_17), kInstruction_sbcs_al_r10_r6_r6_ASR_17, }, { ARRAY_SIZE(kInstruction_sbcs_al_r5_r2_r3_ASR_3), kInstruction_sbcs_al_r5_r2_r3_ASR_3, }, { ARRAY_SIZE(kInstruction_sbcs_al_r14_r14_r1_LSR_19), kInstruction_sbcs_al_r14_r14_r1_LSR_19, }, { ARRAY_SIZE(kInstruction_sbcs_al_r8_r4_r7_LSR_6), kInstruction_sbcs_al_r8_r4_r7_LSR_6, }, { ARRAY_SIZE(kInstruction_sbcs_al_r12_r0_r8_LSR_29), kInstruction_sbcs_al_r12_r0_r8_LSR_29, }, { ARRAY_SIZE(kInstruction_sbcs_al_r9_r0_r1_ASR_29), kInstruction_sbcs_al_r9_r0_r1_ASR_29, }, { ARRAY_SIZE(kInstruction_sbcs_al_r7_r13_r9_ASR_10), kInstruction_sbcs_al_r7_r13_r9_ASR_10, }, { ARRAY_SIZE(kInstruction_sbcs_al_r9_r10_r1_ASR_26), kInstruction_sbcs_al_r9_r10_r1_ASR_26, }, { ARRAY_SIZE(kInstruction_sbcs_al_r1_r11_r10_ASR_30), kInstruction_sbcs_al_r1_r11_r10_ASR_30, }, { ARRAY_SIZE(kInstruction_sbcs_al_r3_r14_r6_LSR_11), kInstruction_sbcs_al_r3_r14_r6_LSR_11, }, }; #endif // VIXL_ASSEMBLER_COND_RD_RN_OPERAND_RM_SHIFT_AMOUNT_1TO32_SBCS_T32_H_
64,090
576
<reponame>agramfort/scipy-2017-sklearn<gh_stars>100-1000 from sklearn.datasets import load_digits from sklearn.model_selection import train_test_split, GridSearchCV from sklearn.ensemble import GradientBoostingClassifier digits = load_digits() X_digits, y_digits = digits.data, digits.target X_digits_train, X_digits_test, y_digits_train, y_digits_test = train_test_split(X_digits, y_digits, random_state=1) param_grid = {'learning_rate': [0.01, 0.1, 0.1, 0.5, 1.0], 'max_depth':[1, 3, 5, 7, 9]} grid = GridSearchCV(GradientBoostingClassifier(), param_grid=param_grid, cv=5, verbose=3) grid.fit(X_digits_train, y_digits_train) print('Best score for GradientBoostingClassifier: {}'.format(grid.score(X_digits_test, y_digits_test))) print('Best parameters for GradientBoostingClassifier: {}'.format(grid.best_params_))
323
711
package com.java110.common.bmo.logSystemError; import com.java110.po.logSystemError.LogSystemErrorPo; import org.springframework.http.ResponseEntity; public interface IUpdateLogSystemErrorBMO { /** * 修改系统异常 * add by wuxw * @param logSystemErrorPo * @return */ ResponseEntity<String> update(LogSystemErrorPo logSystemErrorPo); }
146
577
package javatests; public class JOverload { // ov_posprecXX public String ov_posprec1(int a,long b) { return "(int,long)"; } public String ov_posprec1(long a,int b) { return "(long,int)"; } public String ov_posprec2(long a,int b) { return "(long,int)"; } // ov_scalXX public String ov_scal1(long a) { return "(long)"; } public String ov_scal1(int a) { return "(int)"; } public String ov_scal1(short a) { return "(short)"; } public String ov_scal1(char a) { return "(char)"; } public String ov_scal1(byte a) { return "(byte)"; } public String ov_scal1(double a) { return "(double)"; } public String ov_scal1(float a) { return "(float)"; } public String ov_scal1(boolean a) { return "(boolean)"; } public String ov_scal1(java.lang.String a) { return "(java.lang.String)"; } public String ov_scal1(SubFoo a) { return "(SubFoo)"; } public String ov_scal1(Foo a) { return "(Foo)"; } public String ov_scal1(java.lang.Class a) { return "(java.lang.Class)"; } public String ov_scal1(java.io.Serializable a) { return "(java.io.Serializable)"; } public String ov_scal1(java.lang.Object a) { return "(java.lang.Object)"; } public String ov_scal2(int a) { return "(int)"; } public String ov_scal2(short a) { return "(short)"; } public String ov_scal2(char a) { return "(char)"; } public String ov_scal2(byte a) { return "(byte)"; } public String ov_scal2(double a) { return "(double)"; } public String ov_scal2(float a) { return "(float)"; } public String ov_scal2(boolean a) { return "(boolean)"; } public String ov_scal2(java.lang.String a) { return "(java.lang.String)"; } public String ov_scal2(SubFoo a) { return "(SubFoo)"; } public String ov_scal2(Foo a) { return "(Foo)"; } public String ov_scal2(java.lang.Class a) { return "(java.lang.Class)"; } public String ov_scal2(java.io.Serializable a) { return "(java.io.Serializable)"; } public String ov_scal2(java.lang.Object a) { return "(java.lang.Object)"; } public String ov_scal3(short a) { return "(short)"; } public String ov_scal3(char a) { return "(char)"; } public String ov_scal3(byte a) { return "(byte)"; } public String ov_scal3(double a) { return "(double)"; } public String ov_scal3(float a) { return "(float)"; } public String ov_scal3(boolean a) { return "(boolean)"; } public String ov_scal3(java.lang.String a) { return "(java.lang.String)"; } public String ov_scal3(SubFoo a) { return "(SubFoo)"; } public String ov_scal3(Foo a) { return "(Foo)"; } public String ov_scal3(java.lang.Class a) { return "(java.lang.Class)"; } public String ov_scal3(java.io.Serializable a) { return "(java.io.Serializable)"; } public String ov_scal3(java.lang.Object a) { return "(java.lang.Object)"; } public String ov_scal4(char a) { return "(char)"; } public String ov_scal4(byte a) { return "(byte)"; } public String ov_scal4(double a) { return "(double)"; } public String ov_scal4(float a) { return "(float)"; } public String ov_scal4(boolean a) { return "(boolean)"; } public String ov_scal4(java.lang.String a) { return "(java.lang.String)"; } public String ov_scal4(SubFoo a) { return "(SubFoo)"; } public String ov_scal4(Foo a) { return "(Foo)"; } public String ov_scal4(java.lang.Class a) { return "(java.lang.Class)"; } public String ov_scal4(java.io.Serializable a) { return "(java.io.Serializable)"; } public String ov_scal4(java.lang.Object a) { return "(java.lang.Object)"; } public String ov_scal5(byte a) { return "(byte)"; } public String ov_scal5(double a) { return "(double)"; } public String ov_scal5(float a) { return "(float)"; } public String ov_scal5(boolean a) { return "(boolean)"; } public String ov_scal5(java.lang.String a) { return "(java.lang.String)"; } public String ov_scal5(SubFoo a) { return "(SubFoo)"; } public String ov_scal5(Foo a) { return "(Foo)"; } public String ov_scal5(java.lang.Class a) { return "(java.lang.Class)"; } public String ov_scal5(java.io.Serializable a) { return "(java.io.Serializable)"; } public String ov_scal5(java.lang.Object a) { return "(java.lang.Object)"; } public String ov_scal6(double a) { return "(double)"; } public String ov_scal6(float a) { return "(float)"; } public String ov_scal6(boolean a) { return "(boolean)"; } public String ov_scal6(java.lang.String a) { return "(java.lang.String)"; } public String ov_scal6(SubFoo a) { return "(SubFoo)"; } public String ov_scal6(Foo a) { return "(Foo)"; } public String ov_scal6(java.lang.Class a) { return "(java.lang.Class)"; } public String ov_scal6(java.io.Serializable a) { return "(java.io.Serializable)"; } public String ov_scal6(java.lang.Object a) { return "(java.lang.Object)"; } public String ov_scal7(float a) { return "(float)"; } public String ov_scal7(boolean a) { return "(boolean)"; } public String ov_scal7(java.lang.String a) { return "(java.lang.String)"; } public String ov_scal7(SubFoo a) { return "(SubFoo)"; } public String ov_scal7(Foo a) { return "(Foo)"; } public String ov_scal7(java.lang.Class a) { return "(java.lang.Class)"; } public String ov_scal7(java.io.Serializable a) { return "(java.io.Serializable)"; } public String ov_scal7(java.lang.Object a) { return "(java.lang.Object)"; } public String ov_scal8(boolean a) { return "(boolean)"; } public String ov_scal8(java.lang.String a) { return "(java.lang.String)"; } public String ov_scal8(SubFoo a) { return "(SubFoo)"; } public String ov_scal8(Foo a) { return "(Foo)"; } public String ov_scal8(java.lang.Class a) { return "(java.lang.Class)"; } public String ov_scal8(java.io.Serializable a) { return "(java.io.Serializable)"; } public String ov_scal8(java.lang.Object a) { return "(java.lang.Object)"; } public String ov_scal9(java.lang.String a) { return "(java.lang.String)"; } public String ov_scal9(SubFoo a) { return "(SubFoo)"; } public String ov_scal9(Foo a) { return "(Foo)"; } public String ov_scal9(java.lang.Class a) { return "(java.lang.Class)"; } public String ov_scal9(java.io.Serializable a) { return "(java.io.Serializable)"; } public String ov_scal9(java.lang.Object a) { return "(java.lang.Object)"; } public String ov_scal10(SubFoo a) { return "(SubFoo)"; } public String ov_scal10(Foo a) { return "(Foo)"; } public String ov_scal10(java.lang.Class a) { return "(java.lang.Class)"; } public String ov_scal10(java.io.Serializable a) { return "(java.io.Serializable)"; } public String ov_scal10(java.lang.Object a) { return "(java.lang.Object)"; } public String ov_scal11(Foo a) { return "(Foo)"; } public String ov_scal11(java.lang.Class a) { return "(java.lang.Class)"; } public String ov_scal11(java.io.Serializable a) { return "(java.io.Serializable)"; } public String ov_scal11(java.lang.Object a) { return "(java.lang.Object)"; } public String ov_scal12(java.lang.Class a) { return "(java.lang.Class)"; } public String ov_scal12(java.io.Serializable a) { return "(java.io.Serializable)"; } public String ov_scal12(java.lang.Object a) { return "(java.lang.Object)"; } public String ov_scal13(java.io.Serializable a) { return "(java.io.Serializable)"; } public String ov_scal13(java.lang.Object a) { return "(java.lang.Object)"; } public String ov_scal14(java.lang.Object a) { return "(java.lang.Object)"; } }
2,700
4,197
# Copyright (C) 2020 Intel Corporation # # SPDX-License-Identifier: MIT import os import cv2 import numpy as np from model_loader import ModelLoader from skimage.measure import approximate_polygon, find_contours MASK_THRESHOLD = 0.5 # Ref: https://software.intel.com/en-us/forums/computer-vision/topic/804895 def segm_postprocess(box: list, raw_cls_mask, im_h, im_w): ymin, xmin, ymax, xmax = box width = int(abs(xmax - xmin)) height = int(abs(ymax - ymin)) result = np.zeros((im_h, im_w), dtype=np.uint8) resized_mask = cv2.resize(raw_cls_mask, dsize=(height, width), interpolation=cv2.INTER_CUBIC) # extract the ROI of the image ymin = int(round(ymin)) xmin = int(round(xmin)) ymax = ymin + height xmax = xmin + width result[xmin:xmax, ymin:ymax] = (resized_mask>MASK_THRESHOLD).astype(np.uint8) * 255 return result class ModelHandler: def __init__(self, labels): base_dir = os.path.abspath(os.environ.get("MODEL_PATH", "/opt/nuclio/open_model_zoo/public/mask_rcnn_inception_resnet_v2_atrous_coco/FP32")) model_xml = os.path.join(base_dir, "mask_rcnn_inception_resnet_v2_atrous_coco.xml") model_bin = os.path.join(base_dir, "mask_rcnn_inception_resnet_v2_atrous_coco.bin") self.model = ModelLoader(model_xml, model_bin) self.labels = labels def infer(self, image, threshold): output_layer = self.model.infer(image) results = [] masks = output_layer['masks'] boxes = output_layer['reshape_do_2d'] for index, box in enumerate(boxes): obj_class = int(box[1]) obj_value = box[2] obj_label = self.labels.get(obj_class, "unknown") if obj_value >= threshold: xtl = box[3] * image.width ytl = box[4] * image.height xbr = box[5] * image.width ybr = box[6] * image.height mask = masks[index][obj_class - 1] mask = segm_postprocess((xtl, ytl, xbr, ybr), mask, image.height, image.width) contours = find_contours(mask, MASK_THRESHOLD) contour = contours[0] contour = np.flip(contour, axis=1) contour = approximate_polygon(contour, tolerance=2.5) if len(contour) < 3: continue results.append({ "confidence": str(obj_value), "label": obj_label, "points": contour.ravel().tolist(), "type": "polygon", }) return results
1,313
6,210
<filename>src/java/org/apache/cassandra/serializers/ShortSerializer.java /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.cassandra.serializers; import java.nio.ByteBuffer; import org.apache.cassandra.db.marshal.ValueAccessor; import org.apache.cassandra.utils.ByteBufferUtil; public class ShortSerializer extends TypeSerializer<Short> { public static final ShortSerializer instance = new ShortSerializer(); public <V> Short deserialize(V value, ValueAccessor<V> accessor) { return accessor.isEmpty(value) ? null : accessor.toShort(value); } public ByteBuffer serialize(Short value) { return value == null ? ByteBufferUtil.EMPTY_BYTE_BUFFER : ByteBufferUtil.bytes(value.shortValue()); } public <V> void validate(V value, ValueAccessor<V> accessor) throws MarshalException { if (accessor.size(value) != 2) throw new MarshalException(String.format("Expected 2 bytes for a smallint (%d)", accessor.size(value))); } public String toString(Short value) { return value == null ? "" : String.valueOf(value); } public Class<Short> getType() { return Short.class; } }
617
7,470
/* * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ #include "gtest/gtest.h" #include "TestHelpers.h" #include "hermes/VM/StringPrimitive.h" #include "hermes/VM/SymbolID.h" using namespace hermes; using namespace hermes::vm; namespace { TEST(SymbolIDTest, UniquedTest) { auto id1 = SymbolID::unsafeCreateNotUniqued(0x500001); EXPECT_TRUE(id1.isNotUniqued()); EXPECT_FALSE(id1.isUniqued()); EXPECT_EQ(0x500001 | SymbolID::NOT_UNIQUED_MASK, id1.unsafeGetRaw()); EXPECT_EQ(0x500001, id1.unsafeGetIndex()); auto id2 = SymbolID::unsafeCreate(0x400007); EXPECT_TRUE(id2.isUniqued()); EXPECT_FALSE(id2.isNotUniqued()); EXPECT_EQ(0x400007, id2.unsafeGetRaw()); EXPECT_EQ(0x400007, id2.unsafeGetIndex()); } using SymbolIDRuntimeTest = RuntimeTestFixture; TEST_F(SymbolIDRuntimeTest, WriteBarrier) { // Hades adds a write barrier for symbols. Make sure it correctly captures // mutations. auto arrayResult = JSArray::create(runtime, 100, 100); ASSERT_FALSE(isException(arrayResult)); MutableHandle<JSArray> array{runtime, arrayResult->get()}; auto otherArrayResult = JSArray::create(runtime, 100, 100); ASSERT_FALSE(isException(otherArrayResult)); MutableHandle<JSArray> otherArray{runtime, otherArrayResult->get()}; MutableHandle<SymbolID> symbol{runtime}; MutableHandle<StringPrimitive> str{runtime}; for (JSArray::size_type i = 0; i < 100; i++) { GCScopeMarkerRAII marker{runtime}; std::string iAsStr = std::to_string(i); auto strRes = StringPrimitive::create( runtime, ASCIIRef{iAsStr.c_str(), iAsStr.length()}); ASSERT_FALSE(isException(strRes)); str = vmcast<StringPrimitive>(*strRes); auto symbolRes = runtime->getIdentifierTable().createNotUniquedSymbol(runtime, str); ASSERT_FALSE(isException(symbolRes)); symbol = *symbolRes; JSArray::setElementAt(array, runtime, i, symbol); } // Move everything to OG. runtime->collect("test"); // Copy symbols between arrays, and delete the symbols in the old array. // Do some allocation along the way to try and start a second OG collection. // Repeat this a few times to increase confidence that a write barrier happens // during a GC. for (int repeat = 0; repeat < 5; repeat++) { for (JSArray::size_type i = 0; i < 100; i++) { symbol = array->at(runtime, i).getSymbol(); JSArray::setElementAt(otherArray, runtime, i, symbol); // Set to undefined to execute a write barrier. JSArray::setElementAt(array, runtime, i, runtime->getUndefinedValue()); // Create some garbage to try and start an OG collection. for (int allocs = 0; allocs < 100; allocs++) { JSObject::create(runtime); } } // Swap arrays and repeat. JSArray *tmp = array.get(); array = otherArray.get(); otherArray = tmp; } } } // namespace
1,062
1,675
<gh_stars>1000+ package dev.dworks.apps.anexplorer.ui; import android.content.Context; import android.util.AttributeSet; import android.widget.FrameLayout; import androidx.annotation.NonNull; import androidx.annotation.Nullable; public class CommonFrameLayout extends FrameLayout { public CommonFrameLayout(@NonNull Context context) { super(context); } public CommonFrameLayout(@NonNull Context context, @Nullable AttributeSet attrs) { super(context, attrs); } public CommonFrameLayout(@NonNull Context context, @Nullable AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } }
216
2,219
// Copyright (c) 2013 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // This file contains internal routines that are called by other files in // base/process/. #ifndef BASE_PROCESS_INTERNAL_LINUX_H_ #define BASE_PROCESS_INTERNAL_LINUX_H_ #include <stddef.h> #include <stdint.h> #include <unistd.h> #include "base/files/dir_reader_posix.h" #include "base/files/file_path.h" #include "base/process/process_handle.h" #include "base/strings/string_number_conversions.h" #include "base/threading/platform_thread.h" namespace base { class Time; class TimeDelta; namespace internal { // "/proc" extern const char kProcDir[]; // "stat" extern const char kStatFile[]; // Returns a FilePath to "/proc/pid". base::FilePath GetProcPidDir(pid_t pid); // Reads a file from /proc into a string. This is allowed on any thread as // reading from /proc does not hit the disk. Returns true if the file can be // read and is non-empty. bool ReadProcFile(const FilePath& file, std::string* buffer); // Take a /proc directory entry named |d_name|, and if it is the directory for // a process, convert it to a pid_t. // Returns 0 on failure. // e.g. /proc/self/ will return 0, whereas /proc/1234 will return 1234. pid_t ProcDirSlotToPid(const char* d_name); // Reads /proc/<pid>/stat into |buffer|. Returns true if the file can be read // and is non-empty. bool ReadProcStats(pid_t pid, std::string* buffer); // Takes |stats_data| and populates |proc_stats| with the values split by // spaces. Taking into account the 2nd field may, in itself, contain spaces. // Returns true if successful. bool ParseProcStats(const std::string& stats_data, std::vector<std::string>* proc_stats); // Fields from /proc/<pid>/stat, 0-based. See man 5 proc. // If the ordering ever changes, carefully review functions that use these // values. enum ProcStatsFields { VM_COMM = 1, // Filename of executable, without parentheses. VM_STATE = 2, // Letter indicating the state of the process. VM_PPID = 3, // PID of the parent. VM_PGRP = 4, // Process group id. VM_MINFLT = 9, // Minor page fault count excluding children. VM_MAJFLT = 11, // Major page fault count excluding children. VM_UTIME = 13, // Time scheduled in user mode in clock ticks. VM_STIME = 14, // Time scheduled in kernel mode in clock ticks. VM_NUMTHREADS = 19, // Number of threads. VM_STARTTIME = 21, // The time the process started in clock ticks. VM_VSIZE = 22, // Virtual memory size in bytes. VM_RSS = 23, // Resident Set Size in pages. }; // Reads the |field_num|th field from |proc_stats|. Returns 0 on failure. // This version does not handle the first 3 values, since the first value is // simply |pid|, and the next two values are strings. int64_t GetProcStatsFieldAsInt64(const std::vector<std::string>& proc_stats, ProcStatsFields field_num); // Same as GetProcStatsFieldAsInt64(), but for size_t values. size_t GetProcStatsFieldAsSizeT(const std::vector<std::string>& proc_stats, ProcStatsFields field_num); // Convenience wrappers around GetProcStatsFieldAsInt64(), ParseProcStats() and // ReadProcStats(). See GetProcStatsFieldAsInt64() for details. int64_t ReadStatsFilendGetFieldAsInt64(const FilePath& stat_file, ProcStatsFields field_num); int64_t ReadProcStatsAndGetFieldAsInt64(pid_t pid, ProcStatsFields field_num); int64_t ReadProcSelfStatsAndGetFieldAsInt64(ProcStatsFields field_num); // Same as ReadProcStatsAndGetFieldAsInt64() but for size_t values. size_t ReadProcStatsAndGetFieldAsSizeT(pid_t pid, ProcStatsFields field_num); // Returns the time that the OS started. Clock ticks are relative to this. Time GetBootTime(); // Returns the amount of time spent in user space since boot across all CPUs. TimeDelta GetUserCpuTimeSinceBoot(); // Converts Linux clock ticks to a wall time delta. TimeDelta ClockTicksToTimeDelta(int clock_ticks); // Executes the lambda for every task in the process's /proc/<pid>/task // directory. The thread id and file path of the task directory are provided as // arguments to the lambda. template <typename Lambda> void ForEachProcessTask(base::ProcessHandle process, Lambda&& lambda) { // Iterate through the different threads tracked in /proc/<pid>/task. FilePath fd_path = GetProcPidDir(process).Append("task"); DirReaderPosix dir_reader(fd_path.value().c_str()); if (!dir_reader.IsValid()) return; for (; dir_reader.Next();) { const char* tid_str = dir_reader.name(); if (strcmp(tid_str, ".") == 0 || strcmp(tid_str, "..") == 0) continue; PlatformThreadId tid; if (!StringToInt(tid_str, &tid)) continue; FilePath task_path = fd_path.Append(tid_str); lambda(tid, task_path); } } } // namespace internal } // namespace base #endif // BASE_PROCESS_INTERNAL_LINUX_H_
1,823
407
<gh_stars>100-1000 # 전처리 과정 - 불 반전 갯수 계산 segment = [0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07, 0x7f, 0x6f] number = [[0 for _ in range(10)] for _ in range(10)] for i in range(10): for j in range(10): xor = segment[i] ^ segment[j] while xor: number[i][j] += (xor % 2) xor //= 2 # 입출력 - 경우의 수 계산 n, k, p, x = map(int, input().split()) count = 0 for i in range(1, n + 1): reverse = 0 temp_i = i temp_x = x for j in range(k): reverse += number[temp_i % 10][temp_x % 10] temp_i //= 10 temp_x //= 10 if 1 <= reverse <= p: count += 1 print(count)
394
3,102
//==-- fuzzer_initialize.h - Fuzz Clang ------------------------------------==// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // Defines a function that returns the command line arguments for a specific // call to the fuzz target. // //===----------------------------------------------------------------------===// #include <vector> namespace clang_fuzzer { const std::vector<const char *>& GetCLArgs(); }
163
455
<filename>core/jreleaser-model/src/test/java/org/jreleaser/model/PlatformTest.java /* * SPDX-License-Identifier: Apache-2.0 * * Copyright 2020-2022 The JReleaser authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.jreleaser.model; import org.jreleaser.util.CollectionUtils; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; import java.util.stream.Stream; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; /** * @author <NAME> * @since 0.10.0 */ public class PlatformTest { @ParameterizedTest @MethodSource("platform_inputs") public void testReplacements(String input, String output) { // given: Platform platform = new Platform(); platform.setReplacements(CollectionUtils.<String, String>map() .e("osx-x86_64", "mac") .e("aarch_64", "aarch64") .e("x86_64", "amd64") .e("osx", "darwin")); // then: assertThat(platform.applyReplacements(input), equalTo(output)); } private static Stream<Arguments> platform_inputs() { return Stream.of( Arguments.of("osx-x86_64", "mac"), Arguments.of("linux-aarch_64", "linux-aarch64"), Arguments.of("windows-x86_64", "windows-amd64"), Arguments.of("osx-aarch_64", "darwin-aarch64") ); } }
752
335
{ "word": "Homecoming", "definitions": [ "An instance of returning home.", "A reunion of former students of a university, college, or high school." ], "parts-of-speech": "Noun" }
82
1,457
<reponame>xurui1983/macvim // // NSFileManager+Verification.h // Sparkle // // Created by <NAME> on 3/16/06. // Copyright 2006 <NAME>. All rights reserved. // #import <Cocoa/Cocoa.h> // For the paranoid folks! @interface NSFileManager (SUVerification) - (BOOL)validatePath:(NSString *)path withMD5Hash:(NSString *)hash; - (BOOL)validatePath:(NSString *)path withEncodedDSASignature:(NSString *)encodedSignature; @end
152
454
<filename>Test/TestFiles/attestationOptionsU2F.json { "status":"ok", "errorMessage":"", "rp":{ "name":"localhost", "id":"localhost"}, "user":{ "name":"aseigler", "id":"ABC", "displayName":"aseigler" }, "challenge":"aL2uwApgwumBzTYCcoL0_4DRv_mfYykzgqJBFoJj_WCKNZOpvUQnyjdwMWIWKcY844tyDNLO5pQPBMJrHPz_3g", "pubKeyCredParams":[ { "type":"public-key", "alg":-7 } ], "timeout":0 }
226
354
// // Copyright (c) 2016-2017 <NAME> (<EMAIL> at <EMAIL> dot <EMAIL>) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // // Official repository: https://github.com/boostorg/beast // #ifndef BOOST_BEAST_WEBSOCKET_DETAIL_ERROR_IPP #define BOOST_BEAST_WEBSOCKET_DETAIL_ERROR_IPP #include <boost/beast/core/error.hpp> #include <boost/beast/core/string.hpp> namespace boost { namespace beast { namespace websocket { enum class error; enum class condition; } // websocket } // beast namespace system { template<> struct is_error_code_enum<beast::websocket::error> { static bool const value = true; }; template<> struct is_error_condition_enum<beast::websocket::condition> { static bool const value = true; }; } // system namespace beast { namespace websocket { namespace detail { class error_codes : public error_category { public: const char* name() const noexcept override; std::string message(int ev) const override; error_condition default_error_condition(int ev) const noexcept override; }; class error_conditions : public error_category { public: const char* name() const noexcept override; std::string message(int cv) const override; }; } // detail error_code make_error_code(error e); error_condition make_error_condition(condition c); } // websocket } // beast } // boost #endif
511
8,747
<gh_stars>1000+ #!/usr/bin/env python import os import sys import unittest try: import typing except ImportError: pass sys.path.append(os.path.join(os.path.dirname(__file__), '..')) try: import spiffsgen except ImportError: raise class SpiffsgenTest(unittest.TestCase): def test_configs(self): # type: () -> None """Run spiffsgen with different configs, and check that an image is generated (there is no exception), and the image size is as expected. """ default_config = dict( page_size=256, page_ix_len=spiffsgen.SPIFFS_PAGE_IX_LEN, block_size=4096, block_ix_len=spiffsgen.SPIFFS_BLOCK_IX_LEN, meta_len=4, obj_name_len=32, obj_id_len=spiffsgen.SPIFFS_BLOCK_IX_LEN, span_ix_len=spiffsgen.SPIFFS_SPAN_IX_LEN, packed=True, aligned=True, endianness='little', use_magic=True, use_magic_len=True, aligned_obj_ix_tables=False ) def make_config(**kwargs): # type: (typing.Any) -> spiffsgen.SpiffsBuildConfig """Return SpiffsBuildConfig object with configuration set by default_config plus any options overridden in kwargs. """ new_config = dict(default_config) new_config.update(**kwargs) return spiffsgen.SpiffsBuildConfig(**new_config) configs = [ make_config(), make_config(use_magic_len=False, use_magic=False, aligned_obj_ix_tables=True), make_config(meta_len=4, obj_name_len=16), make_config(block_size=8192), make_config(page_size=512) ] image_size = 64 * 1024 for config in configs: spiffs = spiffsgen.SpiffsFS(image_size, config) spiffs.create_file('/test', __file__) image = spiffs.to_binary() self.assertEqual(len(image), image_size) # Note: it would be nice to compile spiffs for host with the given # config, and verify that the image is parsed correctly. if __name__ == '__main__': unittest.main()
1,066
679
<filename>main/oox/source/drawingml/diagram/diagramdefinitioncontext.cxx /************************************************************** * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * *************************************************************/ #include "diagramdefinitioncontext.hxx" #include "oox/helper/helper.hxx" #include "layoutnodecontext.hxx" #include "oox/drawingml/diagram/datamodelcontext.hxx" using namespace ::oox::core; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::xml::sax; using ::rtl::OUString; namespace oox { namespace drawingml { // CT_DiagramDefinition DiagramDefinitionContext::DiagramDefinitionContext( ContextHandler& rParent, const Reference< XFastAttributeList >& xAttributes, const DiagramLayoutPtr &pLayout ) : ContextHandler( rParent ) , mpLayout( pLayout ) { OSL_TRACE( "OOX: DiagramDefinitionContext::DiagramDefinitionContext()" ); mpLayout->setDefStyle( xAttributes->getOptionalValue( XML_defStyle ) ); OUString sValue = xAttributes->getOptionalValue( XML_minVer ); if( sValue.getLength() == 0 ) { sValue = CREATE_OUSTRING( "http://schemas.openxmlformats.org/drawingml/2006/diagram" ); } mpLayout->setMinVer( sValue ); mpLayout->setUniqueId( xAttributes->getOptionalValue( XML_uniqueId ) ); } DiagramDefinitionContext::~DiagramDefinitionContext() { mpLayout->getNode()->dump(0); } void SAL_CALL DiagramDefinitionContext::endFastElement( ::sal_Int32 ) throw (SAXException, RuntimeException) { } Reference< XFastContextHandler > SAL_CALL DiagramDefinitionContext::createFastChildContext( ::sal_Int32 aElement, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException) { Reference< XFastContextHandler > xRet; switch( aElement ) { case DGM_TOKEN( title ): mpLayout->setTitle( xAttribs->getOptionalValue( XML_val ) ); break; case DGM_TOKEN( desc ): mpLayout->setDesc( xAttribs->getOptionalValue( XML_val ) ); break; case DGM_TOKEN( layoutNode ): mpLayout->getNode().reset( new LayoutNode() ); xRet.set( new LayoutNodeContext( *this, xAttribs, mpLayout->getNode() ) ); break; case DGM_TOKEN( clrData ): // TODO, does not matter for the UI. skip. return xRet; case DGM_TOKEN( sampData ): mpLayout->getSampData().reset( new DiagramData ); xRet.set( new DataModelContext( *this, mpLayout->getSampData() ) ); break; case DGM_TOKEN( styleData ): mpLayout->getStyleData().reset( new DiagramData ); xRet.set( new DataModelContext( *this, mpLayout->getStyleData() ) ); break; case DGM_TOKEN( cat ): case DGM_TOKEN( catLst ): // TODO, does not matter for the UI default: break; } if( !xRet.is() ) xRet.set(this); return xRet; } } }
1,176
852
<reponame>Purva-Chaudhari/cmssw // -*- C++ -*- // // Package: Tracks // Class : FWPFDetailView #include "Rtypes.h" #include "Fireworks/Core/interface/FWDetailViewGL.h" #include "Fireworks/Core/interface/CSGActionSupervisor.h" #include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h" class TGLEmbeddedViewer; class FWIntValueListener; class TEveCaloLego; class TGSlider; namespace reco { // class PFCandidate; class PFRecHit; class PFCluster; class PFRecTrack; } // namespace reco class FWPFCandidateDetailView : public FWDetailViewGL<reco::PFCandidate>, public CSGActionSupervisor { public: FWPFCandidateDetailView(); ~FWPFCandidateDetailView() override; FWPFCandidateDetailView(const FWPFCandidateDetailView &) = delete; // stop default const FWPFCandidateDetailView &operator=(const FWPFCandidateDetailView &) = delete; // stop default private: using FWDetailView<reco::PFCandidate>::build; void build(const FWModelId &id, const reco::PFCandidate *) override; void setTextInfo(const FWModelId &id, const reco::PFCandidate *) override; void makeLegend(void); bool isPntInRng(float x, float y); void rangeChanged(int x); void plotEtChanged(); void rnrHcalChanged(); void buildGLEventScene(); void voteMaxEtEVal(const std::vector<reco::PFRecHit> *hits); void addHits(const std::vector<reco::PFRecHit> *); void addClusters(const std::vector<reco::PFCluster> *); void addTracks(const std::vector<reco::PFRecTrack> *); float eta(); float phi(); float etaMin() { return eta() - m_range; } float etaMax() { return eta() + m_range; } float phiMin() { return phi() - m_range; } float phiMax() { return phi() + m_range; } float m_range; const reco::PFCandidate *m_candidate; TLegend *m_legend; TGSlider *m_slider; FWIntValueListener *m_sliderListener; TEveElementList *m_eventList; bool m_plotEt; bool m_rnrHcal; };
735
420
<filename>seahub/shortcuts.py # Copyright (c) 2012-2016 Seafile Ltd. # encoding: utf-8 def get_first_object_or_none(queryset): """ A shortcut to obtain the first object of a queryset if it exists or None otherwise. """ try: return queryset[:1][0] except IndexError: return None
129
310
<filename>nncf/torch/quantization/init_range.py """ Copyright (c) 2021 Intel Corporation Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. """ from collections import OrderedDict from copy import deepcopy from typing import Callable from typing import Dict from typing import List from typing import Set from typing import Tuple import numpy as np import torch from nncf.common.graph.layer_attributes import WeightedLayerAttributes from nncf.common.quantization.initialization.range import RangeInitConfig from nncf.common.quantization.initialization.range import RangeInitParams from nncf.common.quantization.quantizer_setup import QuantizationPointBase from nncf.common.quantization.quantizer_setup import QuantizerSetupBase from nncf.torch.quantization.layers import get_scale_shape from nncf.common.quantization.structs import NonWeightQuantizerId from nncf.common.quantization.structs import QuantizerGroup from nncf.common.quantization.structs import QuantizerId from nncf.common.quantization.structs import WeightQuantizerId from nncf.common.utils.helpers import should_consider_scope from nncf.torch.graph.graph import PTNNCFGraph from nncf.torch.initialization import DataLoaderBaseRunner from nncf.torch.nncf_network import NNCFNetwork from nncf.torch.quantization.layers import BaseQuantizer from nncf.torch.quantization.translator import PTTargetPointTranslator from nncf.torch.tensor_statistics.algo import TensorStatisticObservationPoint from nncf.torch.tensor_statistics.collectors import MeanMinMaxStatisticCollector from nncf.torch.tensor_statistics.collectors import MeanPercentileStatisticCollector from nncf.torch.tensor_statistics.collectors import MedianMADStatisticCollector from nncf.torch.tensor_statistics.collectors import MinMaxStatisticCollector from nncf.torch.tensor_statistics.collectors import PercentileStatisticCollector from nncf.torch.tensor_statistics.collectors import ReductionShape from nncf.torch.tensor_statistics.collectors import TensorStatisticCollectorBase from nncf.torch.tensor_statistics.statistics import MinMaxTensorStatistic class PTRangeInitParams(RangeInitParams): def get_max_num_init_steps(self) -> int: steps = [] if self.global_init_config is not None: steps.append(self.global_init_config.num_init_samples) for pl_config in self.per_layer_range_init_configs: steps.append(pl_config.num_init_samples) batch_size = self.init_range_data_loader.batch_size return int(np.ceil(max(steps) / batch_size)) def get_init_config_for_quantization_point(self, qp: QuantizationPointBase) -> RangeInitConfig: if qp.is_weight_quantization_point(): qid = WeightQuantizerId(qp.insertion_point.target_node_name) group = QuantizerGroup.WEIGHTS else: qid = NonWeightQuantizerId(qp.insertion_point.target_node_name, qp.insertion_point.input_port_id) group = QuantizerGroup.ACTIVATIONS return self.get_init_config_for_scope_and_group(qid, group) def get_init_config_for_scope_and_group(self, qid: QuantizerId, group: QuantizerGroup) -> RangeInitConfig: matches = [] # type: List[RangeInitConfig] for pl_config in self.per_layer_range_init_configs: if should_consider_scope(qid, pl_config.ignored_scopes, pl_config.target_scopes): if group == pl_config.target_group or pl_config.target_group is None: matches.append(RangeInitConfig(pl_config.init_type, pl_config.num_init_samples, pl_config.init_type_specific_params)) if len(matches) > 1: raise ValueError("Location {} matches more than one per-layer initialization parameter " "definition!".format(str(qid))) if len(matches) == 1: return matches[0] if not matches and self.global_init_config is not None: return deepcopy(self.global_init_config) raise ValueError("Location {} does not match any per-layer initialization parameter " "definition!".format(str(qid))) class StatCollectorGenerator: @staticmethod def generate_collectors_for_range_init_statistics_collection(target_model_graph: PTNNCFGraph, quantizer_setup: QuantizerSetupBase, range_init_params: PTRangeInitParams) -> \ Dict[TensorStatisticObservationPoint, TensorStatisticCollectorBase]: retval = {} for qp in quantizer_setup.quantization_points.values(): init_config = range_init_params.get_init_config_for_quantization_point(qp) is_weights = qp.is_weight_quantization_point() num_batches = int(np.ceil( init_config.num_init_samples / range_init_params.init_range_data_loader.batch_size)) if is_weights: # No need to store extra statistics in memory since weights won't change during range init num_batches = 1 tp = PTTargetPointTranslator.translate(qp.insertion_point) obs_p = TensorStatisticObservationPoint( tp, reduction_shapes=set(StatCollectorGenerator.get_all_scale_shapes(qp, target_model_graph))) collector = StatCollectorGenerator.generate_stat_collector_for_range_init_config( init_config, obs_p.reduction_shapes, num_samples_to_collect_override=num_batches) retval[obs_p] = collector return retval @staticmethod def generate_stat_collector_for_range_init_config( init_config: RangeInitConfig, reduction_shapes: Set[ReductionShape] = None, num_samples_to_collect_override: int = None) -> TensorStatisticCollectorBase: num_samples = init_config.num_init_samples if num_samples_to_collect_override is not None: num_samples = num_samples_to_collect_override if init_config.init_type == "min_max": return MinMaxStatisticCollector(reduction_shapes, num_samples) if init_config.init_type == "mean_min_max": return MeanMinMaxStatisticCollector(reduction_shapes, num_samples) if init_config.init_type == "threesigma": return MedianMADStatisticCollector(reduction_shapes, num_samples) if init_config.init_type == "percentile": min_percentile = init_config.init_type_specific_params.get("min_percentile", 0.1) max_percentile = init_config.init_type_specific_params.get("max_percentile", 99.9) return PercentileStatisticCollector([min_percentile, max_percentile], reduction_shapes, num_samples) if init_config.init_type == "mean_percentile": min_percentile = init_config.init_type_specific_params.get("min_percentile", 0.1) max_percentile = init_config.init_type_specific_params.get("max_percentile", 99.9) return MeanPercentileStatisticCollector([min_percentile, max_percentile], reduction_shapes, num_samples) raise RuntimeError("Unknown range init type: {}".format(init_config.init_type)) @staticmethod def get_all_scale_shapes(qp: QuantizationPointBase, target_nncf_graph: PTNNCFGraph) -> List[Tuple[int]]: qconfigs = qp.get_all_configs_list() if qp.is_weight_quantization_point(): module_node = target_nncf_graph.get_node_by_name(qp.insertion_point.target_node_name) layer_attributes = module_node.layer_attributes assert isinstance(layer_attributes, WeightedLayerAttributes) input_shape = layer_attributes.get_weight_shape() channel_idx = layer_attributes.get_target_dim_for_compression() else: input_shape = target_nncf_graph.get_input_shape_for_insertion_point(qp.insertion_point) channel_idx = 1 # channel dim for activations retval = [] for qconfig in qconfigs: retval.append(tuple(get_scale_shape(input_shape, is_weights=qp.is_weight_quantization_point(), per_channel=qconfig.per_channel, channel_idx=channel_idx))) return retval class DataLoaderRangeInitializeRunner(DataLoaderBaseRunner): def __init__( self, model: NNCFNetwork, modules_to_init_vs_init_configs: Dict[str, Tuple[torch.nn.Module, RangeInitConfig]], init_device: str, batch_size: int = None ): super().__init__(model, init_device) self.modules_to_init = modules_to_init_vs_init_configs self.progressbar_description = 'Range parameters initialization' #pylint:disable=line-too-long self.collectors_and_modules_to_init = OrderedDict() # type: Dict[str, Tuple[TensorStatisticCollectorBase, BaseQuantizer]] self.hook_handles = [] self.batch_size = batch_size def _get_fwd_hook(self, collector: TensorStatisticCollectorBase) -> Callable: def fwd_hook(module, input_, output): collector.register_input(input_[0]) return fwd_hook def _prepare_initialization(self): for name, data in self.modules_to_init.items(): quantizer_module, init_config = data # type: BaseQuantizer, RangeInitConfig num_samples_override = None if self.batch_size is not None: num_batches = np.ceil(init_config.num_init_samples / self.batch_size) num_samples_override = num_batches collector = StatCollectorGenerator.generate_stat_collector_for_range_init_config( init_config, {tuple(quantizer_module.scale_shape)}, num_samples_override ) self.collectors_and_modules_to_init[name] = collector, quantizer_module self.hook_handles.append( quantizer_module.register_forward_hook(self._get_fwd_hook(collector)) ) def _apply_initializers(self): for handle in self.hook_handles: handle.remove() for scope_str, collector_and_module in self.collectors_and_modules_to_init.items(): collector, quantizer_module = collector_and_module scale_shape = tuple(quantizer_module.scale_shape) target_stat = collector.get_statistics()[scale_shape] minmax_stats = MinMaxTensorStatistic.from_stat(target_stat) quantizer_module.apply_minmax_init(minmax_stats.min_values, minmax_stats.max_values, log_module_name=scope_str)
4,890
1,856
<filename>RxLifecycleDemo/app/src/main/java/com/yl/rxlifecycledemo/RxLifecycleNaviActivity.java package com.yl.rxlifecycledemo; import android.os.Bundle; import android.util.Log; import com.trello.navi2.component.NaviActivity; import com.trello.rxlifecycle2.LifecycleProvider; import com.trello.rxlifecycle2.android.ActivityEvent; import com.trello.rxlifecycle2.navi.NaviLifecycle; import java.util.concurrent.TimeUnit; import butterknife.ButterKnife; import io.reactivex.Observable; import io.reactivex.Observer; import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.annotations.NonNull; import io.reactivex.disposables.Disposable; import io.reactivex.schedulers.Schedulers; /** * compile 'com.trello.rxlifecycle2:rxlifecycle-navi:2.1.0' * Created by yangle on 2017/7/4. */ public class RxLifecycleNaviActivity extends NaviActivity { private final LifecycleProvider<ActivityEvent> provider = NaviLifecycle.createActivityLifecycleProvider(this); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_rxlifecycle); ButterKnife.bind(this); initData(); } private void initData() { Observable.interval(1, TimeUnit.SECONDS) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .compose(provider.<Long>bindUntilEvent(ActivityEvent.DESTROY)) .subscribe(new Observer<Long>() { @Override public void onSubscribe(@NonNull Disposable d) { } @Override public void onNext(@NonNull Long aLong) { Log.i("接收数据", String.valueOf(aLong)); } @Override public void onError(@NonNull Throwable e) { } @Override public void onComplete() { } }); } @Override protected void onStart() { super.onStart(); Observable.interval(1, TimeUnit.SECONDS) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .compose(provider.<Long>bindToLifecycle()) .subscribe(new Observer<Long>() { @Override public void onSubscribe(@NonNull Disposable d) { } @Override public void onNext(@NonNull Long aLong) { Log.i("接收数据", String.valueOf(aLong)); } @Override public void onError(@NonNull Throwable e) { } @Override public void onComplete() { } }); } }
1,525
1,273
package org.broadinstitute.hellbender.utils.dragstr; import org.broadinstitute.hellbender.engine.GATKPath; import org.broadinstitute.hellbender.testutils.BaseTest; import org.testng.Assert; import org.testng.annotations.Test; import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; import java.util.Arrays; /** * Unit test for class {@link DragstrParams}. */ public class DragstrParamsUnitTest extends BaseTest { public static final String TEST_PARAMS_FILE = "org/broadinstitute/hellbender/utils/dragstr/dna_nexus_novaseq_plus0_0_params.txt"; @Test public void testToString() throws IOException { final String inputParamsFile = ("src/test/resources/" + TEST_PARAMS_FILE); final DragstrParams subject = DragstrParamUtils.parse(new GATKPath(inputParamsFile)); Assert.assertNotNull(subject.toString()); final File pathFile = new File(subject.toString()); Assert.assertEquals(pathFile.getCanonicalFile(), new File(inputParamsFile).getCanonicalFile()); } @Test public void testReadWriteAndQuery() throws IOException { final String inputParamsFile = ("src/test/resources/" + TEST_PARAMS_FILE); final File outputParamsFile = File.createTempFile("dragst-params-test", ".txt"); outputParamsFile.deleteOnExit(); final DragstrParams subject = DragstrParamUtils.parse(new GATKPath(inputParamsFile)); DragstrParamUtils.print(subject, new GATKPath(outputParamsFile.toPath().toString())); try (final BufferedReader r1 = new BufferedReader(new FileReader(inputParamsFile)); final BufferedReader r2 = new BufferedReader(new FileReader(outputParamsFile))) { String l1, l2; Query query = null; int row = 0; while ((l1 = readRelevantLine(r1)) != null & (l2 = readRelevantLine(r2)) != null) { // We test the read-and-write checking that the content of the new copied params file is the same as the original (except from some irrelevant white-spaces.) Assert.assertEquals(l1.trim(), l2.trim()); // To test the query here we implement a simple and independent parsing of the table rows and check // that the values read match the ones return by the subject. // When we encounter a table header we update the query lambda appropriately and reset the table row index. if (l1.contains("GOP")) { query = subject::gop; row = 0; } else if (l1.contains("GCP")) { query = subject::gcp; row = 0; } else if (l1.contains("API")) { query = subject::api; row = 0; } else if (query != null) { // when we read in a table row, we check that the subject returns the same values for that row/period and repeat length/column. row++; // The way the tables are formatted split return empty string (first or last) element so we filter them out using a stream. final String[] l2parts = Arrays.stream(l2.split("\\s+")).filter(s -> !s.trim().isEmpty()).toArray(String[]::new); Assert.assertEquals(l2parts.length, subject.maximumRepeats(), l2); for (int i = 0; i < l2parts.length; i++) { final double expected = Double.parseDouble(l2parts[i]); final double actual = query.get(row, i + 1); Assert.assertEquals(actual, expected, 0.001); } } } Assert.assertNull(l1); Assert.assertNull(l2); } finally { outputParamsFile.delete(); } } private String readRelevantLine(final BufferedReader reader) throws IOException { String line; while ((line = reader.readLine()) != null) { if (!line.startsWith("#") && !line.trim().isEmpty()) { return line; } } return null; } @Test(dependsOnMethods = "testReadWriteAndQuery") public void additionalSelfConsistencyTests() { final String filePath = ("src/test/resources/" + TEST_PARAMS_FILE); final DragstrParams params = DragstrParamUtils.parse(new GATKPath(filePath)); Assert.assertEquals(params.maximumPeriod(), 8); // we know this for a fact. Assert.assertEquals(params.maximumRepeats(), 20); // we know this for a fact. Assert.assertEquals(params.maximumLengthInBasePairs(), params.maximumRepeats() * params.maximumPeriod()); for (int i = 1; i <= params.maximumPeriod(); i++) { // For each table, we check that repeat lengths larger than the maximum record return the same value as the maximum. // We test maximum + 1 and maximum + N where N >>> 1 Assert.assertEquals(params.gop(i, params.maximumRepeats()), params.gop(i, params.maximumRepeats() + 1)); Assert.assertEquals(params.gop(i, params.maximumRepeats()), params.gop(i, params.maximumRepeats() * 31 + 11)); // any large repeat-length would do. Assert.assertEquals(params.gcp(i, params.maximumRepeats()), params.gcp(i, params.maximumRepeats() + 1)); Assert.assertEquals(params.gcp(i, params.maximumRepeats()), params.gcp(i, params.maximumRepeats() * 131 + 911)); // any large repeat-length would do. Assert.assertEquals(params.api(i, params.maximumRepeats()), params.api(i, params.maximumRepeats() + 1)); Assert.assertEquals(params.api(i, params.maximumRepeats()), params.api(i, params.maximumRepeats() * 311 + 1193)); // any large repeat-length would do. } } @FunctionalInterface interface Query { double get(final int period, final int repeat); } }
2,419
2,195
<filename>app/src/main/cpp/log.h #include <android/log.h> #ifdef LOG_NDEBUG #define LOGI(...) #define LOGE(...) #define LOGV(...) #define LOGD(...) #else #define LOGI(...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__) #define LOGE(...) __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__) #define LOGV(...) __android_log_print(ANDROID_LOG_VERBOSE,LOG_TAG,__VA_ARGS__) #define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__) #endif #ifndef LOG #define LOG(priority, tag, ...) \ LOG_PRI(ANDROID_##priority, tag, __VA_ARGS__) #endif #ifndef LOG_PRI #define LOG_PRI(priority, tag, ...) \ __android_log_print(priority, tag, __VA_ARGS__) #endif #ifndef LOG_ASSERT #define LOG_ASSERT(cond, ...) LOG_FATAL_IF(!(cond), ## __VA_ARGS__) #endif #ifndef LOG_FATAL_IF #define LOG_FATAL_IF(cond, ...) LOG_ALWAYS_FATAL_IF(cond, ## __VA_ARGS__) #endif #ifndef LOG_ALWAYS_FATAL_IF #define LOG_ALWAYS_FATAL_IF(cond, ...) \ ( (CONDITION(cond)) \ ? ((void)android_printAssert(#cond, LOG_TAG, ## __VA_ARGS__)) \ : (void)0 ) #endif #ifndef CONDITION #define CONDITION(cond) (__builtin_expect((cond)!=0, 0)) #endif #define android_printAssert(a, b, ...) printf("%s: ", __VA_ARGS__)
560
358
<filename>setup.py<gh_stars>100-1000 from setuptools import setup version_dict = {} exec(open("./torchbearer/version.py").read(), version_dict) import sys if sys.version_info[0] >= 3: from os import path this_directory = path.abspath(path.dirname(__file__)) with open(path.join(this_directory, 'README.md'), encoding='utf-8') as f: long_description = f.read() else: long_description = 'A model training library for pytorch' setup( name='torchbearer', version=version_dict['__version__'], packages=['torchbearer', 'torchbearer.metrics', 'torchbearer.callbacks', 'torchbearer.callbacks.imaging', 'tests', 'tests.metrics', 'tests.callbacks', 'tests.callbacks.imaging'], url='https://github.com/pytorchbearer/torchbearer', download_url='https://github.com/pytorchbearer/torchbearer/archive/' + version_dict['__version__'] + '.tar.gz', classifiers=[ "License :: OSI Approved :: MIT License" ], author='<NAME>', author_email='<EMAIL>', description='A model training library for pytorch', long_description=long_description, long_description_content_type='text/markdown', install_requires=['torch>=1.0.0', 'numpy', 'tqdm'], python_requires='>=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*', )
507
407
package com.alibaba.tesla.appmanager.server.repository.domain; import java.util.ArrayList; import java.util.Date; import java.util.List; public class NamespaceDOExample { protected String orderByClause; protected boolean distinct; protected List<Criteria> oredCriteria; public NamespaceDOExample() { oredCriteria = new ArrayList<>(); } public void setOrderByClause(String orderByClause) { this.orderByClause = orderByClause; } public String getOrderByClause() { return orderByClause; } public void setDistinct(boolean distinct) { this.distinct = distinct; } public boolean isDistinct() { return distinct; } public List<Criteria> getOredCriteria() { return oredCriteria; } public void or(Criteria criteria) { oredCriteria.add(criteria); } public Criteria or() { Criteria criteria = createCriteriaInternal(); oredCriteria.add(criteria); return criteria; } public Criteria createCriteria() { Criteria criteria = createCriteriaInternal(); if (oredCriteria.size() == 0) { oredCriteria.add(criteria); } return criteria; } protected Criteria createCriteriaInternal() { Criteria criteria = new Criteria(); return criteria; } public void clear() { oredCriteria.clear(); orderByClause = null; distinct = false; } protected abstract static class GeneratedCriteria { protected List<Criterion> criteria; protected GeneratedCriteria() { super(); criteria = new ArrayList<>(); } public boolean isValid() { return criteria.size() > 0; } public List<Criterion> getAllCriteria() { return criteria; } public List<Criterion> getCriteria() { return criteria; } protected void addCriterion(String condition) { if (condition == null) { throw new RuntimeException("Value for condition cannot be null"); } criteria.add(new Criterion(condition)); } protected void addCriterion(String condition, Object value, String property) { if (value == null) { throw new RuntimeException("Value for " + property + " cannot be null"); } criteria.add(new Criterion(condition, value)); } protected void addCriterion(String condition, Object value1, Object value2, String property) { if (value1 == null || value2 == null) { throw new RuntimeException("Between values for " + property + " cannot be null"); } criteria.add(new Criterion(condition, value1, value2)); } public Criteria andIdIsNull() { addCriterion("id is null"); return (Criteria) this; } public Criteria andIdIsNotNull() { addCriterion("id is not null"); return (Criteria) this; } public Criteria andIdEqualTo(Long value) { addCriterion("id =", value, "id"); return (Criteria) this; } public Criteria andIdNotEqualTo(Long value) { addCriterion("id <>", value, "id"); return (Criteria) this; } public Criteria andIdGreaterThan(Long value) { addCriterion("id >", value, "id"); return (Criteria) this; } public Criteria andIdGreaterThanOrEqualTo(Long value) { addCriterion("id >=", value, "id"); return (Criteria) this; } public Criteria andIdLessThan(Long value) { addCriterion("id <", value, "id"); return (Criteria) this; } public Criteria andIdLessThanOrEqualTo(Long value) { addCriterion("id <=", value, "id"); return (Criteria) this; } public Criteria andIdIn(List<Long> values) { addCriterion("id in", values, "id"); return (Criteria) this; } public Criteria andIdNotIn(List<Long> values) { addCriterion("id not in", values, "id"); return (Criteria) this; } public Criteria andIdBetween(Long value1, Long value2) { addCriterion("id between", value1, value2, "id"); return (Criteria) this; } public Criteria andIdNotBetween(Long value1, Long value2) { addCriterion("id not between", value1, value2, "id"); return (Criteria) this; } public Criteria andGmtCreateIsNull() { addCriterion("gmt_create is null"); return (Criteria) this; } public Criteria andGmtCreateIsNotNull() { addCriterion("gmt_create is not null"); return (Criteria) this; } public Criteria andGmtCreateEqualTo(Date value) { addCriterion("gmt_create =", value, "gmtCreate"); return (Criteria) this; } public Criteria andGmtCreateNotEqualTo(Date value) { addCriterion("gmt_create <>", value, "gmtCreate"); return (Criteria) this; } public Criteria andGmtCreateGreaterThan(Date value) { addCriterion("gmt_create >", value, "gmtCreate"); return (Criteria) this; } public Criteria andGmtCreateGreaterThanOrEqualTo(Date value) { addCriterion("gmt_create >=", value, "gmtCreate"); return (Criteria) this; } public Criteria andGmtCreateLessThan(Date value) { addCriterion("gmt_create <", value, "gmtCreate"); return (Criteria) this; } public Criteria andGmtCreateLessThanOrEqualTo(Date value) { addCriterion("gmt_create <=", value, "gmtCreate"); return (Criteria) this; } public Criteria andGmtCreateIn(List<Date> values) { addCriterion("gmt_create in", values, "gmtCreate"); return (Criteria) this; } public Criteria andGmtCreateNotIn(List<Date> values) { addCriterion("gmt_create not in", values, "gmtCreate"); return (Criteria) this; } public Criteria andGmtCreateBetween(Date value1, Date value2) { addCriterion("gmt_create between", value1, value2, "gmtCreate"); return (Criteria) this; } public Criteria andGmtCreateNotBetween(Date value1, Date value2) { addCriterion("gmt_create not between", value1, value2, "gmtCreate"); return (Criteria) this; } public Criteria andGmtModifiedIsNull() { addCriterion("gmt_modified is null"); return (Criteria) this; } public Criteria andGmtModifiedIsNotNull() { addCriterion("gmt_modified is not null"); return (Criteria) this; } public Criteria andGmtModifiedEqualTo(Date value) { addCriterion("gmt_modified =", value, "gmtModified"); return (Criteria) this; } public Criteria andGmtModifiedNotEqualTo(Date value) { addCriterion("gmt_modified <>", value, "gmtModified"); return (Criteria) this; } public Criteria andGmtModifiedGreaterThan(Date value) { addCriterion("gmt_modified >", value, "gmtModified"); return (Criteria) this; } public Criteria andGmtModifiedGreaterThanOrEqualTo(Date value) { addCriterion("gmt_modified >=", value, "gmtModified"); return (Criteria) this; } public Criteria andGmtModifiedLessThan(Date value) { addCriterion("gmt_modified <", value, "gmtModified"); return (Criteria) this; } public Criteria andGmtModifiedLessThanOrEqualTo(Date value) { addCriterion("gmt_modified <=", value, "gmtModified"); return (Criteria) this; } public Criteria andGmtModifiedIn(List<Date> values) { addCriterion("gmt_modified in", values, "gmtModified"); return (Criteria) this; } public Criteria andGmtModifiedNotIn(List<Date> values) { addCriterion("gmt_modified not in", values, "gmtModified"); return (Criteria) this; } public Criteria andGmtModifiedBetween(Date value1, Date value2) { addCriterion("gmt_modified between", value1, value2, "gmtModified"); return (Criteria) this; } public Criteria andGmtModifiedNotBetween(Date value1, Date value2) { addCriterion("gmt_modified not between", value1, value2, "gmtModified"); return (Criteria) this; } public Criteria andNamespaceIdIsNull() { addCriterion("namespace_id is null"); return (Criteria) this; } public Criteria andNamespaceIdIsNotNull() { addCriterion("namespace_id is not null"); return (Criteria) this; } public Criteria andNamespaceIdEqualTo(String value) { addCriterion("namespace_id =", value, "namespaceId"); return (Criteria) this; } public Criteria andNamespaceIdNotEqualTo(String value) { addCriterion("namespace_id <>", value, "namespaceId"); return (Criteria) this; } public Criteria andNamespaceIdGreaterThan(String value) { addCriterion("namespace_id >", value, "namespaceId"); return (Criteria) this; } public Criteria andNamespaceIdGreaterThanOrEqualTo(String value) { addCriterion("namespace_id >=", value, "namespaceId"); return (Criteria) this; } public Criteria andNamespaceIdLessThan(String value) { addCriterion("namespace_id <", value, "namespaceId"); return (Criteria) this; } public Criteria andNamespaceIdLessThanOrEqualTo(String value) { addCriterion("namespace_id <=", value, "namespaceId"); return (Criteria) this; } public Criteria andNamespaceIdLike(String value) { addCriterion("namespace_id like", value, "namespaceId"); return (Criteria) this; } public Criteria andNamespaceIdNotLike(String value) { addCriterion("namespace_id not like", value, "namespaceId"); return (Criteria) this; } public Criteria andNamespaceIdIn(List<String> values) { addCriterion("namespace_id in", values, "namespaceId"); return (Criteria) this; } public Criteria andNamespaceIdNotIn(List<String> values) { addCriterion("namespace_id not in", values, "namespaceId"); return (Criteria) this; } public Criteria andNamespaceIdBetween(String value1, String value2) { addCriterion("namespace_id between", value1, value2, "namespaceId"); return (Criteria) this; } public Criteria andNamespaceIdNotBetween(String value1, String value2) { addCriterion("namespace_id not between", value1, value2, "namespaceId"); return (Criteria) this; } public Criteria andNamespaceNameIsNull() { addCriterion("namespace_name is null"); return (Criteria) this; } public Criteria andNamespaceNameIsNotNull() { addCriterion("namespace_name is not null"); return (Criteria) this; } public Criteria andNamespaceNameEqualTo(String value) { addCriterion("namespace_name =", value, "namespaceName"); return (Criteria) this; } public Criteria andNamespaceNameNotEqualTo(String value) { addCriterion("namespace_name <>", value, "namespaceName"); return (Criteria) this; } public Criteria andNamespaceNameGreaterThan(String value) { addCriterion("namespace_name >", value, "namespaceName"); return (Criteria) this; } public Criteria andNamespaceNameGreaterThanOrEqualTo(String value) { addCriterion("namespace_name >=", value, "namespaceName"); return (Criteria) this; } public Criteria andNamespaceNameLessThan(String value) { addCriterion("namespace_name <", value, "namespaceName"); return (Criteria) this; } public Criteria andNamespaceNameLessThanOrEqualTo(String value) { addCriterion("namespace_name <=", value, "namespaceName"); return (Criteria) this; } public Criteria andNamespaceNameLike(String value) { addCriterion("namespace_name like", value, "namespaceName"); return (Criteria) this; } public Criteria andNamespaceNameNotLike(String value) { addCriterion("namespace_name not like", value, "namespaceName"); return (Criteria) this; } public Criteria andNamespaceNameIn(List<String> values) { addCriterion("namespace_name in", values, "namespaceName"); return (Criteria) this; } public Criteria andNamespaceNameNotIn(List<String> values) { addCriterion("namespace_name not in", values, "namespaceName"); return (Criteria) this; } public Criteria andNamespaceNameBetween(String value1, String value2) { addCriterion("namespace_name between", value1, value2, "namespaceName"); return (Criteria) this; } public Criteria andNamespaceNameNotBetween(String value1, String value2) { addCriterion("namespace_name not between", value1, value2, "namespaceName"); return (Criteria) this; } public Criteria andNamespaceCreatorIsNull() { addCriterion("namespace_creator is null"); return (Criteria) this; } public Criteria andNamespaceCreatorIsNotNull() { addCriterion("namespace_creator is not null"); return (Criteria) this; } public Criteria andNamespaceCreatorEqualTo(String value) { addCriterion("namespace_creator =", value, "namespaceCreator"); return (Criteria) this; } public Criteria andNamespaceCreatorNotEqualTo(String value) { addCriterion("namespace_creator <>", value, "namespaceCreator"); return (Criteria) this; } public Criteria andNamespaceCreatorGreaterThan(String value) { addCriterion("namespace_creator >", value, "namespaceCreator"); return (Criteria) this; } public Criteria andNamespaceCreatorGreaterThanOrEqualTo(String value) { addCriterion("namespace_creator >=", value, "namespaceCreator"); return (Criteria) this; } public Criteria andNamespaceCreatorLessThan(String value) { addCriterion("namespace_creator <", value, "namespaceCreator"); return (Criteria) this; } public Criteria andNamespaceCreatorLessThanOrEqualTo(String value) { addCriterion("namespace_creator <=", value, "namespaceCreator"); return (Criteria) this; } public Criteria andNamespaceCreatorLike(String value) { addCriterion("namespace_creator like", value, "namespaceCreator"); return (Criteria) this; } public Criteria andNamespaceCreatorNotLike(String value) { addCriterion("namespace_creator not like", value, "namespaceCreator"); return (Criteria) this; } public Criteria andNamespaceCreatorIn(List<String> values) { addCriterion("namespace_creator in", values, "namespaceCreator"); return (Criteria) this; } public Criteria andNamespaceCreatorNotIn(List<String> values) { addCriterion("namespace_creator not in", values, "namespaceCreator"); return (Criteria) this; } public Criteria andNamespaceCreatorBetween(String value1, String value2) { addCriterion("namespace_creator between", value1, value2, "namespaceCreator"); return (Criteria) this; } public Criteria andNamespaceCreatorNotBetween(String value1, String value2) { addCriterion("namespace_creator not between", value1, value2, "namespaceCreator"); return (Criteria) this; } public Criteria andNamespaceModifierIsNull() { addCriterion("namespace_modifier is null"); return (Criteria) this; } public Criteria andNamespaceModifierIsNotNull() { addCriterion("namespace_modifier is not null"); return (Criteria) this; } public Criteria andNamespaceModifierEqualTo(String value) { addCriterion("namespace_modifier =", value, "namespaceModifier"); return (Criteria) this; } public Criteria andNamespaceModifierNotEqualTo(String value) { addCriterion("namespace_modifier <>", value, "namespaceModifier"); return (Criteria) this; } public Criteria andNamespaceModifierGreaterThan(String value) { addCriterion("namespace_modifier >", value, "namespaceModifier"); return (Criteria) this; } public Criteria andNamespaceModifierGreaterThanOrEqualTo(String value) { addCriterion("namespace_modifier >=", value, "namespaceModifier"); return (Criteria) this; } public Criteria andNamespaceModifierLessThan(String value) { addCriterion("namespace_modifier <", value, "namespaceModifier"); return (Criteria) this; } public Criteria andNamespaceModifierLessThanOrEqualTo(String value) { addCriterion("namespace_modifier <=", value, "namespaceModifier"); return (Criteria) this; } public Criteria andNamespaceModifierLike(String value) { addCriterion("namespace_modifier like", value, "namespaceModifier"); return (Criteria) this; } public Criteria andNamespaceModifierNotLike(String value) { addCriterion("namespace_modifier not like", value, "namespaceModifier"); return (Criteria) this; } public Criteria andNamespaceModifierIn(List<String> values) { addCriterion("namespace_modifier in", values, "namespaceModifier"); return (Criteria) this; } public Criteria andNamespaceModifierNotIn(List<String> values) { addCriterion("namespace_modifier not in", values, "namespaceModifier"); return (Criteria) this; } public Criteria andNamespaceModifierBetween(String value1, String value2) { addCriterion("namespace_modifier between", value1, value2, "namespaceModifier"); return (Criteria) this; } public Criteria andNamespaceModifierNotBetween(String value1, String value2) { addCriterion("namespace_modifier not between", value1, value2, "namespaceModifier"); return (Criteria) this; } public Criteria andNamespaceExtIsNull() { addCriterion("namespace_ext is null"); return (Criteria) this; } public Criteria andNamespaceExtIsNotNull() { addCriterion("namespace_ext is not null"); return (Criteria) this; } public Criteria andNamespaceExtEqualTo(String value) { addCriterion("namespace_ext =", value, "namespaceExt"); return (Criteria) this; } public Criteria andNamespaceExtNotEqualTo(String value) { addCriterion("namespace_ext <>", value, "namespaceExt"); return (Criteria) this; } public Criteria andNamespaceExtGreaterThan(String value) { addCriterion("namespace_ext >", value, "namespaceExt"); return (Criteria) this; } public Criteria andNamespaceExtGreaterThanOrEqualTo(String value) { addCriterion("namespace_ext >=", value, "namespaceExt"); return (Criteria) this; } public Criteria andNamespaceExtLessThan(String value) { addCriterion("namespace_ext <", value, "namespaceExt"); return (Criteria) this; } public Criteria andNamespaceExtLessThanOrEqualTo(String value) { addCriterion("namespace_ext <=", value, "namespaceExt"); return (Criteria) this; } public Criteria andNamespaceExtLike(String value) { addCriterion("namespace_ext like", value, "namespaceExt"); return (Criteria) this; } public Criteria andNamespaceExtNotLike(String value) { addCriterion("namespace_ext not like", value, "namespaceExt"); return (Criteria) this; } public Criteria andNamespaceExtIn(List<String> values) { addCriterion("namespace_ext in", values, "namespaceExt"); return (Criteria) this; } public Criteria andNamespaceExtNotIn(List<String> values) { addCriterion("namespace_ext not in", values, "namespaceExt"); return (Criteria) this; } public Criteria andNamespaceExtBetween(String value1, String value2) { addCriterion("namespace_ext between", value1, value2, "namespaceExt"); return (Criteria) this; } public Criteria andNamespaceExtNotBetween(String value1, String value2) { addCriterion("namespace_ext not between", value1, value2, "namespaceExt"); return (Criteria) this; } } public static class Criteria extends GeneratedCriteria { protected Criteria() { super(); } } public static class Criterion { private String condition; private Object value; private Object secondValue; private boolean noValue; private boolean singleValue; private boolean betweenValue; private boolean listValue; private String typeHandler; public String getCondition() { return condition; } public Object getValue() { return value; } public Object getSecondValue() { return secondValue; } public boolean isNoValue() { return noValue; } public boolean isSingleValue() { return singleValue; } public boolean isBetweenValue() { return betweenValue; } public boolean isListValue() { return listValue; } public String getTypeHandler() { return typeHandler; } protected Criterion(String condition) { super(); this.condition = condition; this.typeHandler = null; this.noValue = true; } protected Criterion(String condition, Object value, String typeHandler) { super(); this.condition = condition; this.value = value; this.typeHandler = typeHandler; if (value instanceof List<?>) { this.listValue = true; } else { this.singleValue = true; } } protected Criterion(String condition, Object value) { this(condition, value, null); } protected Criterion(String condition, Object value, Object secondValue, String typeHandler) { super(); this.condition = condition; this.value = value; this.secondValue = secondValue; this.typeHandler = typeHandler; this.betweenValue = true; } protected Criterion(String condition, Object value, Object secondValue) { this(condition, value, secondValue, null); } } }
10,802
687
<filename>demos/stm32f103ve/drivers/drv_clk.c /* * Copyright (c) 2006-2019, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * * Change Logs: * Date Author Notes * 2019-10-26 ChenYong first version * 2020-01-08 xiangxistu add HSI configuration * 2020-04-20 chenyaxing add system_clock_config frequency parameter */ #include <stm32f1xx.h> #include <stdio.h> void _error_handler(char *s, int num); #ifndef Error_Handler #define Error_Handler() _error_handler(__FILE__, __LINE__) #endif void system_clock_config(int target_freq_Mhz) { RCC_OscInitTypeDef RCC_OscInitStruct = {0}; RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; /** Initializes the CPU, AHB and APB busses clocks */ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI; RCC_OscInitStruct.HSIState = RCC_HSI_ON; RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT; RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI_DIV2; #if defined(STM32F100xB) || defined(STM32F100xE) RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL6; #endif #if defined(STM32F101x6) || defined(STM32F101xB) || defined(STM32F101xE) || defined(STM32F101xG) RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL9; #endif #if defined(STM32F102x6) || defined(STM32F102xB) RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL12; #endif #if defined(STM32F103x6) || defined(STM32F103xB) || defined(STM32F103xE) || defined(STM32F103xG) RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL16; #endif #if defined(STM32F105xC) || defined(STM32F107xC) RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL9; #endif if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { Error_Handler(); } /** Initializes the CPU, AHB and APB busses clocks */ RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2; RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2; RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; #if defined(STM32F100xB) || defined(STM32F100xE) if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0) != HAL_OK) #endif #if defined(STM32F101x6) || defined(STM32F101xB) || defined(STM32F101xE) || defined(STM32F101xG) if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK) #endif #if defined(STM32F102x6) || defined(STM32F102xB) if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK) #endif #if defined(STM32F103x6) || defined(STM32F103xB) || defined(STM32F103xE) || defined(STM32F103xG) if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK) #endif #if defined(STM32F105xC) || defined(STM32F107xC) if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK) #endif { Error_Handler(); } } int clock_information(void) { printf("System Clock information\n"); printf("SYSCLK_Frequency = %d\n", (int) HAL_RCC_GetSysClockFreq()); printf("HCLK_Frequency = %d\n", (int) HAL_RCC_GetHCLKFreq()); printf("PCLK1_Frequency = %d\n", (int) HAL_RCC_GetPCLK1Freq()); printf("PCLK2_Frequency = %d\n", (int) HAL_RCC_GetPCLK2Freq()); return 0; } void wait_ms(unsigned long ms_time) { HAL_Delay(ms_time); }
1,671
14,668
<reponame>zealoussnow/chromium<gh_stars>1000+ // Copyright 2017 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef THIRD_PARTY_BLINK_RENDERER_CORE_WORKERS_SHARED_WORKER_REPORTING_PROXY_H_ #define THIRD_PARTY_BLINK_RENDERER_CORE_WORKERS_SHARED_WORKER_REPORTING_PROXY_H_ #include "third_party/blink/renderer/core/workers/parent_execution_context_task_runners.h" #include "third_party/blink/renderer/core/workers/worker_reporting_proxy.h" #include "third_party/blink/renderer/platform/heap/garbage_collected.h" namespace blink { class WebSharedWorkerImpl; // An implementation of WorkerReportingProxy for SharedWorker. This is created // and owned by WebSharedWorkerImpl on the main thread, accessed from a worker // thread, and destroyed on the main thread. class SharedWorkerReportingProxy final : public GarbageCollected<SharedWorkerReportingProxy>, public WorkerReportingProxy { public: SharedWorkerReportingProxy(WebSharedWorkerImpl*, ParentExecutionContextTaskRunners*); SharedWorkerReportingProxy(const SharedWorkerReportingProxy&) = delete; SharedWorkerReportingProxy& operator=(const SharedWorkerReportingProxy&) = delete; ~SharedWorkerReportingProxy() override; // WorkerReportingProxy methods: void CountFeature(WebFeature) override; void ReportException(const WTF::String&, std::unique_ptr<SourceLocation>, int exception_id) override; void ReportConsoleMessage(mojom::ConsoleMessageSource, mojom::ConsoleMessageLevel, const String& message, SourceLocation*) override; void DidFailToFetchClassicScript() override; void DidFailToFetchModuleScript() override; void DidEvaluateTopLevelScript(bool success) override; void DidCloseWorkerGlobalScope() override; void WillDestroyWorkerGlobalScope() override {} void DidTerminateWorkerThread() override; void Trace(Visitor*) const; private: // Not owned because this outlives the reporting proxy. WebSharedWorkerImpl* worker_; Member<ParentExecutionContextTaskRunners> parent_execution_context_task_runners_; }; } // namespace blink #endif // THIRD_PARTY_BLINK_RENDERER_CORE_WORKERS_SHARED_WORKER_REPORTING_PROXY_H_
850
1,198
/* Copyright 2017-2019 Google Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS-IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #include "benchmark/benchmark.h" #include "gmock/gmock.h" #include "gtest/gtest.h" #include "lullaby/modules/script/function_binder.h" #include "lullaby/modules/lullscript/script_env.h" #include "lullaby/util/math.h" #include "lullaby/util/registry.h" namespace lull { namespace { using ::testing::Eq; static void RegisterTestFunctions(FunctionBinder* binder) { binder->RegisterFunction("FlipBool", [](bool x) { return !x; }); binder->RegisterFunction( "AddInt16", [](int16_t x) { return static_cast<int16_t>(x + 1); }); binder->RegisterFunction( "AddInt32", [](int32_t x) { return static_cast<int32_t>(x + 1); }); binder->RegisterFunction( "AddInt64", [](int64_t x) { return static_cast<int64_t>(x + 1); }); binder->RegisterFunction( "AddUInt16", [](uint16_t x) { return static_cast<uint16_t>(x + 1); }); binder->RegisterFunction( "AddUInt32", [](uint32_t x) { return static_cast<uint32_t>(x + 1); }); binder->RegisterFunction( "AddUInt64", [](uint64_t x) { return static_cast<uint64_t>(x + 1); }); binder->RegisterFunction("RepeatString", [](const std::string& s) { return s + s; }); binder->RegisterFunction("RotateVec2", [](const mathfu::vec2& v) { return mathfu::vec2(v.y, v.x); }); binder->RegisterFunction("RotateVec3", [](const mathfu::vec3& v) { return mathfu::vec3(v.y, v.z, v.x); }); binder->RegisterFunction("RotateVec4", [](const mathfu::vec4& v) { return mathfu::vec4(v.y, v.z, v.w, v.x); }); binder->RegisterFunction("RotateQuat", [](const mathfu::quat& v) { return mathfu::quat(v.vector().x, v.vector().y, v.vector().z, v.scalar()); }); } static const char* kBenchmarkTestSrc = "(do " "(= bool (FlipBool true)) " "(= int16 (AddInt32 123)) " "(= int32 (AddInt32 123)) " "(= int64 (AddInt32 123)) " "(= uint16 (AddInt32 123)) " "(= uint32 (AddInt32 123)) " "(= uint64 (AddInt32 123)) " "(= entity (AddInt32 123)) " "(= entity (AddInt32 123)) " "(= str (RepeatString 'abc')) " "(= v2 (RotateVec2 (vec2 1.0f 2.0f))) " "(= v3 (RotateVec3 (vec3 1.0f 2.0f 3.0f))) " "(= v4 (RotateVec4 (vec4 1.0f 2.0f 3.0f 4.0f))) " "(= qt (RotateQuat (quat 1.0f 2.0f 3.0f 4.0f))) " ")"; static void BM_Lullscript(benchmark::State& state) { Registry registry; FunctionBinder binder(&registry); RegisterTestFunctions(&binder); ScriptEnv env; env.SetFunctionCallHandler( [&binder](FunctionCall* call) { binder.Call(call); }); auto script = env.Read(kBenchmarkTestSrc); while (state.KeepRunning()) { env.Eval(script); } } BENCHMARK(BM_Lullscript); // This test verifies that the benchmark code actually behaves correctly. TEST(ScriptEnvBenchmarkTest, BenchmarkTestVerification) { Registry registry; FunctionBinder binder(&registry); RegisterTestFunctions(&binder); ScriptEnv env; env.SetFunctionCallHandler( [&binder](FunctionCall* call) { binder.Call(call); }); auto script = env.Read(kBenchmarkTestSrc); env.Eval(script); EXPECT_THAT(*env.GetValue(Symbol("bool")).Get<bool>(), Eq(false)); EXPECT_THAT(*env.GetValue(Symbol("int16")).Get<int32_t>(), Eq(124)); EXPECT_THAT(*env.GetValue(Symbol("int32")).Get<int32_t>(), Eq(124)); EXPECT_THAT(*env.GetValue(Symbol("int64")).Get<int32_t>(), Eq(124)); EXPECT_THAT(*env.GetValue(Symbol("uint16")).Get<int32_t>(), Eq(124)); EXPECT_THAT(*env.GetValue(Symbol("uint32")).Get<int32_t>(), Eq(124)); EXPECT_THAT(*env.GetValue(Symbol("uint64")).Get<int32_t>(), Eq(124)); EXPECT_THAT(*env.GetValue(Symbol("entity")).Get<int32_t>(), Eq(124)); EXPECT_THAT(*env.GetValue(Symbol("str")).Get<std::string>(), Eq(std::string("abcabc"))); auto v2 = *env.GetValue(Symbol("v2")).Get<mathfu::vec2>(); auto v3 = *env.GetValue(Symbol("v3")).Get<mathfu::vec3>(); auto v4 = *env.GetValue(Symbol("v4")).Get<mathfu::vec4>(); auto qt = *env.GetValue(Symbol("qt")).Get<mathfu::quat>(); EXPECT_THAT(v2, Eq(mathfu::vec2(2, 1))); EXPECT_THAT(v3, Eq(mathfu::vec3(2, 3, 1))); EXPECT_THAT(v4, Eq(mathfu::vec4(2, 3, 4, 1))); EXPECT_THAT(qt.vector(), Eq(mathfu::quat(2, 3, 4, 1).vector())); EXPECT_THAT(qt.scalar(), Eq(mathfu::quat(2, 3, 4, 1).scalar())); } } // namespace } // namespace lull
2,000
337
<reponame>qussarah/declare<filename>idea/testData/refactoring/safeDelete/deleteClass/kotlinClassWithJava/classWithDelegationCalls.java class J extends B { public J() { super(); } }
77
678
<filename>cl0ver/src/lib/exploit.h #ifndef EXPLOIT_H #define EXPLOIT_H #include <stdbool.h> // bool #include <mach/mach_types.h> // task_t void panic_leak(void); void dump_kernel(const char *path); task_t get_kernel_task(const char *dir); bool patch_host_special_port_4(task_t kernel_task); #endif
144
2,151
<reponame>zipated/src /* Conversion functions for notes. Copyright (C) 2007, 2009 Red Hat, Inc. This file is part of elfutils. This file is free software; you can redistribute it and/or modify it under the terms of either * the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version or * the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version or both in parallel, as here. elfutils 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 General Public License for more details. You should have received copies of the GNU General Public License and the GNU Lesser General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ static void elf_cvt_note (void *dest, const void *src, size_t len, int encode) { assert (sizeof (Elf32_Nhdr) == sizeof (Elf64_Nhdr)); while (len >= sizeof (Elf32_Nhdr)) { (1 ? Elf32_cvt_Nhdr : Elf64_cvt_Nhdr) (dest, src, sizeof (Elf32_Nhdr), encode); const Elf32_Nhdr *n = encode ? src : dest; Elf32_Word namesz = NOTE_ALIGN (n->n_namesz); Elf32_Word descsz = NOTE_ALIGN (n->n_descsz); len -= sizeof *n; src += sizeof *n; dest += sizeof *n; if (namesz > len) break; len -= namesz; if (descsz > len) break; len -= descsz; if (src != dest) memcpy (dest, src, namesz + descsz); src += namesz + descsz; dest += namesz + descsz; } }
666
6,304
<reponame>mohad12211/skia<filename>docs/examples/default.cpp // Copyright 2020 Google LLC. // Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. #include "tools/fiddle/examples.h" REG_FIDDLE(default, 256, 256, false, 0) { void draw(SkCanvas* canvas) { SkPaint p; p.setColor(SK_ColorRED); p.setAntiAlias(true); p.setStyle(SkPaint::kStroke_Style); p.setStrokeWidth(10); canvas->drawLine(20, 20, 236, 236, p); } } // END FIDDLE
201
348
<filename>docs/data/leg-t2/068/06806376.json {"nom":"Wittenheim","circ":"6ème circonscription","dpt":"Haut-Rhin","inscrits":10221,"abs":6656,"votants":3565,"blancs":186,"nuls":63,"exp":3316,"res":[{"nuance":"REM","nom":"<NAME>","voix":1792},{"nuance":"FN","nom":"M. <NAME>","voix":1524}]}
120
372
/* Editor Settings: expandtabs and use 4 spaces for indentation * ex: set softtabstop=4 tabstop=8 expandtab shiftwidth=4: * * -*- mode: c, c-basic-offset: 4 -*- */ /* * Copyright © BeyondTrust Software 2004 - 2019 * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * BEYONDTRUST MAKES THIS SOFTWARE AVAILABLE UNDER OTHER LICENSING TERMS AS * WELL. IF YOU HAVE ENTERED INTO A SEPARATE LICENSE AGREEMENT WITH * BEYONDTRUST, THEN YOU MAY ELECT TO USE THE SOFTWARE UNDER THE TERMS OF THAT * SOFTWARE LICENSE AGREEMENT INSTEAD OF THE TERMS OF THE APACHE LICENSE, * NOTWITHSTANDING THE ABOVE NOTICE. IF YOU HAVE QUESTIONS, OR WISH TO REQUEST * A COPY OF THE ALTERNATE LICENSING TERMS OFFERED BY BEYONDTRUST, PLEASE CONTACT * BEYONDTRUST AT beyondtrust.com/contact */ /* * Copyright (C) BeyondTrust Software. All rights reserved. * * Module Name: * * provider-main.h * * Abstract: * * BeyondTrust Security and Authentication Subsystem (LSASS) * * Active Directory Authentication Provider * * Authors: <NAME> (<EMAIL>) * <NAME> (<EMAIL>) * <NAME> (<EMAIL>) * <NAME> (<EMAIL>) * <NAME> (<EMAIL>) */ #ifndef __OFFLINE_H__ #define __OFFLINE_H__ BOOLEAN AD_IsOffline( PLSA_AD_PROVIDER_STATE pState ); DWORD AD_OfflineAuthenticateUserPam( PAD_PROVIDER_CONTEXT pContext, LSA_AUTH_USER_PAM_PARAMS* pParams, PLSA_AUTH_USER_PAM_INFO* ppPamAuthInfo ); DWORD AD_OfflineEnumUsers( PAD_PROVIDER_CONTEXT pContext, HANDLE hResume, DWORD dwMaxNumUsers, PDWORD pdwUsersFound, PVOID** pppUserInfoList ); DWORD AD_OfflineEnumGroups( PAD_PROVIDER_CONTEXT pContext, HANDLE hResume, DWORD dwMaxGroups, PDWORD pdwGroupsFound, PVOID** pppGroupInfoList ); DWORD AD_OfflineChangePassword( PAD_PROVIDER_CONTEXT pContext, PCSTR pszUserName, PCSTR pszPassword, PCSTR pszOldPassword ); DWORD AD_OfflineFindNSSArtefactByKey( PAD_PROVIDER_CONTEXT pContext, PCSTR pszKeyName, PCSTR pszMapName, DWORD dwInfoLevel, LSA_NIS_MAP_QUERY_FLAGS dwFlags, PVOID* ppNSSArtefactInfo ); DWORD AD_OfflineEnumNSSArtefacts( PAD_PROVIDER_CONTEXT pContext, HANDLE hResume, DWORD dwMaxNSSArtefacts, PDWORD pdwNSSArtefactsFound, PVOID** pppNSSArtefactInfoList ); DWORD AD_OfflineInitializeOperatingMode( OUT PAD_PROVIDER_DATA* ppProviderData, IN PAD_PROVIDER_CONTEXT pContext, IN PCSTR pszDomain, IN PCSTR pszHostName ); DWORD AD_OfflineFindObjects( IN PAD_PROVIDER_CONTEXT pContext, IN LSA_FIND_FLAGS FindFlags, IN OPTIONAL LSA_OBJECT_TYPE ObjectType, IN LSA_QUERY_TYPE QueryType, IN DWORD dwCount, IN LSA_QUERY_LIST QueryList, OUT PLSA_SECURITY_OBJECT** pppObjects ); DWORD AD_OfflineQueryMemberOf( PAD_PROVIDER_CONTEXT pContext, IN LSA_FIND_FLAGS FindFlags, IN DWORD dwSidCount, IN PSTR* ppszSids, OUT PDWORD pdwGroupSidCount, OUT PSTR** pppszGroupSids ); DWORD AD_OfflineGetGroupMemberSids( IN PAD_PROVIDER_CONTEXT pContext, IN LSA_FIND_FLAGS FindFlags, IN PCSTR pszSid, OUT PDWORD pdwSidCount, OUT PSTR** pppszSids ); #endif /* __OFFLINE_H__ */
1,532
892
{ "schema_version": "1.2.0", "id": "GHSA-g893-8gjr-xqxv", "modified": "2022-05-13T01:24:43Z", "published": "2022-05-13T01:24:43Z", "aliases": [ "CVE-2016-2059" ], "details": "The msm_ipc_router_bind_control_port function in net/ipc_router/ipc_router_core.c in the IPC router kernel module for the Linux kernel 3.x, as used in Qualcomm Innovation Center (QuIC) Android contributions for MSM devices and other products, does not verify that a port is a client port, which allows attackers to gain privileges or cause a denial of service (race condition and list corruption) by making many BIND_CONTROL_PORT ioctl calls.", "severity": [ { "type": "CVSS_V3", "score": "CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:H" } ], "affected": [ ], "references": [ { "type": "ADVISORY", "url": "https://nvd.nist.gov/vuln/detail/CVE-2016-2059" }, { "type": "WEB", "url": "https://us.codeaurora.org/cgit/quic/la/kernel/msm-3.18/commit/?id=9e8bdd63f7011dff5523ea435433834b3702398d" }, { "type": "WEB", "url": "https://www.codeaurora.org/projects/security-advisories/linux-ipc-router-binding-any-port-control-port-cve-2016-2059" }, { "type": "WEB", "url": "http://source.android.com/security/bulletin/2016-10-01.html" }, { "type": "WEB", "url": "http://www.securityfocus.com/bid/90230" }, { "type": "WEB", "url": "http://www.securitytracker.com/id/1035765" } ], "database_specific": { "cwe_ids": [ "CWE-269" ], "severity": "HIGH", "github_reviewed": false } }
760
2,151
<filename>ios/public/provider/chrome/browser/mailto/mailto_handler_provider.h // Copyright 2018 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef IOS_PUBLIC_PROVIDER_CHROME_BROWSER_MAILTO_MAILTO_HANDLER_PROVIDER_H_ #define IOS_PUBLIC_PROVIDER_CHROME_BROWSER_MAILTO_MAILTO_HANDLER_PROVIDER_H_ #import <UIKit/UIKit.h> #include "base/macros.h" namespace ios { class ChromeBrowserState; } // namespace ios @class ChromeIdentity; typedef ChromeIdentity* (^SignedInIdentityBlock)(void); typedef NSArray<ChromeIdentity*>* (^SignedInIdentitiesBlock)(void); // An provider to handle the opening of mailto links. class MailtoHandlerProvider { public: MailtoHandlerProvider(); virtual ~MailtoHandlerProvider(); // Set up mailto handling for the current browser state. virtual void PrepareMailtoHandling(ios::ChromeBrowserState* browserState); // Deprecated: Set up mailto handling for the current user. // The Signed-In Identity Block should return the primary signed in user. // The Signed-In Identities Block should return all users signed in to Chrome. virtual void PrepareMailtoHandling( SignedInIdentityBlock signed_in_identity_block, SignedInIdentitiesBlock signed_in_identities_block); // Returns a properly localized title for the menu item or button used to open // the settings for this handler. Returns nil if mailto handling is not // supported by the provider. virtual NSString* MailtoHandlerSettingsTitle() const; // Creates and returns a view controller for presenting the settings for // mailto handling to the user. Returns nil if mailto handling is not // supported by the provider. virtual UIViewController* MailtoHandlerSettingsController() const; // Dismisses any mailto handling UI immediately. Handling is cancelled. virtual void DismissAllMailtoHandlerInterfaces() const; // Handles the specified mailto: URL. The provider falls back on the built-in // URL handling in case of error. virtual void HandleMailtoURL(NSURL* url) const; private: DISALLOW_COPY_AND_ASSIGN(MailtoHandlerProvider); }; #endif // IOS_PUBLIC_PROVIDER_CHROME_BROWSER_MAILTO_MAILTO_HANDLER_PROVIDER_H_
672
326
<reponame>wanghongxiang2018/postgres-x2 /*------------------------------------------------------------------------- * * clogdesc.c * rmgr descriptor routines for access/transam/clog.c * * Portions Copyright (c) 1996-2013, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * * IDENTIFICATION * src/backend/access/rmgrdesc/clogdesc.c * *------------------------------------------------------------------------- */ #include "postgres.h" #include "access/clog.h" void clog_desc(StringInfo buf, uint8 xl_info, char *rec) { uint8 info = xl_info & ~XLR_INFO_MASK; if (info == CLOG_ZEROPAGE) { int pageno; memcpy(&pageno, rec, sizeof(int)); appendStringInfo(buf, "zeropage: %d", pageno); } else if (info == CLOG_TRUNCATE) { int pageno; memcpy(&pageno, rec, sizeof(int)); appendStringInfo(buf, "truncate before: %d", pageno); } else appendStringInfo(buf, "UNKNOWN"); }
350
1,085
<filename>sabot/kernel/src/main/java/com/dremio/exec/planner/logical/rule/LogicalAggregateGroupKeyFixRule.java /* * Copyright (C) 2017-2019 Dremio Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.dremio.exec.planner.logical.rule; import java.util.ArrayList; import java.util.List; import org.apache.calcite.linq4j.Ord; import org.apache.calcite.plan.RelOptRule; import org.apache.calcite.plan.RelOptRuleCall; import org.apache.calcite.rel.RelNode; import org.apache.calcite.rel.core.Aggregate.Group; import org.apache.calcite.rel.core.AggregateCall; import org.apache.calcite.rel.logical.LogicalAggregate; import org.apache.calcite.rex.RexNode; import org.apache.calcite.tools.RelBuilder; import org.apache.calcite.tools.RelBuilder.AggCall; import org.apache.calcite.tools.RelBuilder.GroupKey; import org.apache.calcite.util.ImmutableBitSet; import org.apache.calcite.util.mapping.Mapping; import org.apache.calcite.util.mapping.MappingType; import org.apache.calcite.util.mapping.Mappings; import com.dremio.exec.planner.logical.RelOptHelper; import com.google.common.collect.ImmutableList; /** * Rule to rewrite aggregate so that the group keys are always first in the input, e.g. * groupSet = {0,2} * will become * groupSet = {0,1} * with an appropriate project added below */ public class LogicalAggregateGroupKeyFixRule { public static final RelOptRule RULE = new RelOptRule( RelOptHelper.any(LogicalAggregate.class, RelNode.class), "LogicalAggregateGroupKeyFix") { @Override public boolean matches(RelOptRuleCall call) { LogicalAggregate agg = call.rel(0); if (!(agg.getGroupType() == Group.SIMPLE)) { return false; } // only need to apply the rule if the group set does not contain continuous values starting with 0 if (agg.getGroupSet().equals(ImmutableBitSet.range(agg.getGroupSet().cardinality()))) { return false; } return true; } @Override public void onMatch(RelOptRuleCall call) { LogicalAggregate agg = call.rel(0); Mapping inputMapping = Mappings.create(MappingType.BIJECTION, agg.getInput().getRowType().getFieldCount(), agg.getInput().getRowType().getFieldCount()); for (Ord<Integer> groupKey : Ord.zip(agg.getGroupSet())) { int source = groupKey.e; int target = groupKey.i; inputMapping.set(source, target); } int target = agg.getGroupCount(); for (int i = 0; i < agg.getInput().getRowType().getFieldCount(); i++) { if (!agg.getGroupSet().get(i)) { inputMapping.set(i, target++); } } RelBuilder relBuilder = call.builder(); relBuilder.push(agg.getInput()); relBuilder.project(relBuilder.fields(Mappings.invert(inputMapping))); GroupKey groupKey = relBuilder.groupKey(Mappings.apply(inputMapping, agg.getGroupSet()), null); List<AggCall> newAggCallList = new ArrayList<>(); for (AggregateCall aggCall : agg.getAggCallList()) { final ImmutableList<RexNode> args = relBuilder.fields( Mappings.apply2(inputMapping, aggCall.getArgList())); RelBuilder.AggCall newAggCall = relBuilder.aggregateCall(aggCall.getAggregation(), args) .distinct(aggCall.isDistinct()) .approximate(aggCall.isApproximate()) .sort(relBuilder.fields(aggCall.collation)) .as(aggCall.name); newAggCallList.add(newAggCall); } relBuilder.aggregate(groupKey, newAggCallList); call.transformTo(relBuilder.build()); } }; }
1,521
670
<reponame>MSPaintIDE/MSPaintIDE package com.uddernetworks.mspaint.texteditor; import com.uddernetworks.mspaint.main.StartupLogic; import com.uddernetworks.mspaint.ocr.FontData; import com.uddernetworks.newocr.detection.SearchImage; import com.uddernetworks.newocr.recognition.Actions; import com.uddernetworks.newocr.recognition.OCRScan; import com.uddernetworks.newocr.utils.IntPair; import com.uddernetworks.newocr.utils.OCRUtils; import it.unimi.dsi.fastutil.chars.Char2IntMap; import it.unimi.dsi.fastutil.chars.Char2IntOpenHashMap; import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import javax.imageio.ImageIO; import java.awt.*; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import java.util.HashMap; import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; public class CenterPopulator { private final Char2IntMap def = new Char2IntOpenHashMap(); private Map<FontData, Int2ObjectMap<Char2IntMap>> centers = new HashMap<>(); private StartupLogic startupLogic; public CenterPopulator(StartupLogic startupLogic) { this.startupLogic = startupLogic; } // Code loosely adapted from com.uddernetworks.newocr.OCRHandle.java // TODO: Clean this up a ton :( public void generateCenters(int fontSize) throws IOException { var activeFont = this.startupLogic.getOCRManager().getActiveFont(); if (centers.containsKey(activeFont) && centers.get(activeFont).containsKey(fontSize)) return; var currentCenters = new Char2IntOpenHashMap(); centers.computeIfAbsent(activeFont, x -> new Int2ObjectOpenHashMap<>()).put(fontSize, currentCenters); var input = new BufferedImage(10, 10, BufferedImage.TYPE_INT_ARGB); var graphics = input.createGraphics(); graphics.setRenderingHints(new RenderingHints(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON)); var font = new Font(activeFont.getFontName(), Font.PLAIN, fontSize); graphics.setFont(font); input = new BufferedImage(graphics.getFontMetrics().stringWidth(OCRScan.RAW_STRING) + 50, fontSize * 2, BufferedImage.TYPE_INT_ARGB); graphics = input.createGraphics(); graphics.setRenderingHints(new RenderingHints(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON)); graphics.setFont(font); graphics.setColor(Color.BLACK); clearImage(input); graphics.drawString(OCRScan.RAW_STRING, 10, fontSize); var centerCalcFile = new File(System.getProperty("java.io.tmpdir"), "center_calc.png"); ImageIO.write(input, "png", centerCalcFile); // Goes through coordinates of image and adds any connecting pixels to `coordinates` var scanImage = activeFont.getScan().scanImage(centerCalcFile).stripLeadingSpaces(); var currentLetter = new AtomicInteger(); var lineBound = getLineBounds(input, activeFont.getActions()); scanImage.getGridLineAtIndex(0).get().forEach(imageLetter -> { if (currentLetter.get() == OCRScan.RAW_STRING.indexOf("W W")) return; var letter = OCRScan.RAW_STRING.charAt(currentLetter.getAndIncrement()); var topOfLetterToCenter = imageLetter.getY() - lineBound.getKey(); // Extra space above character to Y currentCenters.put(letter, topOfLetterToCenter); }); } private IntPair getLineBounds(BufferedImage input, Actions actions) { OCRUtils.filter(input); var values = OCRUtils.createGrid(input); OCRUtils.toGrid(input, values); var searchImage = new SearchImage(values); return actions.getLineBoundsForTraining(searchImage).get(0); } public int getCenter(char cha, int fontSize) { var activeFont = this.startupLogic.getOCRManager().getActiveFont(); if (!centers.containsKey(activeFont)) return 0; return centers.get(activeFont).getOrDefault(fontSize, def).getOrDefault(cha, 0); } private void clearImage(BufferedImage image) { for (int y = 0; y < image.getHeight(); y++) { for (int x = 0; x < image.getWidth(); x++) { image.setRGB(x, y, Color.WHITE.getRGB()); } } } }
1,669
1,319
<filename>ST_DM/GenRegion/src/generate/conf.py # -*- coding: utf-8 -*- ######################################################################## # # Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved # ######################################################################## """ File: conf.py Author: duanjianguo(<EMAIL>) Date: 2019/11/14 10:13:37 """ class Conf(object): """ Desc: 所有资源路径 """ # 名族列表 # 各种level prov_level = 1 city_level = 2 city_other_level = 21 county_level = 3 town_level = 4 shangquan_level = 41 block_level = 5 block_other_level = 51 # Ming's experiment exp_beijing_file = "../result/block_beijing" exp_ny_file = "../result/block_ny" exp_bj_file = "../result/block_bj" # result from online source exp_sh_file = "../result/block_shanghai" exp_cd_file = "../result/block_chengdu" exp_sz_file = "../result/block_shenzhen" exp_wh_file = "../result/block_wuhan" new_york_raw = "../data/NewYork_Edgelist.csv" beijing_raw = "../data/Beijing_Edgelist.csv" shanghai_raw = "../data/Shangai_Edgelist.csv" chengdu_raw = "../data/Chengdu_Edgelist.csv" shenzhen_raw = "../data/Shenzhen_Edgelist.csv" wuhan_raw = "../data/Wuhan_Edgelist.csv" # gridize grid_level1 = 65536 grid_level2 = 8192 grid_level3 = 1024 # simp threshold min_poly_area = 100 # 低于此面积的polygon,丢弃 # simp_threshold = 16 # 线段抽稀的阈值 # block gen min_aoi_area = 1000 # 低于此面积的aoi,将不参与block的生成,但会作为aoi数据 min_block_area = 10000 # block的最小 area min_block_width = 20 # block的最小 area / length clust_width = 25 # 聚类的半径 block_simp_threshold = 8 # block的线段抽稀阈值 # intersect_aoi_ratio = 0.8 # 交集的部分占aoi面积的比例,必须 > intersect_aoi_ratio # intersect_block_ratio = 0.6 # 交集的部分占block面积的比例,必须 > intersect_block_ratio
974
678
<filename>Cydia_Build_cpp/apt-extra/config.h<gh_stars>100-1000 #undef WORDS_BIGENDIAN #define HAVE_TIMEGM //#cmakedefine HAVE_ZLIB //#cmakedefine HAVE_BZ2 //#cmakedefine HAVE_LZMA //#cmakedefine HAVE_LZ4 /* These two are used by the statvfs shim for glibc2.0 and bsd */ /* Define if we have sys/vfs.h */ //#cmakedefine HAVE_VFS_H //#cmakedefine HAVE_STRUCT_STATFS_F_TYPE #undef HAVE_MOUNT_H #undef HAVE_SYS_ENDIAN_H #define HAVE_MACHINE_ENDIAN_H #define HAVE_PTHREAD #undef HAVE_GETRESUID #undef HAVE_GETRESGID #undef HAVE_SETRESUID #undef HAVE_SETRESGID #undef HAVE_PTSNAME_R #define COMMON_ARCH "iphoneos-arm" #define PACKAGE "cydia" // XXX #define PACKAGE_VERSION "${PACKAGE_VERSION}" // XXX #define PACKAGE_MAIL "<EMAIL>" #define CMAKE_INSTALL_FULL_BINDIR "/usr/bin" #define STATE_DIR "/var/lib/apt" #define CACHE_DIR "/var/cache/apt" #define LOG_DIR "/var/log/apt" #define CONF_DIR "/etc/apt" #define LIBEXEC_DIR "/usr/lib/apt" #define BIN_DIR "/usr/bin" #define ROOT_GROUP "wheel" #define APT_8_CLEANER_HEADERS #define APT_9_CLEANER_HEADERS #define APT_10_CLEANER_HEADERS #define SHA2_UNROLL_TRANSFORM
488
879
package com.bookstore.service; import com.bookstore.entity.Author; import com.bookstore.repository.AuthorRepository; import java.util.Random; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; @Service public class InsertSecondAuthorService { private final AuthorRepository authorRepository; public InsertSecondAuthorService(AuthorRepository authorRepository) { this.authorRepository = authorRepository; } @Transactional(propagation = Propagation.MANDATORY) public void insertSecondAuthor() { Author author = new Author(); author.setName("<NAME>"); authorRepository.save(author); if (new Random().nextBoolean()) { throw new RuntimeException("DummyException: this should cause rollback of both inserts!"); } } }
303
1,056
<filename>enterprise/j2ee.common/src/org/netbeans/modules/j2ee/common/ProjectUtil.java /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.netbeans.modules.j2ee.common; import java.util.HashSet; import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; import org.netbeans.api.j2ee.core.Profile; import org.netbeans.api.project.Project; import org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment; import org.netbeans.modules.j2ee.deployment.devmodules.api.InstanceRemovedException; import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eeModule; import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eePlatform; import org.netbeans.modules.j2ee.deployment.devmodules.spi.J2eeModuleProvider; public class ProjectUtil { private static final Logger LOGGER = Logger.getLogger(ProjectUtil.class.getName()); public static Set<Profile> getSupportedProfiles(Project project) { Set<Profile> supportedProfiles = new HashSet<Profile>(); J2eePlatform j2eePlatform = getPlatform(project); if (j2eePlatform != null) { supportedProfiles = j2eePlatform.getSupportedProfiles(); } return supportedProfiles; } /** * Gets {@link J2eePlatform} for the given {@code Project}. * * @param project project * @return {@code J2eePlatform} for given project if found, {@code null} otherwise * @since 1.69 */ public static J2eePlatform getPlatform(Project project) { try { J2eeModuleProvider provider = project.getLookup().lookup(J2eeModuleProvider.class); if (provider != null) { String instance = provider.getServerInstanceID(); if (instance != null) { return Deployment.getDefault().getServerInstance(provider.getServerInstanceID()).getJ2eePlatform(); } } } catch (InstanceRemovedException ex) { // will return null } return null; } /** * Is J2EE version of a given project JavaEE 5 or higher? * * @param project J2EE project * @return true if J2EE version is JavaEE 5 or higher; otherwise false */ public static boolean isJavaEE5orHigher(Project project) { if (project == null) { return false; } J2eeModuleProvider j2eeModuleProvider = project.getLookup().lookup(J2eeModuleProvider.class); if (j2eeModuleProvider != null) { J2eeModule j2eeModule = j2eeModuleProvider.getJ2eeModule(); if (j2eeModule != null) { J2eeModule.Type type = j2eeModule.getType(); String strVersion = j2eeModule.getModuleVersion(); assert strVersion != null : "Module type " + j2eeModule.getType() + " returned null module version"; try { double version = Double.parseDouble(strVersion); if (J2eeModule.Type.EJB.equals(type) && (version > 2.1)) { return true; } if (J2eeModule.Type.WAR.equals(type) && (version > 2.4)) { return true; } if (J2eeModule.Type.CAR.equals(type) && (version > 1.4)) { return true; } } catch (NumberFormatException ex) { LOGGER.log(Level.INFO, "Module version invalid " + strVersion, ex); } } } return false; } }
1,771
764
<reponame>freeunion1possible/sia-gateway<gh_stars>100-1000 /*- * << * sag * == * Copyright (C) 2019 sia * == * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * >> */ package com.common.system; import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.Set; import java.util.concurrent.TimeUnit; import org.apache.shiro.cache.Cache; import org.apache.shiro.cache.CacheException; import org.springframework.data.redis.core.RedisTemplate; /**** * * * @param <K> * @param <V> */ @SuppressWarnings("unchecked") public class ShiroCache<K, V> implements Cache<K, V> { private static final String REDIS_SHIRO_CACHE = "gantry-cache:"; private String cacheKey; private RedisTemplate<K, V> redisTemplate; private long globExpire = 30; @SuppressWarnings("rawtypes") public ShiroCache(String name, RedisTemplate client) { this.cacheKey = REDIS_SHIRO_CACHE + name + ":"; this.redisTemplate = client; } @Override public V get(K key) throws CacheException { redisTemplate.boundValueOps(getCacheKey(key)).expire(globExpire, TimeUnit.MINUTES); return redisTemplate.boundValueOps(getCacheKey(key)).get(); } @Override public V put(K key, V value) throws CacheException { V old = get(key); redisTemplate.boundValueOps(getCacheKey(key)).set(value); return old; } @Override public V remove(K key) throws CacheException { V old = get(key); redisTemplate.delete(getCacheKey(key)); return old; } @Override public void clear() throws CacheException { redisTemplate.delete(keys()); } @Override public int size() { return keys().size(); } @Override public Set<K> keys() { return redisTemplate.keys(getCacheKey("*")); } @Override public Collection<V> values() { Set<K> set = keys(); List<V> list = new ArrayList<V>(); for (K s : set) { list.add(get(s)); } return list; } private K getCacheKey(Object k) { return (K) (this.cacheKey + k); } }
1,013
988
<reponame>Gegy/DataFixerUpper // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. package com.mojang.datafixers.kinds; import com.google.common.collect.ImmutableList; import java.util.List; import java.util.function.Function; import java.util.stream.Collectors; public final class ListBox<T> implements App<ListBox.Mu, T> { public static final class Mu implements K1 {} public static <T> List<T> unbox(final App<Mu, T> box) { return ((ListBox<T>) box).value; } public static <T> ListBox<T> create(final List<T> value) { return new ListBox<>(value); } private final List<T> value; private ListBox(final List<T> value) { this.value = value; } public static <F extends K1, A, B> App<F, List<B>> traverse(final Applicative<F, ?> applicative, final Function<A, App<F, B>> function, final List<A> input) { return applicative.map(ListBox::unbox, Instance.INSTANCE.traverse(applicative, function, create(input))); } public static <F extends K1, A> App<F, List<A>> flip(final Applicative<F, ?> applicative, final List<App<F, A>> input) { return applicative.map(ListBox::unbox, Instance.INSTANCE.flip(applicative, create(input))); } public enum Instance implements Traversable<Mu, Instance.Mu> { INSTANCE; public static final class Mu implements Traversable.Mu {} @Override public <T, R> App<ListBox.Mu, R> map(final Function<? super T, ? extends R> func, final App<ListBox.Mu, T> ts) { return create(ListBox.unbox(ts).stream().map(func).collect(Collectors.toList())); } @Override public <F extends K1, A, B> App<F, App<ListBox.Mu, B>> traverse(final Applicative<F, ?> applicative, final Function<A, App<F, B>> function, final App<ListBox.Mu, A> input) { final List<? extends A> list = unbox(input); App<F, ImmutableList.Builder<B>> result = applicative.point(ImmutableList.builder()); for (final A a : list) { final App<F, B> fb = function.apply(a); result = applicative.ap2(applicative.point(ImmutableList.Builder::add), result, fb); } return applicative.map(b -> create(b.build()), result); } } }
920
595
/****************************************************************************** * Copyright (C) 2017 - 2020 Xilinx, Inc. All rights reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ /*****************************************************************************/ /** * * @file xcframe.c * * This file which contains the code related to CFRAME block. * * <pre> * MODIFICATION HISTORY: * * Ver Who Date Changes * ----- ---- -------- ------------------------------------------------------- * 1.00 kc 11/10/2017 Initial release * 1.01 bsv 29/05/2019 XCframe_ReadReg API added * 1.02 bsv 11/06/2019 XCframe_ClearCframeErr API added * 1.03 bsv 17/02/2020 XCframe_SafetyWriteReg API added * </pre> * * @note * ******************************************************************************/ /***************************** Include Files *********************************/ #include "xcframe.h" /************************** Constant Definitions *****************************/ /**************************** Type Definitions *******************************/ /***************** Macros (Inline Functions) Definitions *********************/ /************************** Function Prototypes ******************************/ /************************** Variable Definitions *****************************/ /*****************************************************************************/ /*****************************************************************************/ /** * * This function initializes an CFRAME core. This function must be called * prior to using an CFRAME driver. * * @param InstancePtr is a pointer to the XCframe instance. * @param CfgPtr is a reference to a structure containing information * about a specific XCframe instance. * @param EffectiveAddr is the device base address in the virtual memory * address space. The caller is responsible for keeping the * address mapping from EffectiveAddr to the device physical * base address unchanged once this function is invoked. * Unexpected errors may occur if the address mapping changes * after this function is called. If address translation is not * used, pass in the physical address instead. * * @return * - XST_SUCCESS if initialization was successful. * * @note None. * ******************************************************************************/ s32 XCframe_CfgInitialize(XCframe *InstancePtr, XCframe_Config *CfgPtr, u32 EffectiveAddr) { /* Verify arguments. */ Xil_AssertNonvoid(InstancePtr != NULL); Xil_AssertNonvoid(CfgPtr != NULL); Xil_AssertNonvoid(EffectiveAddr != ((u32)0x0)); /* Setup the instance */ (void)memcpy((void *)&(InstancePtr->Config), (const void *)CfgPtr, sizeof(XCframe_Config)); InstancePtr->Config.BaseAddress = EffectiveAddr; InstancePtr->IsReady = (u32)(XIL_COMPONENT_IS_READY); return (XST_SUCCESS); } /*****************************************************************************/ /** * This function writes to 128 bit CFRAME register * * @param InstancePtr is a pointer to the XCframe instance. * @param Addr CFRAME register address * @param Value128 128 bit value to be stored * * @return None * ******************************************************************************/ void XCframe_WriteReg(XCframe *InstancePtr, u32 AddrOffset, XCframe_FrameNo FrameNo, Xuint128 *Val) { /* TODO check if we need to disable interrupts */ XCframe_WriteReg32(InstancePtr->Config.BaseAddress + (FrameNo*XCFRAME_FRAME_OFFSET), AddrOffset, Val->Word0); XCframe_WriteReg32(InstancePtr->Config.BaseAddress + (FrameNo*XCFRAME_FRAME_OFFSET) , AddrOffset+4, Val->Word1); XCframe_WriteReg32(InstancePtr->Config.BaseAddress + (FrameNo*XCFRAME_FRAME_OFFSET), AddrOffset+8, Val->Word2); XCframe_WriteReg32(InstancePtr->Config.BaseAddress + (FrameNo*XCFRAME_FRAME_OFFSET), AddrOffset+12, Val->Word3); } /*****************************************************************************/ /** * This function reads the 128 bit CFRAME register * * @param InstancePtr is a pointer to the XCframe instance. * @param Addr CFRAME register address * @param ValPtr 128 bit variable to store the read data * * @return None * ******************************************************************************/ void XCframe_ReadReg(XCframe *InstancePtr, u32 AddrOffset, XCframe_FrameNo FrameNo, u32* ValPtr) { ValPtr[0] = XCframe_ReadReg32(InstancePtr->Config.BaseAddress + (FrameNo*XCFRAME_FRAME_OFFSET), AddrOffset); ValPtr[1] = XCframe_ReadReg32(InstancePtr->Config.BaseAddress + (FrameNo*XCFRAME_FRAME_OFFSET), AddrOffset+4); ValPtr[2] = XCframe_ReadReg32(InstancePtr->Config.BaseAddress + (FrameNo*XCFRAME_FRAME_OFFSET), AddrOffset+8); ValPtr[3] = XCframe_ReadReg32(InstancePtr->Config.BaseAddress + (FrameNo*XCFRAME_FRAME_OFFSET), AddrOffset+12); } /*****************************************************************************/ /** * @brief This function writes to 128 bit CFRAME register and reads it back to * validate the write operation. * * @param InstancePtr is a pointer to the XCframe instance. * @param Addr CFRAME register address * @param Value128 128 bit value to be stored * * @return Success or Failure * ******************************************************************************/ int XCframe_SafetyWriteReg(XCframe *InstancePtr, u32 AddrOffset, XCframe_FrameNo FrameNo, Xuint128 *Val) { int Status = XST_FAILURE; u32 ReadVal[4U]; XCframe_WriteReg(InstancePtr, AddrOffset, FrameNo, Val); XCframe_ReadReg(InstancePtr, AddrOffset, FrameNo, ReadVal); if ((ReadVal[0U] == Val->Word0) && (ReadVal[1U] == Val->Word1) && (ReadVal[2U] == Val->Word2) && (ReadVal[3U] == Val->Word3)) { Status = XST_SUCCESS; } return Status; } /*****************************************************************************/ /** * This function writes the value to CFRAME cmd register * * @param InstancePtr is a pointer to the XCframe instance. * @param Cmd to be initiated by CFRAME block * * @return None * ******************************************************************************/ void XCframe_WriteCmd(XCframe *InstancePtr, XCframe_FrameNo CframeNo, u32 Cmd) { Xuint128 CfrCmd={0}; XCframe_Printf("CFRAME CMD: %0x\n\r", Cmd); CfrCmd.Word0 = Cmd; XCframe_WriteReg(InstancePtr, XCFRAME_CMD_OFFSET, CframeNo, &CfrCmd); } /*****************************************************************************/ /** * This function writes the VGG TRIM value * * @param InstancePtr is a pointer to the XCframe instance. * @param Value Trim value to be applied for * * @return None * ******************************************************************************/ void XCframe_VggTrim(XCframe *InstancePtr, Xuint128 *TrimVal) { Xuint128 MaskVal={0}; MaskVal.Word0 = 0xFFFFFFFF; MaskVal.Word1 = 0xFFFFFFFF; MaskVal.Word2 = 0xFFFFFFFF; XCframe_WriteReg(InstancePtr, XCFRAME_MASK_OFFSET, XCFRAME_FRAME_BCAST, &MaskVal); XCframe_WriteReg(InstancePtr, XCFRAME_VGG_TRIM_OFFSET, XCFRAME_FRAME_BCAST, TrimVal); } /*****************************************************************************/ /** * This function writes the BRAM TRIM value * * @param InstancePtr is a pointer to the XCframe instance. * @param Value Trim value to be applied for * * @return None * ******************************************************************************/ void XCframe_CramTrim(XCframe *InstancePtr, u32 TrimValue) { Xuint128 TrimVal={0}; Xuint128 MaskVal={0}; MaskVal.Word0 = 0xFFFFFFFF; XCframe_WriteReg(InstancePtr, XCFRAME_MASK_OFFSET, XCFRAME_FRAME_BCAST, &MaskVal); TrimVal.Word0 = TrimValue; XCframe_WriteReg(InstancePtr, XCFRAME_CRAM_TRIM_OFFSET, XCFRAME_FRAME_BCAST, &TrimVal); } /*****************************************************************************/ /** * This function writes the BRAM TRIM value * * @param InstancePtr is a pointer to the XCframe instance. * @param Value Trim value to be applied for * * @return None * ******************************************************************************/ void XCframe_BramTrim(XCframe *InstancePtr, u32 TrimValue) { Xuint128 TrimVal={0}; Xuint128 MaskVal={0}; MaskVal.Word0 = 0xFFFFFFFF; MaskVal.Word1 = 0xFFFFFFFF; XCframe_WriteReg(InstancePtr, XCFRAME_MASK_OFFSET, XCFRAME_FRAME_BCAST, &MaskVal); TrimVal.Word0 = TrimValue; XCframe_WriteReg(InstancePtr, XCFRAME_COE_TRIM_OFFSET, XCFRAME_FRAME_BCAST, &TrimVal); XCframe_WriteCmd(InstancePtr, XCFRAME_FRAME_BCAST, XCFRAME_CMD_REG_TRIMB); } /*****************************************************************************/ /** * This function writes the BRAM TRIM value * * @param InstancePtr is a pointer to the XCframe instance. * @param Value Trim value to be applied * * @return None * ******************************************************************************/ void XCframe_UramTrim(XCframe *InstancePtr, u32 TrimValue) { Xuint128 TrimVal={0}; Xuint128 MaskVal={0}; MaskVal.Word0 = 0xFFFFFFFF; MaskVal.Word1 = 0xFFFFFFFF; XCframe_WriteReg(InstancePtr, XCFRAME_MASK_OFFSET, XCFRAME_FRAME_BCAST, &MaskVal); TrimVal.Word0 = TrimValue; XCframe_WriteReg(InstancePtr, XCFRAME_COE_TRIM_OFFSET, XCFRAME_FRAME_BCAST, &TrimVal); XCframe_WriteCmd(InstancePtr, XCFRAME_FRAME_BCAST, XCFRAME_CMD_REG_TRIMU); } /*****************************************************************************/ /** * This function sets the CFRAME read parameters with mentioned CFRAME length and * frame number * * @param * * @return None * ******************************************************************************/ void XCframe_SetReadParam(XCframe *InstancePtr, XCframe_FrameNo CframeNo, u32 CframeLen) { Xuint128 Value128={0}; /* Enable ROWON, READ_CFR, CFRM_CNT */ XCframe_WriteCmd(InstancePtr, CframeNo, XCFRAME_CMD_REG_ROWON); XCframe_WriteCmd(InstancePtr, CframeNo, XCFRAME_CMD_REG_RCFG); XCframe_WriteReg(InstancePtr, XCFRAME_FAR_OFFSET, CframeNo, &Value128); Value128.Word0=CframeLen/4; XCframe_WriteReg(InstancePtr, XCFRAME_FRCNT_OFFSET, CframeNo, &Value128); } /*****************************************************************************/ /** * This function clears CFRAME ISRs and is called as part of CFRAME error recovery * * @param XCframe Instance Pointer * * @return None * ******************************************************************************/ void XCframe_ClearCframeErr(XCframe *InstancePtr) { Xuint128 Value128={0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU}; Xil_AssertVoid(InstancePtr != NULL); XCframe_FrameNo CframeNo = XCFRAME_FRAME_0; /* Clear CFRAME ISRs */ while(CframeNo <= XCFRAME_FRAME_BCAST) { XCframe_WriteReg(InstancePtr, XCFRAME_CFRM_ISR_OFFSET, CframeNo++, &Value128); } }
3,647
480
/* * Copyright [2013-2021], Alibaba Group Holding Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.alibaba.polardbx.gms.topology; import com.alibaba.polardbx.gms.metadb.record.SystemTableRecord; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Timestamp; public class VariableConfigRecord implements SystemTableRecord { public long id; public Timestamp gmtCreated; public Timestamp gmtModified; public String instId; public String paramKey; public String paramValue; public String extra; @Override public VariableConfigRecord fill(ResultSet rs) throws SQLException { this.id = rs.getLong("id"); this.gmtCreated = rs.getTimestamp("gmt_created"); this.gmtModified = rs.getTimestamp("gmt_modified"); this.instId = rs.getString("inst_id"); this.paramKey = rs.getString("param_key"); this.paramValue = rs.getString("param_val"); this.extra = rs.getString("extra"); return this; } }
511
676
<filename>src/openboardview/version.in.h #pragma once /** * Header file template configured by CMake. * * Inject any CMake variables into here using @template@ tags. * Include as "version.h". */ #define OBV_NAME "@PROJECT_NAME@" #define OBV_NAME_LOWER "@PROJECT_NAME_LOWER@" #define OBV_VERSION "@PROJECT_VERSION@" #define OBV_BUILD "@OBV_BUILD@" #define OBV_URL "@PROJECT_URL@" #define OBV_LICENSE "@PROJECT_LICENSE@" #define OBV_LICENSE_TEXT "@PROJECT_LICENSE_TEXT_ESCAPED@"
186
305
<filename>src/main/java/org/mamute/auth/rules/ComposedRule.java<gh_stars>100-1000 package org.mamute.auth.rules; import org.mamute.model.User; public class ComposedRule<T> implements PermissionRule<T> { private PermissionRule<T> current; public ComposedRule(PermissionRule<T> first) { this.current = first; } public ComposedRule<T> or(PermissionRule<T> second) { current = new OrRule<>(current, second); return this; } public ComposedRule<T> and(PermissionRule<T> second) { current = new AndRule<>(current, second); return this; } @Override public boolean isAllowed(User u, T item) { return current.isAllowed(u, item); } public static <T> ComposedRule<T> composedRule(PermissionRule<T> first) { return new ComposedRule<>(first); } private static class OrRule<T> implements PermissionRule<T> { private final PermissionRule<T> second; private final PermissionRule<T> first; public OrRule(PermissionRule<T> first, PermissionRule<T> second) { this.first = first; this.second = second; } @Override public boolean isAllowed(User u, T item) { return first.isAllowed(u, item) || second.isAllowed(u, item); } } private static class AndRule<T> implements PermissionRule<T> { private final PermissionRule<T> second; private final PermissionRule<T> first; public AndRule(PermissionRule<T> first, PermissionRule<T> second) { this.first = first; this.second = second; } @Override public boolean isAllowed(User u, T item) { return first.isAllowed(u, item) && second.isAllowed(u, item); } } }
600
578
<reponame>llitfkitfk/bk-job /* * Tencent is pleased to support the open source community by making BK-JOB蓝鲸智云作业平台 available. * * Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved. * * BK-JOB蓝鲸智云作业平台 is licensed under the MIT License. * * License for BK-JOB蓝鲸智云作业平台: * -------------------------------------------------------------------- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated * documentation files (the "Software"), to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and * to permit persons to whom the Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all copies or substantial portions of * the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS * IN THE SOFTWARE. */ package com.tencent.bk.job.manage.manager.script.check.checker; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.tencent.bk.job.common.util.JobUUID; import com.tencent.bk.job.manage.common.consts.script.ScriptCheckErrorLevelEnum; import com.tencent.bk.job.manage.common.consts.script.ScriptTypeEnum; import com.tencent.bk.job.manage.model.dto.ScriptCheckResultItemDTO; import lombok.extern.slf4j.Slf4j; import org.apache.commons.io.FileUtils; import org.springframework.util.StopWatch; import java.io.BufferedReader; import java.io.File; import java.io.IOException; import java.io.InputStreamReader; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; /** * Bash 语法检查器 */ @Slf4j public class ScriptGrammarChecker implements ScriptChecker { private ScriptTypeEnum type; private String content; public ScriptGrammarChecker(ScriptTypeEnum type, String content) { this.type = type; this.content = content; } @Override public List<ScriptCheckResultItemDTO> call() throws Exception { StopWatch watch = new StopWatch(); watch.start("checkGrammar"); File tmpFile = File.createTempFile(JobUUID.getUUID(), type.getName()); FileUtils.write(tmpFile, content, "UTF-8"); String cmdline = "bash -n " + tmpFile.getAbsolutePath(); // 执行命令,读取命令输出,并转换为字符串 Process process = Runtime.getRuntime().exec(cmdline); Map<Integer, ScriptCheckResultItemDTO> result = Maps.newHashMap(); try (BufferedReader br = new BufferedReader(new InputStreamReader(process.getErrorStream(), StandardCharsets.UTF_8))) { String retLine; Pattern lineMatch = Pattern.compile(".*?line (\\d+):(.*)"); int lineCount = 0; while ((retLine = br.readLine()) != null) { lineCount += 1; log.debug("error line {}:{}", lineCount, retLine); if (retLine.length() == 0) { continue; } final ScriptCheckResultItemDTO checkResult = new ScriptCheckResultItemDTO(); Matcher matcher = lineMatch.matcher(retLine); checkResult.setLevel(level()); if (matcher.find()) { String line = matcher.group(1); checkResult.setLine(Integer.parseInt(line)); checkResult.setDescription(matcher.group(2)); } if (result.containsKey(checkResult.getLine())) { ScriptCheckResultItemDTO old = result.get(checkResult.getLine()); old.setDescription(old.getDescription() + "\n" + checkResult.getDescription()); } else { result.put(checkResult.getLine(), checkResult); } } } catch (IOException e) { log.error("Check script grammar fail", e); } finally { tmpFile.deleteOnExit(); watch.stop(); log.debug("watch={}", watch); } ArrayList<ScriptCheckResultItemDTO> checkResults = Lists.newArrayList(); checkResults.addAll(result.values()); return checkResults; } @Override public ScriptCheckErrorLevelEnum level() { return ScriptCheckErrorLevelEnum.ERROR; } }
1,981
6,304
/* * Copyright 2014 Google Inc. * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #ifndef GrDisableColorXP_DEFINED #define GrDisableColorXP_DEFINED #include "include/core/SkRefCnt.h" #include "include/gpu/GrTypes.h" #include "src/gpu/GrXferProcessor.h" // See the comment above GrXPFactory's definition about this warning suppression. #if defined(__GNUC__) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wnon-virtual-dtor" #endif #if defined(__clang__) #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wnon-virtual-dtor" #endif class GrDisableColorXPFactory : public GrXPFactory { public: static const GrDisableColorXPFactory* Get(); static sk_sp<const GrXferProcessor> MakeXferProcessor(); private: constexpr GrDisableColorXPFactory() {} AnalysisProperties analysisProperties( const GrProcessorAnalysisColor&, const GrProcessorAnalysisCoverage&, const GrCaps&, GrClampType) const override { return AnalysisProperties::kCompatibleWithCoverageAsAlpha | AnalysisProperties::kIgnoresInputColor; } sk_sp<const GrXferProcessor> makeXferProcessor( const GrProcessorAnalysisColor&, GrProcessorAnalysisCoverage, const GrCaps&, GrClampType) const override { return MakeXferProcessor(); } GR_DECLARE_XP_FACTORY_TEST using INHERITED = GrXPFactory; }; #if defined(__GNUC__) #pragma GCC diagnostic pop #endif #if defined(__clang__) #pragma clang diagnostic pop #endif inline const GrDisableColorXPFactory* GrDisableColorXPFactory::Get() { static constexpr const GrDisableColorXPFactory gDisableColorXPFactory; return &gDisableColorXPFactory; } #endif
619
922
from abc import ABC, abstractmethod from dataclasses import dataclass from typing import Type, TypeVar, Generic import numpy as np from paiargparse import pai_dataclass from tfaip.util.multiprocessing.parallelmap import parallel_map from calamari_ocr.utils.image import load_image @pai_dataclass @dataclass class DataAugmenterParams(ABC): @classmethod @abstractmethod def cls(cls) -> Type["DataAugmenterBase"]: raise NotImplementedError def create(self) -> "DataAugmenterBase": return self.cls()(self) TDataAugParams = TypeVar("TDataAugParams", bound=DataAugmenterParams) class DataAugmenterBase(Generic[TDataAugParams], ABC): def __init__(self, params: TDataAugParams): super().__init__() self.params = params @abstractmethod def augment_single(self, data, gt_txt): pass def augment_data(self, data, gt_txt, n_augmentations): if n_augmentations <= 0: return data, gt_txt return zip(*[self.augment_single(data, gt_txt) for _ in range(n_augmentations)]) def augment_data_tuple(self, t): return self.augment_data(*t) def augment_datas(self, datas, gt_txts, n_augmentations, processes=1, progress_bar=False): if n_augmentations < 0 or not isinstance(n_augmentations, int): raise ValueError("Number of augmentation must be an integer >= 0") if n_augmentations == 0: return datas, gt_txts out = parallel_map( self.augment_data_tuple, list(zip(datas, gt_txts, [n_augmentations] * len(datas))), desc="Augmentation", processes=processes, progress_bar=progress_bar, ) out_d, out_t = type(datas)(), type(datas)() for d, t in out: out_d += d out_t += t return datas + out_d, gt_txts + out_t @pai_dataclass(alt="Simple") @dataclass class DefaultDataAugmenterParams(DataAugmenterParams): @classmethod def cls(cls) -> Type["DataAugmenterBase"]: return DefaultDataAugmenter class DefaultDataAugmenter(DataAugmenterBase[DefaultDataAugmenterParams]): def augment_single(self, data, gt_txt): import calamari_ocr.thirdparty.ocrodeg as ocrodeg original_dtype = data.dtype data = data.astype(np.float) m = data.max() data = data / (1 if m == 0 else m) data = ocrodeg.random_pad(data, (0, data.shape[1] * 2)) # data = ocrodeg.transform_image(data, **ocrodeg.random_transform(rotation=(-0.1, 0.1), translation=(-0.1, 0.1))) for sigma in [2, 5]: noise = ocrodeg.bounded_gaussian_noise(data.shape, sigma, 3.0) data = ocrodeg.distort_with_noise(data, noise) data = ocrodeg.printlike_multiscale(data, blur=1, inverted=True) data = (data * 255 / data.max()).astype(original_dtype) return data, gt_txt if __name__ == "__main__": import matplotlib.pyplot as plt aug = DefaultDataAugmenterParams().create() img = 255 - np.mean( load_image("../../test/data/uw3_50lines/train/010001.bin.png")[:, :, 0:2], axis=-1, ) aug_img = [aug.augment_single(img.T, "")[0].T for _ in range(4)] f, ax = plt.subplots(5, 1) ax[0].imshow(255 - img, cmap="gray") for i, x in enumerate(aug_img): ax[i + 1].imshow(255 - x, cmap="gray") plt.show()
1,512
573
#!/usr/bin/env python # Copyright 2015, Yahoo Inc. # Licensed under the terms of the Apache License, Version 2.0. See the LICENSE file associated with the project for terms. import os import json from setuptools import setup # Package Metadata filename METADATA_FILENAME = 'lopq/package_metadata.json' BASEPATH = os.path.dirname(os.path.abspath(__file__)) # Long description of package LONG_DESCRIPTION = """ # Locally Optimized Product Quantization This is Python training and testing code for Locally Optimized Product Quantization (LOPQ) models, as well as Spark scripts to scale training to hundreds of millions of vectors. The resulting model can be used in Python with code provided here or deployed via a Protobuf format to, e.g., search backends for high performance approximate nearest neighbor search. ### Overview Locally Optimized Product Quantization (LOPQ) [1] is a hierarchical quantization algorithm that produces codes of configurable length for data points. These codes are efficient representations of the original vector and can be used in a variety of ways depending on application, including as hashes that preserve locality, as a compressed vector from which an approximate vector in the data space can be reconstructed, and as a representation from which to compute an approximation of the Euclidean distance between points. Conceptually, the LOPQ quantization process can be broken into 4 phases. The training process also fits these phases to the data in the same order. 1. The raw data vector is PCA'd to `D` dimensions (possibly the original dimensionality). This allows subsequent quantization to more efficiently represent the variation present in the data. 2. The PCA'd data is then product quantized [2] by two k-means quantizers. This means that each vector is split into two subvectors each of dimension `D / 2`, and each of the two subspaces is quantized independently with a vocabulary of size `V`. Since the two quantizations occur independently, the dimensions of the vectors are permuted such that the total variance in each of the two subspaces is approximately equal, which allows the two vocabularies to be equally important in terms of capturing the total variance of the data. This results in a pair of cluster ids that we refer to as "coarse codes". 3. The residuals of the data after coarse quantization are computed. The residuals are then locally projected independently for each coarse cluster. This projection is another application of PCA and dimension permutation on the residuals and it is "local" in the sense that there is a different projection for each cluster in each of the two coarse vocabularies. These local rotations make the next and final step, another application of product quantization, very efficient in capturing the variance of the residuals. 4. The locally projected data is then product quantized a final time by `M` subquantizers, resulting in `M` "fine codes". Usually the vocabulary for each of these subquantizers will be a power of 2 for effective storage in a search index. With vocabularies of size 256, the fine codes for each indexed vector will require `M` bytes to store in the index. The final LOPQ code for a vector is a `(coarse codes, fine codes)` pair, e.g. `((3, 2), (14, 164, 83, 49, 185, 29, 196, 250))`. ### Nearest Neighbor Search A nearest neighbor index can be built from these LOPQ codes by indexing each document into its corresponding coarse code bucket. That is, each pair of coarse codes (which we refer to as a "cell") will index a bucket of the vectors quantizing to that cell. At query time, an incoming query vector undergoes substantially the same process. First, the query is split into coarse subvectors and the distance to each coarse centroid is computed. These distances can be used to efficiently compute a priority-ordered sequence of cells [3] such that cells later in the sequence are less likely to have near neighbors of the query than earlier cells. The items in cell buckets are retrieved in this order until some desired quota has been met. After this retrieval phase, the fine codes are used to rank by approximate Euclidean distance. The query is projected into each local space and the distance to each indexed item is estimated as the sum of the squared distances of the query subvectors to the corresponding subquantizer centroid indexed by the fine codes. NN search with LOPQ is highly scalable and has excellent properties in terms of both index storage requirements and query-time latencies when implemented well. #### References For more information and performance benchmarks can be found at http://image.ntua.gr/iva/research/lopq/. 1. <NAME>, <NAME>. [Locally Optimized Product Quantization for Approximate Nearest Neighbor Search.](http://image.ntua.gr/iva/files/lopq.pdf) CVPR 2014. 2. <NAME>, <NAME>, and <NAME>. [Product quantization for nearest neighbor search.](https://lear.inrialpes.fr/pubs/2011/JDS11/jegou_searching_with_quantization.pdf) PAMI, 33(1), 2011. 3. <NAME> and <NAME>. [The inverted multi-index.](http://www.computer.org/csdl/trans/tp/preprint/06915715.pdf) CVPR 2012. """ # Create a dictionary of our arguments, this way this script can be imported # without running setup() to allow external scripts to see the setup settings. setup_arguments = { 'name': 'lopq', 'version': '1.0.0', 'author': '<NAME>,<NAME>,<NAME>', 'author_email': '<EMAIL>', 'url': 'http://github.com/yahoo/lopq', 'license': 'Apache-2.0', 'keywords': ['lopq', 'locally optimized product quantization', 'product quantization', 'compression', 'ann', 'approximate nearest neighbor', 'similarity search'], 'packages': ['lopq'], 'long_description': LONG_DESCRIPTION, 'description': 'Python code for training and deploying Locally Optimized Product Quantization (LOPQ) for approximate nearest neighbor search of high dimensional data.', 'classifiers': [ 'Development Status :: 5 - Production/Stable', 'License :: OSI Approved :: Apache Software License', 'Intended Audience :: Developers', 'Intended Audience :: Science/Research', 'Natural Language :: English', 'Operating System :: MacOS :: MacOS X', 'Operating System :: Microsoft :: Windows', 'Operating System :: POSIX', 'Operating System :: POSIX', 'Operating System :: Unix', 'Programming Language :: Python :: 2.7', 'Topic :: Scientific/Engineering', 'Topic :: Software Development' ], 'package_data': { 'lopq': ['package_metadata.json'] }, 'platforms': 'Windows,Linux,Solaris,Mac OS-X,Unix', 'include_package_data': True, 'install_requires': ['protobuf>=2.6', 'numpy>=1.9', 'scipy>=0.14', 'scikit-learn>=0.18', 'lmdb>=0.87'] } class Git(object): """ Simple wrapper class to the git command line tools """ version_list = ['0', '7', '0'] def __init__(self, version=None): if version: self.version_list = version.split('.') @property def version(self): """ Generate a Unique version value from the git information :return: """ git_rev = len(os.popen('git rev-list HEAD').readlines()) if git_rev != 0: self.version_list[-1] = '%d' % git_rev version = '.'.join(self.version_list) return version @property def branch(self): """ Get the current git branch :return: """ return os.popen('git rev-parse --abbrev-ref HEAD').read().strip() @property def hash(self): """ Return the git hash for the current build :return: """ return os.popen('git rev-parse HEAD').read().strip() @property def origin(self): """ Return the fetch url for the git origin :return: """ for item in os.popen('git remote -v'): split_item = item.strip().split() if split_item[0] == 'origin' and split_item[-1] == '(push)': return split_item[1] def add_scripts_to_package(): """ Update the "scripts" parameter of the setup_arguments with any scripts found in the "scripts" directory. :return: """ global setup_arguments if os.path.isdir('scripts'): setup_arguments['scripts'] = [ os.path.join('scripts', f) for f in os.listdir('scripts') ] def get_and_update_package_metadata(): """ Update the package metadata for this package if we are building the package. :return:metadata - Dictionary of metadata information """ global setup_arguments global METADATA_FILENAME if not os.path.exists('.git') and os.path.exists(METADATA_FILENAME): with open(METADATA_FILENAME) as fh: metadata = json.load(fh) else: git = Git(version=setup_arguments['version']) metadata = { 'version': git.version, 'git_hash': git.hash, 'git_origin': git.origin, 'git_branch': git.branch } with open(METADATA_FILENAME, 'w') as fh: json.dump(metadata, fh) return metadata if __name__ == '__main__': # We're being run from the command line so call setup with our arguments metadata = get_and_update_package_metadata() setup_arguments['version'] = metadata['version'] setup(**setup_arguments)
3,035
2,143
package com.tngtech.archunit.core.domain.testobjects; public class AllPrimitiveDependencies { private byte aByte; private char character; private short aShort; private int anInt; private long aLong; private float aFloat; private double aDouble; private boolean aBoolean; public AllPrimitiveDependencies(byte aByte, char character, short aShort, int anInt, long aLong, float aFloat, double aDouble, boolean aBoolean) { this.aByte = aByte; this.character = character; this.aShort = aShort; this.anInt = anInt; this.aLong = aLong; this.aFloat = aFloat; this.aDouble = aDouble; this.aBoolean = aBoolean; } public void testVoid() { } public byte testByte() { return aByte; } public char testChar() { return character; } public short testShort() { return aShort; } public int testInt() { return anInt; } public long testLong() { return aLong; } public float testFloat() { return aFloat; } public double testDouble() { return aDouble; } public boolean isaBoolean() { return aBoolean; } public void testMethodParameters(byte aByte, char character, short aShort, int anInt, long aLong, float aFloat, double aDouble, boolean aBoolean) { } }
587
1,964
// This file is part of nbind, copyright (C) 2014-2015 BusFaster Ltd. // Released under the MIT license, see LICENSE. #include <cstring> class GetterSetter { public: GetterSetter() {} int get_x() {return(x);} int Gety() {return(y);} int getZ() const {return(z);} const char *gett() const {return(t);} void Sety(int y) {this->y = y;} void setZ(int z) {this->z = z;} void sett(const char *t) {this->t = strdup(t);} int getXYZ() const { return(x + y + z); } private: int x = 1, y = 2, z = 3; const char *t = "foobar"; }; #include "nbind/nbind.h" #ifdef NBIND_CLASS NBIND_CLASS(GetterSetter) { construct<>(); getter(get_x); getset(Gety, Sety); getset(getZ, setZ); getset(gett, sett); getter(getXYZ); } #endif
317
898
#include "lua_cocos2dx_pluginx_auto.hpp" #include "PluginManager.h" #include "ProtocolAnalytics.h" #include "ProtocolIAP.h" #include "ProtocolAds.h" #include "ProtocolShare.h" #include "ProtocolSocial.h" #include "ProtocolUser.h" #include "AgentManager.h" #include "FacebookAgent.h" #include "tolua_fix.h" #include "LuaBasicConversions.h" #include "lua_pluginx_basic_conversions.h" int lua_pluginx_protocols_PluginProtocol_getPluginName(lua_State* tolua_S) { int argc = 0; cocos2d::plugin::PluginProtocol* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"plugin.PluginProtocol",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::plugin::PluginProtocol*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_pluginx_protocols_PluginProtocol_getPluginName'", nullptr); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_pluginx_protocols_PluginProtocol_getPluginName'", nullptr); return 0; } const char* ret = cobj->getPluginName(); tolua_pushstring(tolua_S,(const char*)ret); return 1; } luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "plugin.PluginProtocol:getPluginName",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_pluginx_protocols_PluginProtocol_getPluginName'.",&tolua_err); #endif return 0; } int lua_pluginx_protocols_PluginProtocol_getPluginVersion(lua_State* tolua_S) { int argc = 0; cocos2d::plugin::PluginProtocol* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"plugin.PluginProtocol",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::plugin::PluginProtocol*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_pluginx_protocols_PluginProtocol_getPluginVersion'", nullptr); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_pluginx_protocols_PluginProtocol_getPluginVersion'", nullptr); return 0; } std::string ret = cobj->getPluginVersion(); tolua_pushcppstring(tolua_S,ret); return 1; } luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "plugin.PluginProtocol:getPluginVersion",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_pluginx_protocols_PluginProtocol_getPluginVersion'.",&tolua_err); #endif return 0; } int lua_pluginx_protocols_PluginProtocol_getSDKVersion(lua_State* tolua_S) { int argc = 0; cocos2d::plugin::PluginProtocol* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"plugin.PluginProtocol",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::plugin::PluginProtocol*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_pluginx_protocols_PluginProtocol_getSDKVersion'", nullptr); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_pluginx_protocols_PluginProtocol_getSDKVersion'", nullptr); return 0; } std::string ret = cobj->getSDKVersion(); tolua_pushcppstring(tolua_S,ret); return 1; } luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "plugin.PluginProtocol:getSDKVersion",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_pluginx_protocols_PluginProtocol_getSDKVersion'.",&tolua_err); #endif return 0; } int lua_pluginx_protocols_PluginProtocol_setDebugMode(lua_State* tolua_S) { int argc = 0; cocos2d::plugin::PluginProtocol* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"plugin.PluginProtocol",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::plugin::PluginProtocol*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_pluginx_protocols_PluginProtocol_setDebugMode'", nullptr); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0, "plugin.PluginProtocol:setDebugMode"); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_pluginx_protocols_PluginProtocol_setDebugMode'", nullptr); return 0; } cobj->setDebugMode(arg0); return 0; } luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "plugin.PluginProtocol:setDebugMode",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_pluginx_protocols_PluginProtocol_setDebugMode'.",&tolua_err); #endif return 0; } static int lua_pluginx_protocols_PluginProtocol_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (PluginProtocol)"); return 0; } int lua_register_pluginx_protocols_PluginProtocol(lua_State* tolua_S) { tolua_usertype(tolua_S,"plugin.PluginProtocol"); tolua_cclass(tolua_S,"PluginProtocol","plugin.PluginProtocol","",nullptr); tolua_beginmodule(tolua_S,"PluginProtocol"); tolua_function(tolua_S,"getPluginName",lua_pluginx_protocols_PluginProtocol_getPluginName); tolua_function(tolua_S,"getPluginVersion",lua_pluginx_protocols_PluginProtocol_getPluginVersion); tolua_function(tolua_S,"getSDKVersion",lua_pluginx_protocols_PluginProtocol_getSDKVersion); tolua_function(tolua_S,"setDebugMode",lua_pluginx_protocols_PluginProtocol_setDebugMode); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::plugin::PluginProtocol).name(); g_luaType[typeName] = "plugin.PluginProtocol"; g_typeCast["PluginProtocol"] = "plugin.PluginProtocol"; return 1; } int lua_pluginx_protocols_PluginManager_unloadPlugin(lua_State* tolua_S) { int argc = 0; cocos2d::plugin::PluginManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"plugin.PluginManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::plugin::PluginManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_pluginx_protocols_PluginManager_unloadPlugin'", nullptr); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "plugin.PluginManager:unloadPlugin"); arg0 = arg0_tmp.c_str(); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_pluginx_protocols_PluginManager_unloadPlugin'", nullptr); return 0; } cobj->unloadPlugin(arg0); return 0; } luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "plugin.PluginManager:unloadPlugin",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_pluginx_protocols_PluginManager_unloadPlugin'.",&tolua_err); #endif return 0; } int lua_pluginx_protocols_PluginManager_loadPlugin(lua_State* tolua_S) { int argc = 0; cocos2d::plugin::PluginManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"plugin.PluginManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::plugin::PluginManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_pluginx_protocols_PluginManager_loadPlugin'", nullptr); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "plugin.PluginManager:loadPlugin"); arg0 = arg0_tmp.c_str(); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_pluginx_protocols_PluginManager_loadPlugin'", nullptr); return 0; } cocos2d::plugin::PluginProtocol* ret = cobj->loadPlugin(arg0); object_to_luaval<cocos2d::plugin::PluginProtocol>(tolua_S, "plugin.PluginProtocol",(cocos2d::plugin::PluginProtocol*)ret); return 1; } luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "plugin.PluginManager:loadPlugin",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_pluginx_protocols_PluginManager_loadPlugin'.",&tolua_err); #endif return 0; } int lua_pluginx_protocols_PluginManager_end(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"plugin.PluginManager",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_pluginx_protocols_PluginManager_end'", nullptr); return 0; } cocos2d::plugin::PluginManager::end(); return 0; } luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "plugin.PluginManager:end",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_pluginx_protocols_PluginManager_end'.",&tolua_err); #endif return 0; } int lua_pluginx_protocols_PluginManager_getInstance(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"plugin.PluginManager",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_pluginx_protocols_PluginManager_getInstance'", nullptr); return 0; } cocos2d::plugin::PluginManager* ret = cocos2d::plugin::PluginManager::getInstance(); object_to_luaval<cocos2d::plugin::PluginManager>(tolua_S, "plugin.PluginManager",(cocos2d::plugin::PluginManager*)ret); return 1; } luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "plugin.PluginManager:getInstance",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_pluginx_protocols_PluginManager_getInstance'.",&tolua_err); #endif return 0; } static int lua_pluginx_protocols_PluginManager_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (PluginManager)"); return 0; } int lua_register_pluginx_protocols_PluginManager(lua_State* tolua_S) { tolua_usertype(tolua_S,"plugin.PluginManager"); tolua_cclass(tolua_S,"PluginManager","plugin.PluginManager","",nullptr); tolua_beginmodule(tolua_S,"PluginManager"); tolua_function(tolua_S,"unloadPlugin",lua_pluginx_protocols_PluginManager_unloadPlugin); tolua_function(tolua_S,"loadPlugin",lua_pluginx_protocols_PluginManager_loadPlugin); tolua_function(tolua_S,"end", lua_pluginx_protocols_PluginManager_end); tolua_function(tolua_S,"getInstance", lua_pluginx_protocols_PluginManager_getInstance); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::plugin::PluginManager).name(); g_luaType[typeName] = "plugin.PluginManager"; g_typeCast["PluginManager"] = "plugin.PluginManager"; return 1; } int lua_pluginx_protocols_ProtocolAnalytics_logTimedEventBegin(lua_State* tolua_S) { int argc = 0; cocos2d::plugin::ProtocolAnalytics* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"plugin.ProtocolAnalytics",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::plugin::ProtocolAnalytics*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_pluginx_protocols_ProtocolAnalytics_logTimedEventBegin'", nullptr); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "plugin.ProtocolAnalytics:logTimedEventBegin"); arg0 = arg0_tmp.c_str(); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_pluginx_protocols_ProtocolAnalytics_logTimedEventBegin'", nullptr); return 0; } cobj->logTimedEventBegin(arg0); return 0; } luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "plugin.ProtocolAnalytics:logTimedEventBegin",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_pluginx_protocols_ProtocolAnalytics_logTimedEventBegin'.",&tolua_err); #endif return 0; } int lua_pluginx_protocols_ProtocolAnalytics_logError(lua_State* tolua_S) { int argc = 0; cocos2d::plugin::ProtocolAnalytics* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"plugin.ProtocolAnalytics",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::plugin::ProtocolAnalytics*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_pluginx_protocols_ProtocolAnalytics_logError'", nullptr); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { const char* arg0; const char* arg1; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "plugin.ProtocolAnalytics:logError"); arg0 = arg0_tmp.c_str(); std::string arg1_tmp; ok &= luaval_to_std_string(tolua_S, 3, &arg1_tmp, "plugin.ProtocolAnalytics:logError"); arg1 = arg1_tmp.c_str(); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_pluginx_protocols_ProtocolAnalytics_logError'", nullptr); return 0; } cobj->logError(arg0, arg1); return 0; } luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "plugin.ProtocolAnalytics:logError",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_pluginx_protocols_ProtocolAnalytics_logError'.",&tolua_err); #endif return 0; } int lua_pluginx_protocols_ProtocolAnalytics_setCaptureUncaughtException(lua_State* tolua_S) { int argc = 0; cocos2d::plugin::ProtocolAnalytics* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"plugin.ProtocolAnalytics",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::plugin::ProtocolAnalytics*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_pluginx_protocols_ProtocolAnalytics_setCaptureUncaughtException'", nullptr); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0, "plugin.ProtocolAnalytics:setCaptureUncaughtException"); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_pluginx_protocols_ProtocolAnalytics_setCaptureUncaughtException'", nullptr); return 0; } cobj->setCaptureUncaughtException(arg0); return 0; } luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "plugin.ProtocolAnalytics:setCaptureUncaughtException",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_pluginx_protocols_ProtocolAnalytics_setCaptureUncaughtException'.",&tolua_err); #endif return 0; } int lua_pluginx_protocols_ProtocolAnalytics_setSessionContinueMillis(lua_State* tolua_S) { int argc = 0; cocos2d::plugin::ProtocolAnalytics* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"plugin.ProtocolAnalytics",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::plugin::ProtocolAnalytics*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_pluginx_protocols_ProtocolAnalytics_setSessionContinueMillis'", nullptr); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { long arg0; ok &= luaval_to_long(tolua_S, 2, &arg0, "plugin.ProtocolAnalytics:setSessionContinueMillis"); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_pluginx_protocols_ProtocolAnalytics_setSessionContinueMillis'", nullptr); return 0; } cobj->setSessionContinueMillis(arg0); return 0; } luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "plugin.ProtocolAnalytics:setSessionContinueMillis",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_pluginx_protocols_ProtocolAnalytics_setSessionContinueMillis'.",&tolua_err); #endif return 0; } int lua_pluginx_protocols_ProtocolAnalytics_logEvent(lua_State* tolua_S) { int argc = 0; cocos2d::plugin::ProtocolAnalytics* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"plugin.ProtocolAnalytics",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::plugin::ProtocolAnalytics*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_pluginx_protocols_ProtocolAnalytics_logEvent'", nullptr); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "plugin.ProtocolAnalytics:logEvent"); arg0 = arg0_tmp.c_str(); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_pluginx_protocols_ProtocolAnalytics_logEvent'", nullptr); return 0; } cobj->logEvent(arg0); return 0; } if (argc == 2) { const char* arg0; std::map<std::basic_string<char>, std::basic_string<char>, std::less<std::basic_string<char> >, std::allocator<std::pair<const std::basic_string<char>, std::basic_string<char> > > >* arg1; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "plugin.ProtocolAnalytics:logEvent"); arg0 = arg0_tmp.c_str(); ok &= luaval_to_object<std::map<std::basic_string<char>, std::basic_string<char>, std::less<std::basic_string<char> >, std::allocator<std::pair<const std::basic_string<char>, std::basic_string<char> > > >>(tolua_S, 3, "std::map<std::basic_string<char>, std::basic_string<char>, std::less<std::basic_string<char> >, std::allocator<std::pair<const std::basic_string<char>, std::basic_string<char> > > >*",&arg1); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_pluginx_protocols_ProtocolAnalytics_logEvent'", nullptr); return 0; } cobj->logEvent(arg0, arg1); return 0; } luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "plugin.ProtocolAnalytics:logEvent",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_pluginx_protocols_ProtocolAnalytics_logEvent'.",&tolua_err); #endif return 0; } int lua_pluginx_protocols_ProtocolAnalytics_startSession(lua_State* tolua_S) { int argc = 0; cocos2d::plugin::ProtocolAnalytics* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"plugin.ProtocolAnalytics",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::plugin::ProtocolAnalytics*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_pluginx_protocols_ProtocolAnalytics_startSession'", nullptr); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "plugin.ProtocolAnalytics:startSession"); arg0 = arg0_tmp.c_str(); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_pluginx_protocols_ProtocolAnalytics_startSession'", nullptr); return 0; } cobj->startSession(arg0); return 0; } luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "plugin.ProtocolAnalytics:startSession",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_pluginx_protocols_ProtocolAnalytics_startSession'.",&tolua_err); #endif return 0; } int lua_pluginx_protocols_ProtocolAnalytics_stopSession(lua_State* tolua_S) { int argc = 0; cocos2d::plugin::ProtocolAnalytics* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"plugin.ProtocolAnalytics",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::plugin::ProtocolAnalytics*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_pluginx_protocols_ProtocolAnalytics_stopSession'", nullptr); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_pluginx_protocols_ProtocolAnalytics_stopSession'", nullptr); return 0; } cobj->stopSession(); return 0; } luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "plugin.ProtocolAnalytics:stopSession",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_pluginx_protocols_ProtocolAnalytics_stopSession'.",&tolua_err); #endif return 0; } int lua_pluginx_protocols_ProtocolAnalytics_logTimedEventEnd(lua_State* tolua_S) { int argc = 0; cocos2d::plugin::ProtocolAnalytics* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"plugin.ProtocolAnalytics",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::plugin::ProtocolAnalytics*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_pluginx_protocols_ProtocolAnalytics_logTimedEventEnd'", nullptr); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "plugin.ProtocolAnalytics:logTimedEventEnd"); arg0 = arg0_tmp.c_str(); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_pluginx_protocols_ProtocolAnalytics_logTimedEventEnd'", nullptr); return 0; } cobj->logTimedEventEnd(arg0); return 0; } luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "plugin.ProtocolAnalytics:logTimedEventEnd",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_pluginx_protocols_ProtocolAnalytics_logTimedEventEnd'.",&tolua_err); #endif return 0; } static int lua_pluginx_protocols_ProtocolAnalytics_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (ProtocolAnalytics)"); return 0; } int lua_register_pluginx_protocols_ProtocolAnalytics(lua_State* tolua_S) { tolua_usertype(tolua_S,"plugin.ProtocolAnalytics"); tolua_cclass(tolua_S,"ProtocolAnalytics","plugin.ProtocolAnalytics","plugin.PluginProtocol",nullptr); tolua_beginmodule(tolua_S,"ProtocolAnalytics"); tolua_function(tolua_S,"logTimedEventBegin",lua_pluginx_protocols_ProtocolAnalytics_logTimedEventBegin); tolua_function(tolua_S,"logError",lua_pluginx_protocols_ProtocolAnalytics_logError); tolua_function(tolua_S,"setCaptureUncaughtException",lua_pluginx_protocols_ProtocolAnalytics_setCaptureUncaughtException); tolua_function(tolua_S,"setSessionContinueMillis",lua_pluginx_protocols_ProtocolAnalytics_setSessionContinueMillis); tolua_function(tolua_S,"logEvent",lua_pluginx_protocols_ProtocolAnalytics_logEvent); tolua_function(tolua_S,"startSession",lua_pluginx_protocols_ProtocolAnalytics_startSession); tolua_function(tolua_S,"stopSession",lua_pluginx_protocols_ProtocolAnalytics_stopSession); tolua_function(tolua_S,"logTimedEventEnd",lua_pluginx_protocols_ProtocolAnalytics_logTimedEventEnd); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::plugin::ProtocolAnalytics).name(); g_luaType[typeName] = "plugin.ProtocolAnalytics"; g_typeCast["ProtocolAnalytics"] = "plugin.ProtocolAnalytics"; return 1; } int lua_pluginx_protocols_ProtocolIAP_onPayResult(lua_State* tolua_S) { int argc = 0; cocos2d::plugin::ProtocolIAP* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"plugin.ProtocolIAP",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::plugin::ProtocolIAP*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_pluginx_protocols_ProtocolIAP_onPayResult'", nullptr); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { cocos2d::plugin::PayResultCode arg0; const char* arg1; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "plugin.ProtocolIAP:onPayResult"); std::string arg1_tmp; ok &= luaval_to_std_string(tolua_S, 3, &arg1_tmp, "plugin.ProtocolIAP:onPayResult"); arg1 = arg1_tmp.c_str(); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_pluginx_protocols_ProtocolIAP_onPayResult'", nullptr); return 0; } cobj->onPayResult(arg0, arg1); return 0; } luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "plugin.ProtocolIAP:onPayResult",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_pluginx_protocols_ProtocolIAP_onPayResult'.",&tolua_err); #endif return 0; } int lua_pluginx_protocols_ProtocolIAP_configDeveloperInfo(lua_State* tolua_S) { int argc = 0; cocos2d::plugin::ProtocolIAP* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"plugin.ProtocolIAP",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::plugin::ProtocolIAP*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_pluginx_protocols_ProtocolIAP_configDeveloperInfo'", nullptr); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::plugin::TIAPDeveloperInfo arg0; ok &= pluginx::luaval_to_TIAPDeveloperInfo(tolua_S, 2, &arg0); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_pluginx_protocols_ProtocolIAP_configDeveloperInfo'", nullptr); return 0; } cobj->configDeveloperInfo(arg0); return 0; } luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "plugin.ProtocolIAP:configDeveloperInfo",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_pluginx_protocols_ProtocolIAP_configDeveloperInfo'.",&tolua_err); #endif return 0; } static int lua_pluginx_protocols_ProtocolIAP_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (ProtocolIAP)"); return 0; } int lua_register_pluginx_protocols_ProtocolIAP(lua_State* tolua_S) { tolua_usertype(tolua_S,"plugin.ProtocolIAP"); tolua_cclass(tolua_S,"ProtocolIAP","plugin.ProtocolIAP","plugin.PluginProtocol",nullptr); tolua_beginmodule(tolua_S,"ProtocolIAP"); tolua_function(tolua_S,"onPayResult",lua_pluginx_protocols_ProtocolIAP_onPayResult); tolua_function(tolua_S,"configDeveloperInfo",lua_pluginx_protocols_ProtocolIAP_configDeveloperInfo); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::plugin::ProtocolIAP).name(); g_luaType[typeName] = "plugin.ProtocolIAP"; g_typeCast["ProtocolIAP"] = "plugin.ProtocolIAP"; return 1; } int lua_pluginx_protocols_ProtocolAds_showAds(lua_State* tolua_S) { int argc = 0; cocos2d::plugin::ProtocolAds* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"plugin.ProtocolAds",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::plugin::ProtocolAds*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_pluginx_protocols_ProtocolAds_showAds'", nullptr); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::plugin::TAdsInfo arg0; ok &= pluginx::luaval_to_TAdsInfo(tolua_S, 2, &arg0); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_pluginx_protocols_ProtocolAds_showAds'", nullptr); return 0; } cobj->showAds(arg0); return 0; } if (argc == 2) { cocos2d::plugin::TAdsInfo arg0; cocos2d::plugin::ProtocolAds::AdsPos arg1; ok &= pluginx::luaval_to_TAdsInfo(tolua_S, 2, &arg0); ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1, "plugin.ProtocolAds:showAds"); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_pluginx_protocols_ProtocolAds_showAds'", nullptr); return 0; } cobj->showAds(arg0, arg1); return 0; } luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "plugin.ProtocolAds:showAds",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_pluginx_protocols_ProtocolAds_showAds'.",&tolua_err); #endif return 0; } int lua_pluginx_protocols_ProtocolAds_hideAds(lua_State* tolua_S) { int argc = 0; cocos2d::plugin::ProtocolAds* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"plugin.ProtocolAds",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::plugin::ProtocolAds*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_pluginx_protocols_ProtocolAds_hideAds'", nullptr); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::plugin::TAdsInfo arg0; ok &= pluginx::luaval_to_TAdsInfo(tolua_S, 2, &arg0); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_pluginx_protocols_ProtocolAds_hideAds'", nullptr); return 0; } cobj->hideAds(arg0); return 0; } luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "plugin.ProtocolAds:hideAds",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_pluginx_protocols_ProtocolAds_hideAds'.",&tolua_err); #endif return 0; } int lua_pluginx_protocols_ProtocolAds_queryPoints(lua_State* tolua_S) { int argc = 0; cocos2d::plugin::ProtocolAds* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"plugin.ProtocolAds",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::plugin::ProtocolAds*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_pluginx_protocols_ProtocolAds_queryPoints'", nullptr); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_pluginx_protocols_ProtocolAds_queryPoints'", nullptr); return 0; } cobj->queryPoints(); return 0; } luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "plugin.ProtocolAds:queryPoints",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_pluginx_protocols_ProtocolAds_queryPoints'.",&tolua_err); #endif return 0; } int lua_pluginx_protocols_ProtocolAds_spendPoints(lua_State* tolua_S) { int argc = 0; cocos2d::plugin::ProtocolAds* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"plugin.ProtocolAds",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::plugin::ProtocolAds*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_pluginx_protocols_ProtocolAds_spendPoints'", nullptr); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "plugin.ProtocolAds:spendPoints"); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_pluginx_protocols_ProtocolAds_spendPoints'", nullptr); return 0; } cobj->spendPoints(arg0); return 0; } luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "plugin.ProtocolAds:spendPoints",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_pluginx_protocols_ProtocolAds_spendPoints'.",&tolua_err); #endif return 0; } int lua_pluginx_protocols_ProtocolAds_configDeveloperInfo(lua_State* tolua_S) { int argc = 0; cocos2d::plugin::ProtocolAds* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"plugin.ProtocolAds",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::plugin::ProtocolAds*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_pluginx_protocols_ProtocolAds_configDeveloperInfo'", nullptr); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::plugin::TAdsDeveloperInfo arg0; ok &= pluginx::luaval_to_TAdsDeveloperInfo(tolua_S, 2, &arg0); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_pluginx_protocols_ProtocolAds_configDeveloperInfo'", nullptr); return 0; } cobj->configDeveloperInfo(arg0); return 0; } luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "plugin.ProtocolAds:configDeveloperInfo",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_pluginx_protocols_ProtocolAds_configDeveloperInfo'.",&tolua_err); #endif return 0; } static int lua_pluginx_protocols_ProtocolAds_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (ProtocolAds)"); return 0; } int lua_register_pluginx_protocols_ProtocolAds(lua_State* tolua_S) { tolua_usertype(tolua_S,"plugin.ProtocolAds"); tolua_cclass(tolua_S,"ProtocolAds","plugin.ProtocolAds","plugin.PluginProtocol",nullptr); tolua_beginmodule(tolua_S,"ProtocolAds"); tolua_function(tolua_S,"showAds",lua_pluginx_protocols_ProtocolAds_showAds); tolua_function(tolua_S,"hideAds",lua_pluginx_protocols_ProtocolAds_hideAds); tolua_function(tolua_S,"queryPoints",lua_pluginx_protocols_ProtocolAds_queryPoints); tolua_function(tolua_S,"spendPoints",lua_pluginx_protocols_ProtocolAds_spendPoints); tolua_function(tolua_S,"configDeveloperInfo",lua_pluginx_protocols_ProtocolAds_configDeveloperInfo); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::plugin::ProtocolAds).name(); g_luaType[typeName] = "plugin.ProtocolAds"; g_typeCast["ProtocolAds"] = "plugin.ProtocolAds"; return 1; } int lua_pluginx_protocols_ProtocolShare_onShareResult(lua_State* tolua_S) { int argc = 0; cocos2d::plugin::ProtocolShare* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"plugin.ProtocolShare",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::plugin::ProtocolShare*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_pluginx_protocols_ProtocolShare_onShareResult'", nullptr); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { cocos2d::plugin::ShareResultCode arg0; const char* arg1; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "plugin.ProtocolShare:onShareResult"); std::string arg1_tmp; ok &= luaval_to_std_string(tolua_S, 3, &arg1_tmp, "plugin.ProtocolShare:onShareResult"); arg1 = arg1_tmp.c_str(); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_pluginx_protocols_ProtocolShare_onShareResult'", nullptr); return 0; } cobj->onShareResult(arg0, arg1); return 0; } luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "plugin.ProtocolShare:onShareResult",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_pluginx_protocols_ProtocolShare_onShareResult'.",&tolua_err); #endif return 0; } int lua_pluginx_protocols_ProtocolShare_configDeveloperInfo(lua_State* tolua_S) { int argc = 0; cocos2d::plugin::ProtocolShare* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"plugin.ProtocolShare",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::plugin::ProtocolShare*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_pluginx_protocols_ProtocolShare_configDeveloperInfo'", nullptr); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::plugin::TShareDeveloperInfo arg0; ok &= pluginx::luaval_to_TShareDeveloperInfo(tolua_S, 2, &arg0); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_pluginx_protocols_ProtocolShare_configDeveloperInfo'", nullptr); return 0; } cobj->configDeveloperInfo(arg0); return 0; } luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "plugin.ProtocolShare:configDeveloperInfo",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_pluginx_protocols_ProtocolShare_configDeveloperInfo'.",&tolua_err); #endif return 0; } static int lua_pluginx_protocols_ProtocolShare_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (ProtocolShare)"); return 0; } int lua_register_pluginx_protocols_ProtocolShare(lua_State* tolua_S) { tolua_usertype(tolua_S,"plugin.ProtocolShare"); tolua_cclass(tolua_S,"ProtocolShare","plugin.ProtocolShare","plugin.PluginProtocol",nullptr); tolua_beginmodule(tolua_S,"ProtocolShare"); tolua_function(tolua_S,"onShareResult",lua_pluginx_protocols_ProtocolShare_onShareResult); tolua_function(tolua_S,"configDeveloperInfo",lua_pluginx_protocols_ProtocolShare_configDeveloperInfo); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::plugin::ProtocolShare).name(); g_luaType[typeName] = "plugin.ProtocolShare"; g_typeCast["ProtocolShare"] = "plugin.ProtocolShare"; return 1; } int lua_pluginx_protocols_ProtocolSocial_showLeaderboard(lua_State* tolua_S) { int argc = 0; cocos2d::plugin::ProtocolSocial* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"plugin.ProtocolSocial",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::plugin::ProtocolSocial*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_pluginx_protocols_ProtocolSocial_showLeaderboard'", nullptr); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "plugin.ProtocolSocial:showLeaderboard"); arg0 = arg0_tmp.c_str(); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_pluginx_protocols_ProtocolSocial_showLeaderboard'", nullptr); return 0; } cobj->showLeaderboard(arg0); return 0; } luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "plugin.ProtocolSocial:showLeaderboard",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_pluginx_protocols_ProtocolSocial_showLeaderboard'.",&tolua_err); #endif return 0; } int lua_pluginx_protocols_ProtocolSocial_showAchievements(lua_State* tolua_S) { int argc = 0; cocos2d::plugin::ProtocolSocial* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"plugin.ProtocolSocial",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::plugin::ProtocolSocial*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_pluginx_protocols_ProtocolSocial_showAchievements'", nullptr); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_pluginx_protocols_ProtocolSocial_showAchievements'", nullptr); return 0; } cobj->showAchievements(); return 0; } luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "plugin.ProtocolSocial:showAchievements",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_pluginx_protocols_ProtocolSocial_showAchievements'.",&tolua_err); #endif return 0; } int lua_pluginx_protocols_ProtocolSocial_configDeveloperInfo(lua_State* tolua_S) { int argc = 0; cocos2d::plugin::ProtocolSocial* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"plugin.ProtocolSocial",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::plugin::ProtocolSocial*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_pluginx_protocols_ProtocolSocial_configDeveloperInfo'", nullptr); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::plugin::TSocialDeveloperInfo arg0; ok &= pluginx::luaval_to_TSocialDeveloperInfo(tolua_S, 2, &arg0); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_pluginx_protocols_ProtocolSocial_configDeveloperInfo'", nullptr); return 0; } cobj->configDeveloperInfo(arg0); return 0; } luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "plugin.ProtocolSocial:configDeveloperInfo",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_pluginx_protocols_ProtocolSocial_configDeveloperInfo'.",&tolua_err); #endif return 0; } static int lua_pluginx_protocols_ProtocolSocial_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (ProtocolSocial)"); return 0; } int lua_register_pluginx_protocols_ProtocolSocial(lua_State* tolua_S) { tolua_usertype(tolua_S,"plugin.ProtocolSocial"); tolua_cclass(tolua_S,"ProtocolSocial","plugin.ProtocolSocial","plugin.PluginProtocol",nullptr); tolua_beginmodule(tolua_S,"ProtocolSocial"); tolua_function(tolua_S,"showLeaderboard",lua_pluginx_protocols_ProtocolSocial_showLeaderboard); tolua_function(tolua_S,"showAchievements",lua_pluginx_protocols_ProtocolSocial_showAchievements); tolua_function(tolua_S,"configDeveloperInfo",lua_pluginx_protocols_ProtocolSocial_configDeveloperInfo); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::plugin::ProtocolSocial).name(); g_luaType[typeName] = "plugin.ProtocolSocial"; g_typeCast["ProtocolSocial"] = "plugin.ProtocolSocial"; return 1; } int lua_pluginx_protocols_ProtocolUser_configDeveloperInfo(lua_State* tolua_S) { int argc = 0; cocos2d::plugin::ProtocolUser* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"plugin.ProtocolUser",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::plugin::ProtocolUser*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_pluginx_protocols_ProtocolUser_configDeveloperInfo'", nullptr); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::plugin::TUserDeveloperInfo arg0; ok &= pluginx::luaval_to_TUserDeveloperInfo(tolua_S, 2, &arg0); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_pluginx_protocols_ProtocolUser_configDeveloperInfo'", nullptr); return 0; } cobj->configDeveloperInfo(arg0); return 0; } luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "plugin.ProtocolUser:configDeveloperInfo",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_pluginx_protocols_ProtocolUser_configDeveloperInfo'.",&tolua_err); #endif return 0; } int lua_pluginx_protocols_ProtocolUser_isLoggedIn(lua_State* tolua_S) { int argc = 0; cocos2d::plugin::ProtocolUser* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"plugin.ProtocolUser",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::plugin::ProtocolUser*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_pluginx_protocols_ProtocolUser_isLoggedIn'", nullptr); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_pluginx_protocols_ProtocolUser_isLoggedIn'", nullptr); return 0; } bool ret = cobj->isLoggedIn(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "plugin.ProtocolUser:isLoggedIn",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_pluginx_protocols_ProtocolUser_isLoggedIn'.",&tolua_err); #endif return 0; } int lua_pluginx_protocols_ProtocolUser_getSessionID(lua_State* tolua_S) { int argc = 0; cocos2d::plugin::ProtocolUser* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"plugin.ProtocolUser",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::plugin::ProtocolUser*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_pluginx_protocols_ProtocolUser_getSessionID'", nullptr); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_pluginx_protocols_ProtocolUser_getSessionID'", nullptr); return 0; } std::string ret = cobj->getSessionID(); tolua_pushcppstring(tolua_S,ret); return 1; } luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "plugin.ProtocolUser:getSessionID",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_pluginx_protocols_ProtocolUser_getSessionID'.",&tolua_err); #endif return 0; } int lua_pluginx_protocols_ProtocolUser_getAccessToken(lua_State* tolua_S) { int argc = 0; cocos2d::plugin::ProtocolUser* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"plugin.ProtocolUser",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::plugin::ProtocolUser*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_pluginx_protocols_ProtocolUser_getAccessToken'", nullptr); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_pluginx_protocols_ProtocolUser_getAccessToken'", nullptr); return 0; } std::string ret = cobj->getAccessToken(); tolua_pushcppstring(tolua_S,ret); return 1; } luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "plugin.ProtocolUser:getAccessToken",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_pluginx_protocols_ProtocolUser_getAccessToken'.",&tolua_err); #endif return 0; } static int lua_pluginx_protocols_ProtocolUser_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (ProtocolUser)"); return 0; } int lua_register_pluginx_protocols_ProtocolUser(lua_State* tolua_S) { tolua_usertype(tolua_S,"plugin.ProtocolUser"); tolua_cclass(tolua_S,"ProtocolUser","plugin.ProtocolUser","plugin.PluginProtocol",nullptr); tolua_beginmodule(tolua_S,"ProtocolUser"); tolua_function(tolua_S,"configDeveloperInfo",lua_pluginx_protocols_ProtocolUser_configDeveloperInfo); tolua_function(tolua_S,"isLoggedIn",lua_pluginx_protocols_ProtocolUser_isLoggedIn); tolua_function(tolua_S,"getSessionID",lua_pluginx_protocols_ProtocolUser_getSessionID); tolua_function(tolua_S,"getAccessToken",lua_pluginx_protocols_ProtocolUser_getAccessToken); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::plugin::ProtocolUser).name(); g_luaType[typeName] = "plugin.ProtocolUser"; g_typeCast["ProtocolUser"] = "plugin.ProtocolUser"; return 1; } int lua_pluginx_protocols_AgentManager_getSocialPlugin(lua_State* tolua_S) { int argc = 0; cocos2d::plugin::AgentManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"plugin.AgentManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::plugin::AgentManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_pluginx_protocols_AgentManager_getSocialPlugin'", nullptr); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_pluginx_protocols_AgentManager_getSocialPlugin'", nullptr); return 0; } cocos2d::plugin::ProtocolSocial* ret = cobj->getSocialPlugin(); object_to_luaval<cocos2d::plugin::ProtocolSocial>(tolua_S, "plugin.ProtocolSocial",(cocos2d::plugin::ProtocolSocial*)ret); return 1; } luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "plugin.AgentManager:getSocialPlugin",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_pluginx_protocols_AgentManager_getSocialPlugin'.",&tolua_err); #endif return 0; } int lua_pluginx_protocols_AgentManager_getAdsPlugin(lua_State* tolua_S) { int argc = 0; cocos2d::plugin::AgentManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"plugin.AgentManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::plugin::AgentManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_pluginx_protocols_AgentManager_getAdsPlugin'", nullptr); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_pluginx_protocols_AgentManager_getAdsPlugin'", nullptr); return 0; } cocos2d::plugin::ProtocolAds* ret = cobj->getAdsPlugin(); object_to_luaval<cocos2d::plugin::ProtocolAds>(tolua_S, "plugin.ProtocolAds",(cocos2d::plugin::ProtocolAds*)ret); return 1; } luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "plugin.AgentManager:getAdsPlugin",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_pluginx_protocols_AgentManager_getAdsPlugin'.",&tolua_err); #endif return 0; } int lua_pluginx_protocols_AgentManager_purge(lua_State* tolua_S) { int argc = 0; cocos2d::plugin::AgentManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"plugin.AgentManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::plugin::AgentManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_pluginx_protocols_AgentManager_purge'", nullptr); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_pluginx_protocols_AgentManager_purge'", nullptr); return 0; } cobj->purge(); return 0; } luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "plugin.AgentManager:purge",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_pluginx_protocols_AgentManager_purge'.",&tolua_err); #endif return 0; } int lua_pluginx_protocols_AgentManager_getUserPlugin(lua_State* tolua_S) { int argc = 0; cocos2d::plugin::AgentManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"plugin.AgentManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::plugin::AgentManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_pluginx_protocols_AgentManager_getUserPlugin'", nullptr); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_pluginx_protocols_AgentManager_getUserPlugin'", nullptr); return 0; } cocos2d::plugin::ProtocolUser* ret = cobj->getUserPlugin(); object_to_luaval<cocos2d::plugin::ProtocolUser>(tolua_S, "plugin.ProtocolUser",(cocos2d::plugin::ProtocolUser*)ret); return 1; } luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "plugin.AgentManager:getUserPlugin",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_pluginx_protocols_AgentManager_getUserPlugin'.",&tolua_err); #endif return 0; } int lua_pluginx_protocols_AgentManager_getIAPPlugin(lua_State* tolua_S) { int argc = 0; cocos2d::plugin::AgentManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"plugin.AgentManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::plugin::AgentManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_pluginx_protocols_AgentManager_getIAPPlugin'", nullptr); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_pluginx_protocols_AgentManager_getIAPPlugin'", nullptr); return 0; } cocos2d::plugin::ProtocolIAP* ret = cobj->getIAPPlugin(); object_to_luaval<cocos2d::plugin::ProtocolIAP>(tolua_S, "plugin.ProtocolIAP",(cocos2d::plugin::ProtocolIAP*)ret); return 1; } luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "plugin.AgentManager:getIAPPlugin",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_pluginx_protocols_AgentManager_getIAPPlugin'.",&tolua_err); #endif return 0; } int lua_pluginx_protocols_AgentManager_getSharePlugin(lua_State* tolua_S) { int argc = 0; cocos2d::plugin::AgentManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"plugin.AgentManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::plugin::AgentManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_pluginx_protocols_AgentManager_getSharePlugin'", nullptr); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_pluginx_protocols_AgentManager_getSharePlugin'", nullptr); return 0; } cocos2d::plugin::ProtocolShare* ret = cobj->getSharePlugin(); object_to_luaval<cocos2d::plugin::ProtocolShare>(tolua_S, "plugin.ProtocolShare",(cocos2d::plugin::ProtocolShare*)ret); return 1; } luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "plugin.AgentManager:getSharePlugin",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_pluginx_protocols_AgentManager_getSharePlugin'.",&tolua_err); #endif return 0; } int lua_pluginx_protocols_AgentManager_getAnalyticsPlugin(lua_State* tolua_S) { int argc = 0; cocos2d::plugin::AgentManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"plugin.AgentManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::plugin::AgentManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_pluginx_protocols_AgentManager_getAnalyticsPlugin'", nullptr); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_pluginx_protocols_AgentManager_getAnalyticsPlugin'", nullptr); return 0; } cocos2d::plugin::ProtocolAnalytics* ret = cobj->getAnalyticsPlugin(); object_to_luaval<cocos2d::plugin::ProtocolAnalytics>(tolua_S, "plugin.ProtocolAnalytics",(cocos2d::plugin::ProtocolAnalytics*)ret); return 1; } luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "plugin.AgentManager:getAnalyticsPlugin",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_pluginx_protocols_AgentManager_getAnalyticsPlugin'.",&tolua_err); #endif return 0; } int lua_pluginx_protocols_AgentManager_destroyInstance(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"plugin.AgentManager",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_pluginx_protocols_AgentManager_destroyInstance'", nullptr); return 0; } cocos2d::plugin::AgentManager::destroyInstance(); return 0; } luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "plugin.AgentManager:destroyInstance",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_pluginx_protocols_AgentManager_destroyInstance'.",&tolua_err); #endif return 0; } int lua_pluginx_protocols_AgentManager_getInstance(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"plugin.AgentManager",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_pluginx_protocols_AgentManager_getInstance'", nullptr); return 0; } cocos2d::plugin::AgentManager* ret = cocos2d::plugin::AgentManager::getInstance(); object_to_luaval<cocos2d::plugin::AgentManager>(tolua_S, "plugin.AgentManager",(cocos2d::plugin::AgentManager*)ret); return 1; } luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "plugin.AgentManager:getInstance",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_pluginx_protocols_AgentManager_getInstance'.",&tolua_err); #endif return 0; } static int lua_pluginx_protocols_AgentManager_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (AgentManager)"); return 0; } int lua_register_pluginx_protocols_AgentManager(lua_State* tolua_S) { tolua_usertype(tolua_S,"plugin.AgentManager"); tolua_cclass(tolua_S,"AgentManager","plugin.AgentManager","",nullptr); tolua_beginmodule(tolua_S,"AgentManager"); tolua_function(tolua_S,"getSocialPlugin",lua_pluginx_protocols_AgentManager_getSocialPlugin); tolua_function(tolua_S,"getAdsPlugin",lua_pluginx_protocols_AgentManager_getAdsPlugin); tolua_function(tolua_S,"purge",lua_pluginx_protocols_AgentManager_purge); tolua_function(tolua_S,"getUserPlugin",lua_pluginx_protocols_AgentManager_getUserPlugin); tolua_function(tolua_S,"getIAPPlugin",lua_pluginx_protocols_AgentManager_getIAPPlugin); tolua_function(tolua_S,"getSharePlugin",lua_pluginx_protocols_AgentManager_getSharePlugin); tolua_function(tolua_S,"getAnalyticsPlugin",lua_pluginx_protocols_AgentManager_getAnalyticsPlugin); tolua_function(tolua_S,"destroyInstance", lua_pluginx_protocols_AgentManager_destroyInstance); tolua_function(tolua_S,"getInstance", lua_pluginx_protocols_AgentManager_getInstance); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::plugin::AgentManager).name(); g_luaType[typeName] = "plugin.AgentManager"; g_typeCast["AgentManager"] = "plugin.AgentManager"; return 1; } int lua_pluginx_protocols_FacebookAgent_activateApp(lua_State* tolua_S) { int argc = 0; cocos2d::plugin::FacebookAgent* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"plugin.FacebookAgent",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::plugin::FacebookAgent*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_pluginx_protocols_FacebookAgent_activateApp'", nullptr); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_pluginx_protocols_FacebookAgent_activateApp'", nullptr); return 0; } cobj->activateApp(); return 0; } luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "plugin.FacebookAgent:activateApp",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_pluginx_protocols_FacebookAgent_activateApp'.",&tolua_err); #endif return 0; } int lua_pluginx_protocols_FacebookAgent_getPermissionList(lua_State* tolua_S) { int argc = 0; cocos2d::plugin::FacebookAgent* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"plugin.FacebookAgent",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::plugin::FacebookAgent*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_pluginx_protocols_FacebookAgent_getPermissionList'", nullptr); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_pluginx_protocols_FacebookAgent_getPermissionList'", nullptr); return 0; } std::string ret = cobj->getPermissionList(); tolua_pushcppstring(tolua_S,ret); return 1; } luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "plugin.FacebookAgent:getPermissionList",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_pluginx_protocols_FacebookAgent_getPermissionList'.",&tolua_err); #endif return 0; } int lua_pluginx_protocols_FacebookAgent_getUserID(lua_State* tolua_S) { int argc = 0; cocos2d::plugin::FacebookAgent* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"plugin.FacebookAgent",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::plugin::FacebookAgent*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_pluginx_protocols_FacebookAgent_getUserID'", nullptr); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_pluginx_protocols_FacebookAgent_getUserID'", nullptr); return 0; } std::string ret = cobj->getUserID(); tolua_pushcppstring(tolua_S,ret); return 1; } luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "plugin.FacebookAgent:getUserID",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_pluginx_protocols_FacebookAgent_getUserID'.",&tolua_err); #endif return 0; } int lua_pluginx_protocols_FacebookAgent_logout(lua_State* tolua_S) { int argc = 0; cocos2d::plugin::FacebookAgent* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"plugin.FacebookAgent",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::plugin::FacebookAgent*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_pluginx_protocols_FacebookAgent_logout'", nullptr); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_pluginx_protocols_FacebookAgent_logout'", nullptr); return 0; } cobj->logout(); return 0; } luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "plugin.FacebookAgent:logout",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_pluginx_protocols_FacebookAgent_logout'.",&tolua_err); #endif return 0; } int lua_pluginx_protocols_FacebookAgent_getSDKVersion(lua_State* tolua_S) { int argc = 0; cocos2d::plugin::FacebookAgent* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"plugin.FacebookAgent",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::plugin::FacebookAgent*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_pluginx_protocols_FacebookAgent_getSDKVersion'", nullptr); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_pluginx_protocols_FacebookAgent_getSDKVersion'", nullptr); return 0; } std::string ret = cobj->getSDKVersion(); tolua_pushcppstring(tolua_S,ret); return 1; } luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "plugin.FacebookAgent:getSDKVersion",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_pluginx_protocols_FacebookAgent_getSDKVersion'.",&tolua_err); #endif return 0; } int lua_pluginx_protocols_FacebookAgent_isLoggedIn(lua_State* tolua_S) { int argc = 0; cocos2d::plugin::FacebookAgent* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"plugin.FacebookAgent",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::plugin::FacebookAgent*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_pluginx_protocols_FacebookAgent_isLoggedIn'", nullptr); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_pluginx_protocols_FacebookAgent_isLoggedIn'", nullptr); return 0; } bool ret = cobj->isLoggedIn(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "plugin.FacebookAgent:isLoggedIn",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_pluginx_protocols_FacebookAgent_isLoggedIn'.",&tolua_err); #endif return 0; } int lua_pluginx_protocols_FacebookAgent_getAccessToken(lua_State* tolua_S) { int argc = 0; cocos2d::plugin::FacebookAgent* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"plugin.FacebookAgent",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::plugin::FacebookAgent*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_pluginx_protocols_FacebookAgent_getAccessToken'", nullptr); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_pluginx_protocols_FacebookAgent_getAccessToken'", nullptr); return 0; } std::string ret = cobj->getAccessToken(); tolua_pushcppstring(tolua_S,ret); return 1; } luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "plugin.FacebookAgent:getAccessToken",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_pluginx_protocols_FacebookAgent_getAccessToken'.",&tolua_err); #endif return 0; } int lua_pluginx_protocols_FacebookAgent_destroyInstance(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"plugin.FacebookAgent",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_pluginx_protocols_FacebookAgent_destroyInstance'", nullptr); return 0; } cocos2d::plugin::FacebookAgent::destroyInstance(); return 0; } luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "plugin.FacebookAgent:destroyInstance",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_pluginx_protocols_FacebookAgent_destroyInstance'.",&tolua_err); #endif return 0; } static int lua_pluginx_protocols_FacebookAgent_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (FacebookAgent)"); return 0; } int lua_register_pluginx_protocols_FacebookAgent(lua_State* tolua_S) { tolua_usertype(tolua_S,"plugin.FacebookAgent"); tolua_cclass(tolua_S,"FacebookAgent","plugin.FacebookAgent","",nullptr); tolua_beginmodule(tolua_S,"FacebookAgent"); tolua_function(tolua_S,"activateApp",lua_pluginx_protocols_FacebookAgent_activateApp); tolua_function(tolua_S,"getPermissionList",lua_pluginx_protocols_FacebookAgent_getPermissionList); tolua_function(tolua_S,"getUserID",lua_pluginx_protocols_FacebookAgent_getUserID); tolua_function(tolua_S,"logout",lua_pluginx_protocols_FacebookAgent_logout); tolua_function(tolua_S,"getSDKVersion",lua_pluginx_protocols_FacebookAgent_getSDKVersion); tolua_function(tolua_S,"isLoggedIn",lua_pluginx_protocols_FacebookAgent_isLoggedIn); tolua_function(tolua_S,"getAccessToken",lua_pluginx_protocols_FacebookAgent_getAccessToken); tolua_function(tolua_S,"destroyInstance", lua_pluginx_protocols_FacebookAgent_destroyInstance); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::plugin::FacebookAgent).name(); g_luaType[typeName] = "plugin.FacebookAgent"; g_typeCast["FacebookAgent"] = "plugin.FacebookAgent"; return 1; } TOLUA_API int register_all_pluginx_protocols(lua_State* tolua_S) { tolua_open(tolua_S); tolua_module(tolua_S,"plugin",0); tolua_beginmodule(tolua_S,"plugin"); lua_register_pluginx_protocols_FacebookAgent(tolua_S); lua_register_pluginx_protocols_PluginProtocol(tolua_S); lua_register_pluginx_protocols_ProtocolUser(tolua_S); lua_register_pluginx_protocols_ProtocolShare(tolua_S); lua_register_pluginx_protocols_ProtocolIAP(tolua_S); lua_register_pluginx_protocols_AgentManager(tolua_S); lua_register_pluginx_protocols_ProtocolSocial(tolua_S); lua_register_pluginx_protocols_ProtocolAnalytics(tolua_S); lua_register_pluginx_protocols_ProtocolAds(tolua_S); lua_register_pluginx_protocols_PluginManager(tolua_S); tolua_endmodule(tolua_S); return 1; }
37,059
7,425
package master.flame.danmaku.danmaku.model; public abstract class AbsDanmakuSync { public static final int SYNC_STATE_HALT = 1; public static final int SYNC_STATE_PLAYING = 2; /** * Get the uptime of timer synchronization * * @return */ public abstract long getUptimeMillis(); /** * Get the state of timer synchronization * * @return SYNC_STATE_HALT or SYNC_STATE_PLAYING */ public abstract int getSyncState(); /** * Get the threshold-time of timer synchronization * This value should be greater than or equal to 1000L * * @return */ public long getThresholdTimeMills() { return 1500L; } /** * synchronize pause/resume state with outside playback * @return */ public boolean isSyncPlayingState() { return false; } }
331
190,993
/* Copyright 2021 The TensorFlow Authors. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ==============================================================================*/ #include "tensorflow/compiler/xla/pjrt/metrics.h" #include "absl/strings/str_cat.h" #include "tensorflow/core/lib/monitoring/counter.h" namespace xla { namespace { auto* pjrt_executable_executions = tensorflow::monitoring::Counter<0>::New( "/jax/pjrt/pjrt_executable_executions", "The number of PjRtExecutable::ExecuteHelper calls."); auto* pjrt_executable_execution_time_usecs = tensorflow::monitoring::Counter<0>::New( "/jax/pjrt/pjrt_executable_execution_time_usecs", "The total time spent on PjRtExecutable::ExecuteHelper in " "microseconds."); } // namespace void ReportExecutableEnqueueTime(const uint64_t running_time_usecs) { if (running_time_usecs > 0) { static auto* pjrt_executable_executions_cell = pjrt_executable_executions->GetCell(); static auto* pjrt_executable_execution_time_usecs_cell = pjrt_executable_execution_time_usecs->GetCell(); pjrt_executable_executions_cell->IncrementBy(1); pjrt_executable_execution_time_usecs_cell->IncrementBy(running_time_usecs); } } } // namespace xla
600
3,673
#include <net/addr.hpp> // Initialization of static addresses. namespace net { const Addr Addr::addr_any{}; const ip4::Addr ip4::Addr::addr_any{0}; const ip4::Addr ip4::Addr::addr_bcast{0xff,0xff,0xff,0xff}; const ip6::Addr ip6::Addr::node_all_nodes(0xFF01, 0, 0, 0, 0, 0, 0, 1); const ip6::Addr ip6::Addr::node_all_routers(0xFF01, 0, 0, 0, 0, 0, 0, 2); const ip6::Addr ip6::Addr::node_mDNSv6(0xFF01, 0, 0, 0, 0, 0, 0, 0xFB); const ip6::Addr ip6::Addr::link_unspecified(0, 0, 0, 0, 0, 0, 0, 0); const ip6::Addr ip6::Addr::addr_any{ip6::Addr::link_unspecified}; const ip6::Addr ip6::Addr::link_all_nodes(0xFF02, 0, 0, 0, 0, 0, 0, 1); const ip6::Addr ip6::Addr::link_all_routers(0xFF02, 0, 0, 0, 0, 0, 0, 2); const ip6::Addr ip6::Addr::link_mDNSv6(0xFF02, 0, 0, 0, 0, 0, 0, 0xFB); const ip6::Addr ip6::Addr::link_dhcp_servers(0xFF02, 0, 0, 0, 0, 0, 0x01, 0x02); const ip6::Addr ip6::Addr::site_dhcp_servers(0xFF05, 0, 0, 0, 0, 0, 0x01, 0x03); }
492
5,852
<reponame>autoantwort/proxygen /* * Copyright (c) Facebook, Inc. and its affiliates. * All rights reserved. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. */ #pragma once #include <folly/FBString.h> #include <folly/io/Cursor.h> #include <folly/io/IOBuf.h> #include <proxygen/lib/http/codec/compress/HPACKConstants.h> #include <string> namespace proxygen { namespace huffman { // size of the huffman tables (codes and bits) const uint32_t kTableSize = 256; // not used explicitly, since the prefixes are all 1's and they are // used only for padding of up to 7 bits const uint32_t kEOSHpack = 0x3fffffff; /** * node from the huffman tree * * A leaf has no index table, or index == nullptr */ struct HuffNode { union { uint8_t ch; // leafs hold characters uint8_t superNodeIndex; } data{0}; struct { uint8_t bits : 4; // how many bits are used for representing ch, range is // 0-8 bool isSuperNode : 1; } metadata{0, false}; bool isLeaf() const { return !metadata.isSuperNode; } }; /** * a super node from the condensed Huffman Tree representation with 8-bit level */ struct SuperHuffNode { HuffNode index[256]; }; /** * Immutable Huffman tree used in the process of decoding. Traditionally the * huffman tree is binary, but using that approach leads to major inefficiencies * since it's using per-bit level processing and needs to perform several memory * accesses and bit operations for every single bit. * This implementation is using 8-bit level indexing and uses aggregated nodes * that link up to 256 other nodes. The complexity for lookup is reduced from * O(bits) to O(Bytes) which is 1 or 2 for most of the printable characters. * The tradeoff of using this approach is using more memory and generating the * tree is more laborious since we need to fill all the subtrees denoted by a * character code, which is an unique prefix. * * Example * * bit stream: * 00001111 1111010 * 1. our lookup key is 00001111 which will point to character '/', since the * entire subtree with prefix 0000 points to it. We know the subtree has just * 4 bits, we remove just those from the current key. * bit stream: * 11111111 010 * * 2. key is 11111111 which points to a branch, so we go down one level * bit stream: * 010 * * 3. we don't have enough bits, so we use paddding and we get a key of * 01011111, which points to '(' character, like any other node under the * subtree '010'. */ class HuffTree { public: /** * the constructor assumes the codes and bits tables will not be freed, * ideally they are static */ explicit HuffTree(const uint32_t* codes, const uint8_t* bits); explicit HuffTree(HuffTree&& tree) = default; ~HuffTree() { } /** * decode bitstream into a string literal * * @param buf start of a huffman-encoded bit stream * @param size size of the buffer * @param literal where to append decoded characters * * @return true if the decode process was successful */ bool decode(const uint8_t* buf, uint32_t size, folly::fbstring& literal) const; /** * encode string literal into huffman encoded bit stream * * @param literal string to encode * @param buf where to append the encoded binary data */ uint32_t encode(folly::StringPiece literal, folly::io::QueueAppender& buf) const; /** * get the encode size for a string literal, works as a dry-run for the encode * useful to allocate enough buffer space before doing the actual encode * * @param literal string literal * @return size how many bytes it will take to encode the given string */ uint32_t getEncodeSize(folly::StringPiece literal) const; /** * get the binary representation for a given character, as a 32-bit word and * a number of bits is represented on (<32). The code is aligned to LSB. * * @param ch ASCII character * @return pair<word, bits> * * Example: * 'e' will be encoded as 1 using 4 bits: 0001 */ std::pair<uint32_t, uint8_t> getCode(uint8_t ch) const; // get internal tables for codes and bit lengths, useful for testing const uint32_t* codesTable() const; const uint8_t* bitsTable() const; private: void fillIndex(SuperHuffNode& snode, uint32_t code, uint8_t bits, uint8_t ch, uint8_t level); void buildTree(); void insert(uint32_t code, uint8_t bits, uint8_t ch); uint32_t nodes_{0}; const uint32_t* codes_; const uint8_t* bits_; protected: explicit HuffTree(const HuffTree& tree); SuperHuffNode table_[46]; }; const HuffTree& huffTree(); }} // namespace proxygen::huffman
1,591
384
<reponame>jain-tt/exporterhub.io<filename>api/user/migrations/0007_auto_20210330_1335.py<gh_stars>100-1000 # Generated by Django 3.1.6 on 2021-03-30 04:35 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('user', '0006_user_github_id'), ] operations = [ migrations.AddField( model_name='user', name='intro', field=models.CharField(max_length=4000, null=True), ), migrations.AlterField( model_name='user', name='github_id', field=models.IntegerField(), ), ]
303
1,143
// ================================================================================================= // Copyright 2011 Twitter, Inc. // ------------------------------------------------------------------------------------------------- // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this work except in compliance with the License. // You may obtain a copy of the License in the LICENSE file, or at: // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // ================================================================================================= package com.twitter.common.util.concurrent; import com.google.common.base.Preconditions; import java.util.concurrent.Callable; import java.util.concurrent.ExecutorService; import java.util.concurrent.FutureTask; import java.util.logging.Level; import java.util.logging.Logger; /** * A future task that supports retries by resubmitting itself to an {@link ExecutorService}. * * @author <NAME> */ public class RetryingFutureTask extends FutureTask<Boolean> { private static Logger LOG = Logger.getLogger(RetryingFutureTask.class.getName()); protected final ExecutorService executor; protected final int maxRetries; protected int numRetries = 0; protected final Callable<Boolean> callable; /** * Creates a new retrying future task that will execute a unit of work until successfully * completed, or the retry limit has been reached. * * @param executor The executor service to resubmit the task to upon failure. * @param callable The unit of work. The work is considered successful when {@code true} is * returned. It may return {@code false} or throw an exception when unsueccessful. * @param maxRetries The maximum number of times to retry the task. */ public RetryingFutureTask(ExecutorService executor, Callable<Boolean> callable, int maxRetries) { super(callable); this.callable = Preconditions.checkNotNull(callable); this.executor = Preconditions.checkNotNull(executor); this.maxRetries = maxRetries; } /** * Invokes a retry of this task. */ protected void retry() { executor.execute(this); } @Override public void run() { boolean success = false; try { success = callable.call(); } catch (Exception e) { LOG.log(Level.WARNING, "Exception while executing task.", e); } if (!success) { numRetries++; if (numRetries > maxRetries) { LOG.severe("Task did not complete after " + maxRetries + " retries, giving up."); } else { LOG.info("Task was not successful, resubmitting (num retries: " + numRetries + ")"); retry(); } } else { set(true); } } }
887
348
{"nom":"Lédenon","circ":"6ème circonscription","dpt":"Gard","inscrits":1163,"abs":582,"votants":581,"blancs":3,"nuls":1,"exp":577,"res":[{"nuance":"REM","nom":"<NAME>","voix":194},{"nuance":"FN","nom":"Mme <NAME>","voix":177},{"nuance":"FI","nom":"Mme <NAME>","voix":78},{"nuance":"LR","nom":"M. <NAME>","voix":55},{"nuance":"DLF","nom":"M. <NAME>","voix":17},{"nuance":"ECO","nom":"M. <NAME>","voix":16},{"nuance":"COM","nom":"<NAME>","voix":13},{"nuance":"ECO","nom":"Mme <NAME>","voix":9},{"nuance":"ECO","nom":"M. <NAME>","voix":8},{"nuance":"DIV","nom":"<NAME>","voix":5},{"nuance":"DVD","nom":"M. <NAME>","voix":4},{"nuance":"EXG","nom":"Mme <NAME>","voix":1},{"nuance":"DVG","nom":"<NAME>","voix":0}]}
290
310
<reponame>MaethorNaur/PolyGlot /** * @author <NAME> * @version 1.0 */ package org.darisadesigns.polyglotlina.ExternalCode; import java.awt.geom.AffineTransform; import javax.swing.text.View; public final class ScaleTransform implements TextShapeTransform { private float yScale=1; private float y=0; private float ascent =0; public ScaleTransform(float _yScale) { this.yScale = _yScale; } public AffineTransform getTransform(View gv, AffineTransform original) { AffineTransform newTr=new AffineTransform(); newTr.translate(0, -(y - ascent+3)* yScale); newTr.scale(1, yScale); newTr.translate(0, (y -ascent+3)/ yScale); return newTr; } public float getY() { return y; } public void setY(float _y) { this.y = _y; } public float getYScale() { return yScale; } public void setYScale(float _yScale) { this.yScale = _yScale; } public float getAscent() { return ascent; } public void setAscent(float _ascent) { this.ascent = _ascent; } }
548
348
<reponame>chamberone/Leaflet.PixiOverlay {"nom":"Crégols","circ":"1ère circonscription","dpt":"Lot","inscrits":71,"abs":46,"votants":25,"blancs":7,"nuls":0,"exp":18,"res":[{"nuance":"LR","nom":"<NAME>","voix":10},{"nuance":"REM","nom":"<NAME>","voix":8}]}
106
963
package com.vladmihalcea.book.hpjp.hibernate.concurrency.version; import com.vladmihalcea.book.hpjp.util.AbstractTest; import com.vladmihalcea.book.hpjp.util.providers.Database; import org.junit.Test; import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.Table; import javax.persistence.Version; import static org.junit.Assert.assertEquals; /** * @author <NAME> */ public class DefaultMinValueShortVersionTest extends AbstractTest { @Override protected Class<?>[] entities() { return new Class<?>[]{ Product.class }; } @Override protected Database database() { return Database.MYSQL; } @Test public void testOptimisticLocking() { doInJPA(entityManager -> { entityManager.persist( new Product() .setId(1L) .setQuantity(10) .setVersion(Short.MAX_VALUE) ); }); doInJPA(entityManager -> { Product product = entityManager.find(Product.class, 1L); assertEquals(Short.MAX_VALUE, product.getVersion()); product.setQuantity(9); }); doInJPA(entityManager -> { Product product = entityManager.find(Product.class, 1L); assertEquals(Short.MIN_VALUE, product.getVersion()); }); } @Entity(name = "Product") @Table(name = "product") public static class Product { @Id private Long id; private int quantity; @Version private short version; public Long getId() { return id; } public Product setId(Long id) { this.id = id; return this; } public int getQuantity() { return quantity; } public Product setQuantity(int quantity) { this.quantity = quantity; return this; } public short getVersion() { return version; } public Product setVersion(short version) { this.version = version; return this; } } }
1,021
559
/** * Copyright (c) 2014-2017 Netflix, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package burp.msl.util; import java.security.SecureRandom; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.Map; import java.util.Random; import java.util.Set; import java.util.SortedSet; import java.util.TreeSet; import javax.crypto.SecretKey; import javax.crypto.spec.SecretKeySpec; import burp.msl.tokens.EchoingTokenFactory; import com.netflix.msl.MslCryptoException; import com.netflix.msl.crypto.ICryptoContext; import com.netflix.msl.crypto.JcaAlgorithm; import com.netflix.msl.crypto.SymmetricCryptoContext; import com.netflix.msl.entityauth.EntityAuthenticationData; import com.netflix.msl.entityauth.EntityAuthenticationFactory; import com.netflix.msl.entityauth.EntityAuthenticationScheme; import com.netflix.msl.entityauth.MockPresharedAuthenticationFactory; import com.netflix.msl.entityauth.MockRsaAuthenticationFactory; import com.netflix.msl.entityauth.MockX509AuthenticationFactory; import com.netflix.msl.entityauth.PresharedAuthenticationData; import com.netflix.msl.entityauth.RsaAuthenticationData; import com.netflix.msl.entityauth.UnauthenticatedAuthenticationData; import com.netflix.msl.entityauth.X509AuthenticationData; import com.netflix.msl.io.DefaultMslEncoderFactory; import com.netflix.msl.io.MslEncoderFactory; import com.netflix.msl.keyx.AsymmetricWrappedExchange; import com.netflix.msl.keyx.DiffieHellmanExchange; import com.netflix.msl.keyx.KeyExchangeFactory; import com.netflix.msl.keyx.KeyExchangeScheme; import com.netflix.msl.keyx.MockDiffieHellmanParameters; import com.netflix.msl.keyx.SymmetricWrappedExchange; import com.netflix.msl.msg.MessageCapabilities; import com.netflix.msl.tokens.TokenFactory; import com.netflix.msl.userauth.UserAuthenticationFactory; import com.netflix.msl.userauth.UserAuthenticationScheme; import com.netflix.msl.util.AuthenticationUtils; import com.netflix.msl.util.MockAuthenticationUtils; import com.netflix.msl.util.MslContext; import com.netflix.msl.util.MslStore; import com.netflix.msl.util.NullMslStore; /** * User: skommidi * Date: 9/22/14 */ public class WiretapMslContext extends MslContext { /** * Key exchange factory comparator. */ private static class KeyExchangeFactoryComparator implements Comparator<KeyExchangeFactory> { /** Scheme priorities. Lower values are higher priority. */ private final Map<KeyExchangeScheme,Integer> schemePriorities = new HashMap<KeyExchangeScheme,Integer>(); /** * Create a new key exchange factory comparator. */ public KeyExchangeFactoryComparator() { schemePriorities.put(KeyExchangeScheme.JWK_LADDER, 0); schemePriorities.put(KeyExchangeScheme.JWE_LADDER, 1); schemePriorities.put(KeyExchangeScheme.DIFFIE_HELLMAN, 2); schemePriorities.put(KeyExchangeScheme.SYMMETRIC_WRAPPED, 3); schemePriorities.put(KeyExchangeScheme.ASYMMETRIC_WRAPPED, 4); } /* (non-Javadoc) * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) */ @Override public int compare(final KeyExchangeFactory a, final KeyExchangeFactory b) { final KeyExchangeScheme schemeA = a.getScheme(); final KeyExchangeScheme schemeB = b.getScheme(); final Integer priorityA = schemePriorities.get(schemeA); final Integer priorityB = schemePriorities.get(schemeB); return priorityA.compareTo(priorityB); } } /** * <p>Create a new wiretap MSL context.</p> * * @param entityAuthFactories entity authentication factories. * @param userAuthFactories user authentication factories. */ public WiretapMslContext(final Set<EntityAuthenticationFactory> entityAuthFactories, final Set<UserAuthenticationFactory> userAuthFactories) { final SecretKey mslEncryptionKey = new SecretKeySpec(MSL_ENCRYPTION_KEY, JcaAlgorithm.AES); final SecretKey mslHmacKey = new SecretKeySpec(MSL_HMAC_KEY, JcaAlgorithm.HMAC_SHA256); final SecretKey mslWrappingKey = new SecretKeySpec(MSL_WRAPPING_KEY, JcaAlgorithm.AESKW); this.mslCryptoContext = new SymmetricCryptoContext(this, "TestMslKeys", mslEncryptionKey, mslHmacKey, mslWrappingKey); // Entity authentication factories are mapped as-is. final Map<EntityAuthenticationScheme,EntityAuthenticationFactory> entityAuthFactoriesMap = new HashMap<EntityAuthenticationScheme,EntityAuthenticationFactory>(); for (final EntityAuthenticationFactory factory : entityAuthFactories) { entityAuthFactoriesMap.put(factory.getScheme(), factory); } this.entityAuthFactories = Collections.unmodifiableMap(entityAuthFactoriesMap); // User authentication factories are mapped as-is. final Map<UserAuthenticationScheme,UserAuthenticationFactory> userAuthFactoriesMap = new HashMap<UserAuthenticationScheme,UserAuthenticationFactory>(); for (final UserAuthenticationFactory factory : userAuthFactories) { userAuthFactoriesMap.put(factory.getScheme(), factory); } this.userAuthFactories = Collections.unmodifiableMap(userAuthFactoriesMap); final MockDiffieHellmanParameters params = MockDiffieHellmanParameters.getDefaultParameters(); final AuthenticationUtils authutils = new MockAuthenticationUtils(); final SortedSet<KeyExchangeFactory> keyExchangeFactoriesSet = new TreeSet<KeyExchangeFactory>(new KeyExchangeFactoryComparator()); keyExchangeFactoriesSet.add(new AsymmetricWrappedExchange(authutils)); keyExchangeFactoriesSet.add(new SymmetricWrappedExchange(authutils)); keyExchangeFactoriesSet.add(new DiffieHellmanExchange(params, authutils)); this.keyExchangeFactories = Collections.unmodifiableSortedSet(keyExchangeFactoriesSet); } /* (non-Javadoc) * @see com.netflix.msl.util.MslContext#getTime() */ @Override public long getTime() { return System.currentTimeMillis(); } /* (non-Javadoc) * @see com.netflix.msl.util.MslContext#getRandom() */ @Override public Random getRandom() { return random; } /* (non-Javadoc) * @see com.netflix.msl.util.MslContext#isPeerToPeer() */ @Override public boolean isPeerToPeer() { return false; } /* (non-Javadoc) * @see com.netflix.msl.util.MslContext#getMessageCapabilities() */ @Override public MessageCapabilities getMessageCapabilities() { return capabilities; } /* (non-Javadoc) * @see com.netflix.msl.util.MslContext#getEntityAuthenticationData(com.netflix.msl.util.MslContext.ReauthCode) */ @Override public EntityAuthenticationData getEntityAuthenticationData(final ReauthCode reauthCode) { return entityAuthData; } public void setEntityAuthenticationData(final EntityAuthenticationScheme scheme) throws MslCryptoException { if (EntityAuthenticationScheme.PSK.equals(scheme)) entityAuthData = new PresharedAuthenticationData(MockPresharedAuthenticationFactory.PSK_ESN); else if (EntityAuthenticationScheme.X509.equals(scheme)) entityAuthData = new X509AuthenticationData(MockX509AuthenticationFactory.X509_CERT); else if (EntityAuthenticationScheme.RSA.equals(scheme)) entityAuthData = new RsaAuthenticationData(MockRsaAuthenticationFactory.RSA_ESN, MockRsaAuthenticationFactory.RSA_PUBKEY_ID); else if (EntityAuthenticationScheme.NONE.equals(scheme)) entityAuthData = new UnauthenticatedAuthenticationData("MOCKUNAUTH-ESN"); else throw new IllegalArgumentException("Unsupported authentication type: " + scheme.name()); } /* (non-Javadoc) * @see com.netflix.msl.util.MslContext#getMslCryptoContext() */ @Override public ICryptoContext getMslCryptoContext() { return mslCryptoContext; } /* (non-Javadoc) * @see com.netflix.msl.util.MslContext#getEntityAuthenticationScheme(java.lang.String) */ @Override public EntityAuthenticationScheme getEntityAuthenticationScheme(final String name) { return EntityAuthenticationScheme.getScheme(name); } /* (non-Javadoc) * @see com.netflix.msl.util.MslContext#getEntityAuthenticationFactory(com.netflix.msl.entityauth.EntityAuthenticationScheme) */ @Override public EntityAuthenticationFactory getEntityAuthenticationFactory(final EntityAuthenticationScheme scheme) { return entityAuthFactories.get(scheme); } /* (non-Javadoc) * @see com.netflix.msl.util.MslContext#getUserAuthenticationScheme(java.lang.String) */ @Override public UserAuthenticationScheme getUserAuthenticationScheme(final String name) { return UserAuthenticationScheme.getScheme(name); } /* (non-Javadoc) * @see com.netflix.msl.util.MslContext#getUserAuthenticationFactory(com.netflix.msl.userauth.UserAuthenticationScheme) */ @Override public UserAuthenticationFactory getUserAuthenticationFactory(final UserAuthenticationScheme scheme) { return userAuthFactories.get(scheme); } /* (non-Javadoc) * @see com.netflix.msl.util.MslContext#getTokenFactory() */ @Override public TokenFactory getTokenFactory() { return tokenFactory; } /* (non-Javadoc) * @see com.netflix.msl.util.MslContext#getKeyExchangeScheme(java.lang.String) */ @Override public KeyExchangeScheme getKeyExchangeScheme(final String name) { return KeyExchangeScheme.getScheme(name); } /* (non-Javadoc) * @see com.netflix.msl.util.MslContext#getKeyExchangeFactory(com.netflix.msl.keyx.KeyExchangeScheme) */ @Override public KeyExchangeFactory getKeyExchangeFactory(final KeyExchangeScheme scheme) { for (final KeyExchangeFactory factory : keyExchangeFactories) { if (factory.getScheme().equals(scheme)) return factory; } return null; } /* (non-Javadoc) * @see com.netflix.msl.util.MslContext#getKeyExchangeFactories() */ @Override public SortedSet<KeyExchangeFactory> getKeyExchangeFactories() { return keyExchangeFactories; } /* (non-Javadoc) * @see com.netflix.msl.util.MslContext#getMslStore() */ @Override public MslStore getMslStore() { return mslStore; } /* (non-Javadoc) * @see com.netflix.msl.util.MslContext#getMslEncoderFactory() */ @Override public MslEncoderFactory getMslEncoderFactory() { return encoderFactory; } /** MSL encryption key. */ private static final byte[] MSL_ENCRYPTION_KEY = { (byte)0x1d, (byte)0x58, (byte)0xf3, (byte)0xb8, (byte)0xf7, (byte)0x47, (byte)0xd1, (byte)0x6a, (byte)0xb1, (byte)0x93, (byte)0xc4, (byte)0xc0, (byte)0xa6, (byte)0x24, (byte)0xea, (byte)0xcf, }; /** MSL HMAC key. */ private static final byte[] MSL_HMAC_KEY = { (byte)0xd7, (byte)0xae, (byte)0xbf, (byte)0xd5, (byte)0x87, (byte)0x9b, (byte)0xb0, (byte)0xe0, (byte)0xad, (byte)0x01, (byte)0x6a, (byte)0x4c, (byte)0xf3, (byte)0xcb, (byte)0x39, (byte)0x82, (byte)0xf5, (byte)0xba, (byte)0x26, (byte)0x0d, (byte)0xa5, (byte)0x20, (byte)0x24, (byte)0x5b, (byte)0xb4, (byte)0x22, (byte)0x75, (byte)0xbd, (byte)0x79, (byte)0x47, (byte)0x37, (byte)0x0c, }; /** MSL wrapping key. */ private static final byte[] MSL_WRAPPING_KEY = { (byte)0x83, (byte)0xb6, (byte)0x9a, (byte)0x15, (byte)0x80, (byte)0xd3, (byte)0x23, (byte)0xa2, (byte)0xe7, (byte)0x9d, (byte)0xd9, (byte)0xb2, (byte)0x26, (byte)0x26, (byte)0xb3, (byte)0xf6, }; /** Secure random. */ private final Random random = new SecureRandom(); /** Message capabilities. */ private final MessageCapabilities capabilities = new MessageCapabilities(null, null, null); /** Entity authentication data. */ private EntityAuthenticationData entityAuthData = new UnauthenticatedAuthenticationData("WireTap"); /** MSL token crypto context. */ private final ICryptoContext mslCryptoContext; /** Map of supported entity authentication schemes onto factories. */ private final Map<EntityAuthenticationScheme, EntityAuthenticationFactory> entityAuthFactories; /** Map of supported user authentication schemes onto factories. */ private final Map<UserAuthenticationScheme, UserAuthenticationFactory> userAuthFactories; /** Token factory. */ private final TokenFactory tokenFactory = new EchoingTokenFactory(); /** Supported key exchange factories in preferred order. */ private final SortedSet<KeyExchangeFactory> keyExchangeFactories; /** MSL store. */ private final MslStore mslStore = new NullMslStore(); /** MSL encoder factory. */ private final MslEncoderFactory encoderFactory = new DefaultMslEncoderFactory(); }
5,208
495
<filename>samples/src/main/java/org/m4m/samples/ComposerTranscodeCoreActivity.java<gh_stars>100-1000 /* * Copyright 2014-2016 Media for Mobile * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.m4m.samples; import android.content.DialogInterface; import android.content.Intent; import android.media.MediaCodecInfo; import android.net.Uri; import android.os.Bundle; import android.view.SurfaceHolder; import android.view.View; import android.view.View.OnClickListener; import android.view.Window; import android.view.WindowManager; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.ImageButton; import android.widget.ProgressBar; import android.widget.Spinner; import android.widget.TextView; import org.m4m.android.AndroidMediaObjectFactory; import org.m4m.android.AudioFormatAndroid; import org.m4m.android.VideoFormatAndroid; import org.m4m.domain.ISurfaceWrapper; import org.m4m.samples.controls.TranscodeSurfaceView; import java.io.IOException; import java.nio.ByteBuffer; import java.util.concurrent.TimeUnit; public class ComposerTranscodeCoreActivity extends ActivityWithTimeline implements SurfaceHolder.Callback { protected String srcMediaName1 = null; protected String srcMediaName2 = null; protected String dstMediaPath = null; protected org.m4m.Uri mediaUri1; protected org.m4m.Uri mediaUri2; protected org.m4m.MediaFileInfo mediaFileInfo = null; protected long duration = 0; protected ProgressBar progressBar; protected TextView pathInfo; protected TextView durationInfo; protected TextView effectDetails; private TextView audioChannelCountInfo; private TextView audioSampleRateInfo; protected TextView transcodeInfoView; /////////////////////////////////////////////////////////////////////////// protected org.m4m.AudioFormat audioFormat = null; protected org.m4m.VideoFormat videoFormat = null; // Transcode parameters // Video protected int videoWidthOut; protected int videoHeightOut; protected int videoWidthIn = 640; protected int videoHeightIn = 480; protected Spinner frameSizeSpinner; protected Spinner videoBitRateSpinner; protected final String videoMimeType = "video/avc"; protected int videoBitRateInKBytes = 5000; protected final int videoFrameRate = 30; protected final int videoIFrameInterval = 1; // Audio protected final String audioMimeType = "audio/mp4a-latm"; protected final int audioSampleRate = 44100; protected final int audioChannelCount = 2; protected final int audioBitRate = 96 * 1024; protected Button buttonStop; protected Button buttonStart; /////////////////////////////////////////////////////////////////////////// // Media Composer parameters and logic protected org.m4m.MediaComposer mediaComposer; private boolean isStopped = false; public org.m4m.IProgressListener progressListener = new org.m4m.IProgressListener() { @Override public void onMediaStart() { try { runOnUiThread(new Runnable() { @Override public void run() { progressBar.setProgress(0); frameSizeSpinner.setEnabled(false); videoBitRateSpinner.setEnabled(false); updateUI(true); } }); } catch (Exception e) { } } @Override public void onMediaProgress(float progress) { final float mediaProgress = progress; try { runOnUiThread(new Runnable() { @Override public void run() { progressBar.setProgress((int) (progressBar.getMax() * mediaProgress)); } }); } catch (Exception e) { } } @Override public void onMediaDone() { try { runOnUiThread(new Runnable() { @Override public void run() { if (isStopped) { return; } updateUI(false); reportTranscodeDone(); } }); } catch (Exception e) { } } @Override public void onMediaPause() { } @Override public void onMediaStop() { } @Override public void onError(Exception exception) { try { final Exception e = exception; runOnUiThread(new Runnable() { @Override public void run() { updateUI(false); String message = (e.getMessage() != null) ? e.getMessage() : e.toString(); showMessageBox("Transcoding failed." + "\n" + message, null); } }); } catch (Exception e) { } } }; protected AndroidMediaObjectFactory factory; ///////////////////////////////////////////////////////////////////////// @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.composer_transcode_core_activity); buttonStart = (Button) findViewById(R.id.buttonStart); buttonStop = (Button) findViewById(R.id.buttonStop); pathInfo = (TextView) findViewById(R.id.pathInfo); durationInfo = (TextView) findViewById(R.id.durationInfo); effectDetails = (TextView) findViewById(R.id.effectDetails); audioChannelCountInfo = (TextView) findViewById(R.id.audioChannelCount); audioSampleRateInfo = (TextView) findViewById(R.id.audioSampleRate); initVideoSpinners(); transcodeInfoView = (TextView) findViewById(R.id.transcodeInfo); progressBar = (ProgressBar) findViewById(R.id.progressBar); progressBar.setMax(100); //// TranscodeSurfaceView transcodeSurfaceView = (TranscodeSurfaceView) findViewById(R.id.transcodeSurfaceView); transcodeSurfaceView.getHolder().addCallback(this); //// getActivityInputs(); getFileInfo(); setupUI(); printFileInfo(); transcodeSurfaceView.setImageSize(videoWidthIn, videoHeightIn); updateUI(false); } @Override protected void onDestroy() { if (mediaComposer != null) { mediaComposer.stop(); isStopped = true; } super.onDestroy(); } protected void setupUI() { buttonStart.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { startTranscode(); } }); buttonStop.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { stopTranscode(); } }); } protected void initVideoSpinners() { ArrayAdapter<CharSequence> adapter; // Video parameters spinners frameSizeSpinner = (Spinner) findViewById(R.id.frameSize_spinner); adapter = ArrayAdapter.createFromResource(this, R.array.frame_size_values, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); frameSizeSpinner.setAdapter(adapter); frameSizeSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { String[] frameSizeContainer = frameSizeSpinner.getSelectedItem().toString().split("x", 2); videoWidthOut = Integer.valueOf(frameSizeContainer[0].trim()); videoHeightOut = Integer.valueOf(frameSizeContainer[1].trim()); } @Override public void onNothingSelected(AdapterView<?> adapterView) { } }); videoBitRateSpinner = (Spinner) findViewById(R.id.videoBitRate_spinner); adapter = ArrayAdapter.createFromResource(this, R.array.video_bit_rate_values, android.R.layout.simple_spinner_item); videoBitRateSpinner.setAdapter(adapter); videoBitRateSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { videoBitRateInKBytes = Integer.valueOf(videoBitRateSpinner.getSelectedItem().toString()); } @Override public void onNothingSelected(AdapterView<?> adapterView) { } }); } /////////////////////////////////////////////////////////////////////////// protected void getActivityInputs() { Bundle b = getIntent().getExtras(); srcMediaName1 = b.getString("srcMediaName1"); dstMediaPath = b.getString("dstMediaPath"); mediaUri1 = new org.m4m.Uri(b.getString("srcUri1")); } ///////////////////////////////////////////////////////////////////////// protected void getFileInfo() { try { mediaFileInfo = new org.m4m.MediaFileInfo(new AndroidMediaObjectFactory(getApplicationContext())); mediaFileInfo.setUri(mediaUri1); duration = mediaFileInfo.getDurationInMicroSec(); audioFormat = (org.m4m.AudioFormat) mediaFileInfo.getAudioFormat(); if (audioFormat == null) { showMessageBox("Audio format info unavailable", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { } }); } videoFormat = (org.m4m.VideoFormat) mediaFileInfo.getVideoFormat(); if (videoFormat == null) { showMessageBox("Video format info unavailable", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { } }); } else { videoWidthIn = videoFormat.getVideoFrameSize().width(); videoHeightIn = videoFormat.getVideoFrameSize().height(); } } catch (Exception e) { String message = (e.getMessage() != null) ? e.getMessage() : e.toString(); showMessageBox(message, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { } }); } } protected void displayVideoFrame(SurfaceHolder holder) { if (videoFormat != null) { try { ISurfaceWrapper surface = AndroidMediaObjectFactory.Converter.convert(holder.getSurface()); mediaFileInfo.setOutputSurface(surface); ByteBuffer buffer = ByteBuffer.allocate(1); mediaFileInfo.getFrameAtPosition(100, buffer); } catch (Exception e) { String message = (e.getMessage() != null) ? e.getMessage() : e.toString(); showMessageBox(message, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { } }); } } } /////////////////////////////////////////////////////////////////////////// @Override public void surfaceCreated(SurfaceHolder holder) { displayVideoFrame(holder); } @Override public void surfaceDestroyed(SurfaceHolder holder) { } @Override public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { } /////////////////////////////////////////////////////////////////////////// protected void configureVideoEncoder(org.m4m.MediaComposer mediaComposer, int width, int height) { VideoFormatAndroid videoFormat = new VideoFormatAndroid(videoMimeType, width, height); videoFormat.setVideoBitRateInKBytes(videoBitRateInKBytes); videoFormat.setVideoFrameRate(videoFrameRate); videoFormat.setVideoIFrameInterval(videoIFrameInterval); mediaComposer.setTargetVideoFormat(videoFormat); } protected void configureAudioEncoder(org.m4m.MediaComposer mediaComposer) { /** * TODO: Audio resampling is unsupported by current m4m release * Output sample rate and channel count are the same as for input. */ AudioFormatAndroid aFormat = new AudioFormatAndroid(audioMimeType, audioFormat.getAudioSampleRateInHz(), audioFormat.getAudioChannelCount()); aFormat.setAudioBitrateInBytes(audioBitRate); aFormat.setAudioProfile(MediaCodecInfo.CodecProfileLevel.AACObjectLC); mediaComposer.setTargetAudioFormat(aFormat); } protected void setTranscodeParameters(org.m4m.MediaComposer mediaComposer) throws IOException { mediaComposer.addSourceFile(mediaUri1); int orientation = mediaFileInfo.getRotation(); mediaComposer.setTargetFile(dstMediaPath, orientation); configureVideoEncoder(mediaComposer, videoWidthOut, videoHeightOut); configureAudioEncoder(mediaComposer); } protected void transcode() throws Exception { factory = new AndroidMediaObjectFactory(getApplicationContext()); mediaComposer = new org.m4m.MediaComposer(factory, progressListener); setTranscodeParameters(mediaComposer); mediaComposer.start(); } public void startTranscode() { try { transcode(); } catch (Exception e) { buttonStart.setEnabled(false); String message = (e.getMessage() != null) ? e.getMessage() : e.toString(); showMessageBox(message, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { } }); } } public void stopTranscode() { mediaComposer.stop(); } private void reportTranscodeDone() { String message = "Transcoding finished."; DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { progressBar.setVisibility(View.INVISIBLE); findViewById(R.id.buttonStart).setVisibility(View.GONE); findViewById(R.id.buttonStop).setVisibility(View.GONE); OnClickListener l = new OnClickListener() { @Override public void onClick(View v) { playResult(); } }; ImageButton ib = (ImageButton) findViewById(R.id.imageButtonPlay); ib.setVisibility(View.VISIBLE); ib.setOnClickListener(l); } }; showMessageBox(message, listener); } private void playResult() { String videoUrl = "file:///" + dstMediaPath; Intent intent = new Intent(android.content.Intent.ACTION_VIEW); Uri data = Uri.parse(videoUrl); intent.setDataAndType(data, "video/mp4"); startActivity(intent); } private void updateUI(boolean inProgress) { buttonStart.setEnabled(!inProgress); buttonStop.setEnabled(inProgress); if (inProgress) { progressBar.setVisibility(View.VISIBLE); } else { progressBar.setVisibility(View.INVISIBLE); } } //////////////////////////////////////////////////////////////////////////// protected void printPaths() { pathInfo.setText(String.format("srcMediaFileName = %s\ndstMediaPath = %s\n", srcMediaName1, dstMediaPath)); } protected void getDstDuration() { } protected void printDuration() { getDstDuration(); durationInfo.setText(String.format("Duration = %d sec", TimeUnit.MICROSECONDS.toSeconds(duration))); } protected void printEffectDetails() { } protected void printFileInfo() { printPaths(); printDuration(); printEffectDetails(); printAudioInfo(); } private void printAudioInfo() { audioChannelCountInfo.setText(String.valueOf(audioFormat.getAudioChannelCount())); audioSampleRateInfo.setText(String.valueOf(audioFormat.getAudioSampleRateInHz())); } }
7,309
1,531
/* * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package net.grinder.engine.process; import java.lang.reflect.Constructor; import java.lang.reflect.Method; import java.lang.reflect.Modifier; import net.grinder.script.NonInstrumentableTypeException; import net.grinder.script.Test.InstrumentationFilter; import net.grinder.scriptengine.AbstractDCRInstrumenter; import net.grinder.scriptengine.DCRContext; import net.grinder.scriptengine.Recorder; import net.grinder.util.weave.Weaver.TargetSource; /** * DCR instrumenter for Java. * * This is modified from JavaDCRInstrumenter due to it's package * protected visibility. * * @author <NAME> * @author <NAME> (modified by) */ public class JavaDCRInstrumenterEx extends AbstractDCRInstrumenter { /** * Constructor. * * @param context The DCR context. */ public JavaDCRInstrumenterEx(DCRContext context) { super(context); } /** * {@inheritDoc} */ @Override public String getDescription() { return "byte code transforming instrumenter for Java"; } /** * {@inheritDoc} */ @Override protected boolean instrument(Object target, Recorder recorder, InstrumentationFilter filter) throws NonInstrumentableTypeException { if (target instanceof Class<?>) { instrumentClass((Class<?>) target, recorder, filter); } else if (target != null) { instrumentInstance(target, recorder, filter); } return true; } private void instrumentClass(Class<?> targetClass, Recorder recorder, InstrumentationFilter filter) throws NonInstrumentableTypeException { if (targetClass.isArray()) { throw new NonInstrumentableTypeException("Can't instrument arrays"); } for (Constructor<?> constructor : targetClass.getDeclaredConstructors()) { getContext().add(targetClass, constructor, recorder); } // Instrument the static methods declared by the target class. Ignore // any parent class. for (Method method : targetClass.getDeclaredMethods()) { if (Modifier.isStatic(method.getModifiers()) && filter.matches(method)) { getContext().add(targetClass, method, TargetSource.CLASS, recorder); } } } private void instrumentInstance(Object target, Recorder recorder, InstrumentationFilter filter) throws NonInstrumentableTypeException { Class<?> c = target.getClass(); if (c.isArray()) { throw new NonInstrumentableTypeException("Can't instrument arrays"); } do { for (Method method : c.getDeclaredMethods()) { if (!Modifier.isStatic(method.getModifiers()) && filter.matches(method)) { getContext().add(target, method, TargetSource.FIRST_PARAMETER, recorder); } } c = c.getSuperclass(); } while (getContext().isInstrumentable(c)); } }
1,025
435
{ "copyright_text": "Standard YouTube License", "description": "Large N-body particle datasets present a unique challenge for analysis and visualization. With multi-terabyte datasets becoming increasingly common, the goal of performing large-scale analysis and visualization of such large quantities of data becomes increasingly challenging.\n\nIn this talk we describe a new particle indexing scheme we have designed for yt, a python toolkit for the analysis and visualization of 3D simulation data. By making use of compressed Morton bitmaps to index the locations of particles, we substantially decrease the overhead to perform spatial chunking. By rethinking the high-level yt API for N-body data to be more particle-centric, we are able to scale analysis and visualization to datasets containing very large numbers of particles while reaping performance improvements and decreased memory overhead when working with smaller datasets.", "duration": 1451, "language": "eng", "recorded": "2017-07-14", "related_urls": [ { "label": "schedule", "url": "https://scipy2017.scipy.org/ehome/220975/493422/" } ], "speakers": [ "<NAME>", "<NAME>" ], "tags": [ "yt" ], "thumbnail_url": "https://i.ytimg.com/vi/pkZgQIGac6I/maxresdefault.jpg", "title": "The Demeshening The Next Generation of Particle Support in yt", "videos": [ { "type": "youtube", "url": "https://www.youtube.com/watch?v=pkZgQIGac6I" } ] }
442
1,091
<gh_stars>1000+ /* * Copyright 2017-present Open Networking Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.onosproject.incubator.protobuf.models.core; import org.onosproject.core.Version; import org.onosproject.grpc.core.models.VersionProtoOuterClass.VersionProto; import static org.onosproject.grpc.core.models.VersionProtoOuterClass.VersionProto.getDefaultInstance; /** * gRPC Version message to equivalent ONOS Version conversion related utilities. */ public final class VersionProtoTranslator { /** * Translates {@link Version} to gRPC version message. * * @param version {@link Version} * @return gRPC message */ public static VersionProto translate(Version version) { if (version != null) { return VersionProto.newBuilder() .setMajor(version.major()) .setMinor(version.minor()) .setPatch(version.patch()) .setBuild(version.build()) .build(); } return getDefaultInstance(); } /** * Translates gRPC version message to {@link Version}. * * @param version gRPC message * @return {@link Version} */ public static Version translate(VersionProto version) { return Version.version(version.getMajor(), version.getMinor(), version.getPatch(), version.getBuild()); } // Utility class not intended for instantiation. private VersionProtoTranslator() {} }
722
1,968
<gh_stars>1000+ ////////////////////////////////////////////////////////////////////////////// // // This file is part of the Corona game engine. // For overview and more information on licensing please refer to README.md // Home page: https://github.com/coronalabs/corona // Contact: <EMAIL> // ////////////////////////////////////////////////////////////////////////////// #include "Core/Rtt_Build.h" #include "Rtt_LuaProxy.h" #include "Rtt_LuaProxyVTable.h" #include "Rtt_LuaAux.h" #include "Rtt_MLuaProxyable.h" #include <string.h> // ---------------------------------------------------------------------------- namespace Rtt { // ---------------------------------------------------------------------------- // LuaProxyVTableTracer wraps LuaProxyVTable instances // #ifdef Rtt_DEBUG // Uncomment the following line to enable this functionality: //#define Rtt_TRACE_LUAPROXYDELEGATE #endif #ifdef Rtt_TRACE_LUAPROXYDELEGATE class LuaProxyVTableTracer : public LuaProxyVTable { public: LuaProxyVTableTracer( const LuaProxyVTable& delegate, void* proxy ); protected: void PrintCommon( lua_State *L, const char metamethod[], const char key[] ) const; public: virtual int ValueForKey( lua_State *L, const char key[] ) const; virtual bool SetValueForKey( lua_State *L, const char key[], int valueIndex ) const; private: const LuaProxyVTable& fDelegate; void* fProxy; }; LuaProxyVTableTracer::LuaProxyVTableTracer( const LuaProxyVTable& delegate, void* proxy ) : fDelegate( delegate ), fProxy( proxy ) { } void LuaProxyVTableTracer::PrintCommon( lua_State *L, const char metamethod[], const char key[] ) const { Rtt_ASSERT( metamethod ); Rtt_ASSERT( key ); Rtt_TRACE( ( "META %s( (this=%p) (key=%s) ", metamethod, fProxy, key ) ); } int LuaProxyVTableTracer::ValueForKey( lua_State *L, const char key[] ) const { PrintCommon( L, " __index", key ); Rtt_TRACE( ( ")\n" ) ); return fDelegate.ValueForKey( L, key ); } bool LuaProxyVTableTracer::SetValueForKey( lua_State *L, const char key[], int valueIndex ) const { PrintCommon( L, "__newindex", key ); Rtt_TRACE( ( "(value=" ) ); switch( lua_type( L, valueIndex ) ) { case LUA_TNIL: Rtt_TRACE( ( "nil" ) ); break; case LUA_TBOOLEAN: Rtt_TRACE( ( "%s", lua_toboolean( L, valueIndex ) ? "true" : "false" ) ); break; case LUA_TNUMBER: Rtt_TRACE( ( "%g", lua_tonumber( L, valueIndex ) ) ); break; case LUA_TSTRING: Rtt_TRACE( ( "%s", lua_tostring( L, valueIndex ) ) ); break; case LUA_TLIGHTUSERDATA: Rtt_TRACE( ( "%p [light userdata]", lua_topointer( L, valueIndex ) ) ); break; case LUA_TTABLE: Rtt_TRACE( ( "%p [table]", lua_topointer( L, valueIndex ) ) ); break; case LUA_TFUNCTION: Rtt_TRACE( ( "%p [function]", lua_topointer( L, valueIndex ) ) ); break; case LUA_TUSERDATA: Rtt_TRACE( ( "%p [userdata]", lua_topointer( L, valueIndex ) ) ); break; case LUA_TTHREAD: Rtt_TRACE( ( "%p [thread]", lua_topointer( L, valueIndex ) ) ); break; default: Rtt_ASSERT_NOT_REACHED(); Rtt_TRACE( ( "THAT'S RIGHT! NOTHING!" ) ); break; } Rtt_TRACE( ( ") )\n" ) ); return fDelegate.SetValueForKey( L, key, valueIndex ); } #endif // Rtt_TRACE_LUAPROXYDELEGATE // ---------------------------------------------------------------------------- class NullProxyable : public MLuaProxyable { public: NullProxyable() : MLuaProxyable() {} virtual void InitProxy( lua_State *L ); virtual LuaProxy* GetProxy() const; virtual void ReleaseProxy(); }; void NullProxyable::InitProxy( lua_State * ) { Rtt_ASSERT_NOT_REACHED(); } LuaProxy* NullProxyable::GetProxy() const { Rtt_ASSERT_NOT_REACHED(); return NULL; } void NullProxyable::ReleaseProxy() { Rtt_ASSERT_NOT_REACHED(); } // ---------------------------------------------------------------------------- const char LuaProxyConstant::kProxyKey[] = "ProxyConstant"; const luaL_Reg LuaProxyConstant::kMetatable[] = { { "__index", LuaProxyConstant::__index }, { "__gc", LuaProxyConstant::__gcMeta }, { NULL, NULL } }; LuaProxyConstant* LuaProxyConstant::GetProxy( lua_State *L, int index ) { LuaProxyConstant** p = (LuaProxyConstant**)luaL_checkudata( L, index, kProxyKey ); return ( p ? *p : NULL ); } const MLuaProxyable& LuaProxyConstant::NullProxyableObject() { static const NullProxyable sInstance; return sInstance; } int LuaProxyConstant::__index( lua_State *L ) { int result = 0; LuaProxyConstant* proxy = GetProxy( L, 1 ); if ( proxy ) { const char* key = lua_tostring( L, 2 ); if ( key ) { const LuaProxyVTable& delegate = proxy->Delegate(); const LuaProxyVTable* pDelegate = & delegate; #ifdef Rtt_TRACE_LUAPROXYDELEGATE const LuaProxyVTableTracer tracer( delegate, proxy ); pDelegate = & tracer; #endif result = pDelegate->ValueForKey( L, NullProxyableObject(), key ); // Search for key in C++ delegate } } return result; } int LuaProxyConstant::__gcMeta( lua_State *L ) { LuaProxyConstant* p = GetProxy( L, 1 ); Rtt_DELETE( p ); return 0; } void LuaProxyConstant::Initialize( lua_State *L ) { luaL_newmetatable( L, kProxyKey ); luaL_register( L, NULL, kMetatable ); lua_pop( L, 1 ); } LuaProxyConstant::LuaProxyConstant( lua_State *L, const LuaProxyVTable& delegate ) : fDelegate( delegate ) { } LuaProxyConstant::~LuaProxyConstant() { } void LuaProxyConstant::Push( lua_State *L ) const { const LuaProxyConstant** userdata = (const LuaProxyConstant**)lua_newuserdata( L, sizeof(LuaProxyConstant*) ); * userdata = this; // Set userdata's metatable = mt luaL_getmetatable( L, kProxyKey ); // Fetch mt Rtt_ASSERT( ! lua_isnil( L, -1 ) ); lua_setmetatable( L, -2 ); // implicitly pops mt Rtt_ASSERT( lua_isuserdata( L, -1 ) ); } // ---------------------------------------------------------------------------- // LuaProxy and LuaProxyVTables are used to export C++ objects to Lua. // // LuaProxy instances represent C++ objects (e.g. Rtt::DisplayObject). // Each instance stores a lua reference (see luaL_ref) to a Lua table. // These Lua tables are the objects that a Lua coder uses to manipulate // C++ objects. They should never interact with lua_userdata. // // These Lua tables undergo initialization in two stages --- first in C++ // and second in Lua. // // On the C++ side, Lua tables are initialized (see LuaProxy::CreateTable) // to have a property "_proxy" whose value is LuaProxy instance (stored // as Lua userdata). // // On the Lua side, all tables must set the following C++ methods as the // metamethods in their metatable: // * LuaProxy::__proxyindex // * LuaProxy::__proxynewindex // // In addition, all Lua tables should have a "_class" property whose value // is the Lua table that contains the class definition for the Lua class // corresponding to the C++ class that the LuaProxy represents. // Optimization: // Uncommenting this facilitates a lazy optimization for Lua-to-C function // dispatches. During a dispatch, Lua must first obtain a function value using // the function name as the key. Since userdata isn't a table, the __index // metamethod is invoked. This metamethod is in the userdata's metatable. // // We exploit this by ensuring that each subclass of LuaProxy has its own // metatable. As functions in a particular class are fetched by __index, we // add them to that class' metatable. Subsequent calls for the same function // will hit the cache. #define Rtt_OPTIMIZE_LUAPROXY const char LuaProxy::kProxyKey[] = "Proxy"; const luaL_Reg LuaProxy::kMetatable[] = { { "__gc", LuaProxy::__gcMeta }, { NULL, NULL } }; static const char kProxyFieldKey[] = "_proxy"; static const char kClassFieldKey[] = "_class"; bool LuaProxy::IsProxy(lua_State *L, int index) { bool result = false; if ( lua_istable( L, index ) ) { lua_pushlstring( L, kProxyFieldKey, sizeof( kProxyFieldKey ) - 1 ); lua_rawget( L, index ); result = (lua_isuserdata( L, -1 ) == 1); lua_pop( L, 1 ); } return result; } LuaProxy* LuaProxy::GetProxy( lua_State *L, int index ) { LuaProxy* result = NULL; if ( lua_istable( L, index ) ) { lua_pushlstring( L, kProxyFieldKey, sizeof( kProxyFieldKey ) - 1 ); lua_rawget( L, index ); // lua_getfield( L, index, kProxyFieldKey ); Rtt_ASSERT( lua_isuserdata( L, -1 ) ); #ifdef Rtt_DEVICE_ENV // On devices, disable checking LuaProxy** p =(LuaProxy**)lua_touserdata( L, -1 ); Rtt_ASSERT( luaL_checkudata( L, -1, kProxyKey ) ); #else // On non-devices, enforce checking LuaProxy** p =(LuaProxy**)luaL_checkudata( L, -1, kProxyKey ); Rtt_WARN_SIM( ( p || lua_isnil( L, -1 ) ), ( "ERROR: This object is not a display object but is using a display object metamethod.\n" ) ); #endif if ( p ) { result = *p; } lua_pop( L, 1 ); } else { luaL_error( L, "ERROR: table expected. If this is a function call, you might have used '.' instead of ':'" ); } return result; } LuaProxy* LuaProxy::GetProxyMeta( lua_State *L, int index ) { LuaProxy** p = (LuaProxy**)luaL_checkudata( L, index, kProxyKey ); return ( p ? *p : NULL ); } MLuaProxyable* LuaProxy::GetProxyableObject( lua_State *L, int index ) { MLuaProxyable* result = NULL; LuaProxy* proxy = GetProxy( L, index ); if ( proxy ) { result = proxy->Object(); } return result; } // Does the equivalent of the following pseudo-code: // // function gettable_event( table, eventName ) // return valueForKey( table.proxy_, eventName ) or table._class[eventName] // end // // where valueForKey( ud, key ) would be a C function exported to Lua: // // int valueForKey( L, ud, key ) // { // return ((LuaProxy*)ud)->ValueForKey( L, key ) // } // int LuaProxy::__proxyindex( lua_State *L ) { #if 1 int result = 0; const MLuaProxyable *object = NULL; LuaProxy *proxy = LuaProxy::GetProxy( L, 1 ); // proxy = table.proxy_ if ( Rtt_VERIFY( proxy ) ) { object = proxy->Object(); } if ( object == NULL ) { // Proxy has no object, which means a DO was removed but a reference to the table remains, // and someone is trying to set a DO property on it. Rtt_WARN_SIM( object == NULL, ( "WARNING: Attempting to get property (%s) on a removed DisplayObject\n", lua_tostring( L, 2 ) ) ); } else { // Prevent lua_tostring from converting numbers on the stack to strings // const char* key = ! lua_isnumber( L, 2 ) ? lua_tostring( L, 2 ) : NULL; const char* key = LUA_TSTRING == lua_type( L, 2 ) ? lua_tostring( L, 2 ) : NULL; Rtt_LUA_ASSERT( L, lua_isnumber( L, 2 ) || key, "__proxyindex was passed a NULL key" ); if ( lua_isnil( L, 2 ) ) { luaL_error( L, "ERROR: nil key supplied for property lookup." ); } const LuaProxyVTable& delegate = proxy->Delegate(); const LuaProxyVTable* pDelegate = & delegate; #ifdef Rtt_TRACE_LUAPROXYDELEGATE const LuaProxyVTableTracer tracer( delegate, proxy ); pDelegate = & tracer; #endif result = pDelegate->ValueForKey( L, * object, key ); // Search for key in C++ delegate #ifdef Rtt_PHYSICS // Call extensions delegate if it exists. if ( ! result ) { const LuaProxyVTable *extensions = proxy->GetExtensionsDelegate(); if ( extensions ) { result = extensions->ValueForKey( L, *object, key ); } } #endif if ( ! result ) { lua_getfield( L, 1, kClassFieldKey ); // table._class lua_pushvalue( L, 2 ); // key lua_gettable( L, -2 ); // push table._class[key] lua_remove( L, -2 ); // pop table._class result = 1; // Return even if nil } } return result; #else int result = 1; // Search for cached functions in metatable lua_getmetatable( L, 1 ); // mt = metatable(table) lua_pushvalue( L, 2 ); // key lua_rawget( L, -2 ); // fetch mt[key] if ( lua_isnil( L, -1 ) ) { lua_pop( L, 1 ); // pop nil result = 0; LuaProxy* proxy = LuaProxy::GetProxy( L, 1 ); // proxy = table.proxy_ if ( Rtt_VERIFY( proxy ) ) { // Prevent lua_tostring from converting numbers on the stack to strings const char* key = ! lua_isnumber( L, 2 ) ? lua_tostring( L, 2 ) : NULL; Rtt_LUA_ASSERT( L, lua_isnumber( L, 2 ) || key, "__proxyindex was passed a NULL key" ); const LuaProxyVTable& delegate = proxy->Delegate(); const LuaProxyVTable* pDelegate = & delegate; #ifdef Rtt_TRACE_LUAPROXYDELEGATE const LuaProxyVTableTracer tracer( delegate, proxy ); pDelegate = & tracer; #endif result = pDelegate->ValueForKey( L, key ); // Search for key in C++ delegate if ( result ) { // Cache functions in metatable if ( lua_iscfunction( L, -1 ) ) { lua_pushvalue( L, 2 ); // key lua_pushvalue( L, -2 ); // function lua_rawset( L, -4 ); // mt[key] = function } } else { lua_getfield( L, 1, kClassFieldKey ); // table._class lua_pushvalue( L, 2 ); // key lua_gettable( L, -2 ); // push table._class[key] lua_remove( L, -2 ); // pop table._class result = 1; // Return even if nil } } } lua_remove( L, -2 ); // pop metatable return result; #endif } int LuaProxy::__proxynewindex( lua_State *L ) { MLuaProxyable *object = NULL; LuaProxy* proxy = LuaProxy::GetProxy( L, 1 ); // proxy = table.proxy_ if ( Rtt_VERIFY( proxy ) ) { object = proxy->Object(); } if ( object == NULL ) { // Proxy has no object, which means a DO was removed but a reference to the table remains, // and someone is trying to set a DO property on it. Rtt_WARN_SIM( object == NULL, ( "WARNING: Attempting to set property (%s) on a removed DisplayObject\n", lua_tostring( L, 2 ) ) ); } else { const char* key = lua_tostring( L, 2 ); Rtt_LUA_ASSERT( L, key, "__proxynewindex was passed a NULL key" ); const LuaProxyVTable& delegate = proxy->Delegate(); const LuaProxyVTable* pDelegate = & delegate; #ifdef Rtt_TRACE_LUAPROXYDELEGATE const LuaProxyVTableTracer tracer( delegate, proxy ); pDelegate = & tracer; #endif // Warn whenever the key corresponds to a proxy property (ValueForKey != 0 ) // and the newValue is none; ignore otherwise. Some properties can be set to 'nil'. Rtt_WARN_SIM( pDelegate->ValueForKey( L, * object, key ) == 0 || ! lua_isnone( L, 3 ), ( "WARNING: Attempting to set property(%s) but no value was provided\n", key ) ); bool didSetValue = false; #ifdef Rtt_PHYSICS // Call extensions delegate if it exists. This should be add-on behavior, // not modify original behavior. Therefore, it should return false for all // keys that the original pDelegate handles. It should return true only when // it handles a new key that's not handled by the traditional LuaProxyVTable hierarchy. const LuaProxyVTable *extensions = proxy->GetExtensionsDelegate(); if ( extensions ) { didSetValue = extensions->SetValueForKey( L, *object, key, 3 ); } #endif // Set value in LuaProxy for valid keys if ( ! didSetValue ) { didSetValue = pDelegate->SetValueForKey( L, *object, key, 3 ); } if ( ! didSetValue ) { // TODO: Check whether key is available, i.e. not used // by the delegate as in ValueForKey(). To be efficient, // this requires a perfect hash: // // if ( Rtt_VERIFY( pDelegate->IsKeyAvailable( key ) ) ) // Otherwise set it in the Lua table lua_pushvalue( L, 2 ); // key lua_pushvalue( L, 3 ); // value lua_rawset( L, 1 ); // table[key] = value } } return 0; } int LuaProxy::__proxyregister( lua_State *L ) { bool result = Rtt_VERIFY( lua_isstring( L, 1 ) ) && Rtt_VERIFY( lua_istable( L, 2 ) ); if ( result ) { // TODO: Put these in a single table that lives in the global registry // instead of the global registry itself #ifdef Rtt_DEBUG lua_pushvalue( L, 1 ); lua_gettable( L, LUA_REGISTRYINDEX ); Rtt_ASSERT( lua_isnil( L, -1 ) ); lua_pop( L, 1 ); #endif lua_settable( L, LUA_REGISTRYINDEX ); } lua_pushboolean( L, result ); return 1; } /* int LuaProxy::__proxylen( lua_State *L ) { LuaProxy* proxy = LuaProxy::GetProxy( L, 1 ); // proxy = table.proxy_ return ( Rtt_VERIFY( proxy ) ? proxy->Delegate().Length( L ) : 0 ); } */ int LuaProxy::__gcMeta( lua_State *L ) { // Rtt_TRACE( ( "__gcMeta( %x )\n", lua_topointer( L, 1 ) ) ); LuaProxy* p = GetProxyMeta( L, 1 ); if ( Rtt_VERIFY( p ) ) { p->Release(); Rtt_DELETE( p ); } return 0; } void LuaProxy::Initialize( lua_State *L ) { luaL_newmetatable( L, kProxyKey ); luaL_register( L, NULL, kMetatable ); lua_pop( L, 1 ); } // Need to wrap up Initialize into lua_pcall //#define PROXY_SHARED_ENV #ifdef PROXY_SHARED_ENV static int SetSharedEnvironment( lua_State *L ) { lua_pushstring( L, kInstanceTablesKey ); lua_gettable( L, LUA_REGISTRYINDEX ); if ( lua_isnil( L, -1 ) ) { lua_pop( L, 1 ); // pop nil lua_newtable( L ); // push new table lua_pushstring( L, kInstanceTablesKey ); // push key lua_pushvalue( L, -2 ); // push value (extra ref of table) lua_settable( L, LUA_REGISTRYINDEX ); // table[key] = value (pops key and value) } Rtt_ASSERT( lua_istable( L, -1 ) ); lua_replace( L, LUA_ENVIRONINDEX ); return 0; } #endif // PROXY_SHARED_ENV LuaProxy::LuaProxy( lua_State *L, MLuaProxyable& object, const LuaProxyVTable& delegate, const char* className ) : fObject( & object ), fDelegate( delegate ), #ifdef Rtt_PHYSICS fExtensionsDelegate( NULL ), #endif fTableRef( LUA_NOREF ) { LuaProxy** userdata = (LuaProxy**)lua_newuserdata( L, sizeof(LuaProxy*) ); * userdata = this; // Set userdata's metatable = mt luaL_getmetatable( L, kProxyKey ); // Fetch mt lua_setmetatable( L, -2 ); // implicitly pops mt Rtt_ASSERT( lua_isuserdata( L, -1 ) ); CreateTable( L, className ); Rtt_ASSERT( lua_isuserdata( L, -1 ) ); lua_pop( L, 1 ); // pop userdata } LuaProxy::~LuaProxy() { // luaL_unref( L, LUA_REGISTRYINDEX, TableRef() ); } void LuaProxy::CreateTable( lua_State *L, const char* className ) { Rtt_ASSERT( lua_isuserdata( L, -1 ) ); lua_newtable( L ); // t AcquireTableRef( L ); // t[proxy_] = userdata (this) Rtt_ASSERT( lua_isuserdata( L, -2 ) ); lua_pushvalue( L, -2 ); lua_setfield( L, -2, kProxyFieldKey ); // t[class_] = LUA_REGISTRY[className] lua_getfield( L, LUA_REGISTRYINDEX, className ); Rtt_ASSERT( ! lua_isnil( L, -1 ) ); lua_setfield( L, -2, kClassFieldKey ); // setmetatable( t, Runtime._proxy ) lua_getglobal( L, "Runtime" ); lua_getfield( L, -1, kProxyFieldKey ); lua_setmetatable( L, -3 ); lua_pop( L, 1 ); // pop Runtime lua_pop( L, 1 ); // pop t } void LuaProxy::RestoreTable( lua_State *L ) { int index = TableRef(); // Restore table, stripping away all the proxy baggage if ( Rtt_VERIFY( LUA_NOREF != index ) ) { // push t on top of stack PushTable( L ); // t[proxy_] = nil lua_pushnil( L ); lua_setfield( L, -2, kProxyFieldKey ); // t[class_] = nil lua_pushnil( L ); lua_setfield( L, -2, kClassFieldKey ); // setmetatable( t, nil ) lua_pushnil( L ); lua_setmetatable( L, -2 ); lua_pop( L, 1 ); // pop t } // Release proxy's reference to the MLuaProxyable (e.g. the DisplayObject) Release(); } void LuaProxy::Release() { if ( fObject ) { fObject->ReleaseProxy(); } } void LuaProxy::AcquireTableRef( lua_State *L ) { // TODO: Use environindex instead of global registry... // Assign a Lua ref to table at top of stack if ( LUA_NOREF == fTableRef ) { Rtt_ASSERT( lua_istable( L, -1 ) ); // Rtt_TRACE( ( "acquire table ref(%x)\n", lua_topointer( L, -1 ) ) ); lua_pushvalue( L, -1 ); fTableRef = luaL_ref( L, LUA_REGISTRYINDEX ); // implicitly pops extra table Rtt_ASSERT( LUA_NOREF != fTableRef ); } } void LuaProxy::ReleaseTableRef( lua_State *L ) { luaL_unref( L, LUA_REGISTRYINDEX, TableRef() ); fTableRef = LUA_NOREF; } bool LuaProxy::PushTable( lua_State *L ) const { const int index = TableRef(); Rtt_ASSERT( LUA_NOREF != index ); lua_rawgeti( L, LUA_REGISTRYINDEX, index ); Rtt_ASSERT( ! lua_isnil( L, -1 ) ); // Always return what's on the top of stack return true; } // ---------------------------------------------------------------------------- } // namespace Rtt // ----------------------------------------------------------------------------
7,678
831
<filename>android/testSrc/com/android/tools/idea/gradle/project/sync/setup/module/NdkModuleSetupTest.java /* * Copyright (C) 2016 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.tools.idea.gradle.project.sync.setup.module; import com.android.tools.idea.gradle.project.model.NdkModuleModel; import com.android.tools.idea.gradle.project.sync.ModuleSetupContext; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; import static org.mockito.Mockito.*; import static org.mockito.MockitoAnnotations.initMocks; /** * Tests for {@link NdkModuleSetup}. */ public class NdkModuleSetupTest { @Mock private NdkModuleModel myNdkModel; @Mock private NdkModuleSetupStep mySetupStep1; @Mock private NdkModuleSetupStep mySetupStep2; @Mock private ModuleSetupContext myModuleSetupContext; private NdkModuleSetup myModuleSetup; @Before public void setUp() throws Exception { initMocks(this); myModuleSetup = new NdkModuleSetup(mySetupStep1, mySetupStep2); } @Test public void setUpAndroidModule() { myModuleSetup.setUpModule(myModuleSetupContext, myNdkModel); verify(mySetupStep1, times(1)).setUpModule(myModuleSetupContext, myNdkModel); verify(mySetupStep2, times(1)).setUpModule(myModuleSetupContext, myNdkModel); } }
574
4,587
#define KEYDB_REAL_VERSION "255.255.255" #define KEYDB_VERSION_NUM 0x00ffffff extern const char *KEYDB_SET_VERSION; // Unlike real version, this can be overriden by the config
60
14,668
// Copyright (c) 2021 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "content/browser/media/capture/crop_id_web_contents_helper.h" #include <string> #include <vector> #include "base/callback.h" #include "base/containers/contains.h" #include "base/guid.h" #include "base/token.h" #include "build/build_config.h" #include "content/common/content_export.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/web_contents.h" #if defined(OS_ANDROID) #error Region Capture not supported on Android. #endif namespace content { // TODO(crbug.com/1247761): Remove this protected static function. // See header for more details. base::Token CropIdWebContentsHelper::GUIDToToken(const base::GUID& guid) { std::string lowercase = guid.AsLowercaseString(); // |lowercase| is either empty, or follows the expected pattern. // TODO(crbug.com/1260380): Resolve open question of correct treatment // of an invalid GUID. if (lowercase.empty()) { return base::Token(); } DCHECK_EQ(lowercase.length(), 32u + 4u); // 32 hex-chars; 4 hyphens. base::RemoveChars(lowercase, "-", &lowercase); DCHECK_EQ(lowercase.length(), 32u); // 32 hex-chars; 0 hyphens. base::StringPiece string_piece(lowercase); uint64_t high = 0; bool success = base::HexStringToUInt64(string_piece.substr(0, 16), &high); DCHECK(success); uint64_t low = 0; success = base::HexStringToUInt64(string_piece.substr(16, 16), &low); DCHECK(success); return base::Token(high, low); } CropIdWebContentsHelper::CropIdWebContentsHelper(WebContents* web_contents) : WebContentsObserver(web_contents), WebContentsUserData<CropIdWebContentsHelper>(*web_contents) { DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK(web_contents); } CropIdWebContentsHelper::~CropIdWebContentsHelper() = default; std::string CropIdWebContentsHelper::ProduceCropId() { DCHECK_CURRENTLY_ON(BrowserThread::UI); // Prevent Web-applications from producing an excessive number of crop-IDs. if (crop_ids_.size() >= kMaxCropIdsPerWebContents) { return std::string(); } // Given the exceedingly low likelihood of collisions, the check for // uniqueness could have theoretically been skipped. But it's cheap // enough to perform, given that `kMaxCropIdsPerWebContents` is so small // compared to the space of GUIDs, and it guarantees we never silently fail // the application by cropping to the wrong, duplicate target. base::GUID guid; base::Token crop_id; do { guid = base::GUID::GenerateRandomV4(); crop_id = GUIDToToken(guid); } while (IsAssociatedWithCropId(crop_id)); crop_ids_.push_back(crop_id); return guid.AsLowercaseString(); } bool CropIdWebContentsHelper::IsAssociatedWithCropId( const base::Token& crop_id) const { DCHECK_CURRENTLY_ON(BrowserThread::UI); return base::Contains(crop_ids_, crop_id); } void CropIdWebContentsHelper::ReadyToCommitNavigation( NavigationHandle* navigation_handle) { DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK(navigation_handle); // Cross-document navigation of the top-level frame invalidates all crop-IDs // associated with the observed WebContents. // Using IsInPrimaryMainFrame is valid here since the browser only caches this // state for the active main frame. if (!navigation_handle->IsSameDocument() && navigation_handle->IsInPrimaryMainFrame()) { ClearCropIds(); } } void CropIdWebContentsHelper::ClearCropIds() { DCHECK_CURRENTLY_ON(BrowserThread::UI); crop_ids_.clear(); } WEB_CONTENTS_USER_DATA_KEY_IMPL(CropIdWebContentsHelper); } // namespace content
1,234
560
<filename>app/src/main/java/me/zhanghai/android/douya/item/ui/RecommendationListAdapter.java /* * Copyright (c) 2017 <NAME> <<EMAIL>> * All Rights Reserved. */ package me.zhanghai.android.douya.item.ui; import androidx.annotation.NonNull; import androidx.recyclerview.widget.RecyclerView; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import butterknife.BindView; import butterknife.ButterKnife; import me.zhanghai.android.douya.R; import me.zhanghai.android.douya.link.UriHandler; import me.zhanghai.android.douya.network.api.info.frodo.CollectableItem; import me.zhanghai.android.douya.ui.RatioImageView; import me.zhanghai.android.douya.ui.SimpleAdapter; import me.zhanghai.android.douya.util.ImageUtils; import me.zhanghai.android.douya.util.ViewUtils; public class RecommendationListAdapter extends SimpleAdapter<CollectableItem, RecommendationListAdapter.ViewHolder> { public RecommendationListAdapter() { setHasStableIds(true); } @Override public long getItemId(int position) { return getItem(position).id; } @NonNull @Override public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { return new ViewHolder(ViewUtils.inflate(R.layout.item_recommendation_item, parent)); } @Override public void onBindViewHolder(@NonNull ViewHolder holder, int position) { CollectableItem item = getItem(position); float ratio = 1; switch (item.getType()) { case BOOK: case EVENT: case GAME: case MOVIE: case TV: ratio = 2f / 3f; break; } holder.coverImage.setRatio(ratio); ImageUtils.loadImage(holder.coverImage, item.cover); holder.titleText.setText(item.title); boolean hasRating = item.rating.hasRating(); if (hasRating) { holder.ratingText.setText(item.rating.getRatingString(holder.ratingText.getContext())); } else { holder.ratingText.setText(item.getRatingUnavailableReason( holder.ratingText.getContext())); } ViewUtils.setVisibleOrGone(holder.ratingStarText, hasRating); holder.itemView.setOnClickListener(view -> { // TODO UriHandler.open(item.url, view.getContext()); }); } static class ViewHolder extends RecyclerView.ViewHolder { @BindView(R.id.cover) public RatioImageView coverImage; @BindView(R.id.title) public TextView titleText; @BindView(R.id.rating) public TextView ratingText; @BindView(R.id.rating_star) public TextView ratingStarText; public ViewHolder(View itemView) { super(itemView); ButterKnife.bind(this, itemView); } } }
1,244
14,425
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.hadoop.io.serializer; import java.io.Serializable; import org.apache.hadoop.io.DataInputBuffer; import org.apache.hadoop.io.DataOutputBuffer; import static org.apache.hadoop.io.TestGenericWritable.CONF_TEST_KEY; import static org.apache.hadoop.io.TestGenericWritable.CONF_TEST_VALUE; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.io.Text; import org.apache.hadoop.io.TestGenericWritable.Baz; import org.apache.hadoop.io.TestGenericWritable.FooGenericWritable; import org.apache.hadoop.io.WritableComparator; import org.junit.Test; import static org.junit.Assert.*; public class TestWritableSerialization { private static final Configuration conf = new Configuration(); @Test public void testWritableSerialization() throws Exception { Text before = new Text("test writable"); Text after = SerializationTestUtil.testSerialization(conf, before); assertEquals(before, after); } @Test public void testWritableConfigurable() throws Exception { //set the configuration parameter conf.set(CONF_TEST_KEY, CONF_TEST_VALUE); //reuse TestGenericWritable inner classes to test //writables that also implement Configurable. FooGenericWritable generic = new FooGenericWritable(); generic.setConf(conf); Baz baz = new Baz(); generic.set(baz); Baz result = SerializationTestUtil.testSerialization(conf, baz); assertEquals(baz, result); assertNotNull(result.getConf()); } @Test @SuppressWarnings({"rawtypes", "unchecked"}) public void testWritableComparatorJavaSerialization() throws Exception { Serialization ser = new JavaSerialization(); Serializer<TestWC> serializer = ser.getSerializer(TestWC.class); DataOutputBuffer dob = new DataOutputBuffer(); serializer.open(dob); TestWC orig = new TestWC(0); serializer.serialize(orig); serializer.close(); Deserializer<TestWC> deserializer = ser.getDeserializer(TestWC.class); DataInputBuffer dib = new DataInputBuffer(); dib.reset(dob.getData(), 0, dob.getLength()); deserializer.open(dib); TestWC deser = deserializer.deserialize(null); deserializer.close(); assertEquals(orig, deser); } static class TestWC extends WritableComparator implements Serializable { static final long serialVersionUID = 0x4344; final int val; TestWC() { this(7); } TestWC(int val) { this.val = val; } @Override public boolean equals(Object o) { if (o instanceof TestWC) { return ((TestWC)o).val == val; } return false; } @Override public int hashCode() { return val; } } }
1,122
335
{ "word": "Back", "definitions": [ "In the opposite direction from the one that one is facing or travelling towards.", "Expressing movement of the body into a reclining position.", "At a distance away.", "Behind.", "Losing by a specified margin.", "So as to return to an earlier or normal position or condition.", "At a place previously left or mentioned.", "Fashionable again.", "In or into the past.", "In return." ], "parts-of-speech": "Adverb" }
208
5,169
{ "name": "Commbox", "version": "1.0.1", "summary": "Commbox chat sdk", "description": "Commbox chat sdk desc", "homepage": "https://www.commbox.io/", "license": "MIT", "authors": { "<NAME>": "<EMAIL>" }, "platforms": { "ios": "12.0" }, "source": { "git": "https://[email protected]/commbox-io/mobile-ios-sdk.git", "tag": "1.0.1" }, "swift_versions": "5.0", "source_files": "Commbox/*.{h,m,swift}", "swift_version": "5.0" }
244
348
<gh_stars>100-1000 {"nom":"Saint-Gervais-les-Bains","circ":"6ème circonscription","dpt":"Haute-Savoie","inscrits":4751,"abs":2471,"votants":2280,"blancs":28,"nuls":12,"exp":2240,"res":[{"nuance":"REM","nom":"M. <NAME>","voix":834},{"nuance":"LR","nom":"Mme <NAME>","voix":428},{"nuance":"DIV","nom":"<NAME>","voix":289},{"nuance":"FN","nom":"<NAME>","voix":213},{"nuance":"FI","nom":"Mme <NAME>","voix":186},{"nuance":"ECO","nom":"M. <NAME>","voix":134},{"nuance":"DVD","nom":"M. <NAME>","voix":58},{"nuance":"REG","nom":"M. <NAME>","voix":41},{"nuance":"DLF","nom":"Mme <NAME>","voix":36},{"nuance":"EXG","nom":"Mme <NAME>","voix":13},{"nuance":"DIV","nom":"M. <NAME>","voix":8}]}
278
788
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.usergrid.persistence.cassandra.util; import me.prettyprint.cassandra.connection.HOpTimer; /** * Trace the timed execution of a 'tag' over the course of a number of operations. Facilitates integration with * Dapper-style trace logging infrastructure. * * @author zznate */ public class TaggedOpTimer implements HOpTimer { private TraceTagManager traceTagManager; public TaggedOpTimer( TraceTagManager traceTagManager ) { this.traceTagManager = traceTagManager; } @Override public Object start( String tagName ) { // look for our threadLocal. if not present, return this. return traceTagManager.timerInstance(); } @Override public void stop( Object timedOpTag, String opTagName, boolean success ) { if ( timedOpTag instanceof TimedOpTag ) { TimedOpTag t = ( ( TimedOpTag ) timedOpTag ); t.stopAndApply( opTagName, success ); traceTagManager.addTimer( t ); } } }
547
302
//////////////////////////////////////////////////////////////////////////////////////////////////// // This file is part of CosmoScout VR // // and may be used under the terms of the MIT license. See the LICENSE file for details. // // Copyright: (c) 2019 German Aerospace Center (DLR) // //////////////////////////////////////////////////////////////////////////////////////////////////// #ifndef CSP_MEASUREMENT_TOOLS_LOGGER_HPP #define CSP_MEASUREMENT_TOOLS_LOGGER_HPP #include <spdlog/spdlog.h> namespace csp::measurementtools { /// This creates the default singleton logger for "csp-measurement-tools" when called for the first /// time and returns it. See cs-utils/logger.hpp for more logging details. spdlog::logger& logger(); } // namespace csp::measurementtools #endif // CSP_MEASUREMENT_TOOLS_LOGGER_HPP
338
479
<reponame>balag91/gerrit // Copyright (C) 2015 The Android Open Source Project // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package com.google.gerrit.metrics.dropwizard; import com.codahale.metrics.MetricRegistry; import com.google.gerrit.metrics.CallbackMetric0; class CallbackMetricImpl0<V> extends CallbackMetric0<V> implements CallbackMetricGlue { @SuppressWarnings("unchecked") static <V> V zeroFor(Class<V> valueClass) { if (valueClass == Integer.class) { return (V) Integer.valueOf(0); } else if (valueClass == Long.class) { return (V) Long.valueOf(0); } else if (valueClass == Double.class) { return (V) Double.valueOf(0); } else if (valueClass == Float.class) { return (V) Float.valueOf(0); } else if (valueClass == String.class) { return (V) ""; } else if (valueClass == Boolean.class) { return (V) Boolean.FALSE; } else { throw new IllegalArgumentException("unsupported value type " + valueClass.getName()); } } private final DropWizardMetricMaker metrics; private final MetricRegistry registry; private final String name; private volatile V value; CallbackMetricImpl0( DropWizardMetricMaker metrics, MetricRegistry registry, String name, Class<V> valueType) { this.metrics = metrics; this.registry = registry; this.name = name; this.value = zeroFor(valueType); } @Override public void beginSet() {} @Override public void endSet() {} @Override public void set(V value) { this.value = value; } @Override public void remove() { metrics.remove(name); registry.remove(name); } @Override public void register(Runnable trigger) { registry.register( name, new com.codahale.metrics.Gauge<V>() { @Override public V getValue() { trigger.run(); return value; } }); } }
855
2,039
package org.nd4j.jita.allocator.pointers.cuda; import org.bytedeco.javacpp.Pointer; import org.nd4j.jita.allocator.pointers.CudaPointer; /** * Created by raver119 on 19.04.16. */ public class cublasHandle_t extends CudaPointer { public cublasHandle_t(Pointer pointer) { super(pointer); } }
125
565
 #pragma once #include <string> #include <vector> namespace principia { namespace geometry { namespace internal_rp2_point { // An |RP2Point| is an element of ℝP², the real projective plane. |Scalar| // must be a 1-dimensional vector space over ℝ, typically represented by // |Quantity| or |double|. template<typename Scalar, typename Frame> class RP2Point { public: // Constructs a point from a set of homogeneous coordinates. This class // handles zeros properly and returns infinities of the correct sign. explicit RP2Point(Scalar const& x, Scalar const& y, double z); // Returns true if and only if the point is at infinity. bool is_at_infinity() const; // Returns the Euclidean (inhomogeneous) coordinates of the point. May be // (simultaneously) infinities. The sign of infinities and zeroes is in the // proper quadrant. Scalar x() const; Scalar y() const; private: Scalar x_; Scalar y_; double z_; template<typename S, typename F> friend bool operator==(RP2Point<S, F> const& left, RP2Point<S, F> const& right); template<typename S, typename F> friend bool operator!=(RP2Point<S, F> const& left, RP2Point<S, F> const& right); template<typename S, typename F> friend std::string DebugString(RP2Point<S, F> const& rp2_point); }; // A line formed of RP2Points. template<typename Scalar, typename Frame> using RP2Line = std::vector<RP2Point<Scalar, Frame>>; // A list of disjoint lines. template<typename Scalar, typename Frame> using RP2Lines = std::vector<RP2Line<Scalar, Frame>>; // These operators are implemented using exact multiplication and define a // proper equivalence. template<typename Scalar, typename Frame> bool operator==(RP2Point<Scalar, Frame> const& left, RP2Point<Scalar, Frame> const& right); template<typename Scalar, typename Frame> bool operator!=(RP2Point<Scalar, Frame> const& left, RP2Point<Scalar, Frame> const& right); template<typename Scalar, typename Frame> std::string DebugString(RP2Point<Scalar, Frame> const& rp2_point); template<typename Scalar, typename Frame> std::ostream& operator<<(std::ostream& os, RP2Point<Scalar, Frame> const& rp2_point); } // namespace internal_rp2_point using internal_rp2_point::RP2Line; using internal_rp2_point::RP2Lines; using internal_rp2_point::RP2Point; } // namespace geometry } // namespace principia #include "geometry/rp2_point_body.hpp"
919
515
<filename>src/ezdxf/tools/test.py # Copyright (c) 2011-2021, <NAME> # License: MIT License from typing import Sequence, TYPE_CHECKING, Iterable, List, Set from ezdxf.lldxf.tagger import internal_tag_compiler if TYPE_CHECKING: from ezdxf.eztypes import DXFTag, EntityDB, ExtendedTags, DXFEntity def compile_tags_without_handles(text: str) -> Iterable["DXFTag"]: return ( tag for tag in internal_tag_compiler(text) if tag.code not in (5, 105) ) def normlines(text: str) -> Sequence[str]: lines = text.split("\n") return [line.strip() for line in lines] def load_section(text: str, name: str) -> List["ExtendedTags"]: from ezdxf.lldxf.loader import load_dxf_structure dxf = load_dxf_structure( internal_tag_compiler(text), ignore_missing_eof=True ) return dxf[name] # type: ignore def load_entities(text: str, name: str): from ezdxf.lldxf.loader import load_dxf_structure, load_dxf_entities dxf = load_dxf_structure( internal_tag_compiler(text), ignore_missing_eof=True ) return load_dxf_entities(dxf[name]) # type: ignore def parse_hex_dump(txt: str) -> bytes: b = bytearray() lines = txt.split("\n") for line in lines: if line == "": continue data = [int(v, 16) for v in line.strip().split(" ")] assert data[0] == len(b) b.extend(data[1:]) return b
585
3,428
<filename>lib/node_modules/@stdlib/datasets/spam-assassin/data/easy-ham-1/01818.25094be6fb43cd96116debebf792807f.json {"id":"01818","group":"easy-ham-1","checksum":{"type":"MD5","value":"25094be6fb43cd96116debebf792807f"},"text":"From <EMAIL> Mon Sep 2 12:31:10 2002\nReturn-Path: <<EMAIL>>\nDelivered-To: <EMAIL>.<EMAIL>\nReceived: from localhost (localhost [127.0.0.1])\n\tby phobos.labs.netnoteinc.com (Postfix) with ESMTP id 679CA43F9B\n\tfor <jm@localhost>; Mon, 2 Sep 2002 07:31:09 -0400 (EDT)\nReceived: from phobos [127.0.0.1]\n\tby localhost with IMAP (fetchmail-5.9.0)\n\tfor jm@localhost (single-drop); Mon, 02 Sep 2002 12:31:09 +0100 (IST)\nReceived: from petting-zoo.net (petting-zoo.net [6192.168.127.1219]) by\n dogma.slashnull.org (8.11.6/8.11.6) with ESMTP id g7UMh7Z10885 for\n <<EMAIL>>; Fri, 30 Aug 2002 23:43:08 +0100\nReceived: by petting-zoo.net (Postfix, from userid 1004) id 6770BEA3D;\n Fri, 30 Aug 2002 15:42:18 -0700 (PDT)\nOld-Return-Path: <<EMAIL>>\nDelivered-To: [email protected]\nReceived: from petting-zoo.net (localhost [127.0.0.1]) by petting-zoo.net\n (Postfix) with ESMTP id 53DEBEA0A for <<EMAIL>>;\n Fri, 30 Aug 2002 15:42:07 -0700 (PDT)\nFrom: <EMAIL> (glen mccready)\nTo: [email protected]\nSubject: Promises.\nDate: Fri, 30 Aug 2002 15:41:47 -0700\nSender: <EMAIL>\nMessage-Id: <<EMAIL>>\nResent-Message-Id: <<EMAIL>>\nResent-From: [email protected]\nX-Mailing-List: <0<EMAIL>> archive/latest/532\nX-Loop: [email protected]\nList-Post: <mailto:<EMAIL>>\nList-Help: <mailto:<EMAIL>?subject=help>\nList-Subscribe: <mailto:<EMAIL>?subject=subscribe>\nList-Unsubscribe: <mailto:<EMAIL>?subject=unsubscribe>\nPrecedence: list\nResent-Sender: [email protected]\nResent-Date: Fri, 30 Aug 2002 15:42:18 -0700 (PDT)\n\n\nForwarded-by: <NAME> <<EMAIL>>\nForwarded-by: \"<NAME>\"\nForwarded-by: cjw59068\nForwarded-by: Joe & <NAME>\n\nThere were four buddies golfing and the first guy said, \"I had to\npromise my wife that I would paint the whole outside of the house\njust to go golfing.\"\n\nThe second guy said, \"I promised my wife that I would remodel the\nkitchen for her.\"\n\nThe third guy said, \"You guys have it easy! I promised my wife that\nI would build her a new deck.\" They continued to play the hole.\nThen the first guy said to the fourth guy, \"What did you have to\npromise your wife?\"\n\nThe fourth guy replied, \"I didn't promise anything.\" All the guys\nwere shocked, \"How did you do it?!\" He replied, \"It's simple. I\nset the alarm clock for 5:30. Then I poked my wife and asked, 'Golf\ncourse or intercourse?' And she said, 'Wear your sweater.'\"\n\n\n"}
1,089