- Timestamp:
- 08/14/24 00:56:06 (4 months ago)
- Location:
- js/sdk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
js/sdk/Makefile-SDK-Emscripten.mak
r865 r1324 1 1 # 2 2 # Framsticks SDK makefile for Emscripten builds 3 # 4 # Before 2020, this makefile could be used natively under Windows as well (see history if needed). 5 # However, now that the Windows Subsystem for Linux (WSL) exists, this file only supports Linux. 3 6 # 4 7 5 8 include frams/Makefile-SDK-files 6 9 10 # set this path based on the project directory structure 7 11 JS_PATH=../js/sdk 8 9 #Note: CURDIR needed because on linux, Emscripten does not differentiate between relative and absolute path, which causes shutil to raise Error("%s and %s are the same file" % (src, dst))10 ifeq ($(OS),Windows_NT)11 CACHE_DIR=cache-tmp12 else13 CACHE_DIR=$(CURDIR)/cache-tmp14 endif15 12 16 13 SDK_JS=$(JS_PATH)/frams-sdk.js … … 25 22 26 23 # same as in cpp/frams/Makefile-SDK: 27 CXXWARNINGS=-Wall -Wno-parentheses -Wno-overloaded-virtual -Wno-format -W error=return-type24 CXXWARNINGS=-Wall -Wno-parentheses -Wno-overloaded-virtual -Wno-format -Wno-invalid-offsetof -Werror=return-type 28 25 29 SDK_BUILD_CONFIG= -include frams/config/sdk_build_config.h 30 CACHE_DESTINATION= --cache $(CACHE_DIR) 31 CXXFLAGS= -I$(CURDIR) -std=gnu++11 -O3 $(SDK_BUILD_CONFIG) $(CXXWARNINGS) $(CACHE_DESTINATION) 26 SDK_BUILD_CONFIG= -include frams/config/sdk-build-config.h 27 CXXFLAGS= -I$(CURDIR) -std=gnu++17 -O3 $(SDK_BUILD_CONFIG) $(CXXWARNINGS) 28 29 # avoid "duplicate symbol" linking errors. Instead of this pipeline, could use the "uniq" function built in included gmsl, or define a recursive function to filter out duplicates while preserving the order of elements. Also consider "$^". 30 SDK_LIB_OBJS := $(shell echo $(SDK_LIB_OBJS) | tr ' ' '\n' | sort | uniq | tr '\n' ' ') 32 31 33 32 ############################################# 34 33 35 $(SDK_JS): $(I_IMPL_JS) $(I_IMPL_SRC) $(I_OBJ) $(SDK_BIN) 36 $(CXX) $(SDK_BIN) $(I_OBJ) --post-js $(I_IMPL_JS) -g4 --memory-init-file 0 -s FORCE_FILESYSTEM=1 -s ALIASING_FUNCTION_POINTERS=0 -s ALLOW_MEMORY_GROWTH=1 -s ASSERTIONS=3 -s BINARYEN_ASYNC_COMPILATION=0 -s WASM=0 $(CACHE_DESTINATION) -o $@ 37 38 $(SDK_BIN): $(SDK_LIB_OBJS) 39 $(CXX) $(SDK_LIB_OBJS) $(LDFLAGS) $(CACHE_DESTINATION) -o $@ 34 $(SDK_JS): $(I_IMPL_JS) $(I_IMPL_SRC) $(I_OBJ) $(SDK_LIB_OBJS) 35 $(CXX) $(SDK_LIB_OBJS) $(I_OBJ) --post-js $(I_IMPL_JS) -O3 -s FORCE_FILESYSTEM=1 -s ALIASING_FUNCTION_POINTERS=0 -s ALLOW_MEMORY_GROWTH=1 -s ASSERTIONS=3 -s BINARYEN_ASYNC_COMPILATION=0 -sWASM=0 -o $@ 40 36 41 37 $(I_IMPL_SRC) $(I_IMPL_JS): $(I_IDL) 42 python $(EMSCRIPTEN)/tools/webidl_binder.py $(I_IDL) $(I_PATH)/js_interface_impl38 python3 $(EMSCRIPTEN)/tools/webidl_binder.py $(I_IDL) $(I_PATH)/js_interface_impl 43 39 44 40 ############################################# 45 41 42 include common/Makefile-maintain 46 43 47 full_clean: 48 ifeq ($(OS),Windows_NT) 49 del /s /q WebIDLGrammar.pkl parser.out *.o 50 rmdir /s /q $(CACHE_DIR) 51 else 52 rm -f WebIDLGrammar.pkl parser.out $(SDK_LIB_OBJS) 53 rm -rf $(CACHE_DIR) 54 endif 44 full_clean: clean 45 rm -f WebIDLGrammar.pkl parser.out $(I_OBJ) $(I_IMPL_SRC) $(I_IMPL_JS) $(SDK_BIN) $(SDK_JS) -
js/sdk/README.txt
r865 r1324 8 8 of Emscripten installed. To perform a compilation, you first need to activate the Emscripten SDK: 9 9 10 On Windows :10 On Windows (deprecated): 11 11 emsdk.bat activate latest 12 12 … … 18 18 After activating the Emscripten SDK, to compile Framsticks SDK you need to call: 19 19 20 On Windows :20 On Windows (deprecated): 21 21 emmake.bat mingw32-make.exe -j8 --directory=../../cpp -f ../js/sdk/Makefile-SDK-Emscripten.mak 22 22 -
js/sdk/js_interface/js_interface.cpp
r944 r1324 15 15 #include <frams/genetics/f9/f9_oper.h> 16 16 #include <frams/genetics/fF/fF_oper.h> 17 #include <frams/genetics/fS/fS_oper.h> 18 #include <frams/genetics/fn/fn_oper.h> 19 #include <frams/genetics/genoconv.h> 20 #include <frams/genetics/f4/f4_conv.h> 21 #include <frams/genetics/fH/fH_conv.h> 22 #include <frams/genetics/fB/fB_conv.h> 23 #include <frams/genetics/f9/f9_conv.h> 24 #include <frams/genetics/fS/fS_conv.h> 25 #include <frams/genetics/fn/fn_conv.h> 26 #include <frams/genetics/fL/fL_conv.h> 17 27 #include <common/loggers/loggers.h> 18 28 #include <common/loggers/loggertostdout.h> -
js/sdk/js_interface/js_interface.idl
r944 r1324 91 91 92 92 enum Part_Shape { 93 "Part::SHAPE_BALL _AND_STICK",93 "Part::SHAPE_BALL", 94 94 "Part::SHAPE_ELLIPSOID", 95 95 "Part::SHAPE_CUBOID", … … 111 111 [Value] attribute Pt3D scale; 112 112 [Value] attribute Pt3D vcolor; 113 attribute double vsize;114 113 attribute long shape; 115 116 void Part(optional Part_Shape s = "Part::SHAPE_BALL_AND_STICK"); 114 static readonly attribute double BALL_AND_STICK_RADIUS; 115 116 void Part(optional Part_Shape s = "Part::SHAPE_BALL"); 117 117 118 118 void setPositionAndRotationFromAxis([Const, Ref] Pt3D p1, [Const, Ref] Pt3D p2); … … 126 126 127 127 enum Joint_Shape { 128 "Joint::SHAPE_BALL_AND_STICK", 129 "Joint::SHAPE_FIXED" 128 "Joint::SHAPE_STICK", 129 "Joint::SHAPE_FIXED", 130 "Joint::SHAPE_HINGE_X", 131 "Joint::SHAPE_HINGE_XY" 130 132 }; 131 133 … … 247 249 void Geno([Const] DOMString genstring, byte genformat, [Const] DOMString genname, [Const] DOMString comment); 248 250 boolean isValid(); 249 bytegetFormat();251 [Value] SString getFormat(); 250 252 [Value] SString getGenes(); 253 [Value] SString getGenesAndFormat(); 251 254 static Validators useValidators(Validators val); 252 255 static GenoConvManager useConverters(GenoConvManager gcm); … … 261 264 262 265 enum Model_ShapeType { 263 "Model::SHAPE _UNKNOWN",264 "Model::SHAPE _ILLEGAL",265 "Model::SHAPE _BALL_AND_STICK",266 "Model::SHAPE _SOLIDS"266 "Model::SHAPETYPE_UNKNOWN", 267 "Model::SHAPETYPE_ILLEGAL", 268 "Model::SHAPETYPE_BALL_AND_STICK", 269 "Model::SHAPETYPE_SOLIDS" 267 270 }; 268 271 … … 272 275 attribute double startenergy; 273 276 274 void Model(); 275 void Model([Ref, Const] Geno newgeno, optional boolean buildmaps = false); 277 void Model(optional Model_ShapeType sh = "Model::SHAPETYPE_UNKNOWN"); 278 279 void Model([Ref, Const] Geno src, Model_ShapeType sh, optional boolean buildmaps = false, optional boolean _using_checkpoints = false, optional boolean _is_checkpoint = false); 280 // The following constructor exists in the SDK, however in idl functions need to differ in number of arguments so it can't exist with the previous constructor 281 //void Model([Ref, Const] Model model, optional boolean buildmaps = false, optional boolean _using_checkpoints = false, optional boolean _is_checkpoint = false); 276 282 277 283 [Value] MultiMap getMap(); … … 283 289 long getErrorPosition(boolean includingwarnings); 284 290 Model_ShapeType getShapeType(); 291 void declareShapeType(Model_ShapeType sh); 285 292 void updateRefno(); 286 293 [Const, Value] Geno getF0Geno(); 287 void makeGeno([Ref] Geno geno );294 void makeGeno([Ref] Geno geno, optional MultiMap sh,optional boolean handle_defaults,optional boolean can_be_invalid); 288 295 void setGeno([Const, Ref] Geno newgeno); 289 296 void setValidationLevel(long level); … … 348 355 349 356 interface GenotypeMiniLoader : MultiParamLoader { 350 void GenotypeMiniLoader(VirtFILE f); 357 //this constructor has the same number of arguments as the next one which is not allowed in idl 358 //void GenotypeMiniLoader(VirtFILE f); 359 void GenotypeMiniLoader([Const] DOMString filename); 351 360 GenotypeMini loadNextGenotype(); 352 361 }; … … 442 451 }; 443 452 453 interface GenoConverter { 454 [Const] attribute DOMString name; 455 [Value] attribute SString in_format; 456 [Value] attribute SString out_format; 457 }; 458 459 interface GenoConv_f40 : GenoConverter{ 460 void GenoConv_f40(); 461 }; 462 463 interface GenoConv_f90 : GenoConverter{ 464 void GenoConv_f90(); 465 }; 466 467 interface GenoConv_fL0 : GenoConverter{ 468 void GenoConv_fL0(); 469 }; 470 471 interface GenoConv_fBH : GenoConverter{ 472 void GenoConv_fBH(); 473 }; 474 475 476 interface GenoConv_fS0s : GenoConverter{ 477 void GenoConv_fS0s(); 478 }; 479 480 interface GenoConv_fH0 : GenoConverter{ 481 void GenoConv_fH0(); 482 }; 483 484 interface GenoConvHelper{ 485 void GenoConvHelper(GenoConverter genoConv); 486 [Const] DOMString getName(); 487 }; 488 444 489 interface GenoOperators { 445 490 void GenoOperators(); … … 447 492 long checkValidity([Const] DOMString geno, [Const] DOMString genoname); 448 493 long validate(DOMString geno, [Const] DOMString genoname); 449 [ Value] SString getSimplest();494 [Const] DOMString getSimplest(); 450 495 }; 451 496 … … 473 518 void GenoOper_fF(); 474 519 }; 520 521 interface GenoOper_fS : GenoOperators { 522 void GenoOper_fS(); 523 }; 524 475 525 476 526 interface GenoOperatorsHelper { … … 481 531 [Value] SString getLastCrossGeno1(); 482 532 [Value] SString getLastCrossGeno2(); 533 [Const] DOMString getSimplest(); 483 534 }; 484 535 … … 542 593 void quickCopyFrom(ParamInterface src); 543 594 544 //long save (VirtFILE file, [Const] DOMString altname, optional boolean force = false);595 //long saveMultiLine(VirtFILE file, [Const] DOMString altname, optional boolean force = false); 545 596 546 597 static boolean isValidTypeDescription([Const] DOMString t); … … 553 604 interface Param : SimpleAbstractParam { 554 605 void Param(ParamEntry t, VoidPtr o); 555 //long save(VirtFILE file, [Const] DOMString altname, optional boolean force = false);606 long saveMultiLine(VirtFILE file, [Const] DOMString altname, optional boolean force = false); 556 607 }; 557 608 -
js/sdk/js_interface/js_types.h
r879 r1324 205 205 } 206 206 207 const char* getSimplest() 208 { 209 return genoOper->getSimplest(); 210 } 211 207 212 ~GenoOperatorsHelper() 208 213 { … … 214 219 }; 215 220 221 struct GenoConvHelper 222 { 223 GenoConverter* genoConv; 224 GenoConvHelper(GenoConverter* _genoConv) 225 { 226 genoConv = _genoConv; 227 } 228 const char* getName() 229 { 230 return genoConv->name; 231 } 232 }; 233 216 234 #endif 217 235 #endif //JS_TYPES_H_
Note: See TracChangeset
for help on using the changeset viewer.